├── .cargo └── config ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── Makefile ├── app.c ├── rust-toolchain └── src └── lib.rs /.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | rustflags = ["-C", "lto", "-Z", "embed-bitcode"] 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | **/*.rs.bk 3 | /app 4 | 5 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "bitcoder" 5 | version = "0.1.0" 6 | 7 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bitcoder" 3 | version = "0.1.0" 4 | authors = ["saturday06"] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: run clean 2 | 3 | info: app 4 | xcrun --sdk iphoneos clang --version 5 | cat rust-toolchain 6 | file app 7 | 8 | app: app.c Makefile target/aarch64-apple-ios/debug/libbitcoder.a 9 | xcrun --sdk iphoneos clang -arch arm64 -fembed-bitcode app.c target/aarch64-apple-ios/debug/libbitcoder.a -framework CoreFoundation -framework Security -o $@ 10 | 11 | target/aarch64-apple-ios/debug/libbitcoder.a: Cargo.toml src/lib.rs .cargo/config 12 | cargo build --target aarch64-apple-ios --verbose 13 | 14 | clean: 15 | rm -fr target app 16 | -------------------------------------------------------------------------------- /app.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int bitcoder_add(int, int); 4 | 5 | int main() { 6 | printf("Hello %d\n", bitcoder_add(1, 2)); 7 | } 8 | -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | nightly-2019-09-13 2 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #[no_mangle] 2 | pub extern "C" fn bitcoder_add(l: i32, r: i32) -> i32 { 3 | l + r 4 | } 5 | 6 | #[cfg(test)] 7 | mod tests { 8 | use super::*; 9 | #[test] 10 | fn it_works() { 11 | assert_eq!(bitcoder_add(1, 2), 3); 12 | } 13 | } 14 | --------------------------------------------------------------------------------