Skip to content

Commit

Permalink
deno: search rusty-v8 libs/srcs with target suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
licy183 committed Nov 30, 2024
1 parent cee6c09 commit 017dd50
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 16 deletions.
13 changes: 0 additions & 13 deletions packages/deno/0001-enable-libffi-system-feature.patch

This file was deleted.

File renamed without changes.
43 changes: 40 additions & 3 deletions packages/deno/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,52 @@ termux_step_configure() {
termux_setup_rust
termux_setup_cmake
termux_setup_protobuf

: "${CARGO_HOME:=$HOME/.cargo}"
export CARGO_HOME

cargo vendor
patch --silent -p1 \
-d ./vendor/v8/ \
< "$TERMUX_PKG_BUILDER_DIR"/rusty-v8-search-files-with-target-suffix.diff

patch --silent -p1 \
-d "$TERMUX_PKG_SRCDIR" \
< "$TERMUX_PKG_BUILDER_DIR"/patch-root-Cargo.diff

local _CARGO_TARGET_LIBDIR="target/${CARGO_TARGET_NAME}/release/deps"
mkdir -p $_CARGO_TARGET_LIBDIR

mv $TERMUX_PREFIX/lib/libz.so.1{,.tmp}
mv $TERMUX_PREFIX/lib/libz.so{,.tmp}

ln -sfT $(readlink -f $TERMUX_PREFIX/lib/libz.so.1.tmp) \
$_CARGO_TARGET_LIBDIR/libz.so.1
ln -sfT $(readlink -f $TERMUX_PREFIX/lib/libz.so.tmp) \
$_CARGO_TARGET_LIBDIR/libz.so
}

termux_step_make() {
export RUSTY_V8_ARCHIVE="${TERMUX_PREFIX}/lib/librusty_v8.a"
export RUSTY_V8_SRC_BINDING_PATH="${TERMUX_PREFIX}/include/librusty_v8/src_binding.rs"

local env_name=RUSTY_V8_ARCHIVE_${CARGO_TARGET_NAME@U}
env_name=${env_name//-/_}
export "$env_name"="${TERMUX_PREFIX}/lib/librusty_v8.a"
env_name=RUSTY_V8_SRC_BINDING_PATH_${CARGO_TARGET_NAME@U}
env_name=${env_name//-/_}
export "$env_name"="${TERMUX_PREFIX}/include/librusty_v8/src_binding.rs"

cargo build --jobs "${TERMUX_PKG_MAKE_PROCESSES}" --target "${CARGO_TARGET_NAME}" --release
}

termux_step_make_install() {
install -Dm700 -t "${TERMUX_PREFIX}/bin" "target/${CARGO_TARGET_NAME}/release/deno"
}

termux_step_post_make_install() {
mv $TERMUX_PREFIX/lib/libz.so.1{.tmp,}
mv $TERMUX_PREFIX/lib/libz.so{.tmp,}
}

termux_step_post_massage() {
rm -f lib/libz.so.1
rm -f lib/libz.so
}
9 changes: 9 additions & 0 deletions packages/deno/patch-root-Cargo.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -334,3 +334,6 @@
opt-level = 3
[profile.release.package.zstd-sys]
opt-level = 3
+
+[patch.crates-io]
+v8 = { path = "./vendor/v8" }
42 changes: 42 additions & 0 deletions packages/deno/rusty-v8-search-files-with-target-suffix.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--- a/build.rs
+++ b/build.rs
@@ -55,6 +55,16 @@
println!("cargo:rerun-if-env-changed={}", env);
}

+ // Also rebuild for some vars with target suffix
+ let envs2 = vec![
+ "RUSTY_V8_ARCHIVE",
+ "RUSTY_V8_SRC_BINDING_PATH",
+ ];
+ for env in envs2 {
+ let target = env::var("TARGET").unwrap().replace("-", "_").to_uppercase();
+ println!("cargo:rerun-if-env-changed={}_{}", env, target);
+ }
+
// Detect if trybuild tests are being compiled.
let is_trybuild = env::var_os("DENO_TRYBUILD").is_some();

@@ -407,6 +417,10 @@
}

fn static_lib_url() -> String {
+ let target_u = env::var("TARGET").unwrap().replace("-", "_").to_uppercase();
+ if let Ok(custom_archive_u) = env::var(format!("RUSTY_V8_ARCHIVE_{}", target_u)) {
+ return custom_archive_u;
+ }
if let Ok(custom_archive) = env::var("RUSTY_V8_ARCHIVE") {
return custom_archive;
}
@@ -681,6 +695,11 @@
}

fn print_prebuilt_src_binding_path() {
+ let target_u = env::var("TARGET").unwrap().replace("-", "_").to_uppercase();
+ if let Ok(binding_u) = env::var(format!("RUSTY_V8_SRC_BINDING_PATH_{}", target_u)) {
+ println!("cargo:rustc-env=RUSTY_V8_SRC_BINDING_PATH={}", binding_u);
+ return;
+ }
if let Ok(binding) = env::var("RUSTY_V8_SRC_BINDING_PATH") {
println!("cargo:rustc-env=RUSTY_V8_SRC_BINDING_PATH={}", binding);
return;

0 comments on commit 017dd50

Please sign in to comment.