Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure xcode build to link library
- Loading branch information
Showing
6 changed files
with
202 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
set -euvx | ||
|
||
# This should be invoked from inside xcode, not manually | ||
if [ "$#" -ne 4 ] | ||
then | ||
echo "Usage (note: only call inside xcode!):" | ||
echo "Args: $*" | ||
echo "path/to/build-scripts/xc-universal-binary.sh <STATIC_LIB_NAME> <FFI_TARGET> <APPSVC_ROOT_PATH> <buildvariant>" | ||
exit 1 | ||
fi | ||
# e.g. libglean_ffi.a | ||
STATIC_LIB_NAME=$1 | ||
# what to pass to cargo build -p, e.g. glean_ffi | ||
FFI_TARGET=$2 | ||
# path to app services root | ||
APPSVC_ROOT=$3 | ||
# buildvariant from our xcconfigs | ||
BUILDVARIANT=$4 | ||
|
||
RELFLAG= | ||
RELDIR="debug" | ||
if [[ "$BUILDVARIANT" != "debug" ]]; then | ||
RELFLAG=--release | ||
RELDIR=release | ||
fi | ||
|
||
TARGETDIR=$APPSVC_ROOT/target | ||
|
||
# We can't use cargo lipo because we can't link to universal libraries :( | ||
# https://github.com/rust-lang/rust/issues/55235 | ||
LIBS_ARCHS=("x86_64" "arm64") | ||
IOS_TRIPLES=("x86_64-apple-ios" "aarch64-apple-ios") | ||
for i in "${!LIBS_ARCHS[@]}"; do | ||
LIB_ARCH=${LIBS_ARCHS[$i]} | ||
env -i PATH="$PATH" \ | ||
$HOME/.cargo/bin/cargo build -p $FFI_TARGET --lib $RELFLAG --target ${IOS_TRIPLES[$i]} | ||
done | ||
|
||
UNIVERSAL_BINARY=$TARGETDIR/universal/$RELDIR/$STATIC_LIB_NAME | ||
NEED_LIPO= | ||
|
||
# if the universal binary doesnt exist, or if it's older than the static libs, | ||
# we need to run `lipo` again. | ||
if [[ ! -f "$UNIVERSAL_BINARY" ]]; then | ||
NEED_LIPO=1 | ||
elif [[ $(stat -f "%m" $TARGETDIR/x86_64-apple-ios/$RELDIR/$STATIC_LIB_NAME) -gt $(stat -f "%m" $UNIVERSAL_BINARY) ]]; then | ||
NEED_LIPO=1 | ||
elif [[ $(stat -f "%m" $TARGETDIR/aarch64-apple-ios/$RELDIR/$STATIC_LIB_NAME) -gt $(stat -f "%m" $UNIVERSAL_BINARY) ]]; then | ||
NEED_LIPO=1 | ||
fi | ||
if [[ "$NEED_LIPO" = "1" ]]; then | ||
mkdir -p $TARGETDIR/universal/$RELDIR | ||
lipo -create -output "$UNIVERSAL_BINARY" \ | ||
$TARGETDIR/x86_64-apple-ios/$RELDIR/$STATIC_LIB_NAME \ | ||
$TARGETDIR/aarch64-apple-ios/$RELDIR/$STATIC_LIB_NAME | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "common.xcconfig" | ||
|
||
INFOPLIST_FILE = Glean/Info.plist | ||
LIBRARY_SEARCH_PATHS = "../../target/universal/$(buildvariant)" | ||
SWIFT_OBJC_BRIDGING_HEADER = Glean/Glean.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
SDKROOT = iphoneos | ||
ONLY_ACTIVE_ARCH = YES | ||
DEFINES_MODULE = YES | ||
PRODUCT_NAME = $(TARGET_NAME:c99extidentifier) | ||
|
||
CURRENT_PROJECT_VERSION = 1 | ||
VERSION_INFO_PREFIX = | ||
VERSIONING_SYSTEM = apple-generic | ||
TARGETED_DEVICE_FAMILY = 1,2 | ||
IPHONEOS_DEPLOYMENT_TARGET = 11.0 | ||
DYLIB_COMPATIBILITY_VERSION = 1 | ||
DYLIB_CURRENT_VERSION = 1 | ||
DYLIB_INSTALL_NAME_BASE = @rpath | ||
LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks | ||
|
||
SWIFT_VERSION = 4.0 | ||
ENABLE_BITCODE = NO | ||
|
||
SWIFT_OPTIMIZATION_LEVEL_debug = -Onone | ||
SWIFT_OPTIMIZATION_LEVEL_release = -O | ||
SWIFT_OPTIMIZATION_LEVEL = $(SWIFT_OPTIMIZATION_LEVEL_$(buildvariant)) | ||
|
||
SWIFT_ACTIVE_COMPILATION_CONDITIONS_debug = DEBUG | ||
SWIFT_ACTIVE_COMPILATION_CONDITIONS_release = | ||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(SWIFT_ACTIVE_COMPILATION_CONDITIONS_$(buildvariant)) | ||
|
||
SWIFT_COMPILATION_MODE_debug = | ||
SWIFT_COMPILATION_MODE_release = wholemodule | ||
SWIFT_COMPILATION_MODE = $(SWIFT_COMPILATION_MODE_$(buildvariant)) | ||
|
||
ENABLE_TESTABILITY_debug = YES | ||
ENABLE_TESTABILITY_release = NO | ||
ENABLE_TESTABILITY = $(ENABLE_TESTABILITY_$(buildvariant)) | ||
|
||
GCC_OPTIMIZATION_LEVEL_debug = 0 | ||
GCC_OPTIMIZATION_LEVEL_release = s | ||
GCC_OPTIMIZATION_LEVEL = $(GCC_OPTIMIZATION_LEVEL_$(buildvariant)) | ||
|
||
GCC_PREPROCESSOR_DEFINITIONS_debug = DEBUG=1 | ||
GCC_PREPROCESSOR_DEFINITIONS_release = | ||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_$(buildvariant)) | ||
|
||
GCC_DYNAMIC_NO_PIC = NO | ||
GCC_NO_COMMON_BLOCKS = YES | ||
GCC_C_LANGUAGE_STANDARD = gnu11 | ||
CLANG_CXX_LANGUAGE_STANDARD = gnu++14 | ||
CLANG_CXX_LIBRARY = libc++ | ||
CLANG_ENABLE_OBJC_ARC = YES | ||
CLANG_ENABLE_OBJC_WEAK = YES | ||
ENABLE_STRICT_OBJC_MSGSEND = YES | ||
|
||
// Warnings | ||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES | ||
CLANG_WARN_EMPTY_BODY = YES | ||
CLANG_WARN_BOOL_CONVERSION = YES | ||
CLANG_WARN_CONSTANT_CONVERSION = YES | ||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES | ||
CLANG_WARN_ENUM_CONVERSION = YES | ||
CLANG_WARN_INT_CONVERSION = YES | ||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES | ||
CLANG_WARN_INFINITE_RECURSION = YES | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES | ||
CLANG_WARN_STRICT_PROTOTYPES = YES | ||
CLANG_WARN_COMMA = YES | ||
GCC_WARN_UNINITIALIZED_AUTOS = YES | ||
CLANG_WARN_UNREACHABLE_CODE = YES | ||
GCC_WARN_UNUSED_FUNCTION = YES | ||
GCC_WARN_UNUSED_VARIABLE = YES | ||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES | ||
CLANG_WARN_SUSPICIOUS_MOVE = YES | ||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES | ||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES | ||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES | ||
GCC_WARN_UNDECLARED_SELECTOR = YES | ||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
buildvariant = debug | ||
#include "base.xcconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
buildvariant = release | ||
#include "base.xcconfig" |