Sfoglia il codice sorgente

add freetype library build scripts (#41)

* Add initial revision of code to generate freetype 3p library
* add parameterization of the build config name per platform
* Fix build settings for Linux
* Changes to get freetype building on Mac
* Changes to get android building & fix windows build
* Update freetype package revision to 16
* Update license header on the freetype build scripts & cmake files

Signed-off-by: rgba16f <[email protected]>
rgba16f [Amazon] 3 anni fa
parent
commit
bd28e35d21

+ 1 - 1
Scripts/extras/pull_and_build_from_git.py

@@ -199,7 +199,7 @@ class PackageInfo(object):
             'platform_name': self.platform_name.lower(),
             'package_url': self.package_url,
             'package_license': self.package_license,
-            'package_license_file': self.package_license_file
+            'package_license_file': os.path.basename(self.package_license_file)
         }
         package_info_content = string.Template(PackageInfo.PACKAGE_INFO_TEMPLATE).substitute(package_info_env)
         package_info_target_file.write_text(package_info_content)

+ 23 - 0
package-system/freetype/Findfreetype.cmake

@@ -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
+#
+#
+
+# this file actually ingests the library and defines targets.
+set(TARGET_WITH_NAMESPACE "3rdParty::freetype")
+if (TARGET ${TARGET_WITH_NAMESPACE})
+    return()
+endif()
+
+set(freetype_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/freetype/include/freetype2)
+set(freetype_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/freetype/lib)
+set(freetype_LIBRARY ${freetype_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}freetype$<IF:$<CONFIG:Debug>,d,>${CMAKE_STATIC_LIBRARY_SUFFIX})
+
+add_library(${TARGET_WITH_NAMESPACE} INTERFACE IMPORTED GLOBAL)
+ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${freetype_INCLUDE_DIR})
+target_link_libraries(${TARGET_WITH_NAMESPACE} INTERFACE ${freetype_LIBRARY})
+
+set(freetype_FOUND True)

+ 45 - 0
package-system/freetype/build_config.json

@@ -0,0 +1,45 @@
+{
+   "git_url":"https://gitlab.freedesktop.org/freetype/freetype.git",
+   "git_tag":"VER-2-10-4",
+   "package_name":"freetype",
+   "package_version":"2.10.4.16",
+   "package_url":"https://www.freetype.org/",
+   "package_license":"FTL",
+   "package_license_file":"docs/FTL.TXT",
+   "cmake_find_source":"Findfreetype.cmake",
+   "cmake_find_target":"Findfreetype.cmake",
+   "patch_file":"freetype.patch",
+   "Platforms":{
+      "Windows":{
+         "Windows":{
+            "custom_build_cmd": [
+               "build_package_image.py --platform windows"
+            ]
+         },
+         "Android":{
+            "custom_build_cmd": [
+               "build_package_image.py --platform android"
+            ]
+         }
+      },
+      "Darwin":{
+        "Mac":{
+            "custom_build_cmd": [
+                "python3 build_package_image.py --platform mac"
+            ]
+        },
+        "iOS":{
+            "custom_build_cmd": [
+                "python3 build_package_image.py --platform ios"
+            ]
+        }
+      },
+      "Linux":{
+         "Linux":{
+            "custom_build_cmd": [
+                "python3 build_package_image.py --platform linux"
+             ]
+         }
+      }
+   }
+}

+ 102 - 0
package-system/freetype/build_package_image.py

@@ -0,0 +1,102 @@
+# 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 argparse
+import os
+import platform
+import subprocess
+import sys
+
+parser = argparse.ArgumentParser(description='Builds this package')
+parser.add_argument('--platform', default=platform.system().lower(), required=False, help=f'Platform to build (defaults to \"{platform.system().lower()}\")')
+args = parser.parse_args()
+
+this_dir = os.path.dirname(os.path.realpath(__file__))
+cmake_scripts_path = os.path.abspath(os.path.join(this_dir, '../../Scripts/cmake'))
+
+ly_3rdparty_path = os.getenv('LY_3RDPARTY_PATH')
+ly_android_sdk_path = os.getenv('LY_ANDROID_SDK_PATH');
+
+folder_names = { 
+    #system-name  cmake generation, cmake build
+    'mac'       : ([
+        '-G', 'Xcode',
+         '-DCMAKE_OSX_ARCHITECTURES=x86_64'
+    ], [], 'Debug', 'Release'),
+    'ios'       : ([
+        '-G', 'Xcode',
+        f'-DCMAKE_TOOLCHAIN_FILE={cmake_scripts_path}/Platform/iOS/Toolchain_ios.cmake',
+        '-DPACKAGE_PLATFORM=ios'
+    ], [
+        '--',
+        '-destination generic/platform=iOS'
+    ], 'Debug', 'Release'),
+    'linux'     : ([
+        '-G', 'Ninja Multi-Config',
+        '-DCMAKE_C_COMPILER=clang-6.0', 
+        '-DCMAKE_CXX_COMPILER=clang++-6.0',
+        '-DCMAKE_POSITION_INDEPENDENT_CODE=ON'
+    ], [], 'Debug', 'Release'),
+    'windows'   : ([
+        '-G', 'Visual Studio 16 2019',
+        '-Ax64', '-Thost=x64'
+    ], [], 'Debug', 'Release'),
+    'android'   : ([
+        '-G', 'Ninja Multi-Config',
+        f'-DCMAKE_TOOLCHAIN_FILE={cmake_scripts_path}/Platform/Android/Toolchain_android.cmake',
+        '-DANDROID_ABI=arm64-v8a',
+        '-DANDROID_ARM_MODE=arm',
+        '-DANDROID_ARM_NEON=FALSE',
+        '-DANDROID_NATIVE_API_LEVEL=21',
+        f'-DLY_NDK_DIR={ly_android_sdk_path}/ndk/22.0.7026061',
+        '-DPACKAGE_PLATFORM=android',
+        '-DCMAKE_POSITION_INDEPENDENT_CODE=ON'
+    ], [], 'debug', 'release') # Android needs to have ninja in the path
+}
+
+# intentionally generate a keyerror if its not a good platform:
+cmake_generation, cmake_build, debug_build_name, release_build_name = folder_names[args.platform]
+
+script_dir = os.path.dirname(os.path.realpath(__file__))
+package_name = os.path.basename(script_dir) 
+build_dir = os.path.join(script_dir, 'temp/build', args.platform)
+os.makedirs(build_dir, exist_ok=True)
+
+# generate
+generate_call = ['cmake', 
+                 '-Stemp/src', 
+                 f'-B{build_dir}', 
+                 f'-DCMAKE_INSTALL_PREFIX=../{package_name}-{args.platform}/{package_name}/', 
+                 '-DBUILD_SHARED_LIBS=FALSE',
+                 '-DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=TRUE',
+                 '-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE',
+                 '-DCMAKE_DISABLE_FIND_PACKAGE_PNG=TRUE',
+                 '-DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE',
+                 '-DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE']
+if cmake_generation:
+    generate_call += cmake_generation
+print(f"Cmake command '{generate_call}'")
+result_value = subprocess.run(generate_call, shell=False, cwd=script_dir)
+if result_value.returncode != 0:
+    sys.exit(result_value.returncode)
+
+# build debug
+build_call =['cmake', '--build', build_dir, '--config', debug_build_name, '--target', 'install']
+if cmake_build:
+    build_call += cmake_build
+print(build_call)
+result_value = subprocess.run(build_call, shell=False, cwd=script_dir)
+if result_value.returncode != 0:
+    sys.exit(result_value.returncode)
+
+# build release
+build_call =['cmake', '--build', build_dir, '--config', release_build_name, '--target', 'install']
+if cmake_build:
+    build_call += cmake_build
+result_value = subprocess.run(build_call, shell=False, cwd=script_dir)
+sys.exit(result_value.returncode)

+ 28 - 0
package-system/freetype/freetype.patch

@@ -0,0 +1,28 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 3ed55aad7..87a302d85 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -405,7 +405,7 @@ if (WIN32)
+ endif ()
+ 
+ if (BUILD_SHARED_LIBS)
+-  set_target_properties(freetype PROPERTIES
++set_target_properties(freetype PROPERTIES
+     VERSION ${LIBRARY_VERSION}
+     SOVERSION ${LIBRARY_SOVERSION})
+ endif ()
+diff --git a/include/ft2build.h b/include/ft2build.h
+index b4fd1f8c3..56c261b10 100644
+--- a/include/ft2build.h
++++ b/include/ft2build.h
+@@ -34,6 +34,10 @@
+ #ifndef FT2BUILD_H_
+ #define FT2BUILD_H_
+ 
++#ifndef FT2_BUILD_LIBRARY
++#define FT2_BUILD_LIBRARY
++#endif
++
+ #include <freetype/config/ftheader.h>
+ 
+ #endif /* FT2BUILD_H_ */

+ 4 - 4
package_build_list_host_darwin.json

@@ -10,8 +10,8 @@
         "Lua-5.3.5-rev5-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Lua --platform-name iOS --package-root ../../package-system --clean",
         "AwsIotDeviceSdkCpp-1.12.2-rev1-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AwsIotDeviceSdkCpp --platform-name Mac --package-root ../../package-system --clean",
         "etc2comp-9cd0f9cae0-rev1-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/etc2comp --platform-name Mac --package-root ../../package-system --clean",
-        "freetype-2.10.4.9-mac": "package-system/FreeType2/build_package_image.py --platform mac",
-        "freetype-2.10.4.9-ios": "package-system/FreeType2/build_package_image.py --platform ios",
+        "freetype-2.10.4.16-mac" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name Mac --package-root ../../package-system --clean",
+        "freetype-2.10.4.16-ios" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name iOS --package-root ../../package-system --clean",
         "googlebenchmark-1.5.0-rev2-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name iOS --package-root ../../package-system --clean",
         "googlebenchmark-1.5.0-rev2-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name Mac --package-root ../../package-system --clean",
         "googletest-1.8.1-rev4-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name iOS --package-root ../../package-system --clean",
@@ -50,8 +50,8 @@
         "Lua-5.3.5-rev5-ios": "package-system/Lua-ios",
         "AwsIotDeviceSdkCpp-1.12.2-rev1-mac": "package-system/AwsIotDeviceSdkCpp-mac",
         "etc2comp-9cd0f9cae0-rev1-mac": "package-system/etc2comp-mac",
-        "freetype-2.10.4.9-mac": "package-system/FreeType2-mac",
-        "freetype-2.10.4.9-ios": "package-system/FreeType2-ios",
+        "freetype-2.10.4.16-mac" : "package-system/freetype-mac",
+        "freetype-2.10.4.16-ios" : "package-system/freetype-ios",
         "googlebenchmark-1.5.0-rev2-ios": "package-system/googlebenchmark-ios",
         "googlebenchmark-1.5.0-rev2-mac": "package-system/googlebenchmark-mac",
         "googletest-1.8.1-rev4-ios": "package-system/googletest-ios",

+ 2 - 2
package_build_list_host_linux.json

@@ -8,7 +8,7 @@
         "Lua-5.3.5-rev5-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Lua --platform-name Linux --package-root ../../package-system --clean",
         "AwsIotDeviceSdkCpp-1.12.2-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AwsIotDeviceSdkCpp --platform-name Linux --package-root ../../package-system --clean",
         "etc2comp-9cd0f9cae0-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/etc2comp --platform-name Linux --package-root ../../package-system --clean",
-        "freetype-2.10.4.9-linux": "package-system/FreeType2/build_package_image.py --platform linux",
+        "freetype-2.10.4.16-linux" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name Linux --package-root ../../package-system --clean",
         "googlebenchmark-1.5.0-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name Linux --package-root ../../package-system --clean",
         "googletest-1.8.1-rev4-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name Linux --package-root ../../package-system --clean",
         "ISPCTexComp-36b80aa-rev1-linux": "package-system/ISPCTexComp/build_package_image.py",
@@ -36,7 +36,7 @@
         "Lua-5.3.5-rev5-linux": "package-system/Lua-linux",
         "AwsIotDeviceSdkCpp-1.12.2-rev1-linux": "package-system/AwsIotDeviceSdkCpp-linux",
         "etc2comp-9cd0f9cae0-rev1-linux": "package-system/etc2comp-linux",
-        "freetype-2.10.4.9-linux": "package-system/FreeType2-linux",
+        "freetype-2.10.4.16-linux" : "package-system/freetype-linux",
         "googlebenchmark-1.5.0-rev2-linux": "package-system/googlebenchmark-linux",
         "googletest-1.8.1-rev4-linux": "package-system/googletest-linux",
         "ISPCTexComp-36b80aa-rev1-linux": "package-system/ISPCTexComp-linux",

+ 4 - 4
package_build_list_host_windows.json

@@ -13,8 +13,8 @@
         "AwsIotDeviceSdkCpp-1.12.2-rev1-windows" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/AwsIotDeviceSdkCpp --build-path c:/Temp/awsiot --platform-name Windows --package-root ../../package-system --clean",
         "AwsIotDeviceSdkCpp-1.12.2-rev1-android" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/AwsIotDeviceSdkCpp --build-path c:/Temp/awsiot --platform-name Android --package-root ../../package-system --clean",
         "etc2comp-9cd0f9cae0-rev1-windows" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/etc2comp --platform-name Windows --package-root ../../package-system --clean",
-        "freetype-2.10.4.9-windows" : "package-system/FreeType2/build_package_image.py",
-        "freetype-2.10.4.9-android" : "package-system/FreeType2/build_package_image.py --platform android",
+        "freetype-2.10.4.16-windows" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name Windows --package-root ../../package-system --clean",
+        "freetype-2.10.4.16-android" : "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name Android --package-root ../../package-system --clean",
         "googlebenchmark-1.5.0-rev2-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name Windows --package-root ../../package-system --clean",
         "googlebenchmark-1.5.0-rev2-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name Android --package-root ../../package-system --clean",
         "googletest-1.8.1-rev4-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name Windows --package-root ../../package-system --clean",
@@ -56,8 +56,8 @@
     "AwsIotDeviceSdkCpp-1.12.2-rev1-windows": "package-system/AwsIotDeviceSdkCpp-windows",
     "AwsIotDeviceSdkCpp-1.12.2-rev1-android": "package-system/AwsIotDeviceSdkCpp-android",
     "etc2comp-9cd0f9cae0-rev1-windows": "package-system/etc2comp-windows",
-    "freetype-2.10.4.9-windows": "package-system/FreeType2-windows",
-    "freetype-2.10.4.9-android": "package-system/FreeType2-android",
+    "freetype-2.10.4.16-windows": "package-system/freetype-windows",
+    "freetype-2.10.4.16-android": "package-system/freetype-android",
     "googlebenchmark-1.5.0-rev2-windows": "package-system/googlebenchmark-windows",
     "googlebenchmark-1.5.0-rev2-android": "package-system/googlebenchmark-android",
     "googletest-1.8.1-rev4-windows": "package-system/googletest-windows",