diff --git a/.gitignore b/.gitignore index 4ba439ba4..aebccc6ec 100644 --- a/.gitignore +++ b/.gitignore @@ -56,4 +56,10 @@ Thumbs.db # types ios-typings-prj -.nx/cache \ No newline at end of file +.nx/cache + +#rust +/target + +#android +.cxx \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..cbb446ba9 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,195 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ada-url" +version = "2.1.0" +source = "git+https://github.com/triniwiz/ada-url-rust?rev=bc35ae9#bc35ae9c54d96a18655d5069ad4b63829c9beb31" +dependencies = [ + "cc", + "derive_more", + "link_args", + "regex", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "link_args" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7721e472624c9aaad27a5eb6b7c9c6045c7a396f2efb6dabaec1b640d5e89b" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "nativescript-core" +version = "0.1.0" +dependencies = [ + "ada-url", + "base64", + "bytes", + "encoding_rs", +] + +[[package]] +name = "proc-macro2" +version = "1.0.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "semver" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..18dbd19a1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[workspace] +members = [ + "crates/libs/*" +] + +resolver = "2" + +#[dev.release] +#panic = "abort" + +[profile.release] +panic = "abort" +codegen-units = 1 +lto = true +opt-level = 3 +debug = false +incremental = false +strip = true \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..e6b03ed2c --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +ARCHS_IOS = x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim +ARCHS_ANDROID = i686-linux-android x86_64-linux-android aarch64-linux-android armv7-linux-androideabi +LIB = libnativescriptcore.dylib +XCFRAMEWORK = NativeScriptCore.xcframework +RUST_LIB = nativescriptcore + +all:GENERATE_HEADERS ios android + +ios: $(XCFRAMEWORK) + +android: GENERATE_ANDROID + + +.PHONY: android_only +android_only: GENERATE_HEADERS android + +.PHONY: ios_only +ios_only: GENERATE_HEADERS android + +.PHONY: GENERATE_HEADERS +GENERATE_HEADERS: + ./tools/scripts/build-rust-headers.sh + +# PHONY keyword on make means this is not a file, just an identifier for a target +.PHONY: $(ARCHS_IOS) +$(ARCHS_IOS): %: + cargo +nightly build -Z build-std='std,panic_abort' -Z build-std-features=panic_immediate_abort --target $@ --release -p nativescript-core + +$(XCFRAMEWORK): $(ARCHS_IOS) + rm -rf target/simulator_fat + mkdir target/simulator_fat + lipo -create $(wildcard target/x86_64-apple-ios/release/$(LIB)) $(wildcard target/aarch64-apple-ios-sim/release/$(LIB)) -output target/simulator_fat/$(LIB) + xcodebuild -create-xcframework -library $(wildcard target/aarch64-apple-ios/release/$(LIB)) -headers crates/libs/nativescript-core/include -library target/simulator_fat/$(LIB) -headers crates/libs/nativescript-core/include -output target/$@ && ./tools/scripts/copy-rust-ios.sh + +.PHONY: $(ARCHS_ANDROID) +$(ARCHS_ANDROID): %: + ./tools/scripts/build-rust-android.sh $@ + +.PHONY: GENERATE_ANDROID +GENERATE_ANDROID: $(ARCHS_ANDROID) + ./tools/scripts/copy-rust-android.sh + +.PHONY: clean +clean: + rm -rf target rm -rf $(XCFRAMEWORK) rm -rf simulator_fat/$(LIB) \ No newline at end of file diff --git a/apps/toolbox/src/main-page.xml b/apps/toolbox/src/main-page.xml index 0588cfa03..0af69c510 100644 --- a/apps/toolbox/src/main-page.xml +++ b/apps/toolbox/src/main-page.xml @@ -25,6 +25,7 @@