From 2212a6c6313160ae7128501fb009bfc60404ecd4 Mon Sep 17 00:00:00 2001 From: Komo Date: Thu, 28 Nov 2024 21:05:03 +0800 Subject: [PATCH] enable,bump(main/librusty-v8): 130.0.1 (#22404) Co-authored-by: Chongyun Lee <45286352+licy183@users.noreply.github.com> --- disabled-packages/librusty-v8/build.sh | 45 ---------------- .../librusty-v8/0001-sizeof-in-i686.patch | 28 ++++++++++ packages/librusty-v8/0002-build-triple.patch | 20 ++++++++ packages/librusty-v8/build.sh | 51 +++++++++++++++++++ scripts/setup-ubuntu.sh | 4 ++ 5 files changed, 103 insertions(+), 45 deletions(-) delete mode 100644 disabled-packages/librusty-v8/build.sh create mode 100644 packages/librusty-v8/0001-sizeof-in-i686.patch create mode 100644 packages/librusty-v8/0002-build-triple.patch create mode 100644 packages/librusty-v8/build.sh diff --git a/disabled-packages/librusty-v8/build.sh b/disabled-packages/librusty-v8/build.sh deleted file mode 100644 index 092eda86200f0b..00000000000000 --- a/disabled-packages/librusty-v8/build.sh +++ /dev/null @@ -1,45 +0,0 @@ -TERMUX_PKG_HOMEPAGE=https://github.com/denoland/rusty_v8 -TERMUX_PKG_DESCRIPTION="High quality Rust bindings to V8's C++ API" -TERMUX_PKG_LICENSE="MIT" -TERMUX_PKG_MAINTAINER="@termux" -_COMMIT=8b90dfd2f4fcbbaefd2c4d2be220d94a00a3ebba -TERMUX_PKG_VERSION=2022.02.02 -TERMUX_PKG_SRCURL=git+https://github.com/denoland/rusty_v8 -TERMUX_PKG_GIT_BRANCH=main -TERMUX_PKG_BUILD_IN_SRC=true -TERMUX_PKG_NO_STATICSPLIT=true -TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64" - -termux_step_post_get_source() { - git fetch --unshallow || true - git checkout $_COMMIT - - local version="$(git log -1 --format=%cs | sed 's/-/./g')" - if [ "$version" != "$TERMUX_PKG_VERSION" ]; then - echo -n "ERROR: The specified version \"$TERMUX_PKG_VERSION\"" - echo " is different from what is expected to be: \"$version\"" - return 1 - fi - - git submodule update --init --recursive -} - -termux_step_pre_configure() { - export V8_FROM_SOURCE=1 - export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig -} - -termux_step_make() { - termux_setup_rust - cargo build --jobs $TERMUX_PKG_MAKE_PROCESSES --target $CARGO_TARGET_NAME --release -} - -termux_step_make_install() { - install -Dm600 -t $TERMUX_PREFIX/lib \ - target/$CARGO_TARGET_NAME/release/gn_out/obj/librusty_v8.a -} - -termux_step_post_make_install() { - unset V8_FROM_SOURCE - unset PKG_CONFIG_PATH -} diff --git a/packages/librusty-v8/0001-sizeof-in-i686.patch b/packages/librusty-v8/0001-sizeof-in-i686.patch new file mode 100644 index 00000000000000..53c5e9f73e22e2 --- /dev/null +++ b/packages/librusty-v8/0001-sizeof-in-i686.patch @@ -0,0 +1,28 @@ +--- a/src/binding.cc ++++ b/src/binding.cc +@@ -54,6 +54,7 @@ + + static_assert(sizeof(v8::Locker) == sizeof(size_t) * 2, "Locker size mismatch"); + ++#if !(defined(__ANDROID__) && defined(__i386__)) + static_assert(sizeof(v8::ScriptCompiler::CompilationDetails) == + sizeof(int64_t) * 3, + "CompilationDetails size mismatch"); +@@ -66,6 +67,17 @@ + align_to(sizeof(size_t)) + + sizeof(v8::ScriptCompiler::CompilationDetails)), + "Source size mismatch"); ++#else ++static_assert(sizeof(v8::ScriptCompiler::CompilationDetails) == ++ sizeof(int64_t) * 2 + sizeof(uint32_t) /* enum class */, ++ "CompilationDetails size mismatch"); ++ ++static_assert( ++ sizeof(v8::ScriptCompiler::Source) == ++ align_to(sizeof(size_t) * 8 + sizeof(int) * 3 + ++ sizeof(v8::ScriptCompiler::CompilationDetails)), ++ "Source size mismatch"); ++#endif + + static_assert(sizeof(v8::FunctionCallbackInfo) == sizeof(size_t) * 3, + "FunctionCallbackInfo size mismatch"); diff --git a/packages/librusty-v8/0002-build-triple.patch b/packages/librusty-v8/0002-build-triple.patch new file mode 100644 index 00000000000000..13bf253f53aa24 --- /dev/null +++ b/packages/librusty-v8/0002-build-triple.patch @@ -0,0 +1,20 @@ +--- a/build.rs ++++ b/build.rs +@@ -259,11 +259,17 @@ + "x64" + } else if target_arch == "aarch64" { + "arm64" ++ } else if target_arch == "arm" { ++ "arm" ++ } else if target_triple.starts_with("i686-") { ++ "x86" + } else { + "unknown" + }; + if target_arch == "x86_64" { + maybe_install_sysroot("amd64"); ++ } else if target_triple.starts_with("i686-") { ++ maybe_install_sysroot("i386"); + } + gn_args.push(format!(r#"v8_target_cpu="{}""#, arch).to_string()); + gn_args.push(format!(r#"target_cpu="{}""#, arch).to_string()); diff --git a/packages/librusty-v8/build.sh b/packages/librusty-v8/build.sh new file mode 100644 index 00000000000000..a2541c847b540b --- /dev/null +++ b/packages/librusty-v8/build.sh @@ -0,0 +1,51 @@ +TERMUX_PKG_HOMEPAGE=https://github.com/denoland/rusty_v8 +TERMUX_PKG_DESCRIPTION="High quality Rust bindings to V8's C++ API" +TERMUX_PKG_LICENSE="MIT" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION=130.0.1 +TERMUX_PKG_SRCURL=git+https://github.com/denoland/rusty_v8 +TERMUX_PKG_BUILD_IN_SRC=true +TERMUX_PKG_NO_STATICSPLIT=true + +termux_step_configure() { + termux_setup_rust + termux_setup_ninja + termux_setup_gn + + export EXTRA_GN_ARGS=" +android32_ndk_api_level=$TERMUX_PKG_API_LEVEL +android64_ndk_api_level=$TERMUX_PKG_API_LEVEL +android_ndk_root=\"$NDK\" +android_ndk_version=\"$TERMUX_NDK_VERSION\" +" + + if [ "$TERMUX_ARCH" = "arm" ]; then + EXTRA_GN_ARGS+=" target_cpu = \"arm\"" + EXTRA_GN_ARGS+=" v8_target_cpu = \"arm\"" + EXTRA_GN_ARGS+=" arm_arch = \"armv7-a\"" + EXTRA_GN_ARGS+=" arm_float_abi = \"softfp\"" + fi + + # shellcheck disable=SC2155 # Ignore command exit-code + export GN="$(command -v gn)" + + # Make build.rs happy + ln -sf "$NDK" "$TERMUX_PKG_SRCDIR"/third_party/android_ndk + + BINDGEN_EXTRA_CLANG_ARGS="--target=$CCTERMUX_HOST_PLATFORM" + BINDGEN_EXTRA_CLANG_ARGS+=" --sysroot=$TERMUX_PKG_SRCDIR/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot" + export BINDGEN_EXTRA_CLANG_ARGS + local env_name=BINDGEN_EXTRA_CLANG_ARGS_${CARGO_TARGET_NAME@U} + env_name=${env_name//-/_} + export "$env_name"="$BINDGEN_EXTRA_CLANG_ARGS" +} + +termux_step_make() { + export V8_FROM_SOURCE=1 + cargo build -vv --jobs "${TERMUX_PKG_MAKE_PROCESSES}" --target "${CARGO_TARGET_NAME}" --release +} + +termux_step_make_install() { + install -Dm600 -t "${TERMUX_PREFIX}/include/librusty_v8" "target/${CARGO_TARGET_NAME}/release/gn_out/src_binding.rs" + install -Dm600 -t "${TERMUX_PREFIX}/lib" "target/${CARGO_TARGET_NAME}/release/gn_out/obj/librusty_v8.a" +} diff --git a/scripts/setup-ubuntu.sh b/scripts/setup-ubuntu.sh index 50fa9a7722a28f..e89d12fa1ea5e7 100755 --- a/scripts/setup-ubuntu.sh +++ b/scripts/setup-ubuntu.sh @@ -149,6 +149,10 @@ PACKAGES+=" llvm-17-dev" PACKAGES+=" llvm-17-tools" PACKAGES+=" clang-17" +# Needed by librusty-v8 +PACKAGES+=" libclang-rt-17-dev" +PACKAGES+=" libclang-rt-17-dev:i386" + # Needed for package smalltalk. PACKAGES+=" libsigsegv-dev" PACKAGES+=" zip"