From 2c9b8b961c6234182e784d881eede8edc50db24f Mon Sep 17 00:00:00 2001 From: Jurvis Tan Date: Thu, 24 Nov 2022 16:59:38 -0800 Subject: [PATCH 1/3] Only build C static libs if they do not currently exist --- build-libwally.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/build-libwally.sh b/build-libwally.sh index 1486d5e..0798f99 100755 --- a/build-libwally.sh +++ b/build-libwally.sh @@ -24,6 +24,7 @@ build() { CC="$(xcrun --sdk $SDK_NAME -f clang) -isysroot $(xcrun --sdk $SDK_NAME --show-sdk-path)" CC_FOR_BUILD="$(xcrun --sdk macosx -f clang) -isysroot $(xcrun --sdk macosx --show-sdk-path)" + sh ./tools/autogen.sh ./configure --disable-shared --host=$HOST --enable-static --disable-elements --enable-standard-secp \ CC="$CC $EXTRA_CFLAGS" \ CPP="$CC $EXTRA_CFLAGS -E" \ @@ -42,8 +43,6 @@ build() { } if [[ ${ACTION:-build} = "build" || $ACTION = "install" ]]; then - sh ./tools/autogen.sh - if [[ $PLATFORM_NAME = "macosx" ]]; then TARGET_OS="macos" elif [[ $PLATFORM_NAME = "iphonesimulator" ]]; then @@ -61,6 +60,8 @@ if [[ ${ACTION:-build} = "build" || $ACTION = "install" ]]; then ARCHES=() LIBWALLYCORE_EXECUTABLES=() LIBSECP256K1_EXECUTABLES=() + NEEDS_LIPO=false + for ARCH in $ARCHS do TARGET_ARCH=$ARCH @@ -68,13 +69,29 @@ if [[ ${ACTION:-build} = "build" || $ACTION = "install" ]]; then TARGET_ARCH="aarch64" fi - build ${PLATFORM_NAME} ${TARGET_ARCH}-apple-darwin "-arch ${ARCH} -m${TARGET_OS}-version-min=7.0 -fembed-bitcode" - LIBWALLYCORE_EXECUTABLES+=("${BUILD_DIR}/${PLATFORM_NAME}/libwallycore-${TARGET_ARCH}-apple-darwin.a") - LIBSECP256K1_EXECUTABLES+=("${BUILD_DIR}/${PLATFORM_NAME}/libsecp256k1-${TARGET_ARCH}-apple-darwin.a") + LIBWALLY_DIR="${BUILD_DIR}/${PLATFORM_NAME}/libwallycore-${TARGET_ARCH}-apple-darwin.a" + SECP_DIR="${BUILD_DIR}/${PLATFORM_NAME}/libsecp256k1-${TARGET_ARCH}-apple-darwin.a" + + # If we haven't built our static library, let's go ahead and build it. Else, we can probably just not try and build at all. + if [ ! -f $LIBWALLY_DIR ] || [ ! -f $SECP_DIR ] + then + echo "DEBUG:: File not found, let's build!" + build ${PLATFORM_NAME} ${TARGET_ARCH}-apple-darwin "-arch ${ARCH} -m${TARGET_OS}-version-min=7.0 -fembed-bitcode" + + # Tracks our list of executables so we know the static libraries we need to lipo later + LIBWALLYCORE_EXECUTABLES+=($LIBWALLY_DIR) + LIBSECP256K1_EXECUTABLES+=($SECP_DIR) + + # Something changed, we should lipo later. + NEEDS_LIPO=true + fi done - xcrun --sdk $PLATFORM_NAME lipo -create "${LIBWALLYCORE_EXECUTABLES[@]}" -output "${BUILD_DIR}/LibWallyCore" - xcrun --sdk $PLATFORM_NAME lipo -create "${LIBSECP256K1_EXECUTABLES[@]}" -output "${BUILD_DIR}/libsecp256k1" + # If nothing changed, we can just not try lipo at all and skip. + if [ "$NEEDS_LIPO" = true ] ; then + xcrun --sdk $PLATFORM_NAME lipo -create "${LIBWALLYCORE_EXECUTABLES[@]}" -output "${BUILD_DIR}/LibWallyCore" + xcrun --sdk $PLATFORM_NAME lipo -create "${LIBSECP256K1_EXECUTABLES[@]}" -output "${BUILD_DIR}/libsecp256k1" + fi elif [[ $ACTION = "clean" ]]; then make clean fi From 3442c8678ef068f0dd7bf0cf1bb53ce9ea084abb Mon Sep 17 00:00:00 2001 From: Jurvis Tan Date: Thu, 24 Nov 2022 17:00:03 -0800 Subject: [PATCH 2/3] Comment out build cache cleaning from scheme --- LibWally.xcodeproj/project.pbxproj | 8 ++++---- .../xcshareddata/xcschemes/LibWally.xcscheme | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LibWally.xcodeproj/project.pbxproj b/LibWally.xcodeproj/project.pbxproj index 928b045..b17541e 100644 --- a/LibWally.xcodeproj/project.pbxproj +++ b/LibWally.xcodeproj/project.pbxproj @@ -28,7 +28,7 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 75B9EE002810F88400E31B4D /* PBXContainerItemProxy */ = { + 75683E51293049380014553B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = FE9CD3A8229C397900345DFA /* Project object */; proxyType = 1; @@ -209,7 +209,7 @@ buildRules = ( ); dependencies = ( - 75B9EE012810F88400E31B4D /* PBXTargetDependency */, + 75683E52293049380014553B /* PBXTargetDependency */, ); name = LibWally; productName = LibWally; @@ -325,10 +325,10 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 75B9EE012810F88400E31B4D /* PBXTargetDependency */ = { + 75683E52293049380014553B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 75B9EDFC2810F83700E31B4D /* LibWallyCore */; - targetProxy = 75B9EE002810F88400E31B4D /* PBXContainerItemProxy */; + targetProxy = 75683E51293049380014553B /* PBXContainerItemProxy */; }; FE9CD3BD229C397900345DFA /* PBXTargetDependency */ = { isa = PBXTargetDependency; diff --git a/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme b/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme index d296b8a..0cdd861 100644 --- a/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme +++ b/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme @@ -10,7 +10,7 @@ ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction"> + scriptText = "# We want to clean the libwally-core static build files for simulator so we can # build the ones for device. # cd $PROJECT_DIR/CLibWally/libwally-core # make clean # rm -rf "$(pwd)/build" "> Date: Fri, 25 Nov 2022 11:49:12 -0800 Subject: [PATCH 3/3] Remove build pre-action that deletes static libraries --- .../xcshareddata/xcschemes/LibWally.xcscheme | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme b/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme index 0cdd861..344920c 100644 --- a/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme +++ b/LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme @@ -5,24 +5,6 @@ - - - - - - - - - -