unify ios mac build
This commit is contained in:
parent
46504e44b8
commit
ef313133cf
@ -4,10 +4,10 @@ CARGO=`which cargo`
|
||||
CARGO=${CARGO:=~/.cargo/bin/cargo}
|
||||
CARGO_DIR=$(dirname $CARGO)
|
||||
|
||||
WORKING_DIR=$1
|
||||
shift
|
||||
echo $WORKING_DIR
|
||||
pushd $WORKING_DIR >/dev/null
|
||||
# WORKING_DIR=$1
|
||||
# shift
|
||||
# echo $WORKING_DIR
|
||||
# pushd $WORKING_DIR >/dev/null
|
||||
echo PWD: `pwd`
|
||||
|
||||
CARGO_MANIFEST_PATH=$(python3 -c "import os; import json; print(json.loads(os.popen('$CARGO locate-project').read())['root'])")
|
||||
@ -40,7 +40,6 @@ do
|
||||
else
|
||||
CARGO_TARGET=aarch64-apple-ios
|
||||
fi
|
||||
#CARGO_TOOLCHAIN=+ios-arm64-1.57.0
|
||||
CARGO_TOOLCHAIN=
|
||||
elif [ "$arch" == "x86_64" ]; then
|
||||
echo x86_64
|
||||
|
61
scripts/macos_build.sh
Executable file
61
scripts/macos_build.sh
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
CARGO=`which cargo`
|
||||
CARGO=${CARGO:=~/.cargo/bin/cargo}
|
||||
CARGO_DIR=$(dirname $CARGO)
|
||||
|
||||
# WORKING_DIR=$1
|
||||
# shift
|
||||
# echo $WORKING_DIR
|
||||
# pushd $WORKING_DIR >/dev/null
|
||||
# echo PWD: `pwd`
|
||||
|
||||
CARGO_MANIFEST_PATH=$(python3 -c "import os; import json; print(json.loads(os.popen('$CARGO locate-project').read())['root'])")
|
||||
CARGO_WORKSPACE_PATH=$(python3 -c "import os; import json; print(json.loads(os.popen('$CARGO locate-project --workspace').read())['root'])")
|
||||
TARGET_PATH=$(python3 -c "import os; print(os.path.realpath(\"$CARGO_WORKSPACE_PATH/../target\"))")
|
||||
PACKAGE_NAME=$1
|
||||
shift
|
||||
|
||||
if [ "$CONFIGURATION" == "Debug" ]; then
|
||||
EXTRA_CARGO_OPTIONS="$@"
|
||||
BUILD_MODE="debug"
|
||||
else
|
||||
EXTRA_CARGO_OPTIONS="$@ --release"
|
||||
BUILD_MODE="release"
|
||||
fi
|
||||
ARCHS=${ARCHS:=arm64}
|
||||
|
||||
LIPO_OUT_NAME="lipo-darwin"
|
||||
|
||||
for arch in $ARCHS
|
||||
do
|
||||
if [ "$arch" == "arm64" ]; then
|
||||
echo arm64
|
||||
CARGO_TARGET=aarch64-apple-darwin
|
||||
CARGO_TOOLCHAIN=
|
||||
elif [ "$arch" == "x86_64" ]; then
|
||||
echo x86_64
|
||||
CARGO_TARGET=x86_64-apple-darwin
|
||||
CARGO_TOOLCHAIN=
|
||||
else
|
||||
echo Unsupported ARCH: $arch
|
||||
continue
|
||||
fi
|
||||
|
||||
# Choose arm64 brew for unit tests by default if we are on M1
|
||||
if [ -f /opt/homebrew/bin/brew ]; then
|
||||
HOMEBREW_DIR=/opt/homebrew/bin
|
||||
elif [ -f /usr/local/bin/brew ]; then
|
||||
HOMEBREW_DIR=/usr/local/bin
|
||||
else
|
||||
HOMEBREW_DIR=$(dirname `which brew`)
|
||||
fi
|
||||
|
||||
env -i PATH=/usr/bin:/bin:$HOMEBREW_DIR:$CARGO_DIR HOME="$HOME" USER="$USER" cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH
|
||||
|
||||
LIPOS="$LIPOS $TARGET_PATH/$CARGO_TARGET/$BUILD_MODE/lib$PACKAGE_NAME.a"
|
||||
|
||||
done
|
||||
|
||||
mkdir -p "$TARGET_PATH/$LIPO_OUT_NAME/$BUILD_MODE/"
|
||||
lipo $LIPOS -create -output "$TARGET_PATH/$LIPO_OUT_NAME/$BUILD_MODE/lib$PACKAGE_NAME.a"
|
@ -167,7 +167,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "../../../../../scripts/ios_build.sh ../../../../ veilid_core --features veilid_core_ios_tests,rt-tokio\n";
|
||||
shellScript = "../../../../../scripts/ios_build.sh veilid_core --features veilid_core_ios_tests,rt-tokio\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
|
@ -23,18 +23,19 @@ Veilid Network Plugin
|
||||
|
||||
require 'json'
|
||||
require 'pathname'
|
||||
cargo_target_dir = File.join(File.dirname(JSON.parse(`cargo locate-project`)['root']), 'target')
|
||||
workspace_dir = File.dirname(JSON.parse(`cargo locate-project --workspace`)['root'])
|
||||
cargo_target_dir = File.join(workspace_dir, 'target')
|
||||
|
||||
s.xcconfig = {
|
||||
'OTHER_LDFLAGS' => "-Wl,-force_load,#{File.join(cargo_target_dir, 'ios_lib', 'libveilid_flutter.a')}",
|
||||
"LIBRARY_SEARCH_PATHS" => File.join(cargo_target_dir, 'ios_lib')
|
||||
'OTHER_LDFLAGS' => "-Wl,-force_load,#{File.join(cargo_target_dir, 'lipo-ios', 'libveilid_flutter.a')}",
|
||||
"LIBRARY_SEARCH_PATHS" => File.join(cargo_target_dir, 'lipo-ios')
|
||||
}
|
||||
|
||||
s.script_phase = {
|
||||
:name => 'Cargo Build',
|
||||
:script => File.join(File.dirname(__dir__), 'rust', 'ios_build.sh'),
|
||||
:script => File.join(workspace_dir, 'scripts', 'ios_build.sh') + ' veilid_flutter',
|
||||
:execution_position => :before_compile
|
||||
# :output_files => [ File.join(cargo_target_dir, 'ios_lib', 'libveilid_flutter.a') ]
|
||||
# :output_files => [ File.join(cargo_target_dir, 'lipo-ios', 'libveilid_flutter.a') ]
|
||||
}
|
||||
|
||||
end
|
||||
|
@ -22,13 +22,14 @@ Veilid Network Plugin
|
||||
|
||||
require 'json'
|
||||
require 'pathname'
|
||||
cargo_target_dir = File.join(File.dirname(JSON.parse(`cargo locate-project`)['root']), 'target')
|
||||
workspace_dir = File.dirname(JSON.parse(`cargo locate-project --workspace`)['root'])
|
||||
cargo_target_dir = File.join(workspace_dir, 'target')
|
||||
|
||||
s.script_phase = {
|
||||
:name => 'Cargo Build',
|
||||
:script => File.join(File.dirname(__dir__), 'rust', 'macos_build.sh'),
|
||||
:script => File.join(workspace_dir, 'scripts', 'macos_build.sh') + ' veilid_flutter',
|
||||
:execution_position => :before_compile
|
||||
#:output_files => [ File.join(cargo_target_dir, 'macos_lib', 'libveilid_flutter.dylib') ]
|
||||
#:output_files => [ File.join(cargo_target_dir, 'lipo-darwin', 'libveilid_flutter.dylib') ]
|
||||
}
|
||||
|
||||
end
|
||||
|
@ -12,6 +12,7 @@ rt-async-std = [ "veilid-core/rt-async-std", "async-std", "opentelemetry/rt-asyn
|
||||
rt-tokio = [ "veilid-core/rt-tokio", "tokio", "tokio-stream", "tokio-util", "opentelemetry/rt-tokio"]
|
||||
|
||||
[dependencies]
|
||||
veilid-core = { path="../../veilid-core" }
|
||||
tracing = { version = "^0", features = ["log", "attributes"] }
|
||||
tracing-subscriber = "^0"
|
||||
parking_lot = "^0"
|
||||
@ -25,7 +26,6 @@ data-encoding = { version = "^2" }
|
||||
# Dependencies for native builds only
|
||||
# Linux, Windows, Mac, iOS, Android
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
veilid-core = { path="../../veilid-core" }
|
||||
tracing-opentelemetry = "^0"
|
||||
opentelemetry = { version = "^0" }
|
||||
opentelemetry-otlp = { version = "^0" }
|
||||
@ -41,7 +41,6 @@ hostname = "^0"
|
||||
|
||||
# Dependencies for WASM builds only
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
veilid-core = { path="../../veilid-core" }
|
||||
|
||||
# Dependencies for Android builds only
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
|
@ -1,55 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo Running veilid-flutter rust iOS build script
|
||||
|
||||
# Setup varaiables
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
FLUTTER_DIR=$(dirname `which flutter`)
|
||||
HOMEBREW_DIR=$(dirname `which brew`)
|
||||
CARGO_DIR=$(dirname `which cargo`)
|
||||
CARGO_MANIFEST_PATH=$(python3 -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))")
|
||||
TARGET_DIR=$(dirname `cargo locate-project --message-format plain`)/target
|
||||
|
||||
# Configure outputs
|
||||
OUTPUT_FILENAME=libveilid_flutter.a
|
||||
OUTPUT_DIR=$TARGET_DIR/ios_lib
|
||||
|
||||
# Get Rust configurations from xcode configurations
|
||||
if [ "$CONFIGURATION" == "Debug" ]; then
|
||||
EXTRA_CARGO_OPTIONS="$@"
|
||||
RUST_CONFIGURATION="debug"
|
||||
else
|
||||
EXTRA_CARGO_OPTIONS="$@ --release"
|
||||
RUST_CONFIGURATION="release"
|
||||
fi
|
||||
|
||||
# Build all the matching architectures for the xcode configurations
|
||||
ARCHS=${ARCHS:=arm64}
|
||||
echo ARCHS: $ARCHS
|
||||
LIPO_LIST=""
|
||||
for arch in $ARCHS
|
||||
do
|
||||
if [ "$arch" == "arm64" ]; then
|
||||
echo arm64
|
||||
CARGO_TARGET=aarch64-apple-ios
|
||||
#CARGO_TOOLCHAIN=+ios-arm64-1.57.0
|
||||
CARGO_TOOLCHAIN=
|
||||
elif [ "$arch" == "x86_64" ]; then
|
||||
echo x86_64
|
||||
CARGO_TARGET=x86_64-apple-ios
|
||||
CARGO_TOOLCHAIN=
|
||||
else
|
||||
echo Unsupported ARCH: $arch
|
||||
continue
|
||||
fi
|
||||
|
||||
# Cargo build
|
||||
env -i PATH=/usr/bin:/bin:/usr/local/bin:$HOMEBREW_DIR:$FLUTTER_DIR:$CARGO_DIR HOME="$HOME" USER="$USER" cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH
|
||||
|
||||
# Add output to lipo list
|
||||
LIPO_LIST="$LIPO_LIST $TARGET_DIR/$CARGO_TARGET/$RUST_CONFIGURATION/$OUTPUT_FILENAME"
|
||||
done
|
||||
|
||||
# Lipo the architectures together
|
||||
mkdir -p $OUTPUT_DIR
|
||||
lipo -output "$OUTPUT_DIR/$OUTPUT_FILENAME" -create $LIPO_LIST
|
@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo Running veilid-flutter rust MacOS build script
|
||||
|
||||
# Setup varaiables
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
FLUTTER_DIR=$(dirname `which flutter`)
|
||||
HOMEBREW_DIR=$(dirname `which brew`)
|
||||
CARGO_DIR=$(dirname `which cargo`)
|
||||
CARGO_MANIFEST_PATH=$(python3 -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))")
|
||||
TARGET_DIR=$(dirname `cargo locate-project --message-format plain`)/target
|
||||
|
||||
# Configure outputs
|
||||
OUTPUT_FILENAME=libveilid_flutter.dylib
|
||||
OUTPUT_DIR=$TARGET_DIR/macos_lib
|
||||
|
||||
# Get Rust configurations from xcode configurations
|
||||
if [ "$CONFIGURATION" == "Debug" ]; then
|
||||
EXTRA_CARGO_OPTIONS="$@"
|
||||
RUST_CONFIGURATION="debug"
|
||||
else
|
||||
EXTRA_CARGO_OPTIONS="$@ --release"
|
||||
RUST_CONFIGURATION="release"
|
||||
fi
|
||||
|
||||
# Build all the matching architectures for the xcode configurations
|
||||
ARCHS=${ARCHS:=x86_64}
|
||||
echo ARCHS: $ARCHS
|
||||
LIPO_LIST=""
|
||||
for arch in $ARCHS
|
||||
do
|
||||
if [ "$arch" == "arm64" ]; then
|
||||
echo arm64
|
||||
CARGO_TARGET=aarch64-apple-darwin
|
||||
CARGO_TOOLCHAIN=
|
||||
elif [ "$arch" == "x86_64" ]; then
|
||||
echo x86_64
|
||||
CARGO_TARGET=x86_64-apple-darwin
|
||||
CARGO_TOOLCHAIN=
|
||||
else
|
||||
echo Unsupported ARCH: $arch
|
||||
continue
|
||||
fi
|
||||
|
||||
# Cargo build
|
||||
env -i PATH=/usr/bin:/bin:/usr/local/bin:$HOMEBREW_DIR:$FLUTTER_DIR:$CARGO_DIR HOME="$HOME" USER="$USER" cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH
|
||||
|
||||
# Add output to lipo list
|
||||
LIPO_LIST="$LIPO_LIST $TARGET_DIR/$CARGO_TARGET/$RUST_CONFIGURATION/$OUTPUT_FILENAME"
|
||||
done
|
||||
|
||||
# Lipo the architectures together
|
||||
mkdir -p $OUTPUT_DIR
|
||||
lipo -output "$OUTPUT_DIR/$OUTPUT_FILENAME" -create $LIPO_LIST
|
@ -167,7 +167,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "../../../../../scripts/ios_build.sh ../../../../ veilid_tools --features veilid_tools_ios_tests,rt-tokio\n";
|
||||
shellScript = "../../../../../scripts/ios_build.sh veilid_tools --features veilid_tools_ios_tests,rt-tokio\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user