mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-22 03:53:47 +00:00
spidermonkey_91: factor out into a common expression
This commit is contained in:
parent
eac7fe255a
commit
1573bc9229
@ -1,125 +1,4 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
|
||||
# build time
|
||||
, buildPackages
|
||||
, cargo
|
||||
, m4
|
||||
, perl
|
||||
, pkg-config
|
||||
, python3
|
||||
, rust-cbindgen
|
||||
, rustc
|
||||
, which
|
||||
, zip
|
||||
|
||||
# runtime
|
||||
, icu
|
||||
, nspr
|
||||
, readline
|
||||
, zlib
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "spidermonkey";
|
||||
import ./common.nix {
|
||||
version = "91.12.0";
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz";
|
||||
sha512 = "323fb752488b45872b40f0b0ee1d8c1dffa16874dbff2afde19a54286c824ef48177233e029faeafa5946184e71c31c6bc5ba7ec17a571e21af64fc5f7334042";
|
||||
};
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
setOutputFlags = false; # Configure script only understands --includedir
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo
|
||||
m4
|
||||
perl
|
||||
pkg-config
|
||||
python3
|
||||
rust-cbindgen
|
||||
rustc
|
||||
rustc.llvmPackages.llvm # for llvm-objdump
|
||||
which
|
||||
zip
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
icu
|
||||
nspr
|
||||
readline
|
||||
zlib
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
export LIBXUL_DIST=$out
|
||||
export PYTHON="${buildPackages.python3.interpreter}"
|
||||
export M4=m4
|
||||
export AWK=awk
|
||||
export AC_MACRODIR=$PWD/build/autoconf/
|
||||
|
||||
pushd js/src
|
||||
sh ../../build/autoconf/autoconf.sh --localdir=$PWD configure.in > configure
|
||||
chmod +x configure
|
||||
popd
|
||||
# We can't build in js/src/, so create a build dir
|
||||
mkdir obj
|
||||
cd obj/
|
||||
configureScript=../js/src/configure
|
||||
'';
|
||||
|
||||
configureFlags = [
|
||||
"--with-intl-api"
|
||||
"--with-system-icu"
|
||||
"--with-system-nspr"
|
||||
"--with-system-zlib"
|
||||
"--enable-optimize"
|
||||
"--enable-readline"
|
||||
"--enable-release"
|
||||
"--enable-shared-js"
|
||||
"--disable-debug"
|
||||
"--disable-jemalloc"
|
||||
"--disable-strip"
|
||||
"--disable-tests"
|
||||
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
# Spidermonkey seems to use different host/build terminology for cross
|
||||
# compilation here.
|
||||
"--host=${stdenv.buildPlatform.config}"
|
||||
"--target=${stdenv.hostPlatform.config}"
|
||||
];
|
||||
|
||||
# mkDerivation by default appends --build/--host to configureFlags when cross compiling
|
||||
# These defaults are bogus for Spidermonkey - avoid passing them by providing an empty list
|
||||
configurePlatforms = [ ];
|
||||
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
|
||||
# Remove unnecessary static lib
|
||||
preFixup = ''
|
||||
moveToOutput bin/js91-config "$dev"
|
||||
rm $out/lib/libjs_static.ajs
|
||||
ln -s $out/bin/js91 $out/bin/js
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postPatch = ''
|
||||
# This patch is a manually applied fix of
|
||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1644600
|
||||
# Once that bug is fixed, this can be removed.
|
||||
# This is needed in, for example, `zeroad`.
|
||||
substituteInPlace js/public/StructuredClone.h \
|
||||
--replace "class SharedArrayRawBufferRefs {" \
|
||||
"class JS_PUBLIC_API SharedArrayRawBufferRefs {"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Mozilla's JavaScript engine written in C/C++";
|
||||
homepage = "https://spidermonkey.dev/";
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [ lostnet ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
hash = "sha512-Mj+3UkiLRYcrQPCw7h2MHf+haHTb/yr94ZpUKGyCTvSBdyM+Ap+ur6WUYYTnHDHGvFun7BelceIa9k/F9zNAQg==";
|
||||
}
|
||||
|
130
pkgs/development/interpreters/spidermonkey/common.nix
Normal file
130
pkgs/development/interpreters/spidermonkey/common.nix
Normal file
@ -0,0 +1,130 @@
|
||||
{ version, hash }:
|
||||
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
|
||||
# build time
|
||||
, buildPackages
|
||||
, cargo
|
||||
, m4
|
||||
, perl
|
||||
, pkg-config
|
||||
, python3
|
||||
, rust-cbindgen
|
||||
, rustc
|
||||
, which
|
||||
, zip
|
||||
|
||||
# runtime
|
||||
, icu
|
||||
, nspr
|
||||
, readline
|
||||
, zlib
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "spidermonkey";
|
||||
inherit version;
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz";
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo
|
||||
m4
|
||||
perl
|
||||
pkg-config
|
||||
python3
|
||||
rust-cbindgen
|
||||
rustc
|
||||
rustc.llvmPackages.llvm # for llvm-objdump
|
||||
which
|
||||
zip
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
icu
|
||||
nspr
|
||||
readline
|
||||
zlib
|
||||
];
|
||||
|
||||
depsBuildBuild = [
|
||||
buildPackages.stdenv.cc
|
||||
];
|
||||
|
||||
setOutputFlags = false; # Configure script only understands --includedir
|
||||
|
||||
configureFlags = [
|
||||
"--with-intl-api"
|
||||
"--with-system-icu"
|
||||
"--with-system-nspr"
|
||||
"--with-system-zlib"
|
||||
"--enable-optimize"
|
||||
"--enable-readline"
|
||||
"--enable-release"
|
||||
"--enable-shared-js"
|
||||
"--disable-debug"
|
||||
"--disable-jemalloc"
|
||||
"--disable-strip"
|
||||
"--disable-tests"
|
||||
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
# Spidermonkey seems to use different host/build terminology for cross
|
||||
# compilation here.
|
||||
"--host=${stdenv.buildPlatform.config}"
|
||||
"--target=${stdenv.hostPlatform.config}"
|
||||
];
|
||||
|
||||
# mkDerivation by default appends --build/--host to configureFlags when cross compiling
|
||||
# These defaults are bogus for Spidermonkey - avoid passing them by providing an empty list
|
||||
configurePlatforms = [ ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postPatch = ''
|
||||
# This patch is a manually applied fix of
|
||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1644600
|
||||
# Once that bug is fixed, this can be removed.
|
||||
# This is needed in, for example, `zeroad`.
|
||||
substituteInPlace js/public/StructuredClone.h \
|
||||
--replace "class SharedArrayRawBufferRefs {" \
|
||||
"class JS_PUBLIC_API SharedArrayRawBufferRefs {"
|
||||
'';
|
||||
|
||||
preConfigure = ''
|
||||
export LIBXUL_DIST=$out
|
||||
export PYTHON="${buildPackages.python3.interpreter}"
|
||||
export M4=m4
|
||||
export AWK=awk
|
||||
export AC_MACRODIR=$PWD/build/autoconf/
|
||||
|
||||
pushd js/src
|
||||
sh ../../build/autoconf/autoconf.sh --localdir=$PWD configure.in > configure
|
||||
chmod +x configure
|
||||
popd
|
||||
# We can't build in js/src/, so create a build dir
|
||||
mkdir obj
|
||||
cd obj/
|
||||
configureScript=../js/src/configure
|
||||
'';
|
||||
|
||||
# Remove unnecessary static lib
|
||||
preFixup = ''
|
||||
moveToOutput bin/js${lib.versions.major version}-config "$dev"
|
||||
rm $out/lib/libjs_static.ajs
|
||||
ln -s $out/bin/js${lib.versions.major version} $out/bin/js
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Mozilla's JavaScript engine written in C/C++";
|
||||
homepage = "https://spidermonkey.dev/";
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [ lostnet ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user