nouveau/headers: add script to sync in-tree headers with open-gpu-doc
authorKarol Herbst <kherbst@redhat.com>
Thu, 19 May 2022 12:33:40 +0000 (14:33 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:52 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/meson.build
src/nouveau/nvidia-headers/meson.build [new file with mode: 0644]
src/nouveau/nvidia-headers/update-from-open-gpu-doc.py [new file with mode: 0755]

index e8520b7..bc0e42f 100644 (file)
@@ -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 (file)
index 0000000..8575043
--- /dev/null
@@ -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 (executable)
index 0000000..5e0e4a4
--- /dev/null
@@ -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)