Skip to content

Commit

Permalink
Merge remote-tracking branch 'jurvis/jurvis/build-tweaks'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Nov 26, 2022
2 parents d7c12bc + 2f7f66f commit fa1ce00
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
8 changes: 4 additions & 4 deletions LibWally.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
75B9EE002810F88400E31B4D /* PBXContainerItemProxy */ = {
75683E51293049380014553B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FE9CD3A8229C397900345DFA /* Project object */;
proxyType = 1;
Expand Down Expand Up @@ -209,7 +209,7 @@
buildRules = (
);
dependencies = (
75B9EE012810F88400E31B4D /* PBXTargetDependency */,
75683E52293049380014553B /* PBXTargetDependency */,
);
name = LibWally;
productName = LibWally;
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 0 additions & 18 deletions LibWally.xcodeproj/xcshareddata/xcschemes/LibWally.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,6 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "# We want to clean the libwally-core static build files for simulator so we can&#10;# build the ones for device.&#10;cd $PROJECT_DIR/CLibWally/libwally-core&#10;make clean&#10;rm -rf &quot;$(pwd)/build&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FE9CD3B0229C397900345DFA"
BuildableName = "LibWally.framework"
BlueprintName = "LibWally"
ReferencedContainer = "container:LibWally.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
31 changes: 24 additions & 7 deletions build-libwally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -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
Expand All @@ -61,20 +60,38 @@ if [[ ${ACTION:-build} = "build" || $ACTION = "install" ]]; then
ARCHES=()
LIBWALLYCORE_EXECUTABLES=()
LIBSECP256K1_EXECUTABLES=()
NEEDS_LIPO=false

for ARCH in $ARCHS
do
TARGET_ARCH=$ARCH
if [[ $TARGET_ARCH = "arm64" ]]; 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

0 comments on commit fa1ce00

Please sign in to comment.