Преглед изворни кода

Defined the install step for assimp. Created a new json definition for the install step.

Signed-off-by: AMZN-stankowi <[email protected]>
AMZN-stankowi пре 3 година
родитељ
комит
39729600cf

+ 36 - 0
Scripts/extras/pull_and_build_from_git.py

@@ -84,6 +84,10 @@ The following keys can only exist at the target platform level as they describe
                                             this argument is optional.  You could do the install in your custom build command instead.
                                             see the note about environment variables below.
 
+* custom_install_json                     : A list of json files that track copy from and to targets to copy and assemble the built binaries
+                                            into the target package folder. This argument is optional. 
+                                            You could do the install in your custom build command instead. See the note about environment variables below.
+
 * custom_test_cmd                         : after making the package, it will run this and expect exit code 0
                                             this argument is optional.
                                             see the note about environment variables below.
@@ -701,6 +705,38 @@ class BuildInfo(object):
                                          env=env_to_use)
             if call_result.returncode != 0:
                 raise BuildError(f"Error executing custom install command {custom_install_cmd}")
+                
+        # Allow libraries to define a list of files to include via a json script that stores folder paths and
+        # individual files in the "Install_Paths" array
+        custom_install_jsons = self.platform_config.get('custom_install_json', [])
+        for custom_install_json_file in custom_install_jsons:
+            custom_json_full_path = os.path.join(self.base_folder, custom_install_json_file)
+            print(f"Running custom install json file {custom_json_full_path}")
+            custom_json_full_path_file = open(custom_json_full_path)
+            custom_install_json = json.loads(custom_json_full_path_file.read())
+            if not custom_install_json:
+                raise BuildError(f"Error loading custom install json file {custom_install_json_file}")
+            source_subfolder = None
+            if "Source_Subfolder" in custom_install_json:
+                source_subfolder = custom_install_json["Source_Subfolder"]
+            for install_path in custom_install_json["Install_Paths"]:
+                install_src_path = install_path
+                if source_subfolder is not None:
+                    install_src_path = os.path.join(source_subfolder, install_src_path)
+                resolved_src_path = os.path.join(env_to_use['TEMP_FOLDER'], install_src_path)
+                resolved_target_path = os.path.join(env_to_use['TARGET_INSTALL_ROOT'], install_path)
+                if os.path.isdir(resolved_src_path):
+                    # Newer versions of Python support the parameter dirs_exist_ok=True,
+                    # but that's not available in earlier Python versions.
+                    # It's useful to treat it as an error if the target exists, because that means that something has
+                    # already touched that folder and there might be unexpected behavior copying an entire tree into it.
+                    shutil.copytree(resolved_src_path, resolved_target_path)
+                elif os.path.isfile(resolved_src_path):
+                    os.makedirs(os.path.dirname(resolved_target_path), exist_ok=True)
+                    shutil.copy2(resolved_src_path, resolved_target_path)
+                else:
+                    raise BuildError(f"Error executing custom install command {custom_install_cmd}, found invalid source path {resolved_target_path}")
+
 
     def check_build_keys(self, keys_to_check):
         """

+ 6 - 0
package-system/assimp/PackageInfo.json

@@ -0,0 +1,6 @@
+{
+  "PackageName": "assimp-5.0.1-rev12",
+  "URL": "https://github.com/assimp/assimp/blob/master/LICENSE",
+  "License": "BSD-3-Clause",
+  "LicenseFile": "LICENSE"
+}

+ 3 - 3
package-system/assimp/build_config.json

@@ -19,9 +19,9 @@
                 "custom_build_cmd" : [
                     "build_assimp_windows.cmd"
                 ],
-                "custom_install_cmd": [
-                    "install_assimp_windows.cmd"
-                ],
+              "custom_install_json": [
+                "install_assimp_windows.json"
+              ],
                 "custom_test_cmd" : [
                     "test_assimp_windows.cmd"
                 ]

+ 16 - 0
package-system/assimp/install_assimp_windows.json

@@ -0,0 +1,16 @@
+{
+  "Source_Subfolder": "src",
+  "Install_Paths": [
+    "include/",
+    "lib/Debug/assimp-vc142-mtd.lib",
+    "lib/Debug/assimp-vc142-mtd.pdb",
+    "lib/Release/assimp-vc142-mt.lib",
+    "bin/Release/assimp.exe",
+    "bin/Release/assimp-vc142-mt.dll",
+    "bin/Debug/assimpd.exe",
+    "bin/Debug/assimpd.pdb",
+    "bin/Debug/assimp-vc142-mtd.dll",
+    "bin/Debug/assimp-vc142-mtd.pdb",
+    "port/PyAssimp/"
+  ]
+}