From b9f1d7519a8c595fd6ef1db10ecec9033a2b7e2d Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Tue, 23 Jun 2020 16:08:00 -0400 Subject: [PATCH] Makefile add debug build targets. Fix crash during creation of fat dSYMs. Travis only build macOS version of everything. --- .travis.yml | 4 +-- Makefile | 42 ++++++++++++++++++++++++------ README.md | 52 +++++++++++++++++--------------------- Scripts/create_fat_libs.sh | 13 +++++++--- 4 files changed, 68 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78127c21..f8f52740 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,6 @@ install: - ./fetchDependencies -v --macos script: - - xcodebuild -project MoltenVKPackaging.xcodeproj -scheme "MoltenVK Package" - - xcodebuild -workspace Demos/Demos.xcworkspace -scheme "Cube-macOS" + - xcodebuild build -project MoltenVKPackaging.xcodeproj -scheme "MoltenVK Package (macOS only)" + - xcodebuild build -workspace Demos/Demos.xcworkspace -scheme "Cube-macOS" diff --git a/Makefile b/Makefile index bd6ac45b..ebfee2cd 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -XCODE_PROJ := MoltenVKPackaging.xcodeproj -XCODE_SCHEME_BASE := MoltenVK Package +XC_PROJ := MoltenVKPackaging.xcodeproj +XC_SCHEME := MoltenVK Package # Specify individually (not as dependencies) so the sub-targets don't run in parallel .PHONY: all @@ -8,29 +8,55 @@ all: @$(MAKE) iosfat @$(MAKE) tvosfat +.PHONY: all-debug +all-debug: + @$(MAKE) macos-debug + @$(MAKE) iosfat-debug + @$(MAKE) tvosfat-debug + .PHONY: macos macos: - xcodebuild -quiet -project "$(XCODE_PROJ)" -scheme "$(XCODE_SCHEME_BASE) (macOS only)" build + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (macOS only)" + +.PHONY: macos-debug +macos-debug: + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (macOS only)" -configuration "Debug" .PHONY: ios ios: - xcodebuild -quiet -project "$(XCODE_PROJ)" -scheme "$(XCODE_SCHEME_BASE) (iOS only)" build + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (iOS only)" + +.PHONY: ios-debug +ios-debug: + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (iOS only)" -configuration "Debug" .PHONY: iosfat iosfat: ios - xcodebuild -quiet -project "$(XCODE_PROJ)" -scheme "$(XCODE_SCHEME_BASE) (iOS only)" -destination "generic/platform=iOS Simulator" build + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (iOS only)" -destination "generic/platform=iOS Simulator" + +.PHONY: iosfat-debug +iosfat-debug: ios-debug + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (iOS only)" -destination "generic/platform=iOS Simulator" -configuration "Debug" .PHONY: tvos tvos: - xcodebuild -quiet -project "$(XCODE_PROJ)" -scheme "$(XCODE_SCHEME_BASE) (tvOS only)" build + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (tvOS only)" + +.PHONY: tvos-debug +tvos-debug: + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (tvOS only)" -configuration "Debug" .PHONY: tvosfat tvosfat: tvos - xcodebuild -quiet -project "$(XCODE_PROJ)" -scheme "$(XCODE_SCHEME_BASE) (tvOS only)" -destination "generic/platform=tvOS Simulator" build + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (tvOS only)" -destination "generic/platform=tvOS Simulator" + +.PHONY: tvosfat-debug +tvosfat-debug: tvos-debug + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (tvOS only)" -destination "generic/platform=tvOS Simulator" -configuration "Debug" .PHONY: clean clean: - xcodebuild -quiet -project "$(XCODE_PROJ)" -scheme "$(XCODE_SCHEME_BASE)" clean + xcodebuild clean -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME)" rm -rf Package # Usually requires 'sudo make install' diff --git a/README.md b/README.md index 39c39c1a..7413542c 100644 --- a/README.md +++ b/README.md @@ -178,14 +178,14 @@ to test your app with either a **_Debug_** build, or a higher-performance **_Rel ### Building from the Command Line If you prefer to build **MoltenVK** from the command line, or to include the activity in a larger build script, -you can do so using the following command within the `MoltenVK` repository folder, and identifying one of the -*Xcode Schemes* from the list above. For example, the following command will build **MoltenVK** in the -**_Release_** configuration for both *macOS* and *iOS*: +you can do so by executing a command similar to the following command within the `MoltenVK` repository folder, +and identifying one of the *Xcode Schemes* from the list above. For example, the following command will build +**MoltenVK** in the **_Debug_** configuration for *macOS* only: - xcodebuild -quiet -project MoltenVKPackaging.xcodeproj -scheme "MoltenVK Package" build + xcodebuild build -quiet -project MoltenVKPackaging.xcodeproj -scheme "MoltenVK Package (macOS only)" -configuration "Debug" Alternately, you can use the basic `Makefile` in the `MoltenVK` repository folder to build **MoltenVK** -in the **_Release_** configuration from the command line. The following `make` targets are provided: +from the command line. The following `make` targets are provided: make make all @@ -194,19 +194,27 @@ in the **_Release_** configuration from the command line. The following `make` t make iosfat make tvos make tvosfat + + make all-debug + make macos-debug + make ios-debug + make iosfat-debug + make tvos-debug + make tvosfat-debug + make clean make install - -Running `make all` is the same as running all of `make macos`, `make iosfat`, and `make tvosfat`. -Running `make` with no arguments is the same as running `make all`. - -The `install` target will copy the most recently built *macOS* `MoltenVK.framework` into -the `/Library/Frameworks` folder of your computer. Since `/Library/Frameworks` is protected, -you will generally need to run it as `sudo make install` and enter your password. - -The `install` target just installs the built framework, it does not first build the framework. -You will first need to at least run `make macos`, or use *Xcode* to build the framework as described above. +- The `all` target is the default target. Running `make` with no arguments is the same as running `make all`. +- The `*fat*` targets build fat binaries containing both platform and simulator code. +- The `*-debug` targets build the binaries using the **_Debug_** configuration. +- The `all` target executes the `macos`, `iosfat`, and `tvosfat` targets. +- The `all-debug` target executes the `macos-debug`, `iosfat-debug`, and `tvosfat-debug` targets. +- The `install` target will copy the most recently built *macOS* `MoltenVK.framework` into + the `/Library/Frameworks` folder of your computer. Since `/Library/Frameworks` is protected, + you will generally need to run it as `sudo make install` and enter your password. + The `install` target just installs the built framework, it does not first build the framework. + You will first need to at least run `make macos` first. The `make` targets all require that *Xcode* is installed on your system. @@ -214,20 +222,6 @@ Building from the command line creates the same `Package` folder structure descr building from within *Xcode*. -### Building Within a Larger External Build Environment - -If you build **MoltenVK** as part of a larger build environment, that does not use the scripts or *Xcode* -projects provided by **MoltenVK**, you may be interested in certain build options designed to allow you to -customize the use of **MoltenVK** within your custom build environment. These options are not available -in the default **MoltenVK** build environment described in the previous sections. - -- `MoltenVKShaderConverter` uses the `SPIRV-Tools` external library to log SPIR-V code for diagnostics. - If this is not useful to you, you can define the `MVK_EXCLUDE_SPIRV_TOOLS` when building the - `MoltenVKShaderConverter` code base, and **MoltenVK** will not attempt to use code from the `SPIRV-Tools` - repository. In this way, you will not need to retrieve or build the `SPIRV-Tools` repository, or link to - a `SPIRV-Tools` external library. - - Running the **MoltenVK** Demo Applications diff --git a/Scripts/create_fat_libs.sh b/Scripts/create_fat_libs.sh index 6b030f17..4a2f9229 100755 --- a/Scripts/create_fat_libs.sh +++ b/Scripts/create_fat_libs.sh @@ -9,14 +9,19 @@ set -e export MVK_BUILT_OS_PROD_DIR="${BUILT_PRODUCTS_DIR}/../${CONFIGURATION}-${MVK_OS_PROD_EXTN}" export MVK_BUILT_SIM_PROD_DIR="${BUILT_PRODUCTS_DIR}/../${CONFIGURATION}-${MVK_SIM_PROD_EXTN}" export MVK_BUILT_FAT_PROD_DIR="${BUILT_PRODUCTS_DIR}/../${CONFIGURATION}-${MVK_OS}" - create_fat_lib "lib${PRODUCT_NAME}.a" -# Dynamic library and associated dSYM +# Dynamic library export MVK_BUILT_OS_PROD_DIR="${MVK_BUILT_OS_PROD_DIR}/dynamic" export MVK_BUILT_SIM_PROD_DIR="${MVK_BUILT_SIM_PROD_DIR}/dynamic" export MVK_BUILT_FAT_PROD_DIR="${MVK_BUILT_FAT_PROD_DIR}/dynamic" - create_fat_lib "lib${PRODUCT_NAME}.dylib" -create_fat_lib "lib${PRODUCT_NAME}.dylib.dSYM" +# Dynamic library dSYM +if [ "${CONFIGURATION}" == "Debug" ]; then + cp -a "${MVK_BUILT_OS_PROD_DIR}/lib${PRODUCT_NAME}.dylib.dSYM" "${MVK_BUILT_FAT_PROD_DIR}" + export MVK_BUILT_OS_PROD_DIR="${MVK_BUILT_OS_PROD_DIR}/lib${PRODUCT_NAME}.dylib.dSYM/Contents/Resources/DWARF" + export MVK_BUILT_SIM_PROD_DIR="${MVK_BUILT_SIM_PROD_DIR}/lib${PRODUCT_NAME}.dylib.dSYM/Contents/Resources/DWARF" + export MVK_BUILT_FAT_PROD_DIR="${MVK_BUILT_FAT_PROD_DIR}/lib${PRODUCT_NAME}.dylib.dSYM/Contents/Resources/DWARF" + create_fat_lib "lib${PRODUCT_NAME}.dylib" +fi