Selaa lähdekoodia

Upgraded openxr dependency to 1.1.41. (#270)

This update makes it straightforward to build O3DE applications for Meta
Quest devices, because the developer is not required anymore to download
and decompress the `Oculus OpenXR Mobile SDK`.

To understand this change, let's review a little bit of history: When
making O3DE apps for Meta Quest devices, the developer was instructed to
manually download and decompress the
`Oculus OpenXR Mobile SDK` into a particular directory of the `OpenXRVk`
Gem.

Those instructions worked well until SDK v62. Starting SDK v63+ (It's
currently at v72) Meta stopped distributing pre-compiled OpenXR Loader
libraries, and now applications are simply required to get the OpenXR
Loader directly from github: https://github.com/KhronosGroup/OpenXR-SDK

In particular, this PR picks version 1.1.41 because that's the version
used by `v72` of `Oculus OpenXR Mobile SDK`.

In other words, with this change, OpenXR is now supported in its purest
form, because there are no custom steps for a particular vendor.

Also, it was found that when creating the Android package, the
Android-tool.cmake tool doesn't copy the headers in the "install"
directories. So I added an improvement to the
`pull_and_build_from_git.py` script, where the `"extra_files_to_copy"`
property now supports copying directories, with a third, optional,
parameter, which is a list of file patterns to ignore when deepcopying
the directories. Example:
```json
{
    "extra_files_to_copy": [
      ["temp/src/include", "OpenXR/include", ["*.txt", "*.license"]]
    ],
}
```
Additionally, when copying files, it now supports automatic creation of
non-existing sub-folders.

---------

Signed-off-by: galibzon <[email protected]>
galibzon 5 kuukautta sitten
vanhempi
commit
c28365bf87

+ 37 - 5
Scripts/extras/pull_and_build_from_git.py

@@ -80,7 +80,11 @@ The following keys can exist at the root level or the target-platform level:
                             platforms and configurations.
                             platforms and configurations.
                             The final args will be (cmake_build_args || cmake_build_args_CONFIG) + cmake_build_args_common
                             The final args will be (cmake_build_args || cmake_build_args_CONFIG) + cmake_build_args_common
                             `cmake --build (build folder) --config config` will automatically be supplied.
                             `cmake --build (build folder) --config config` will automatically be supplied.
-* extra_files_to_copy   : (optional) a list of pairs of files to copy [source, destination].
+* extra_files_to_copy   : (optional) a list of pairs or triplets.
+                          if the item is a pair, then it can be (source file, destination file) or
+                                                                (source directory, destination directory).
+                          Directories are always deep copied.
+                          If a triplet is specified, then the third element is another list of file patterns to ignore when copying a directory.
 
 
 * cmake_install_filter                    : Optional list of filename patterns to filter what is actually copied to the target package based on
 * cmake_install_filter                    : Optional list of filename patterns to filter what is actually copied to the target package based on
                                             the 3rd party library's install definition. (For example, a library may install headers and static
                                             the 3rd party library's install definition. (For example, a library may install headers and static
@@ -936,17 +940,45 @@ class BuildInfo(object):
 
 
         return False
         return False
 
 
+    def copy_file_or_directory(self, src: pathlib.Path, dst: pathlib.Path, ignore_patterns: list[str]):
+        """
+        if @src is a directory, makes a deep copy of it into @dst. In this case @ignore_patterns is used.
+        if @src is a file, copies it as @dst, and will create all intermediate directories in @dst as needed.
+        """
+        print(f"Source file: {src}, Destination file: {dst}")
+        if src.is_dir():
+            # Recursive deep copy. Will create all subdirectories as needed.
+            def custom_copy(src, dst):
+                #If the destination file exists, we'll leave it as is, because
+                #it was generated already by the the build commands.
+                if os.path.exists(dst):
+                   print(f"Destination file '{dst}' already exists. Skipping.")
+                else:
+                    shutil.copy2(src, dst)
+            shutil.copytree(src, dst, ignore=shutil.ignore_patterns(*ignore_patterns), copy_function=custom_copy, dirs_exist_ok=True)
+        else:
+            # If the destination directory doesn't exist, shutil.copy2 raises an exception.
+            # Take care of this first.
+            dst.parent.mkdir(parents=True, exist_ok=True)
+            shutil.copy2(src,dst)
+
     def copy_extra_files(self):
     def copy_extra_files(self):
         """
         """
         Copies any extra files specified in the build config into the destination folder for packaging.
         Copies any extra files specified in the build config into the destination folder for packaging.
         """
         """
         extra_files_to_copy = self.package_info.extra_files_to_copy
         extra_files_to_copy = self.package_info.extra_files_to_copy
         if extra_files_to_copy:
         if extra_files_to_copy:
-            for (source, dest) in extra_files_to_copy:
-                print(f"Source file: {self.base_folder / source}, Destination file: {self.package_install_root / dest}")
-                shutil.copy2(
+            for params in extra_files_to_copy:
+                source = params[0]
+                dest = params[1]
+                if len(params) < 3:
+                    ignore_patterns = ["",]
+                else:
+                    ignore_patterns = params[2]
+                self.copy_file_or_directory(
                     self.base_folder / source,
                     self.base_folder / source,
-                    self.package_install_root / dest
+                    self.package_install_root / dest,
+                    ignore_patterns
                 )
                 )
 
 
     def build_for_platform(self):
     def build_for_platform(self):

+ 6 - 3
package-system/OpenXR/build_config.json

@@ -1,8 +1,8 @@
 {
 {
    "git_url":"https://github.com/KhronosGroup/OpenXR-SDK.git",
    "git_url":"https://github.com/KhronosGroup/OpenXR-SDK.git",
-   "git_tag":"release-1.0.22",
+   "git_tag":"release-1.1.41",
    "package_name":"OpenXR",
    "package_name":"OpenXR",
-   "package_version":"1.0.22-rev2",
+   "package_version":"1.1.41-rev1",
    "package_url":"https://www.khronos.org/openxr/",
    "package_url":"https://www.khronos.org/openxr/",
    "package_license":"Apache-2.0",
    "package_license":"Apache-2.0",
    "package_license_file":"LICENSE",
    "package_license_file":"LICENSE",
@@ -25,6 +25,9 @@
       "Release",
       "Release",
       "Debug"
       "Debug"
    ],
    ],
+   "extra_files_to_copy": [
+      ["temp/src/include", "OpenXR/include", ["*.txt", "*.license"]]
+   ],
    "Platforms":{
    "Platforms":{
       "Windows":{
       "Windows":{
          "Windows":{
          "Windows":{
@@ -32,7 +35,7 @@
             ],
             ],
             "cmake_generate_args": [
             "cmake_generate_args": [
                 "-G",
                 "-G",
-                "\"Visual Studio 16 2019\""
+                "\"Visual Studio 17 2022\""
             ],
             ],
             "custom_test_cmd" : [
             "custom_test_cmd" : [
            ]
            ]

+ 4 - 4
package_build_list_host_windows.json

@@ -39,8 +39,8 @@
         "OpenMesh-8.1-rev3-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenMesh --platform-name Windows --package-root ../../package-system --clean",
         "OpenMesh-8.1-rev3-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenMesh --platform-name Windows --package-root ../../package-system --clean",
         "OpenSSL-1.1.1o-rev2-android": "package-system/OpenSSL/build_package_image.py --platform-name android",
         "OpenSSL-1.1.1o-rev2-android": "package-system/OpenSSL/build_package_image.py --platform-name android",
         "OpenSSL-1.1.1o-rev1-windows": "package-system/OpenSSL/build_package_image.py",
         "OpenSSL-1.1.1o-rev1-windows": "package-system/OpenSSL/build_package_image.py",
-        "OpenXR-1.0.22-rev1-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenXR --platform-name Android --package-root ../../package-system --clean",
-        "OpenXR-1.0.22-rev1-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenXR --platform-name Windows --package-root ../../package-system --clean",
+        "OpenXR-1.1.41-rev1-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenXR --platform-name Android --package-root ../../package-system/OpenXR/temp --clean",
+        "OpenXR-1.1.41-rev1-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenXR --platform-name Windows --package-root ../../package-system/OpenXR/temp --clean",
         "PhysX-4.1.2.29882248-rev8-android": "package-system/PhysX/build_package_image.py --package-name PhysX-4.1.2.29882248 --package-rev rev8 --platform android",
         "PhysX-4.1.2.29882248-rev8-android": "package-system/PhysX/build_package_image.py --package-name PhysX-4.1.2.29882248 --package-rev rev8 --platform android",
         "PhysX-4.1.2.29882248-rev8-windows": "package-system/PhysX/build_package_image.py --package-name PhysX-4.1.2.29882248 --package-rev rev8 --platform windows",
         "PhysX-4.1.2.29882248-rev8-windows": "package-system/PhysX/build_package_image.py --package-name PhysX-4.1.2.29882248 --package-rev rev8 --platform windows",
         "PhysX-5.1.1-rev4-android": "package-system/PhysX5/build_package_image.py --package-name PhysX-5.1.1 --package-rev rev4 --platform android",
         "PhysX-5.1.1-rev4-android": "package-system/PhysX5/build_package_image.py --package-name PhysX-5.1.1 --package-rev rev4 --platform android",
@@ -108,8 +108,8 @@
     "OpenMesh-8.1-rev3-windows": "package-system/OpenMesh-windows",
     "OpenMesh-8.1-rev3-windows": "package-system/OpenMesh-windows",
     "OpenSSL-1.1.1o-rev2-android": "package-system/OpenSSL/temp/OpenSSL-android",
     "OpenSSL-1.1.1o-rev2-android": "package-system/OpenSSL/temp/OpenSSL-android",
     "OpenSSL-1.1.1o-rev1-windows": "package-system/OpenSSL/temp/OpenSSL-windows",
     "OpenSSL-1.1.1o-rev1-windows": "package-system/OpenSSL/temp/OpenSSL-windows",
-    "OpenXR-1.0.22-rev1-android": "package-system/OpenXR-android",
-    "OpenXR-1.0.22-rev1-windows": "package-system/OpenXR-windows",
+    "OpenXR-1.1.41-rev1-android": "package-system/OpenXR/temp/OpenXR-android",
+    "OpenXR-1.1.41-rev1-windows": "package-system/OpenXR/temp/OpenXR-windows",
     "PhysX-4.1.2.29882248-rev8-android": "package-system/PhysX-android",
     "PhysX-4.1.2.29882248-rev8-android": "package-system/PhysX-android",
     "PhysX-4.1.2.29882248-rev8-windows": "package-system/PhysX-windows",
     "PhysX-4.1.2.29882248-rev8-windows": "package-system/PhysX-windows",
     "PhysX-5.1.1-rev4-android": "package-system/PhysX5/temp/PhysX5-android",
     "PhysX-5.1.1-rev4-android": "package-system/PhysX5/temp/PhysX5-android",