Skip to content

Commit

Permalink
Support multiple architectures per platform
Browse files Browse the repository at this point in the history
Delete Package.swift from pbxproj
  • Loading branch information
jurvis committed May 2, 2022
1 parent c7ab2c8 commit 8b60f26
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 26 deletions.
20 changes: 12 additions & 8 deletions LibWally.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
754D4D182811112400216F1E /* libsecp256k1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 754D4D172811111B00216F1E /* libsecp256k1.a */; };
A20C942522C6BC3900B0D206 /* libwallycore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A20C942422C6BC3900B0D206 /* libwallycore.a */; };
75F6BED1281F6F680072D4DE /* libsecp256k1 in Frameworks */ = {isa = PBXBuildFile; fileRef = 75F6BED0281F6F650072D4DE /* libsecp256k1 */; };
75F6BED2281F6F680072D4DE /* LibWallyCore in Frameworks */ = {isa = PBXBuildFile; fileRef = 75F6BECF281F6F650072D4DE /* LibWallyCore */; };
A232260122B94A6B00C3B79C /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A232260022B94A6B00C3B79C /* Transaction.swift */; };
A232260322B94A8400C3B79C /* TransactionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A232260222B94A8400C3B79C /* TransactionTests.swift */; };
A23509D72398F33E0045D3A5 /* DataExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A23509D62398F33E0045D3A5 /* DataExtensionTests.swift */; };
Expand Down Expand Up @@ -46,6 +46,8 @@

/* Begin PBXFileReference section */
754D4D172811111B00216F1E /* libsecp256k1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsecp256k1.a; path = "CLibWally/libwally-core/src/secp256k1/.libs/libsecp256k1.a"; sourceTree = "<group>"; };
75F6BECF281F6F650072D4DE /* LibWallyCore */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = LibWallyCore; path = "CLibWally/libwally-core/build/LibWallyCore"; sourceTree = "<group>"; };
75F6BED0281F6F650072D4DE /* libsecp256k1 */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsecp256k1; path = "CLibWally/libwally-core/build/libsecp256k1"; sourceTree = "<group>"; };
A20557A522C6CDBE007221AA /* LibWally.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = LibWally.modulemap; sourceTree = "<group>"; };
A20C942422C6BC3900B0D206 /* libwallycore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libwallycore.a; path = "CLibWally/libwally-core/src/.libs/libwallycore.a"; sourceTree = "<group>"; };
A20C942622C6BDB000B0D206 /* CLibWally */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CLibWally; sourceTree = "<group>"; };
Expand Down Expand Up @@ -76,8 +78,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
754D4D182811112400216F1E /* libsecp256k1.a in Frameworks */,
A20C942522C6BC3900B0D206 /* libwallycore.a in Frameworks */,
75F6BED1281F6F680072D4DE /* libsecp256k1 in Frameworks */,
75F6BED2281F6F680072D4DE /* LibWallyCore in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -156,6 +158,8 @@
FEB0B466229C6B6C00459518 /* Frameworks */ = {
isa = PBXGroup;
children = (
75F6BED0281F6F650072D4DE /* libsecp256k1 */,
75F6BECF281F6F650072D4DE /* LibWallyCore */,
754D4D172811111B00216F1E /* libsecp256k1.a */,
A20C942422C6BC3900B0D206 /* libwallycore.a */,
);
Expand Down Expand Up @@ -503,6 +507,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "";
INFOPLIST_FILE = LibWally/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
Expand All @@ -513,8 +518,7 @@
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/CLibWally/libwally-core/src/.libs",
"$(PROJECT_DIR)/CLibWally/libwally-core/src/secp256k1/.libs",
"$(PROJECT_DIR)/CLibWally/libwally-core/build",
);
MARKETING_VERSION = 0.0.6;
MODULEMAP_FILE = "$(SRCROOT)/LibWally/LibWally.modulemap";
Expand Down Expand Up @@ -542,6 +546,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "";
INFOPLIST_FILE = LibWally/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
Expand All @@ -552,8 +557,7 @@
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/CLibWally/libwally-core/src/.libs",
"$(PROJECT_DIR)/CLibWally/libwally-core/src/secp256k1/.libs",
"$(PROJECT_DIR)/CLibWally/libwally-core/build",
);
MARKETING_VERSION = 0.0.6;
MODULEMAP_FILE = "$(SRCROOT)/LibWally/LibWally.modulemap";
Expand Down
1 change: 1 addition & 0 deletions build-libwally-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ xcodebuild archive -scheme LibWally \
# build the ones for device.
pushd CLibWally/libwally-core
make clean
rm -rf $(pwd)/build
popd

xcodebuild archive -scheme LibWally \
Expand Down
53 changes: 35 additions & 18 deletions build-libwally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,37 @@ pushd src/secp256k1
git checkout 8746600eec5e7fcd35dabd480839a3a4bdfee87b || exit 1
popd

BUILD_DIR="$(pwd)/build"

build() {
SDK_NAME=$1 # iphonesimulator, iphoneos
HOST=$2 # 'aarch64-apple-darwin' or 'x86_64-apple-darwin'
EXTRA_CFLAGS=$3 # '-arch arm64 -mios...'
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)"

./configure --disable-shared --host=$HOST --enable-static --disable-elements --enable-standard-secp \
CC="$CC $EXTRA_CFLAGS" \
CPP="$CC $EXTRA_CFLAGS -E" \
CC_FOR_BUILD="$CC_FOR_BUILD" \
CPP_FOR_BUILD="$CC_FOR_BUILD -E" \

make

SDK_DIR="${BUILD_DIR}/${SDK_NAME}"
mkdir -p "${SDK_DIR}"

cp src/.libs/libwallycore.a "${SDK_DIR}/libwallycore-$HOST.a"
cp src/secp256k1/.libs/libsecp256k1.a "${SDK_DIR}/libsecp256k1-$HOST.a"

make clean
}

if [[ ${ACTION:-build} = "build" || $ACTION = "install" ]]; then
sh ./tools/autogen.sh

cd $PROJECT_DIR

if [[ $PLATFORM_NAME = "macosx" ]]; then
TARGET_OS="darwin"
TARGET_OS="macos"
elif [[ $PLATFORM_NAME = "iphonesimulator" ]]; then
TARGET_OS="ios-simulator"
else
Expand All @@ -35,29 +59,22 @@ if [[ ${ACTION:-build} = "build" || $ACTION = "install" ]]; then
fi

ARCHES=()
EXECUTABLES=()
LIBWALLYCORE_EXECUTABLES=()
LIBSECP256K1_EXECUTABLES=()
for ARCH in $ARCHS
do
ARCHES+=("-arch $ARCH")

TARGET_ARCH=$ARCH
if [[ $TARGET_ARCH = "arm64" ]]; then
TARGET_ARCH="aarch64"
fi
done

pushd "CLibWally/libwally-core"
export CFLAGS="-O3 ${ARCHES[@]} -fembed-bitcode -m${TARGET_OS}-version-min=11.0 -isysroot `xcrun -sdk ${PLATFORM_NAME} --show-sdk-path`"
export CXXFLAGS="-O3 ${ARCHES[@]} -fembed-bitcode -m${TARGET_OS}-version-min=11.0 -isysroot `xcrun -sdk ${PLATFORM_NAME} --show-sdk-path`"

# CPPFLAGS only required for x86 host machines, doing this on arm64 machines will cause a duplicate symbols error.
if [[ $NATIVE_ARCH = "x86_64" ]]; then
export CPPFLAGS="-O3 ${ARCHES[@]} -fembed-bitcode -m${TARGET_OS}-version-min=11.0 -isysroot `xcrun -sdk ${PLATFORM_NAME} --show-sdk-path`"
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")
done

./configure --disable-shared --host="${TARGET_ARCH}-apple-darwin" --enable-static --disable-elements --enable-standard-secp
make
popd
xcrun --sdk $PLATFORM_NAME lipo -create "${LIBWALLYCORE_EXECUTABLES[@]}" -output "${BUILD_DIR}/LibWallyCore"
xcrun --sdk $PLATFORM_NAME lipo -create "${LIBSECP256K1_EXECUTABLES[@]}" -output "${BUILD_DIR}/libsecp256k1"
elif [[ $ACTION = "clean" ]]; then
make clean
fi

0 comments on commit 8b60f26

Please sign in to comment.