diff --git a/.travis.yml b/.travis.yml index 3856b713..78127c21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ osx_image: xcode11.5 # Build dependencies with verbose logging to avoid Travis timing out. install: - - ./fetchDependencies -v + - ./fetchDependencies -v --macos script: - xcodebuild -project MoltenVKPackaging.xcodeproj -scheme "MoltenVK Package" diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 14e79ac6..673bf7c5 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -21,6 +21,7 @@ Released TBD - Add support for extensions: - VK_KHR_sampler_ycbcr_conversion - VK_EXT_robustness2 +- `fetchDependencies` script supports platform build selection. - Fix issue where mapped host-coherent device memory not updated from image contents on *macOS*. - Remove use of `@available()` directive as it was causing issues in some build environments. - Refactor **MoltenVK** *Xcode* build architectures. diff --git a/ExternalDependencies.xcodeproj/project.pbxproj b/ExternalDependencies.xcodeproj/project.pbxproj index c72b18e6..e7093c08 100644 --- a/ExternalDependencies.xcodeproj/project.pbxproj +++ b/ExternalDependencies.xcodeproj/project.pbxproj @@ -55,11 +55,12 @@ isa = PBXAggregateTarget; buildConfigurationList = A972A7F521CEC81B0013AB25 /* Build configuration list for PBXAggregateTarget "ExternalDependencies" */; buildPhases = ( + A9FC5F8B249DB48D003CB086 /* Package Finish */, ); dependencies = ( + A972A7F921CEC8500013AB25 /* PBXTargetDependency */, A972A7FB21CEC8540013AB25 /* PBXTargetDependency */, 2FEA0CF82490344F00EEF3AD /* PBXTargetDependency */, - A972A7F921CEC8500013AB25 /* PBXTargetDependency */, ); name = ExternalDependencies; productName = "ExternalLibraries-macOS"; @@ -2185,6 +2186,7 @@ A9765DF02485758500FDD115 /* decoration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decoration.h; 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 = ""; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ @@ -2391,6 +2393,7 @@ A932E9DF249BC44D00D64150 /* create_fat_ext_libs.sh */, A932E9C5249A743B00D64150 /* create_fat_lib_func.sh */, A91BF011235F9C510039B7DE /* gen_spirv_cross_rev_hdr.sh */, + A9FC5F7F249DA96D003CB086 /* package_ext_libs_finish.sh */, A9679AAE21D269D900856BF7 /* package_ext_libs.sh */, A9415EF624366B0E00566F16 /* packagePregenSpirvToolsHeaders */, ); @@ -4069,6 +4072,24 @@ shellPath = /bin/sh; shellScript = "export MVK_OS=\"tvOS\"\nexport MVK_OS_PROD_EXTN=\"appletvos\"\nexport MVK_SIM_PROD_EXTN=\"appletvsimulator\"\n\n. \"${SRCROOT}/Scripts/create_fat_ext_libs.sh\"\n"; }; + A9FC5F8B249DB48D003CB086 /* Package Finish */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Package Finish"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ". \"${SRCROOT}/Scripts/package_ext_libs_finish.sh\"\n"; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/Scripts/package_ext_libs.sh b/Scripts/package_ext_libs.sh index 221e7e1e..68516a6b 100755 --- a/Scripts/package_ext_libs.sh +++ b/Scripts/package_ext_libs.sh @@ -9,10 +9,3 @@ rm -rf "${MVK_EXT_LIB_DST_OS_PATH}" mkdir -p "${MVK_EXT_LIB_DST_OS_PATH}" cp -a "${MVK_BUILT_PROD_PATH}/"*.a "${MVK_EXT_LIB_DST_OS_PATH}" - -# Assign symlink to Latest -ln -sfn "${CONFIGURATION}" "${MVK_EXT_LIB_DST_PATH}/Latest" - -# Clean MoltenVK to ensure the next MoltenVK build will use the latest external library versions. -make --quiet clean - diff --git a/Scripts/package_ext_libs_finish.sh b/Scripts/package_ext_libs_finish.sh new file mode 100755 index 00000000..d44a2d30 --- /dev/null +++ b/Scripts/package_ext_libs_finish.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +export MVK_EXT_LIB_DST_PATH="${PROJECT_DIR}/External/build/" + +# Assign symlink to Latest +ln -sfn "${CONFIGURATION}" "${MVK_EXT_LIB_DST_PATH}/Latest" + +# Clean MoltenVK to ensure the next MoltenVK build will use the latest external library versions. +make --quiet clean + diff --git a/fetchDependencies b/fetchDependencies index e7531ba4..2404e7da 100755 --- a/fetchDependencies +++ b/fetchDependencies @@ -36,6 +36,9 @@ # Build the external libraries in Debug mode, which may be useful when debugging # and tracing calls into those libraries. # +# --no-parallel-build +# Build the external libraries serially instead of in parallel using background processes. +# # --glslang-root path # "path" specifies a directory path to a KhronosGroup/glslang repository. # This repository does need to be built and the build directory must be in the @@ -74,6 +77,7 @@ BLD_MACOS="" BLD_SPECIFIED="" XC_CONFIG="Release" XC_BUILD_VERBOSITY="-quiet" +XC_USE_BCKGND="Y" V_HEADERS_ROOT="" SPIRV_CROSS_ROOT="" GLSLANG_ROOT="" @@ -121,6 +125,10 @@ while (( "$#" )); do XC_CONFIG="Debug" shift 1 ;; + --no-parallel-build) + XC_USE_BCKGND="" + shift 1 + ;; -v) XC_BUILD_VERBOSITY="" shift 1 @@ -357,57 +365,102 @@ cd - > /dev/null cd .. -# -------------- Build MoltenVK dependencies ----------------- -echo -echo ========== Building dependency libraries quietly. Please be patient on first build. ========== +# -------------- Build MoltenVK external library dependencies ----------------- echo +echo ========== Started building dependency libraries at `date +"%r"` ========== +echo Please be patient on first build + +# Build an Xcode scheme for an OS and platform +# 1 - OS +# 2 - platform +function build_impl() { + XC_OS=${1} + XC_PLTFM=${2} + + XC_SCHEME="${EXT_DEPS}-${XC_OS}" + XC_LCL_DD_PATH="${XC_DD_PATH}/Intermediates/${XC_OS}" + XC_DEST="generic/platform=${XC_PLTFM}" -# Build an Xcode scheme -function build() { echo Building external libraries for ${XC_PLTFM} + xcodebuild \ -project "${XC_PROJ}" \ -scheme "${XC_SCHEME}" \ - -destination "generic/platform=${XC_PLTFM}" \ + -destination "${XC_DEST}" \ -configuration "${XC_CONFIG}" \ - -derivedDataPath "${XC_DD_PATH}" \ + -derivedDataPath "${XC_LCL_DD_PATH}" \ ${XC_BUILD_VERBOSITY} \ build + + echo Completed building external libraries for ${XC_PLTFM} +} + +# Select whether or not to run the build in parallel. +# 1 - OS +# 2 - platform +function build() { + if [ "$XC_USE_BCKGND" != "" ]; then + build_impl ${1} ${2} & + else + build_impl ${1} ${2} + fi +} + +# Build a fat library for the OS containing code for the OS and its Simulator +# Builds serially to ensure both are built +# 1 - OS +function build_fat_impl() { + XC_OS=${1} + + build_impl ${XC_OS} ${XC_OS} + build_impl ${XC_OS} "${XC_OS} Simulator" +} + +# Select whether or not to run the build in parallel. +# 1 - OS +function build_fat() { + if [ "$XC_USE_BCKGND" != "" ]; then + build_fat_impl ${1} & + else + build_fat_impl ${1} + fi } EXT_DEPS=ExternalDependencies XC_PROJ="${EXT_DEPS}.xcodeproj" XC_DD_PATH="${EXT_DIR}/build" -if [ "$BLD_IOS" != "" ]; then - XC_SCHEME="${EXT_DEPS}-iOS" - XC_PLTFM="iOS" - build +# Structure build tasks by platform so they can be built in parallel per platform. +# Content for each platform must be built in series to avoid +trap "exit" INT TERM ERR +trap "kill 0" EXIT + +if [ "$BLD_MACOS" != "" ]; then + build "macOS" "macOS" fi -if [ "$BLD_IOS_SIM" != "" ]; then - XC_SCHEME="${EXT_DEPS}-iOS" - XC_PLTFM="iOS Simulator" - build +if [ "$BLD_IOS" != "" ]; then + if [ "$BLD_IOS_SIM" != "" ]; then + build_fat "iOS" + else + build "iOS" "iOS" + fi fi if [ "$BLD_TVOS" != "" ]; then - XC_SCHEME="${EXT_DEPS}-tvOS" - XC_PLTFM="tvOS" - build + if [ "$BLD_TVOS_SIM" != "" ]; then + build_fat "tvOS" + else + build "tvOS" "tvOS" + fi fi -if [ "$BLD_TVOS_SIM" != "" ]; then - XC_SCHEME="${EXT_DEPS}-tvOS" - XC_PLTFM="tvOS Simulator" - build -fi +# Wait for any background process (if selected) to finish +wait -if [ "$BLD_MACOS" != "" ]; then - XC_SCHEME="${EXT_DEPS}-macOS" - XC_PLTFM="macOS" - build -fi - -echo ========== Done! ========== +# Update latest symlink and clean MoltenVK for rebuild +PROJECT_DIR="." +CONFIGURATION=${XC_CONFIG} +. "./Scripts/package_ext_libs_finish.sh" +echo ========== Finished at `date +"%r"` ==========