-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/lifetime-support' into develop
- Loading branch information
Showing
200 changed files
with
10,202 additions
and
54,222 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
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
extern crate cbindgen; | ||
extern crate ferment_sys; | ||
|
||
use std::process::Command; | ||
use ferment_sys::{Ferment, Lang, ObjC, XCodeConfig}; | ||
|
||
pub const SELF_NAME: &str = "example_nested"; | ||
fn main() { | ||
let c_header = format!("target/{}.h", SELF_NAME); | ||
match Ferment::with_crate_name(SELF_NAME) | ||
.with_default_mod_name() | ||
.with_external_crates(vec!["example-simple"]) | ||
.with_languages(vec![ | ||
Lang::ObjC(ObjC::new(XCodeConfig { class_prefix: "DS".to_string(), framework_name: "Fermented".to_string() })), | ||
]) | ||
.generate() { | ||
Ok(()) => match Command::new("cbindgen") | ||
.args(["--config", "cbindgen.toml", "-o", c_header.as_str()]) | ||
.status() { | ||
Ok(status) => println!("[cbindgen] [ok] generated into {c_header} with status: {status}"), | ||
Err(err) => panic!("[cbindgen] [error] {}", err) | ||
} | ||
Err(err) => panic!("[ferment-sys] Can't create FFI fermentate: {}", err) | ||
} | ||
} | ||
const SELF_NAME: &str = "example_nested"; | ||
match ferment_sys::Ferment::with_crate_name(SELF_NAME) | ||
.with_default_mod_name() | ||
.with_cbindgen_config_from_file("cbindgen.toml") | ||
.with_external_crates(vec![ | ||
"versioned-feature-core", | ||
"example-simple", | ||
"dashcore", | ||
"dpp", | ||
"platform-value", | ||
"platform-version" | ||
]) | ||
.with_languages(vec![ | ||
#[cfg(feature = "objc")] | ||
ferment_sys::Lang::ObjC(ferment_sys::ObjC::new(ferment_sys::XCodeConfig { | ||
class_prefix: "DS".to_string(), | ||
framework_name: "DSExampleNested".to_string(), | ||
header_name: SELF_NAME.to_string() | ||
} | ||
)), | ||
]) | ||
.generate() { | ||
Ok(_) => println!("[ferment] [ok]: {SELF_NAME}"), | ||
Err(err) => panic!("[ferment] [err]: {}", err) | ||
} | ||
} |
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,79 @@ | ||
#!/bin/bash | ||
echo "Building Dash Shared Core..." | ||
pwd | ||
compare_version() { | ||
# shellcheck disable=SC2053 | ||
if [[ $1 == $2 ]]; then | ||
return 1 | ||
fi | ||
local IFS=. | ||
# shellcheck disable=SC2206 | ||
local i a=(${1%%[^0-9.]*}) b=(${2%%[^0-9.]*}) | ||
local arem=${1#${1%%[^0-9.]*}} brem=${2#${2%%[^0-9.]*}} | ||
for ((i=0; i<${#a[@]} || i<${#b[@]}; i++)); do | ||
if ((10#${a[i]:-0} < 10#${b[i]:-0})); then | ||
return 1 | ||
elif ((10#${a[i]:-0} > 10#${b[i]:-0})); then | ||
return 0 | ||
fi | ||
done | ||
if [ "$arem" '<' "$brem" ]; then | ||
return 1 | ||
elif [ "$arem" '>' "$brem" ]; then | ||
return 0 | ||
fi | ||
return 1 | ||
} | ||
REQUIRED_VERSION=1.66.0 | ||
CURRENT_VERSION=$(rustc -V | awk '{sub(/-.*/,"");print $2}') | ||
FRAMEWORK=DSExampleNested | ||
HEADER=example_nested | ||
echo "rustc -V: current ${CURRENT_VERSION} vs. required ${REQUIRED_VERSION}" | ||
if compare_version "${REQUIRED_VERSION}" "${CURRENT_VERSION}"; then | ||
echo "ERROR: rustc version ${CURRENT_VERSION} not supported, please upgrade to at least ${REQUIRED_VERSION}" | ||
exit 1 | ||
fi | ||
|
||
cargo install cargo-lipo | ||
for target in "x86_64-apple-darwin" "aarch64-apple-darwin" "x86_64-apple-ios" "aarch64-apple-ios" "aarch64-apple-ios-sim"; do | ||
if ! rustup target list | grep -q "${target} (installed)"; then | ||
rustup target add "$target" | ||
fi | ||
done | ||
rm -rf target/{framework,include,lib} | ||
cargo lipo --release | ||
build_targets=( | ||
"x86_64-apple-ios" | ||
"aarch64-apple-ios" | ||
"aarch64-apple-ios-sim" | ||
"x86_64-apple-darwin" | ||
"aarch64-apple-darwin" | ||
|
||
) | ||
for target in "${build_targets[@]}"; do | ||
if [ ! -f "../../target/$target/release/lib${HEADER}.a" ]; then | ||
cargo build --target="$target" --release --no-default-features & | ||
fi | ||
done | ||
wait | ||
mkdir -p target/{framework,include,lib/{ios,ios-simulator,macos}} | ||
lipo -create ../../target/x86_64-apple-darwin/release/lib${HEADER}.a \ | ||
../../target/aarch64-apple-darwin/release/lib${HEADER}.a \ | ||
-output target/lib/macos/lib${HEADER}_macos.a & | ||
cp -r -p ../../target/aarch64-apple-ios/release/lib${HEADER}.a target/lib/ios/lib${HEADER}_ios.a & | ||
lipo -create ../../target/x86_64-apple-ios/release/lib${HEADER}.a \ | ||
../../target/aarch64-apple-ios-sim/release/lib${HEADER}.a \ | ||
-output target/lib/ios-simulator/lib${HEADER}_ios.a & | ||
wait | ||
wait | ||
|
||
if which clang-format >/dev/null; then | ||
find "target/include" -name 'objc_wrapper.h' -print0 | xargs -0 clang-format -i -style=file | ||
else | ||
echo "warning: clang-format not installed, install it by running $(brew install clang-format)" | ||
fi | ||
|
||
xcodebuild -create-xcframework \ | ||
-library target/lib/ios/lib${HEADER}_ios.a -headers target/include \ | ||
-library target/lib/ios-simulator/lib${HEADER}_ios.a -headers target/include \ | ||
-output target/framework/${FRAMEWORK}.xcframework |
Oops, something went wrong.