diff --git a/ExternalDependencies.xcodeproj/project.pbxproj b/ExternalDependencies.xcodeproj/project.pbxproj index b924a06c..fed16be8 100644 --- a/ExternalDependencies.xcodeproj/project.pbxproj +++ b/ExternalDependencies.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ isa = PBXAggregateTarget; buildConfigurationList = A972A7F521CEC81B0013AB25 /* Build configuration list for PBXAggregateTarget "ExternalDependencies" */; buildPhases = ( + A9194DF624E8990C00FB127B /* Create XCFramework */, A9FC5F8B249DB48D003CB086 /* Package Finish */, ); dependencies = ( @@ -1728,6 +1729,9 @@ A913F24424CF87AE006CB02F /* ShaderLang.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderLang.h; sourceTree = ""; }; A913F25724CF87AE006CB02F /* CodeGen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGen.cpp; sourceTree = ""; }; A913F25824CF87AE006CB02F /* Link.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Link.cpp; sourceTree = ""; }; + A9194DE624E77A2E00FB127B /* copy_to_staging.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = copy_to_staging.sh; sourceTree = ""; }; + A9194DF424E8940600FB127B /* copy_ext_lib_to_staging.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = copy_ext_lib_to_staging.sh; sourceTree = ""; }; + A9194DF524E8979100FB127B /* create_ext_lib_xcframeworks.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_ext_lib_xcframeworks.sh; sourceTree = ""; }; A932E9C5249A743B00D64150 /* create_fat_lib_func.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_fat_lib_func.sh; sourceTree = ""; }; A932E9DF249BC44D00D64150 /* create_fat_ext_libs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_fat_ext_libs.sh; sourceTree = ""; }; A9415EF624366B0E00566F16 /* packagePregenSpirvToolsHeaders */ = {isa = PBXFileReference; lastKnownFileType = text; path = packagePregenSpirvToolsHeaders; sourceTree = ""; }; @@ -2179,6 +2183,7 @@ A9765DEE2485758500FDD115 /* validation_state.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validation_state.cpp; sourceTree = ""; }; A9765DEF2485758500FDD115 /* validate_primitives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validate_primitives.cpp; sourceTree = ""; }; A9765DF02485758500FDD115 /* decoration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decoration.h; sourceTree = ""; }; + A991DB2124E6016E00AEEC36 /* create_xcframework.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_xcframework.sh; sourceTree = ""; }; A9C2104521D14FD7006BA2D3 /* fetchDependencies */ = {isa = PBXFileReference; lastKnownFileType = text; path = fetchDependencies; sourceTree = ""; }; A9C2104721D15843006BA2D3 /* ExternalRevisions */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ExternalRevisions; sourceTree = ""; }; A9FC5F7F249DA96D003CB086 /* package_ext_libs_finish.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = package_ext_libs_finish.sh; sourceTree = ""; }; @@ -2381,8 +2386,12 @@ A9679AAB21D2699800856BF7 /* Scripts */ = { isa = PBXGroup; children = ( + A9194DF424E8940600FB127B /* copy_ext_lib_to_staging.sh */, + A9194DE624E77A2E00FB127B /* copy_to_staging.sh */, + A9194DF524E8979100FB127B /* create_ext_lib_xcframeworks.sh */, A932E9DF249BC44D00D64150 /* create_fat_ext_libs.sh */, A932E9C5249A743B00D64150 /* create_fat_lib_func.sh */, + A991DB2124E6016E00AEEC36 /* create_xcframework.sh */, A9FC5F7F249DA96D003CB086 /* package_ext_libs_finish.sh */, A9679AAE21D269D900856BF7 /* package_ext_libs.sh */, A9415EF624366B0E00566F16 /* packagePregenSpirvToolsHeaders */, @@ -3725,6 +3734,7 @@ buildPhases = ( 2FEA0AE92490321700EEF3AD /* Headers */, 2FEA0B1C2490321700EEF3AD /* Sources */, + A9194DF124E8855F00FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3741,6 +3751,7 @@ buildPhases = ( 2FEA0B4C2490322100EEF3AD /* Headers */, 2FEA0C0A2490322100EEF3AD /* Sources */, + A9194DEE24E8852B00FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3757,6 +3768,7 @@ buildPhases = ( 2FEA0CDA2490322B00EEF3AD /* Headers */, 2FEA0CE32490322B00EEF3AD /* Sources */, + A9194DEC24E884FC00FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3773,6 +3785,7 @@ buildPhases = ( A976290021CC608E00B52A68 /* Headers */, A976290121CC609100B52A68 /* Sources */, + A9194DE724E8431600FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3789,6 +3802,7 @@ buildPhases = ( A97628FF21CC608900B52A68 /* Headers */, A97628FE21CC608400B52A68 /* Sources */, + A9194DEB24E85ABC00FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3805,6 +3819,7 @@ buildPhases = ( A972A7FD21CECBBF0013AB25 /* Headers */, A972A80521CECBBF0013AB25 /* Sources */, + A9194DED24E8851900FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3821,6 +3836,7 @@ buildPhases = ( A972A81121CECBE90013AB25 /* Headers */, A972A81921CECBE90013AB25 /* Sources */, + A9194DEF24E8853B00FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3837,6 +3853,7 @@ buildPhases = ( A972ABCA21CED7BC0013AB25 /* Headers */, A972ABD221CED7BC0013AB25 /* Sources */, + A9194DF024E8854D00FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3853,6 +3870,7 @@ buildPhases = ( A972ABDE21CED7CB0013AB25 /* Headers */, A972ABE621CED7CB0013AB25 /* Sources */, + A9194DF224E8856E00FB127B /* Copy to Staging */, ); buildRules = ( ); @@ -3936,6 +3954,186 @@ shellPath = /bin/sh; shellScript = "export MVK_OS=\"tvOS\"\nexport MVK_BUILT_PROD_DIR=\"${BUILT_PRODUCTS_DIR}-${MVK_OS}\"\n\n. \"${SRCROOT}/Scripts/package_ext_libs.sh\"\n"; }; + A9194DE724E8431600FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DEB24E85ABC00FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DEC24E884FC00FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DED24E8851900FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DEE24E8852B00FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DEF24E8853B00FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DF024E8854D00FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DF124E8855F00FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n\n"; + }; + A9194DF224E8856E00FB127B /* Copy to Staging */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy to Staging"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/copy_ext_lib_to_staging.sh\"\n"; + }; + A9194DF624E8990C00FB127B /* Create XCFramework */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Create XCFramework"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/create_ext_lib_xcframeworks.sh\"\n"; + }; A932E9C6249A7B9B00D64150 /* Create Fat Libraries */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -5307,6 +5505,11 @@ COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + "EXCLUDED_ARCHS[sdk=appletvos*]" = arm64e; + "EXCLUDED_ARCHS[sdk=appletvsimulator*]" = arm64; + "EXCLUDED_ARCHS[sdk=iphoneos*]" = arm64e; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; + "EXCLUDED_ARCHS[sdk=macosx*]" = arm64; GCC_INLINES_ARE_PRIVATE_EXTERN = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -5356,6 +5559,11 @@ COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + "EXCLUDED_ARCHS[sdk=appletvos*]" = arm64e; + "EXCLUDED_ARCHS[sdk=appletvsimulator*]" = arm64; + "EXCLUDED_ARCHS[sdk=iphoneos*]" = arm64e; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; + "EXCLUDED_ARCHS[sdk=macosx*]" = arm64; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = YES; GCC_NO_COMMON_BLOCKS = YES; diff --git a/Scripts/copy_ext_lib_to_staging.sh b/Scripts/copy_ext_lib_to_staging.sh new file mode 100755 index 00000000..a2dbe9d6 --- /dev/null +++ b/Scripts/copy_ext_lib_to_staging.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export MVK_XCFWK_STAGING_DIR="${PROJECT_DIR}/External/build/Intermediates/XCFrameworkStaging/${CONFIGURATION}" +. "${SRCROOT}/Scripts/copy_to_staging.sh" diff --git a/Scripts/copy_to_staging.sh b/Scripts/copy_to_staging.sh new file mode 100755 index 00000000..740abdd1 --- /dev/null +++ b/Scripts/copy_to_staging.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Query the architectures in the built static library. If it contains only a single architecture, +# copy the file into a separate file in its own directory within the XCFrameworkStaging directory. +# If it contains mulitple architectures, extract each architecture into a separate file in its own +# directory within the XCFrameworkStaging directory. +# +# Requires the variable MVK_XCFWK_STAGING_DIR. +# +export MVK_PROD_FILENAME="lib${PRODUCT_NAME}.a" +export MVK_BUILT_PROD_FILE="${BUILT_PRODUCTS_DIR}/${MVK_PROD_FILENAME}" + +IFS=' ' read -ra archs <<< $(lipo -archs "${MVK_BUILT_PROD_FILE}") +if [ ${#archs[@]} -eq '1' ]; then + arch="${archs[0]}" + staging_dir="${MVK_XCFWK_STAGING_DIR}/${arch}${EFFECTIVE_PLATFORM_NAME}" + mkdir -p "${staging_dir}" + cp -a "${MVK_BUILT_PROD_FILE}" "${staging_dir}/${MVK_PROD_FILENAME}" +else + for arch in ${archs[@]}; do + staging_dir="${MVK_XCFWK_STAGING_DIR}/${arch}${EFFECTIVE_PLATFORM_NAME}" + mkdir -p "${staging_dir}" + lipo "${MVK_BUILT_PROD_FILE}" -thin ${arch} -output "${staging_dir}/${MVK_PROD_FILENAME}" + done +fi + + + + + + + + diff --git a/Scripts/create_ext_lib_xcframeworks.sh b/Scripts/create_ext_lib_xcframeworks.sh new file mode 100755 index 00000000..83f99328 --- /dev/null +++ b/Scripts/create_ext_lib_xcframeworks.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +. "${PROJECT_DIR}/Scripts/create_xcframework.sh" + +export MVK_EXT_DIR="${PROJECT_DIR}/External" +export MVK_XCFWK_STAGING_DIR="${MVK_EXT_DIR}/build/Intermediates/XCFrameworkStaging" +export MVK_XCFWK_DEST_DIR="${MVK_EXT_DIR}/build" + +# Assemble the headers for the external libraries +abs_ext_dir=`cd "${MVK_EXT_DIR}"; pwd; cd - > /dev/null` +hdr_dir="${MVK_XCFWK_STAGING_DIR}/Headers" +rm -rf "${hdr_dir}" +mkdir -p "${hdr_dir}" +ln -sfn "${abs_ext_dir}/SPIRV-Cross" "${hdr_dir}/SPIRVCross" +ln -sfn "${abs_ext_dir}/glslang/External/spirv-tools/include/spirv-tools" "${hdr_dir}/SPIRVTools" +ln -sfn "${abs_ext_dir}/glslang" "${hdr_dir}/glslang" + +create_xcframework "SPIRVCross" +create_xcframework "SPIRVTools" +create_xcframework "glslang" diff --git a/Scripts/create_xcframework.sh b/Scripts/create_xcframework.sh new file mode 100755 index 00000000..237e4458 --- /dev/null +++ b/Scripts/create_xcframework.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Creates a universal XCFramework for a product from any libraries that can be found for the product. +# +# Takes one parameter: +# 1 - product_name +# +# Requires the variables MVK_XCFWK_STAGING_DIR and MVK_XCFWK_DEST_DIR. +# +function create_xcframework() { + prod_name=${1} + xcfwk_path="${MVK_XCFWK_DEST_DIR}/${CONFIGURATION}/${prod_name}.xcframework" + hdr_path="${MVK_XCFWK_STAGING_DIR}/Headers/${prod_name}" + + xcfwk_cmd="xcodebuild -create-xcframework -output \"${xcfwk_path}\"" + + for prod_staging_dir in "${MVK_XCFWK_STAGING_DIR}/${CONFIGURATION}"/*; do + prod_lib_path="${prod_staging_dir}/lib${prod_name}.a" + xcfwk_cmd+=" -library \"${prod_lib_path}\"" + xcfwk_cmd+=" -headers \"${hdr_path}\"" + done + + rm -rf "${xcfwk_path}" + eval "${xcfwk_cmd}" +} diff --git a/fetchDependencies b/fetchDependencies index 583993ae..50989d9f 100755 --- a/fetchDependencies +++ b/fetchDependencies @@ -480,9 +480,10 @@ if [ "$XC_USE_BCKGND" != "" ]; then wait fi -# Update latest symlink and clean MoltenVK for rebuild +# Build XCFrameworks, update latest symlink, and clean MoltenVK for rebuild PROJECT_DIR="." CONFIGURATION=${XC_CONFIG} +. "./Scripts/create_ext_lib_xcframeworks.sh" . "./Scripts/package_ext_libs_finish.sh" echo ========== Finished at `date +"%r"` ==========