From b081325fc7741a3e7b001a047b6a945269fb4b1c Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Thu, 19 May 2022 14:33:40 +0200 Subject: [PATCH] nouveau/headers: add script to sync in-tree headers with open-gpu-doc Part-of: --- src/nouveau/meson.build | 1 + src/nouveau/nvidia-headers/meson.build | 3 ++ .../nvidia-headers/update-from-open-gpu-doc.py | 53 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/nouveau/nvidia-headers/meson.build create mode 100755 src/nouveau/nvidia-headers/update-from-open-gpu-doc.py diff --git a/src/nouveau/meson.build b/src/nouveau/meson.build index e8520b7..bc0e42f 100644 --- a/src/nouveau/meson.build +++ b/src/nouveau/meson.build @@ -18,6 +18,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +subdir('nvidia-headers') subdir('compiler') subdir('winsys') if with_tools.contains('drm-shim') diff --git a/src/nouveau/nvidia-headers/meson.build b/src/nouveau/nvidia-headers/meson.build new file mode 100644 index 0000000..8575043 --- /dev/null +++ b/src/nouveau/nvidia-headers/meson.build @@ -0,0 +1,3 @@ +idep_nvidia_headers = declare_dependency( + include_directories : include_directories('.') +) diff --git a/src/nouveau/nvidia-headers/update-from-open-gpu-doc.py b/src/nouveau/nvidia-headers/update-from-open-gpu-doc.py new file mode 100755 index 0000000..5e0e4a4 --- /dev/null +++ b/src/nouveau/nvidia-headers/update-from-open-gpu-doc.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +import argparse +import git +from git import Repo +import glob +import os +import shutil +import sys + +# where should files go +dirs = { + '/classes/compute/': 'classes/', + '/classes/dma-copy/': 'classes/', + '/classes/memory-to-memory-format/': 'classes/', + '/classes/twod/': 'classes/', +} +branch = 'master' +target = os.path.abspath(os.path.dirname(__file__)) + "/" + +parser = argparse.ArgumentParser(description='Updates Nvidia header files from git.') +parser.add_argument('git_path', type=str, help='Path to the open-gpu-doc repo') + +args = parser.parse_args() +repo_path = os.path.abspath(args.git_path) + +# 1. create repo object +try: + repo = Repo(repo_path) + assert not repo.bare +except git.exc.NoSuchPathError: + print("{} doesn't point to a git repository".format(repo_path)) + sys.exit(-1) + +# 2. update repo +repo.remotes.origin.fetch() +repo.git.checkout(branch) +repo.git.rebase('origin/' + branch) + +# 3. check if all needed directories exist +for dir in dirs.keys(): + path = repo_path + dir + if not os.path.isdir(path): + print(dir + " does not exist in repository. Was the correct repository choosen?") + sys.exit(-1) + +# 4. copy over files +for src, dest in dirs.items(): + src = repo_path + src + dest = target + dest + for header in glob.glob(src + "*.h"): + print(header + " => " + dest) + shutil.copy(header, dest) -- 2.7.4