Add macos/ios app using rust lib
This commit is contained in:
13
FastCoster/CosterRs/coster-bridge.h
Normal file
13
FastCoster/CosterRs/coster-bridge.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// coster-bridge.h
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/2/2023.
|
||||
//
|
||||
|
||||
#ifndef coster_bridge_h
|
||||
#define coster_bridge_h
|
||||
|
||||
#import "libcoster_rs.h"
|
||||
|
||||
#endif /* coster_bridge_h */
|
||||
56
FastCoster/CosterRs/create-lib.sh
Normal file
56
FastCoster/CosterRs/create-lib.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
|
||||
# create-lib.sh
|
||||
# FastCoster
|
||||
#
|
||||
# Created by Michael Pivato on 3/2/2023.
|
||||
#
|
||||
|
||||
set -x
|
||||
# create-iospw.sh
|
||||
# Build the correct Rust target and place
|
||||
# the resulting library in the build products
|
||||
#
|
||||
# The $PATH used by Xcode likely won't contain Cargo, fix that.
|
||||
# In addition, the $PATH used by XCode has lots of Apple-specific
|
||||
# developer tools that your Cargo isn't expecting to use, fix that.
|
||||
# Note: This assumes a default `rustup` setup and default path.
|
||||
build_path="$HOME/.cargo/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
#
|
||||
# Figure out the correct Rust target from the ARCHS and PLATFORM.
|
||||
# This script expects just one element in ARCHS.
|
||||
case "$ARCHS" in
|
||||
"arm64") rust_arch="aarch64" ;;
|
||||
"x86_64") rust_arch="x86_64" ;;
|
||||
*) echo "error: unsupported architecture: $ARCHS" ;;
|
||||
esac
|
||||
if [[ "$PLATFORM_NAME" == "macosx" ]]; then
|
||||
rust_platform="apple-darwin"
|
||||
else
|
||||
rust_platform="apple-ios"
|
||||
fi
|
||||
if [[ "$PLATFORM_NAME" == "iphonesimulator" ]]; then
|
||||
if [[ "${rust_arch}" == "aarch64" ]]; then
|
||||
rust_abi="-sim"
|
||||
else
|
||||
rust_abi=""
|
||||
fi
|
||||
else
|
||||
rust_abi=""
|
||||
fi
|
||||
rust_target="${rust_arch}-${rust_platform}${rust_abi}"
|
||||
#
|
||||
# Build library in debug or release
|
||||
build_args=(--manifest-path ../costerrs/Cargo.toml --target "${rust_target}")
|
||||
if [[ "$CONFIGURATION" == "Release" ]]; then
|
||||
rust_config="release"
|
||||
env PATH="${build_path}" cargo build --release "${build_args[@]}"
|
||||
elif [[ "$CONFIGURATION" == "Debug" ]]; then
|
||||
rust_config="release"
|
||||
env PATH="${build_path}" cargo build --release "${build_args[@]}"
|
||||
else
|
||||
echo "error: Unexpected build configuration: $CONFIGURATION"
|
||||
fi
|
||||
#
|
||||
# Copy the built library to the derived files directory
|
||||
cp -v "../costerrs/target/${rust_target}/${rust_config}/libcoster_rs.a" ${DERIVED_FILES_DIR}
|
||||
8
FastCoster/CosterRs/libcoster_rs.h
Normal file
8
FastCoster/CosterRs/libcoster_rs.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char *move_money_from_text(const char *rules, const char *lines, bool use_numeric_accounts);
|
||||
|
||||
void move_money_from_text_free(char *s);
|
||||
8
FastCoster/CosterRs/remove-lib.sh
Normal file
8
FastCoster/CosterRs/remove-lib.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -x
|
||||
# delete-iospw.sh
|
||||
# keyring-tester
|
||||
#
|
||||
# Created by Daniel Brotsky on 1/1/22.
|
||||
#
|
||||
rm -fv ${DERIVED_FILES_DIR}/libcoster_rs.a
|
||||
Reference in New Issue
Block a user