Sfoglia il codice sorgente

Enable package dependencies and package tests (#54)

Adds the ability to download package dependencies
Adds the ability to test packages
Uses these new systems in TIFF

Signed-off-by: lawsonamzn <[email protected]>
Nicholas Lawson 3 anni fa
parent
commit
16c56eaefb

+ 175 - 0
Scripts/extras/package_downloader.py

@@ -0,0 +1,175 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+import os
+import urllib
+import urllib.request
+from urllib.error import URLError
+import ssl
+import certifi
+import hashlib
+import pathlib
+import tarfile
+import sys
+
+
+# used if LY_PACKAGE_SERVER_URLS is not set.
+DEFAULT_LY_PACKAGE_SERVER_URLS = "https://d2c171ws20a1rv.cloudfront.net"
+
+# its not necessarily the case that you ever actually have to use boto3
+# if all the servers you specify in your server list (Default above) are 
+# not s3 buckets.  So it is not a failure to be missing boto3 unless you actually
+# try to use it later.
+_aws_s3_available = False
+try:
+    import boto3
+    from botocore.exceptions import BotoCoreError
+    from botocore.exceptions import ClientError
+    _aws_s3_available = True
+except:
+    pass
+
+class PackageDownloader(): 
+    @staticmethod
+    def DownloadAndUnpackPackage(package_name, package_hash, folder_target):
+        '''Given a package name, hash, and folder to unzip it into, 
+            attempts to find the package. If found, downloads and unpacks to the target_folder location.
+            Only the first found package is downloaded, and then the search stops. If the checksum of
+            the downloaded file doesn't match the checksum in the O3DE dependency list, the package
+            isn't unpacked on the filesystem and the download is deleted.
+        
+            This method supports all URI types handled by the O3DE package system, including S3 URIs.
+            
+            PRECONDITIONS:
+            * LY_PACKAGE_SERVER_URLS must be set in the environment to override the defaultg
+            * If using S3 URIs, LY_AWS_PROFILE must be set in the environment and the 'aws' command
+              must be on the PATH
+            
+            Returns True if successful, False otherwise.
+         '''
+
+        def ComputeHashOfFile(file_path):
+            file_path = os.path.normpath(file_path)
+            hasher = hashlib.sha256()
+            hash_result = None
+            
+            # we don't follow symlinks here, this is strictly to check actual packages.
+            with open(file_path, 'rb') as afile:
+                buf = afile.read()
+                hasher.update(buf)
+                hash_result = hasher.hexdigest()
+        
+            return hash_result
+
+        # make sure a package with that name is not already present:
+        server_urls = os.environ.get("LY_PACKAGE_SERVER_URLS", default = "")
+
+        if not server_urls:
+            print(f"Server url list is empty - please set LY_PACKAGE_SERVER_URLS env var to semicolon-seperated list of urls to check")
+            print(f"Using default URL for convenience: {DEFAULT_LY_PACKAGE_SERVER_URLS}")
+            server_urls = DEFAULT_LY_PACKAGE_SERVER_URLS
+
+        download_location = pathlib.Path(folder_target)
+        package_file_name = package_name + ".tar.xz"
+        package_download_name = download_location / package_file_name
+        package_unpack_folder = download_location / package_name
+        
+        server_list = server_urls.split(';')
+
+        package_download_name.unlink(missing_ok=True)
+        download_location.mkdir(parents=True, exist_ok=True)
+
+        print(f"Downloading package {package_name}...")
+
+        for package_server in server_list:
+            if not package_server:
+                continue
+            full_package_url = package_server + "/" + package_file_name
+            print(f"    - attempting '{full_package_url}' ...")
+
+            try:
+                if full_package_url.startswith("s3://"):
+                    if not _aws_s3_available:
+                        print(f"S3 URL given, but boto3 could not be located. Please ensure that you have installed")
+                        print(f"installed requirements: {sys.executable} -m pip install --upgrade boto3 certifi six")
+                        continue
+                    # it may be legitimate not have a blank AWS profile, so we can't supply a default here
+                    aws_profile_name = os.environ.get("LY_AWS_PROFILE", default = "")
+                    # if it is blank, its still worth noting in the log:
+                    if not aws_profile_name:
+                        print("    - LY_AWS_PROFILE env var is not set - using blank AWS profile by default")
+                    session = boto3.session.Session(profile_name=aws_profile_name)
+                    bucket_name = full_package_url[len("s3://"):]
+                    slash_pos = bucket_name.find('/')
+                    if slash_pos != -1:
+                        bucket_name = bucket_name[:slash_pos]
+                    print(f"    - using aws to download {package_file_name} from bucket {bucket_name}...")
+                    session.client('s3').download_file(bucket_name, package_file_name, str(package_download_name))
+                else:
+                    tls_context = ssl.create_default_context(cafile=certifi.where())
+                    with urllib.request.urlopen(url=full_package_url, context = tls_context) as server_response:
+                        print("    - Downloading package...")
+                        file_data = server_response.read()
+                        with open(package_download_name, "wb") as save_package:
+                            save_package.write(file_data)
+            except (ClientError, BotoCoreError, ssl.SSLError, URLError, OSError) as e:
+                print(f"        - Unable to get package from this server: {e}")
+                continue # try the next URL, if any...
+
+            try:
+                # validate that the package matches its hash
+                print("    - Checking hash ... ")
+                hash_result = ComputeHashOfFile(str(package_download_name))
+                if hash_result != package_hash:
+                    print("    - Warning: Hash of package does not match - will not use it")
+                    continue
+
+                # hash matched.  Unpack and return!
+                package_unpack_folder.mkdir(parents=True, exist_ok=True)
+                with tarfile.open(package_download_name) as archive_file:
+                    print("    - unpacking package...")
+                    archive_file.extractall(package_unpack_folder)
+                    print(f"Downloaded successfuly to {os.path.realpath(package_unpack_folder)}")
+                return True
+            except (OSError, tarfile.TarError) as e:
+                # note that anything that causes this to fail should result in trying the next one.
+                print(f"    - unable to unpack or verify the package: {e}")
+                continue # try the next server, if you have any
+            finally:
+                # clean up
+                if os.path.exists(package_download_name):
+                    try:
+                        os.remove(package_download_name)
+                    except:
+                        pass
+        print("FAILED - unable to find the package on any servers.")
+        return False
+
+# you can also use this module from a bash script to get a package
+if __name__ == '__main__':
+    import argparse
+    parser = argparse.ArgumentParser(description="Download, verify hash, and unpack a 3p package")
+
+    parser.add_argument('--package-name',
+                        help='The package name to download',
+                        required=True)
+
+    parser.add_argument('--package-hash',
+                        help='The package hash to verify',
+                        required=True)
+    
+    parser.add_argument('--output-folder',
+                        help='The folder to unpack to.  It will get unpacked into (package-name) subfolder!',
+                        required=True)
+
+    parsed_args = parser.parse_args()
+    if PackageDownloader.DownloadAndUnpackPackage(parsed_args.package_name, parsed_args.package_hash, parsed_args.output_folder):
+        sys.exit(0)
+
+    sys.exit(1)
+

+ 100 - 10
Scripts/extras/pull_and_build_from_git.py

@@ -19,6 +19,8 @@ import string
 import subprocess
 import subprocess
 import sys
 import sys
 
 
+from package_downloader import PackageDownloader
+
 SCHEMA_DESCRIPTION = """
 SCHEMA_DESCRIPTION = """
 Build Config Description:
 Build Config Description:
 
 
@@ -58,7 +60,7 @@ The following keys can exist at the root level or the target-platform level:
 * git_skip              : (optional) Option to skip all git commands, requires source_path
 * git_skip              : (optional) Option to skip all git commands, requires source_path
 
 
 
 
-The following keys can only exist at the target platform level as they describe the specifics for that platform
+The following keys can only exist at the target platform level as they describe the specifics for that platform.
 
 
 * cmake_generate_args                     : The cmake generation arguments (minus the build folder target or any configuration) for generating 
 * cmake_generate_args                     : The cmake generation arguments (minus the build folder target or any configuration) for generating 
                                             the project for the platform (for all configurations). To perform specific generation commands (i.e.
                                             the project for the platform (for all configurations). To perform specific generation commands (i.e.
@@ -74,10 +76,17 @@ The following keys can only exist at the target platform level as they describe
 
 
 * custom_build_cmd                        : A list of custom scripts to run to build from the source that was pulled from git. This option is 
 * custom_build_cmd                        : A list of custom scripts to run to build from the source that was pulled from git. This option is 
                                             mutually exclusive from the cmake_generate_args and cmake_build_args options.
                                             mutually exclusive from the cmake_generate_args and cmake_build_args options.
-                                            
+                                            see the note about environment variables below.
+
 * custom_install_cmd                      : A list of custom scripts to run (after the custom_build_cmd) to copy and assemble the built binaries
 * custom_install_cmd                      : A list of custom scripts to run (after the custom_build_cmd) to copy and assemble the built binaries
                                             into the target package folder.
                                             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.
+
 * custom_additional_compile_definitions   : Any additional compile definitions to apply in the find*.cmake file for the library that will applied
 * custom_additional_compile_definitions   : Any additional compile definitions to apply in the find*.cmake file for the library that will applied
                                             to targets that consume this 3P library
                                             to targets that consume this 3P library
                                             
                                             
@@ -90,6 +99,35 @@ The following keys can only exist at the target platform level as they describe
 * custom_cmake_install                    : Custom flag for certain platforms (ie iOS) that needs the installation arguments applied during the 
 * custom_cmake_install                    : Custom flag for certain platforms (ie iOS) that needs the installation arguments applied during the 
                                             cmake generation, and not to apply the cmake install process
                                             cmake generation, and not to apply the cmake install process
 
 
+* depends_on_packages                     : list of name of 3-TUPLES of [package name, package hash, subfolder] that 'find' files live in] 
+                                            [  ["zlib-1.5.3-rev5",    "some hash", ""],
+                                               ["some other package", "some other hash", "subfoldername"], 
+                                               ...
+                                            ] 
+                                            that we need to download and use).
+    - note that we don't check recursively - you must name your recursive deps!
+    - The packages must be on a public CDN or locally tested with FILE:// - it uses env var 
+      "LY_PACKAGE_SERVER_URLS" which can be a semicolon seperated list of places to try.
+    - The packages unzip path + subfolder is added to CMAKE_MODULE_PATH if you use cmake commands.
+    - Otherwise you can use DOWNLOADED_PACKAGE_FOLDERS env var in your custom script and set
+    - CMAKE_MODULE_PATH to be that value, yourself.
+    - The subfolder can be empty, in which case the root of the package will be used.
+
+Note about environment variables:
+When custom commands are issued (build, install, and test), the following environment variables will be set
+for the process:
+         PACKAGE_ROOT = root of the package being made (where PackageInfo.json is generated/copied)
+         TARGET_INSTALL_ROOT = $PACKAGE_ROOT/$PACKAGE_NAME - usually where you target cmake install to
+         TEMP_FOLDER = the temp folder.  This folder usually has subfolder 'build' and 'src'
+         DOWNLOADED_PACKAGE_FOLDERS = semicolon seperated list of abs paths to each downloaded package Find folder.
+            - usually used to set CMAKE_MODULE_PATH so it can find the packages.
+            - unset if there are no dependencies declared
+    Note that any of the above environment variables that contain paths will use system native slashes for script
+    compatibility, and may need to be converted to forward slash in your script on windows 
+    if you feed it to cmake.
+    Also note that the working directory for all custom commands will the folder containing the build_config.json file.
+
+
 The general layout of the build_config.json file is as follows:
 The general layout of the build_config.json file is as follows:
 
 
 {
 {
@@ -178,6 +216,7 @@ class PackageInfo(object):
         self.cmake_find_target = _get_value("cmake_find_target")
         self.cmake_find_target = _get_value("cmake_find_target")
         self.cmake_find_template_custom_indent = _get_value("cmake_find_template_custom_indent", default=1)
         self.cmake_find_template_custom_indent = _get_value("cmake_find_template_custom_indent", default=1)
         self.additional_src_files = _get_value("additional_src_files", required=False)
         self.additional_src_files = _get_value("additional_src_files", required=False)
+        self.depends_on_packages = _get_value("depends_on_packages", required=False)
 
 
         if self.cmake_find_template and self.cmake_find_source:
         if self.cmake_find_template and self.cmake_find_source:
             raise BuildError("Bad build config file. 'cmake_find_template' and 'cmake_find_source' cannot both be set in the configuration.")            
             raise BuildError("Bad build config file. 'cmake_find_template' and 'cmake_find_source' cannot both be set in the configuration.")            
@@ -479,6 +518,13 @@ class BuildInfo(object):
                                           cwd=str(self.src_folder.absolute()))
                                           cwd=str(self.src_folder.absolute()))
             if patch_result.returncode != 0:
             if patch_result.returncode != 0:
                 raise BuildError(f"Error Applying patch {str(patch_file_path.absolute())}: {patch_result.stderr.decode('UTF-8', 'ignore')}")
                 raise BuildError(f"Error Applying patch {str(patch_file_path.absolute())}: {patch_result.stderr.decode('UTF-8', 'ignore')}")
+        # Check if there are any package dependencies.
+        if self.package_info.depends_on_packages:
+            for package_name, package_hash, _ in self.package_info.depends_on_packages:
+                temp_packages_folder = self.base_temp_folder
+                if not PackageDownloader.DownloadAndUnpackPackage(package_name, package_hash, str(temp_packages_folder)):
+                    raise BuildError(f"Failed to download a required dependency: {package_name}")
+
 
 
     def build_and_install_cmake(self):
     def build_and_install_cmake(self):
         """
         """
@@ -524,7 +570,20 @@ class BuildInfo(object):
                 if self.custom_toolchain_file:
                 if self.custom_toolchain_file:
                     cmake_generator_args.append( f'-DCMAKE_TOOLCHAIN_FILE="{self.custom_toolchain_file}"')
                     cmake_generator_args.append( f'-DCMAKE_TOOLCHAIN_FILE="{self.custom_toolchain_file}"')
 
 
+                cmake_module_path = ""
+                paths_to_join = []
+                if self.package_info.depends_on_packages:
+                    paths_to_join = []
+                    for package_name, package_hash, subfolder_name in self.package_info.depends_on_packages:
+                        package_download_location = self.base_temp_folder / package_name / subfolder_name
+                        paths_to_join.append(str(package_download_location.resolve()))
+                    cmake_module_path = ';'.join(paths_to_join).replace('\\', '/')
+
+                if cmake_module_path:
+                    cmake_generate_cmd.extend([f"-DCMAKE_MODULE_PATH={cmake_module_path}"])
+
                 cmake_generate_cmd.extend(cmake_generator_args)
                 cmake_generate_cmd.extend(cmake_generator_args)
+                
                 if custom_cmake_install:
                 if custom_cmake_install:
                     cmake_generate_cmd.extend([f"-DCMAKE_INSTALL_PREFIX={str(self.build_install_folder.resolve())}"])
                     cmake_generate_cmd.extend([f"-DCMAKE_INSTALL_PREFIX={str(self.build_install_folder.resolve())}"])
 
 
@@ -593,30 +652,45 @@ class BuildInfo(object):
                         target_folder_path.mkdir(parents=True)
                         target_folder_path.mkdir(parents=True)
                     shutil.copy2(glob_result, str(target_folder_path.resolve()), follow_symlinks=False)
                     shutil.copy2(glob_result, str(target_folder_path.resolve()), follow_symlinks=False)
 
 
+    def create_custom_env(self):
+        custom_env = os.environ.copy()
+        custom_env['TARGET_INSTALL_ROOT'] = str(self.build_install_folder.resolve())
+        custom_env['PACKAGE_ROOT'] = str(self.package_install_root.resolve())
+        custom_env['TEMP_FOLDER'] = str(self.base_temp_folder.resolve())
+        if self.package_info.depends_on_packages:
+            package_folder_list = []
+            for package_name, _, subfoldername in self.package_info.depends_on_packages:
+                package_folder_list.append(str( (self.base_temp_folder / package_name / subfoldername).resolve().absolute()))
+            custom_env['DOWNLOADED_PACKAGE_FOLDERS'] = ';'.join(package_folder_list)
+        return custom_env
+
     def build_and_install_custom(self):
     def build_and_install_custom(self):
         """
         """
         Build and install from source using custom commands defined by 'custom_build_cmd' and 'custom_install_cmd'
         Build and install from source using custom commands defined by 'custom_build_cmd' and 'custom_install_cmd'
         """
         """
-
+        # we add TARGET_INSTALL_ROOT, TEMP_FOLDER and DOWNLOADED_PACKAGE_FOLDERS to the environ for both
+        # build and install, as they are useful to refer to from scripts.
+        
+        env_to_use = self.create_custom_env()
         custom_build_cmds = self.platform_config.get('custom_build_cmd', [])
         custom_build_cmds = self.platform_config.get('custom_build_cmd', [])
         for custom_build_cmd in custom_build_cmds:
         for custom_build_cmd in custom_build_cmds:
 
 
             call_result = subprocess.run(custom_build_cmd,
             call_result = subprocess.run(custom_build_cmd,
                                          shell=True,
                                          shell=True,
                                          capture_output=False,
                                          capture_output=False,
-                                         cwd=str(self.base_folder))
+                                         cwd=str(self.base_folder),
+                                         env=env_to_use)
             if call_result.returncode != 0:
             if call_result.returncode != 0:
                 raise BuildError(f"Error executing custom build command {custom_build_cmd}")
                 raise BuildError(f"Error executing custom build command {custom_build_cmd}")
 
 
         custom_install_cmds = self.platform_config.get('custom_install_cmd', [])
         custom_install_cmds = self.platform_config.get('custom_install_cmd', [])
-        custom_install_env = os.environ.copy()
-        custom_install_env['TARGET_INSTALL_ROOT'] = str(self.build_install_folder.resolve())
+       
         for custom_install_cmd in custom_install_cmds:
         for custom_install_cmd in custom_install_cmds:
             call_result = subprocess.run(custom_install_cmd,
             call_result = subprocess.run(custom_install_cmd,
                                          shell=True,
                                          shell=True,
                                          capture_output=False,
                                          capture_output=False,
                                          cwd=str(self.base_folder),
                                          cwd=str(self.base_folder),
-                                         env=custom_install_env)
+                                         env=env_to_use)
             if call_result.returncode != 0:
             if call_result.returncode != 0:
                 raise BuildError(f"Error executing custom install command {custom_install_cmd}")
                 raise BuildError(f"Error executing custom install command {custom_install_cmd}")
 
 
@@ -690,10 +764,8 @@ class BuildInfo(object):
             find_cmake_content = string.Template(template_file_content).substitute(template_env)
             find_cmake_content = string.Template(template_file_content).substitute(template_env)
 
 
         elif self.cmake_find_source is not None:
         elif self.cmake_find_source is not None:
-
             find_cmake_content = self.cmake_find_source.read_text("UTF-8", "ignore")
             find_cmake_content = self.cmake_find_source.read_text("UTF-8", "ignore")
 
 
-
         target_cmake_find_script = self.package_install_root / self.package_info.cmake_find_target
         target_cmake_find_script = self.package_install_root / self.package_info.cmake_find_target
         target_cmake_find_script.write_text(find_cmake_content)
         target_cmake_find_script.write_text(find_cmake_content)
 
 
@@ -745,6 +817,22 @@ class BuildInfo(object):
 
 
         pass
         pass
 
 
+    def test_package(self):
+        has_test_commands = self.check_build_keys(['custom_test_cmd'])
+        if not has_test_commands:
+            return
+
+        custom_test_cmds= self.platform_config.get('custom_test_cmd', [])
+        for custom_test_cmd in custom_test_cmds:
+
+            call_result = subprocess.run(custom_test_cmd,
+                                        shell=True,
+                                        capture_output=False,
+                                        cwd=str(self.base_folder),
+                                        env=self.create_custom_env())
+            if call_result.returncode != 0:
+                raise BuildError(f"Error executing custom test command {custom_test_cmd}")
+
     def execute(self):
     def execute(self):
         """
         """
         Perform all the steps to build a folder for the 3rd party library for packaging
         Perform all the steps to build a folder for the 3rd party library for packaging
@@ -765,6 +853,8 @@ class BuildInfo(object):
         # Generate the Find*.cmake file
         # Generate the Find*.cmake file
         self.generate_cmake()
         self.generate_cmake()
 
 
+        self.test_package()
+
         # Generate the package info file
         # Generate the package info file
         self.generate_package_info()
         self.generate_package_info()
 
 

+ 76 - 0
package-system/tiff/FindTIFF.cmake

@@ -0,0 +1,76 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+# TIFF depends on ZLIB.  For maximum compatibility here, we use the
+# official ZLIB library name, ie, ZLIB::ZLIB and not o3de 3rdParty::ZLIB.
+# O3DE's zlib package will define both.  If we're in O3DE we can also
+# auto-download ZLIB.
+if (NOT TARGET ZLIB::ZLIB)
+    if (COMMAND ly_download_associated_package)
+        ly_download_associated_package(ZLIB REQUIRED MODULE)
+    endif()
+    find_package(ZLIB)
+endif()
+
+# note that all variables defined in find_package will apply in THIS scope
+# which is why its a good idea to run them above before we do anything
+#  or risk them overwriting our own variables like TARGET_WITH_NAMESPACE:
+
+# this file actually ingests the library and defines targets.
+set(TARGET_WITH_NAMESPACE "3rdParty::TIFF")
+if (TARGET ${TARGET_WITH_NAMESPACE})
+    return()
+endif()
+
+# the following block sets the variables that are expected
+# if you were to use the built-in CMake FindTIFF.cmake
+set(TIFF_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/tiff/include)
+set(TIFF_INCLUDE_DIR ${TIFF_INCLUDE_DIRS})
+set(TIFF_LIBRARIES ${CMAKE_CURRENT_LIST_DIR}/tiff/lib/${CMAKE_STATIC_LIBRARY_PREFIX}tiff${CMAKE_STATIC_LIBRARY_SUFFIX})
+set(TIFF_LIBRARY ${TIFF_LIBRARIES})
+set(TIFF_LIBRARY_RELEASE ${TIFF_LIBRARIES})
+set(TIFF_LIBRARY_DEBUG ${TIFF_LIBRARIES})
+set(TIFF_FOUND True)
+
+set(TIFF_VERSION_STRING "4.2.0.15")
+set(TIFF_VERSION_MAJOR "4")
+set(TIFF_VERSION_MINOR "2")
+set(TIFF_VERSION_PATCH "0")
+set(TIFF_MAJOR_VERSION "4")
+set(TIFF_MINOR_VERSION "2")
+set(TIFF_PATCH_VERSION "0")
+set(TIFF_CXX_FOUND 0) # we don't support TIFF_Cxx feature
+set(TIFF_FOUND True)
+
+# add the CMake standard TIFF::TIFF library.  It is a static library.
+add_library(TIFF::TIFF STATIC IMPORTED GLOBAL)
+set_target_properties(TIFF::TIFF PROPERTIES IMPORTED_LOCATION "${TIFF_LIBRARY}")
+
+
+target_link_libraries(TIFF::TIFF INTERFACE ZLIB::ZLIB)
+
+if (COMMAND ly_target_include_system_directories)
+    # O3DE has an extension to fix system directory includes until CMake
+    # has a proper fix for it, so if its available, use that:
+    ly_target_include_system_directories(TARGET TIFF::TIFF INTERFACE ${TIFF_INCLUDE_DIRS})
+else()
+    # extension is not available (or not necessary anymore) 
+    # so use default CMake SYSTEM include feature:
+    target_include_directories(TIFF::TIFF SYSTEM INTERFACE ${TIFF_INCLUDE_DIRS})
+endif()
+
+# alias the TIFF library to the O3DE 3rdParty library
+add_library(${TARGET_WITH_NAMESPACE} ALIAS TIFF::TIFF)
+
+# if we're NOT in O3DE, it's also useful to show a message indicating that this
+# library was successfully picked up, as opposed to the system one.
+# A good way to know if you're in O3DE or not is that O3DE sets various cache variables before 
+# calling find_package, specifically, LY_VERSION_ENGINE_NAME is always set very early:
+if (NOT LY_VERSION_ENGINE_NAME)
+    message(STATUS "Using the O3DE version of the TIFF library from ${CMAKE_CURRENT_LIST_DIR}")
+endif()

+ 0 - 34
package-system/tiff/FindTIFF_compat.cmake

@@ -1,34 +0,0 @@
-#
-# Copyright (c) Contributors to the Open 3D Engine Project.
-# For complete copyright and license terms please see the LICENSE at the root of this distribution.
-# 
-# SPDX-License-Identifier: Apache-2.0 OR MIT
-#
-#
-
-# this file is provided to give compatibility to non-o3de-projects
-# it defines the same targets as is defined in the default FindTIFF.cmake
-# shipped with CMAKE.
-# Its meant to be deployed into the zlib subfolder of the package
-# and then allows you set the variable TIFF_ROOT on the command line to point at this folder,
-# to force it to use this package instead of system TIFF. 
-
-set(TIFF_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/include)
-set(TIFF_INCLUDE_DIR ${TIFF_INCLUDE_DIRS})
-set(TIFF_LIBRARIES ${CMAKE_CURRENT_LIST_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}tiff${CMAKE_STATIC_LIBRARY_SUFFIX})
-set(TIFF_LIBRARY ${TIFF_LIBRARIES})
-set(TIFF_LIBRARY_RELEASE ${TIFF_LIBRARIES})
-set(TIFF_LIBRARY_DEBUG ${TIFF_LIBRARIES})
-set(TIFF_FOUND True)
-
-set(TIFF_VERSION_STRING "4.2.0.15")
-set(TIFF_VERSION_MAJOR "4")
-set(TIFF_VERSION_MINOR "2")
-set(TIFF_VERSION_PATCH "0")
-set(TIFF_MAJOR_VERSION "4")
-set(TIFF_MINOR_VERSION "2")
-set(TIFF_PATCH_VERSION "0")
-
-add_library(TIFF::TIFF INTERFACE IMPORTED GLOBAL)
-set_target_properties(TIFF::TIFF PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${TIFF_INCLUDE_DIRS}")
-target_link_libraries(TIFF::TIFF INTERFACE ${TIFF_LIBRARIES})

+ 0 - 31
package-system/tiff/Findtiff.cmake

@@ -1,31 +0,0 @@
-#
-# Copyright (c) Contributors to the Open 3D Engine Project.
-# For complete copyright and license terms please see the LICENSE at the root of this distribution.
-# 
-# SPDX-License-Identifier: Apache-2.0 OR MIT
-#
-#
-
-# this file actually ingests the library and defines targets.
-set(TARGET_WITH_NAMESPACE "3rdParty::tiff")
-if (TARGET ${TARGET_WITH_NAMESPACE})
-    return()
-endif()
-
-set(TIFF_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/tiff/include)
-set(TIFF_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/tiff/lib)
-set(TIFF_CXX_FOUND 0)
-
-set(TIFF_LIBRARY_RELEASE ${TIFF_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}tiff${CMAKE_STATIC_LIBRARY_SUFFIX})
-set(TIFF_LIBRARY_DEBUG ${TIFF_LIBRARY_RELEASE})
-
-# we set it to a generator expression for multi-config situations:
-set(TIFF_LIBRARY                  "$<$<CONFIG:profile>:${TIFF_LIBRARY_RELEASE}>")
-set(TIFF_LIBRARY ${TIFF_LIBRARY} "$<$<CONFIG:Release>:${TIFF_LIBRARY_RELEASE}>")
-set(TIFF_LIBRARY ${TIFF_LIBRARY} "$<$<CONFIG:Debug>:${TIFF_LIBRARY_DEBUG}>")
-
-add_library(${TARGET_WITH_NAMESPACE} INTERFACE IMPORTED GLOBAL)
-ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${TIFF_INCLUDE_DIR})
-target_link_libraries(${TARGET_WITH_NAMESPACE} INTERFACE ${TIFF_LIBRARY})
-
-set(TIFF_FOUND True)

+ 37 - 6
package-system/tiff/build_config.json

@@ -2,60 +2,91 @@
     "git_url":"https://gitlab.com/libtiff/libtiff.git",
     "git_url":"https://gitlab.com/libtiff/libtiff.git",
     "git_tag":"v4.2.0",
     "git_tag":"v4.2.0",
     "package_name":"tiff",
     "package_name":"tiff",
-    "package_version":"4.2.0.15-rev2",
+    "package_version":"4.2.0.15-rev3",
     "package_url":"http://www.simplesystems.org/libtiff/misc.html",
     "package_url":"http://www.simplesystems.org/libtiff/misc.html",
     "package_license":"libtiff",
     "package_license":"libtiff",
     "package_license_file":"COPYRIGHT",
     "package_license_file":"COPYRIGHT",
-    "cmake_find_source":"Findtiff.cmake",
-    "cmake_find_target":"Findtiff.cmake",
+    "cmake_find_source":"FindTIFF.cmake",
+    "cmake_find_target":"FindTIFF.cmake",
     "cmake_build_args" : [ "-j", "8"],
     "cmake_build_args" : [ "-j", "8"],
     "patch_file" : "o3de_patch.patch",
     "patch_file" : "o3de_patch.patch",
     "Platforms":{
     "Platforms":{
         "Windows":{
         "Windows":{
             "Windows":{
             "Windows":{
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-windows", "8847112429744eb11d92c44026fc5fc53caa4a06709382b5f13978f3c26c4cbd", ""]
+                ],
                 "custom_build_cmd" : [
                 "custom_build_cmd" : [
                     "build_tiff_windows.cmd"
                     "build_tiff_windows.cmd"
                 ],
                 ],
                 "custom_install_cmd": [
                 "custom_install_cmd": [
                     "install_tiff_windows.cmd"
                     "install_tiff_windows.cmd"
+                ],
+                "custom_test_cmd" : [
+                    "test_tiff_windows.cmd"
                 ]
                 ]
             },
             },
             "Android":{
             "Android":{
+                "package_version":"4.2.0.15-rev4",
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-android", "73c9e88892c237a3fc6eafc04268ccd9d479e6d55f9df2ed58b236c8f9cf2cae", ""]
+                ],
                 "custom_build_cmd" : [
                 "custom_build_cmd" : [
                     "build_tiff_android.cmd"
                     "build_tiff_android.cmd"
                 ],
                 ],
                 "custom_install_cmd": [
                 "custom_install_cmd": [
                     "install_tiff_android.cmd"
                     "install_tiff_android.cmd"
+                ],
+                "custom_test_cmd": [
+                    "test_tiff_android.cmd"
                 ]
                 ]
             }
             }
         },
         },
         
         
         "Darwin":{
         "Darwin":{
             "Mac":{
             "Mac":{
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-mac", "b6fea9c79b8bf106d4703b67fecaa133f832ad28696c2ceef45fb5f20013c096", ""]
+                ],
                 "custom_build_cmd": [
                 "custom_build_cmd": [
                     "./build_tiff_mac.sh"
                     "./build_tiff_mac.sh"
                  ],
                  ],
                  "custom_install_cmd": [
                  "custom_install_cmd": [
                     "./install_tiff_mac.sh"
                     "./install_tiff_mac.sh"
-                 ]
+                 ],
+                 "custom_test_cmd" : [
+                    "./test_tiff_mac.sh"
+                ]
             },
             },
             "iOS":{
             "iOS":{
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-ios", "c7f10b4d0fe63192054d926f53b08e852cdf472bc2b18e2f7be5aecac1869f7f", ""]
+                ],
                 "custom_build_cmd": [
                 "custom_build_cmd": [
                     "./build_tiff_ios.sh"
                     "./build_tiff_ios.sh"
                  ],
                  ],
                  "custom_install_cmd": [
                  "custom_install_cmd": [
                     "./install_tiff_ios.sh"
                     "./install_tiff_ios.sh"
-                 ]
+                 ],
+                 "custom_test_cmd" : [
+                    "./test_tiff_ios.sh"
+                ]
              }
              }
         },
         },
         "Linux":{
         "Linux":{
             "Linux":{
             "Linux":{
+                "depends_on_packages" :[ 
+                    ["zlib-1.2.11-rev5-linux", "9be5ea85722fc27a8645a9c8a812669d107c68e6baa2ca0740872eaeb6a8b0fc", ""]
+                ],
                 "custom_build_cmd": [
                 "custom_build_cmd": [
                     "./build_tiff_linux.sh"
                     "./build_tiff_linux.sh"
                 ],
                 ],
                 "custom_install_cmd": [
                 "custom_install_cmd": [
                     "./install_tiff_linux.sh"
                     "./install_tiff_linux.sh"
-                ]
+                ],
+                "custom_test_cmd" : [
+                   "./test_tiff_linux.sh"
+               ]
             }
             }
         }
         }
     }
     }

+ 26 - 9
package-system/tiff/build_tiff_android.cmd

@@ -5,14 +5,31 @@
 @rem # SPDX-License-Identifier: Apache-2.0 OR MIT
 @rem # SPDX-License-Identifier: Apache-2.0 OR MIT
 @rem #
 @rem #
 
 
-@IF "%LY_ANDROID_NDK_ROOT%" == "" (
-    @echo Need to set the varible LY_ANDROID_NDK_ROOT to the location of your NDK install!
-    @exit /b 1
-)
+@rem # note that we explicitly turn off the compilation of all features that rely on 3rd Party Libraries
+@rem # except the ones we want.  This prevents the cmake build system from automatically finding things
+@rem # if they happen to be installed locally, which we don't want.
 
 
-cmake -S temp/src -B temp/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_STANDARD=17 -DCMAKE_TOOLCHAIN_FILE=%LY_ANDROID_NDK_ROOT%\\build\\cmake\\android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DBUILD_SHARED_LIBS=OFF -Djpeg=OFF -Dold-jpeg=OFF -Dpixarlog=OFF -Dzlib=ON -DZLIB_ROOT=../zlib-android/zlib -DCMAKE_POLICY_DEFAULT_CMP0074=NEW
-@if %errorlevel% NEQ 0 ( exit /b 1 )
-cmake --build temp/build --target tiff -j 8
-@if %errorlevel% NEQ 0 ( exit /b 1 )
+@rem # cmake expects fowardslashes:
+set "DOWNLOADED_PACKAGE_FOLDERS=%DOWNLOADED_PACKAGE_FOLDERS:\=/%"
 
 
-exit /b 0
+cmake -S temp/src -B temp/build -G Ninja ^
+    -DCMAKE_BUILD_TYPE=Release ^
+    -DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/Android/Toolchain_android.cmake ^
+    -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ^
+    -DBUILD_SHARED_LIBS=OFF ^
+    -Djpeg=OFF ^
+    -Dold-jpeg=OFF ^
+    -Dpixarlog=OFF ^
+    -Dlzma=OFF ^
+    -Dwebp=OFF ^
+    -Djbig=OFF ^
+    -Dzstd=OFF ^
+    -Djpeg12=OFF ^
+    -Dzlib=ON ^
+    -Dlibdeflate=OFF ^
+    -Dcxx=OFF ^
+    -DCMAKE_MODULE_PATH="%DOWNLOADED_PACKAGE_FOLDERS%" || exit /b 1
+
+cmake --build temp/build --target tiff --parallel || exit /b 1
+
+exit /b

+ 21 - 22
package-system/tiff/build_tiff_ios.sh

@@ -6,26 +6,25 @@
 #
 #
 #
 #
 
 
-cmake -S temp/src -B temp/build -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 \
-                                         -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 \
-                                         -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
-                                         -DCMAKE_C_FLAGS="-fPIC" \
-                                         -DBUILD_SHARED_LIBS=OFF \
-                                         -Djpeg=OFF -Dold-jpeg=OFF -Dpixarlog=OFF \
-                                         -Dzlib=ON -DZLIB_ROOT=../zlib-ios/zlib \
-                                         -Dlzma=OFF \
-                                         -DCMAKE_MACOSX_BUNDLE=OFF \
-                                         -Dwebp=OFF \
-                                         -Djbig=OFF \
-                                         -Dzstd=OFF \
-                                         -Djpeg12=OFF
-if [ $? -ne 0 ]; then
-    echo "Error generating build"
-    exit 1
-fi
+# note that we explicitly turn off the compilation of all features that rely on 3rd Party Libraries
+# except the ones we want.  This prevents the cmake build system from automatically finding things
+# if they happen to be installed locally, which we don't want.
+cmake -S temp/src -B temp/build -G Xcode \
+    -DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/iOS/Toolchain_ios.cmake \
+    -DCMAKE_MACOSX_BUNDLE=OFF \
+    -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
+    -DBUILD_SHARED_LIBS=OFF \
+    -Djpeg=OFF \
+    -Dold-jpeg=OFF \
+    -Dpixarlog=OFF \
+    -Dlzma=OFF \
+    -Dwebp=OFF \
+    -Djbig=OFF \
+    -Dzstd=OFF \
+    -Djpeg12=OFF \
+    -Dzlib=ON \
+    -Dlibdeflate=OFF \
+    -Dcxx=OFF \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS" || exit 1
 
 
-cmake --build temp/build --target tiff --config Release -j 8
-if [ $? -ne 0 ]; then
-    echo "Error building"
-    exit 1
-fi
+cmake --build temp/build --target tiff --config Release --parallel || exit 1

+ 21 - 21
package-system/tiff/build_tiff_linux.sh

@@ -6,25 +6,25 @@
 #
 #
 #
 #
 
 
-cmake -S temp/src -B temp/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 \
-                                -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
-                                -DCMAKE_C_FLAGS="-fPIC" \
-                                -DBUILD_SHARED_LIBS=OFF \
-                                -Djpeg=OFF -Dold-jpeg=OFF -Dpixarlog=OFF \
-                                -Dlzma=OFF \
-                                -Dzlib=ON -DZLIB_ROOT=../zlib-linux/zlib \
-                                -Dwebp=OFF \
-                                -Djbig=OFF \
-                                -Dzstd=OFF \
-                                -Djpeg12=OFF
-                                
-if [ $? -ne 0 ]; then
-    echo "Error generating build"
-    exit 1
-fi
+# note that we explicitly turn off the compilation of all features that rely on 3rd Party Libraries
+# except the ones we want.  This prevents the cmake build system from automatically finding things
+# if they happen to be installed locally, which we don't want.
+cmake -S temp/src -B temp/build \
+    -DCMAKE_BUILD_TYPE=Release \
+    -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
+    -DCMAKE_C_FLAGS="-fPIC" \
+    -DBUILD_SHARED_LIBS=OFF \
+    -Djpeg=OFF \
+    -Dold-jpeg=OFF \
+    -Dpixarlog=OFF \
+    -Dlzma=OFF \
+    -Dwebp=OFF \
+    -Djbig=OFF \
+    -Dzstd=OFF \
+    -Djpeg12=OFF \
+    -Dzlib=ON \
+    -Dlibdeflate=OFF \
+    -Dcxx=OFF \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS" || exit 1
 
 
-cmake --build temp/build --target tiff -j 8
-if [ $? -ne 0 ]; then
-    echo "Error building"
-    exit 1
-fi
+cmake --build temp/build --target tiff --parallel || exit 1

+ 20 - 22
package-system/tiff/build_tiff_mac.sh

@@ -6,26 +6,24 @@
 #
 #
 #
 #
 
 
-cmake -S temp/src -B temp/build -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 \
-                                         -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
-                                         -DCMAKE_C_FLAGS="-fPIC" \
-                                         -DBUILD_SHARED_LIBS=OFF \
-                                         -Djpeg=OFF -Dold-jpeg=OFF -Dpixarlog=OFF \
-                                         -Dlzma=OFF \
-                                         -Dzlib=ON -DZLIB_ROOT=../zlib-mac/zlib \
-                                         -Dwebp=OFF \
-                                         -Djbig=OFF \
-                                         -Dzstd=OFF \
-                                         -Djpeg12=OFF
-
-if [ $? -ne 0 ]; then
-    echo "Error generating build"
-    exit 1
-fi
-
-cmake --build temp/build --target tiff --config Release -j 8
-if [ $? -ne 0 ]; then
-    echo "Error building"
-    exit 1
-fi
+# note that we explicitly turn off the compilation of all features that rely on 3rd Party Libraries
+# except the ones we want.  This prevents the cmake build system from automatically finding things
+# if they happen to be installed locally, which we don't want.
+cmake -S temp/src -B temp/build -G Xcode \
+    -DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/Mac/Toolchain_mac.cmake \
+    -DCMAKE_C_FLAGS="-fPIC" \
+    -DBUILD_SHARED_LIBS=OFF \
+    -Djpeg=OFF \
+    -Dold-jpeg=OFF \
+    -Dpixarlog=OFF \
+    -Dlzma=OFF \
+    -Dwebp=OFF \
+    -Djbig=OFF \
+    -Dzstd=OFF \
+    -Djpeg12=OFF \
+    -Dzlib=ON \
+    -Dlibdeflate=OFF \
+    -Dcxx=OFF \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS" || exit 1
 
 
+cmake --build temp/build --target tiff --config Release --parallel || exit 1

+ 24 - 13
package-system/tiff/build_tiff_windows.cmd

@@ -5,18 +5,29 @@
 @rem # SPDX-License-Identifier: Apache-2.0 OR MIT
 @rem # SPDX-License-Identifier: Apache-2.0 OR MIT
 @rem #
 @rem #
 
 
-cmake -S temp/src -B temp/build -DCMAKE_CXX_STANDARD=17 ^
-                                -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ^
-                                -DBUILD_SHARED_LIBS=OFF ^
-                                -Djpeg=OFF -Dold-jpeg=OFF -Dpixarlog=OFF ^
-                                -Dlzma=OFF ^
-                                -Dzlib=ON -DZLIB_ROOT=../zlib-windows/zlib ^
-                                -Dwebp=OFF ^
-                                -Djbig=OFF ^
-                                -Dzstd=OFF ^
-                                -Djpeg12=OFF
-@if %errorlevel% NEQ 0 ( exit /b 1 )
-cmake --build temp/build --target tiff --config Release -j 8
-@if %errorlevel% NEQ 0 ( exit /b 1 )
+@rem # note that we explicitly turn off the compilation of all features that rely on 3rd Party Libraries
+@rem # except the ones we want.  This prevents the cmake build system from automatically finding things
+@rem # if they happen to be installed locally, which we don't want.
+
+@rem # cmake expects fowardslashes:
+set "DOWNLOADED_PACKAGE_FOLDERS=%DOWNLOADED_PACKAGE_FOLDERS:\=/%"
+
+cmake -S temp/src -B temp/build ^
+    -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ^
+    -DBUILD_SHARED_LIBS=OFF ^
+    -Djpeg=OFF ^
+    -Dold-jpeg=OFF ^
+    -Dpixarlog=OFF ^
+    -Dlzma=OFF ^
+    -Dwebp=OFF ^
+    -Djbig=OFF ^
+    -Dzstd=OFF ^
+    -Djpeg12=OFF ^
+    -Dzlib=ON ^
+    -Dlibdeflate=OFF ^
+    -Dcxx=OFF ^
+    -DCMAKE_MODULE_PATH="%DOWNLOADED_PACKAGE_FOLDERS%" || exit /b 1
+
+cmake --build temp/build --target tiff --config Release --parallel || exit /b 1
 
 
 exit /b 0
 exit /b 0

+ 3 - 5
package-system/tiff/install_tiff_android.cmd

@@ -16,17 +16,15 @@ mkdir %OUT_PATH%\lib
 
 
 copy %BLD_PATH%\libtiff\tiffconf.h %OUT_PATH%\include\tiffconf.h
 copy %BLD_PATH%\libtiff\tiffconf.h %OUT_PATH%\include\tiffconf.h
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 @if %errorlevel% NEQ 0 ( exit /b 1 )
-copy %BLD_PATH%\libtiff\tif_config.h %OUT_PATH%\include\tif_config.h
-@if %errorlevel% NEQ 0 ( exit /b 1 )
-copy %SRC_PATH%\libtiff\tiffio.h %OUT_PATH%\include\tiffio.h
+copy %SRC_PATH%\libtiff\tiff.h %OUT_PATH%\include\tiff.h
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 copy %SRC_PATH%\libtiff\tiffvers.h %OUT_PATH%\include\tiffvers.h
 copy %SRC_PATH%\libtiff\tiffvers.h %OUT_PATH%\include\tiffvers.h
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 @if %errorlevel% NEQ 0 ( exit /b 1 )
+copy %SRC_PATH%\libtiff\tiffio.h %OUT_PATH%\include\tiffio.h
+@if %errorlevel% NEQ 0 ( exit /b 1 )
 copy %SRC_PATH%\COPYRIGHT %OUT_PATH%\COPYRIGHT
 copy %SRC_PATH%\COPYRIGHT %OUT_PATH%\COPYRIGHT
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 copy %BLD_PATH%\libtiff\libtiff.a %OUT_PATH%\lib\libtiff.a
 copy %BLD_PATH%\libtiff\libtiff.a %OUT_PATH%\lib\libtiff.a
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 @if %errorlevel% NEQ 0 ( exit /b 1 )
-copy FindTIFF_compat.cmake %OUT_PATH%\FindTIFF.cmake
-@if %errorlevel% NEQ 0 ( exit /b 1 )
 
 
 exit /b 0
 exit /b 0

+ 0 - 1
package-system/tiff/install_tiff_ios.sh

@@ -22,6 +22,5 @@ cp $BLD_PATH/libtiff/tiffconf.h $OUT_PATH/include/tiffconf.h || exit 1
 cp $SRC_PATH/libtiff/tiff.h $OUT_PATH/include/tiff.h || exit 1
 cp $SRC_PATH/libtiff/tiff.h $OUT_PATH/include/tiff.h || exit 1
 cp $SRC_PATH/libtiff/tiffvers.h $OUT_PATH/include/tiffvers.h || exit 1
 cp $SRC_PATH/libtiff/tiffvers.h $OUT_PATH/include/tiffvers.h || exit 1
 cp $SRC_PATH/libtiff/tiffio.h $OUT_PATH/include/tiffio.h || exit 1
 cp $SRC_PATH/libtiff/tiffio.h $OUT_PATH/include/tiffio.h || exit 1
-cp FindTIFF_compat.cmake $OUT_PATH/FindTIFF.cmake || exit 1
 
 
 exit 0
 exit 0

+ 0 - 1
package-system/tiff/install_tiff_linux.sh

@@ -22,6 +22,5 @@ cp $BLD_PATH/libtiff/tiffconf.h $OUT_PATH/include/tiffconf.h || exit 1
 cp $SRC_PATH/libtiff/tiff.h $OUT_PATH/include/tiff.h || exit 1
 cp $SRC_PATH/libtiff/tiff.h $OUT_PATH/include/tiff.h || exit 1
 cp $SRC_PATH/libtiff/tiffvers.h $OUT_PATH/include/tiffvers.h || exit 1
 cp $SRC_PATH/libtiff/tiffvers.h $OUT_PATH/include/tiffvers.h || exit 1
 cp $SRC_PATH/libtiff/tiffio.h $OUT_PATH/include/tiffio.h || exit 1
 cp $SRC_PATH/libtiff/tiffio.h $OUT_PATH/include/tiffio.h || exit 1
-cp FindTIFF_compat.cmake $OUT_PATH/FindTIFF.cmake || exit 1
 
 
 exit 0
 exit 0

+ 1 - 1
package-system/tiff/install_tiff_mac.sh

@@ -22,6 +22,6 @@ cp $BLD_PATH/libtiff/tiffconf.h $OUT_PATH/include/tiffconf.h || exit 1
 cp $SRC_PATH/libtiff/tiff.h $OUT_PATH/include/tiff.h || exit 1
 cp $SRC_PATH/libtiff/tiff.h $OUT_PATH/include/tiff.h || exit 1
 cp $SRC_PATH/libtiff/tiffvers.h $OUT_PATH/include/tiffvers.h || exit 1
 cp $SRC_PATH/libtiff/tiffvers.h $OUT_PATH/include/tiffvers.h || exit 1
 cp $SRC_PATH/libtiff/tiffio.h $OUT_PATH/include/tiffio.h || exit 1
 cp $SRC_PATH/libtiff/tiffio.h $OUT_PATH/include/tiffio.h || exit 1
-cp FindTIFF_compat.cmake $OUT_PATH/FindTIFF.cmake || exit 1
+
 
 
 exit 0
 exit 0

+ 0 - 2
package-system/tiff/install_tiff_windows.cmd

@@ -26,7 +26,5 @@ copy %SRC_PATH%\COPYRIGHT %OUT_PATH%\COPYRIGHT
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 copy %BLD_PATH%\libtiff\Release\tiff.lib %OUT_PATH%\lib\tiff.lib
 copy %BLD_PATH%\libtiff\Release\tiff.lib %OUT_PATH%\lib\tiff.lib
 @if %errorlevel% NEQ 0 ( exit /b 1 )
 @if %errorlevel% NEQ 0 ( exit /b 1 )
-copy FindTIFF_compat.cmake %OUT_PATH%\FindTIFF.cmake
-@if %errorlevel% NEQ 0 ( exit /b 1 )
 
 
 exit /b 0
 exit /b 0

+ 25 - 0
package-system/tiff/test/CMakeLists.txt

@@ -0,0 +1,25 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+cmake_minimum_required(VERSION 3.20)
+
+PROJECT(test_TIFF VERSION 1.0 LANGUAGES C)
+
+find_package(TIFF)
+
+add_executable(test_TIFF test_tiff.c)
+
+# note that we use 3rdParty::TIFF here.  This will ONLY work 
+# if the O3DE version of TIFF is used, which is what we are testing for.
+target_link_libraries(test_TIFF PRIVATE 3rdParty::TIFF)
+
+set_target_properties(test_TIFF PROPERTIES
+                 XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED OFF
+                 MACOSX_BUNDLE TRUE
+                 XCODE_ATTRIBUTE_EXECUTABLE_NAME "test_TIFF")
+

+ 23 - 0
package-system/tiff/test/test_tiff.c

@@ -0,0 +1,23 @@
+/*
+ Copyright (c) Contributors to the Open 3D Engine Project.
+ For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ 
+ SPDX-License-Identifier: Apache-2.0 OR MIT
+*/
+
+// test that the TIFF library imports correctly
+// Doesn't test much else about it.  Can be expanded if this becomes a problem in the
+// future.
+
+#include <tiffio.h>
+#include <stdio.h>
+
+int main()
+{
+    printf("Tiff Version: %s\n", TIFFGetVersion());
+    if (TIFFGetVersion())
+    {
+        return 0;
+    }
+    return 1;
+}

+ 27 - 0
package-system/tiff/test_tiff_android.cmd

@@ -0,0 +1,27 @@
+@rem #
+@rem # Copyright (c) Contributors to the Open 3D Engine Project.
+@rem # For complete copyright and license terms please see the LICENSE at the root of this distribution.
+@rem # 
+@rem # SPDX-License-Identifier: Apache-2.0 OR MIT
+@rem #
+@rem #
+
+rmdir /S /Q  temp\build_test
+mkdir temp\build_test
+
+@rem CMAKE demands forward slashes but PACKAGE_ROOT is in native path:
+set "PACKAGE_ROOT=%PACKAGE_ROOT:\=/%"
+set "DOWNLOADED_PACKAGE_FOLDERS=%DOWNLOADED_PACKAGE_FOLDERS:\=/%"
+
+cmake -S test -B temp/build_test ^
+    -G Ninja ^
+    -DCMAKE_BUILD_TYPE=Release ^
+    -DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/Android/Toolchain_android.cmake ^
+    -DCMAKE_MODULE_PATH="%DOWNLOADED_PACKAGE_FOLDERS%;%PACKAGE_ROOT%" || exit /b 1
+
+cmake --build temp/build_test --parallel || exit /b 1
+
+@rem we can't actually run this - its an android binary.  But at least the above
+@rem makes sure it links and that our FindTIFF script is working.
+
+exit /b 0

+ 21 - 0
package-system/tiff/test_tiff_ios.sh

@@ -0,0 +1,21 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+rm -rf temp/build_test
+mkdir temp/build_test
+
+cmake -S test -B temp/build_test -G Xcode \
+    -DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/iOS/Toolchain_ios.cmake \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS;$PACKAGE_ROOT" || exit 1
+
+cmake --build temp/build_test --parallel --config Release || exit 1
+
+# we can't actually run it on ios, that'd require an emulator or device as well as
+# cert / signing - but we can at least make sure it compiles.
+
+exit 0

+ 19 - 0
package-system/tiff/test_tiff_linux.sh

@@ -0,0 +1,19 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+rm -rf temp/build_test
+mkdir temp/build_test
+
+cmake -S test -B temp/build_test -G Ninja -DCMAKE_BUILD_TYPE=Release  \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS;$PACKAGE_ROOT" || exit 1
+
+cmake --build temp/build_test --parallel || exit 1
+
+temp/build_test/test_TIFF || exit 1
+
+exit 0

+ 20 - 0
package-system/tiff/test_tiff_mac.sh

@@ -0,0 +1,20 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+rm -rf temp/build_test
+mkdir temp/build_test
+
+cmake -S test -B temp/build_test -G Xcode \
+    -DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/Mac/Toolchain_mac.cmake \
+    -DCMAKE_MODULE_PATH="$DOWNLOADED_PACKAGE_FOLDERS;$PACKAGE_ROOT" || exit 1
+
+cmake --build temp/build_test --parallel --config Release || exit 1
+
+temp/build_test/Release/test_TIFF.app/Contents/MacOS/test_TIFF || exit 1
+
+exit 0

+ 23 - 0
package-system/tiff/test_tiff_windows.cmd

@@ -0,0 +1,23 @@
+@rem #
+@rem # Copyright (c) Contributors to the Open 3D Engine Project.
+@rem # For complete copyright and license terms please see the LICENSE at the root of this distribution.
+@rem # 
+@rem # SPDX-License-Identifier: Apache-2.0 OR MIT
+@rem #
+@rem #
+
+rmdir /S /Q  temp\build_test
+mkdir temp\build_test
+
+@rem CMAKE demands forward slashes but PACKAGE_ROOT is in native path:
+set "PACKAGE_ROOT=%PACKAGE_ROOT:\=/%"
+set "DOWNLOADED_PACKAGE_FOLDERS=%DOWNLOADED_PACKAGE_FOLDERS:\=/%"
+
+cmake -S test -B temp/build_test ^
+    -DCMAKE_MODULE_PATH="%DOWNLOADED_PACKAGE_FOLDERS%;%PACKAGE_ROOT%" || exit /b 1
+
+cmake --build temp/build_test --parallel --config Release || exit /b 1
+
+temp\build_test\Release\test_TIFF.exe || exit /b 1
+
+exit /b 0

+ 4 - 4
package_build_list_host_darwin.json

@@ -42,8 +42,8 @@
         "zlib-1.2.11-rev5-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name iOS --package-root ../../package-system --clean",
         "zlib-1.2.11-rev5-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name iOS --package-root ../../package-system --clean",
         "lz4-1.9.3-vcpkg-rev4-mac": "package-system/lz4/build_package_image.py --platform-name mac",
         "lz4-1.9.3-vcpkg-rev4-mac": "package-system/lz4/build_package_image.py --platform-name mac",
         "lz4-1.9.3-vcpkg-rev4-ios": "package-system/lz4/build_package_image.py --platform-name ios",
         "lz4-1.9.3-vcpkg-rev4-ios": "package-system/lz4/build_package_image.py --platform-name ios",
-        "tiff-4.2.0.15-rev2-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Mac --package-root ../../package-system --clean",
-        "tiff-4.2.0.15-rev2-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name iOS --package-root ../../package-system --clean"
+        "tiff-4.2.0.15-rev3-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Mac --package-root ../../package-system --clean",
+        "tiff-4.2.0.15-rev3-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name iOS --package-root ../../package-system --clean"
     },
     },
     "build_from_folder": {
     "build_from_folder": {
         "AWSNativeSDK-1.7.167-rev5-mac": "package-system/AWSNativeSDK-mac",
         "AWSNativeSDK-1.7.167-rev5-mac": "package-system/AWSNativeSDK-mac",
@@ -65,8 +65,8 @@
         "OpenSSL-1.1.1b-rev2-mac": "package-system/OpenSSL-mac",
         "OpenSSL-1.1.1b-rev2-mac": "package-system/OpenSSL-mac",
         "OpenSSL-1.1.1b-rev2-ios": "package-system/OpenSSL-ios",
         "OpenSSL-1.1.1b-rev2-ios": "package-system/OpenSSL-ios",
         "ilmbase-2.3.0-rev4-mac": "package-system/ilmbase-mac",
         "ilmbase-2.3.0-rev4-mac": "package-system/ilmbase-mac",
-        "tiff-4.2.0.15-rev2-mac": "package-system/tiff-mac",
-        "tiff-4.2.0.15-rev2-ios": "package-system/tiff-ios",
+        "tiff-4.2.0.15-rev3-mac": "package-system/tiff-mac",
+        "tiff-4.2.0.15-rev3-ios": "package-system/tiff-ios",
         "python-3.7.10-rev1-darwin": "package-system/python/darwin_x64/package",
         "python-3.7.10-rev1-darwin": "package-system/python/darwin_x64/package",
         "asn1-0.9.27-rev2-ios": "package-system/asn1-ios",
         "asn1-0.9.27-rev2-ios": "package-system/asn1-ios",
         "PhysX-4.1.2.29882248-rev3-mac": "package-system/PhysX-mac",
         "PhysX-4.1.2.29882248-rev3-mac": "package-system/PhysX-mac",

+ 2 - 2
package_build_list_host_linux.json

@@ -25,7 +25,7 @@
         "astc-encoder-3.2-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/astc-encoder --platform-name Linux --package-root ../../package-system --clean",
         "astc-encoder-3.2-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/astc-encoder --platform-name Linux --package-root ../../package-system --clean",
         "DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/DirectXShaderCompiler --platform-name Linux --package-root ../../package-system --clean",
         "DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/DirectXShaderCompiler --platform-name Linux --package-root ../../package-system --clean",
         "azslc-1.7.23-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/azslc --platform-name Linux --package-root ../../package-system --clean",
         "azslc-1.7.23-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/azslc --platform-name Linux --package-root ../../package-system --clean",
-        "tiff-4.2.0.15-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Linux --package-root ../../package-system --clean",
+        "tiff-4.2.0.15-rev3-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Linux --package-root ../../package-system --clean",
         "python-3.7.10-rev2-linux": "package-system/python/build_package_image.py",
         "python-3.7.10-rev2-linux": "package-system/python/build_package_image.py",
         "mikkelsen-1.0.0.4-linux": "package-system/mikkelsen/build_package_image.py",
         "mikkelsen-1.0.0.4-linux": "package-system/mikkelsen/build_package_image.py",
         "zlib-1.2.11-rev5-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Linux --package-root ../../package-system --clean",
         "zlib-1.2.11-rev5-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Linux --package-root ../../package-system --clean",
@@ -50,7 +50,7 @@
         "astc-encoder-3.2-rev1-linux": "package-system/astc-encoder-linux",
         "astc-encoder-3.2-rev1-linux": "package-system/astc-encoder-linux",
         "DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-linux": "package-system/DirectXShaderCompilerDxc-linux",
         "DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-linux": "package-system/DirectXShaderCompilerDxc-linux",
         "azslc-1.7.23-rev2-linux": "package-system/azslc-linux",
         "azslc-1.7.23-rev2-linux": "package-system/azslc-linux",
-        "tiff-4.2.0.15-rev2-linux": "package-system/tiff-linux",
+        "tiff-4.2.0.15-rev3-linux": "package-system/tiff-linux",
         "python-3.7.10-rev2-linux": "package-system/python/linux_x64/package",
         "python-3.7.10-rev2-linux": "package-system/python/linux_x64/package",
         "PhysX-4.1.2.29882248-rev3-linux": "package-system/PhysX-linux",
         "PhysX-4.1.2.29882248-rev3-linux": "package-system/PhysX-linux",
         "NvCloth-v1.1.6-4-gd243404-pr58-rev1-linux": "package-system/NvCloth-linux",
         "NvCloth-v1.1.6-4-gd243404-pr58-rev1-linux": "package-system/NvCloth-linux",

+ 4 - 4
package_build_list_host_windows.json

@@ -46,8 +46,8 @@
         "zlib-1.2.11-rev5-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Android --package-root ../../package-system --clean",
         "zlib-1.2.11-rev5-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Android --package-root ../../package-system --clean",
         "lz4-1.9.3-vcpkg-rev4-windows": "package-system/lz4/build_package_image.py --platform-name windows",
         "lz4-1.9.3-vcpkg-rev4-windows": "package-system/lz4/build_package_image.py --platform-name windows",
         "lz4-1.9.3-vcpkg-rev4-android": "package-system/lz4/build_package_image.py --platform-name android",
         "lz4-1.9.3-vcpkg-rev4-android": "package-system/lz4/build_package_image.py --platform-name android",
-        "tiff-4.2.0.15-rev2-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Windows --package-root ../../package-system --clean",
-        "tiff-4.2.0.15-rev2-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Android --package-root ../../package-system --clean"
+        "tiff-4.2.0.15-rev3-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Windows --package-root ../../package-system --clean",
+        "tiff-4.2.0.15-rev4-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Android --package-root ../../package-system --clean"
     },
     },
     "build_from_folder": {
     "build_from_folder": {
         "AWSGameLiftServerSDK-3.4.1-rev1-windows": "package-system/AWSGameLiftServerSDK/windows",
         "AWSGameLiftServerSDK-3.4.1-rev1-windows": "package-system/AWSGameLiftServerSDK/windows",
@@ -71,8 +71,8 @@
         "libsamplerate-0.2.1-rev2-android": "package-system/libsamplerate-android",
         "libsamplerate-0.2.1-rev2-android": "package-system/libsamplerate-android",
         "OpenSSL-1.1.1b-rev2-windows": "package-system/OpenSSL-windows",
         "OpenSSL-1.1.1b-rev2-windows": "package-system/OpenSSL-windows",
         "OpenSSL-1.1.1b-rev1-android": "package-system/OpenSSL-android",
         "OpenSSL-1.1.1b-rev1-android": "package-system/OpenSSL-android",
-        "tiff-4.2.0.15-rev2-android": "package-system/tiff-android",
-        "tiff-4.2.0.15-rev2-windows": "package-system/tiff-windows",
+        "tiff-4.2.0.15-rev4-android": "package-system/tiff-android",
+        "tiff-4.2.0.15-rev3-windows": "package-system/tiff-windows",
         "lux_core-2.2-rev5-multiplatform": "package-system/luxcore-multiplatform",
         "lux_core-2.2-rev5-multiplatform": "package-system/luxcore-multiplatform",
         "python-3.7.10-rev2-windows": "package-system/python/win_x64/package",
         "python-3.7.10-rev2-windows": "package-system/python/win_x64/package",
         "pybind11-2.4.3-rev1-multiplatform": "package-system/pybind11-multiplatform",
         "pybind11-2.4.3-rev1-multiplatform": "package-system/pybind11-multiplatform",