-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
94 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
members = [ | ||
"jsi-sys", | ||
"jsi-macros", | ||
"jsi-tests", | ||
"jsi", | ||
"js-api", | ||
"js-tests", | ||
] | ||
resolver = "2" |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,13 @@ | ||
# `js-tests` | ||
|
||
This crate contains tests for `jsi-rs`. The tests are run against | ||
[Hermes](https://github.com/facebook/hermes), which is Facebook's reference | ||
implementation of JavaScript for React Native. | ||
|
||
## Building and running tests | ||
|
||
Hermes is a Git submodule of this repository, so it should be cloned | ||
automatically when you clone this repo. The initial build of this crate will | ||
take a while because it builds Hermes first. | ||
|
||
Once that build finishes, you can run `cargo test` as normal. |
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,71 @@ | ||
use std::{env, os::unix::process::CommandExt, path::PathBuf, process::Command}; | ||
|
||
fn main() { | ||
let pkg_base = env::var_os("CARGO_MANIFEST_DIR").unwrap(); | ||
let pkg_base = PathBuf::from(pkg_base); | ||
|
||
let hermes_build_status = Command::new("bash") | ||
.args([pkg_base.join("../vendor/build-hermes.sh")]) | ||
.current_dir(pkg_base.join("../vendor")) | ||
.output() | ||
.expect("hermes build script could not be executed"); | ||
|
||
if !hermes_build_status.status.success() { | ||
panic!( | ||
"hermes build script failed\n\nstdout: {}\n\nstderr: {}", | ||
String::from_utf8_lossy(&hermes_build_status.stdout), | ||
String::from_utf8_lossy(&hermes_build_status.stderr), | ||
) | ||
} | ||
|
||
let rn_base = pkg_base.join("../vendor/react-native/packages/react-native"); | ||
|
||
let includes = vec![ | ||
rn_base.join("React"), | ||
rn_base.join("React/Base"), | ||
rn_base.join("ReactCommon/jsi"), | ||
rn_base.join("ReactCommon/callinvoker"), | ||
pkg_base.join("../vendor/hermes/API"), | ||
pkg_base.join("../vendor/hermes/public"), | ||
pkg_base.join("include"), | ||
]; | ||
|
||
for include in &includes { | ||
println!("cargo:rerun-if-changed={:?}", include); | ||
} | ||
|
||
let includes: Vec<_> = IntoIterator::into_iter(includes) | ||
.map(|p| dunce::canonicalize(&p).expect(&format!("missing include path {:?}", p))) | ||
.collect(); | ||
|
||
let compiles: Vec<PathBuf> = vec![]; | ||
|
||
let compiles: Vec<_> = IntoIterator::into_iter(compiles) | ||
.map(|p| dunce::canonicalize(&p).expect(&format!("missing compile file {:?}", p))) | ||
.collect(); | ||
|
||
cxx_build::CFG | ||
.exported_header_dirs | ||
.extend(includes.iter().map(|e| e.as_path())); | ||
|
||
let bridges = vec!["src/ffi.rs"]; | ||
|
||
for bridge in &bridges { | ||
println!("cargo:rerun-if-changed={}", bridge); | ||
} | ||
|
||
cxx_build::bridges(bridges) | ||
.flag_if_supported("-std=c++17") | ||
.files(compiles) | ||
.compile("js-tests"); | ||
|
||
println!("cargo:rustc-link-lib=hermes"); | ||
println!( | ||
"cargo:rustc-link-search={}", | ||
pkg_base.join("../vendor/hermes/build/API/hermes/").to_string_lossy() | ||
); | ||
println!( | ||
"cargo:rustc-env=LD_LIBRARY_PATH={}", | ||
pkg_base.join("../vendor/hermes/build/API/hermes/").to_string_lossy() | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
cd hermes | ||
utils/build/configure.py | ||
cd build | ||
ninja | ||
cmake -S . -B build -G Ninja | ||
cmake --build ./build |