quickjs-ng: 0.6.0 -> 0.6.1; quickjs; refactor (#344999)

This commit is contained in:
h7x4
2024-10-01 21:07:33 +02:00
committed by GitHub
2 changed files with 143 additions and 58 deletions
+38 -21
View File
@@ -1,23 +1,30 @@
{ lib
, stdenv
, cmake
, fetchFromGitHub
, testers
, texinfo
{
lib,
cmake,
fetchFromGitHub,
stdenv,
testers,
texinfo,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "quickjs-ng";
version = "0.6.0";
version = "0.6.1";
src = fetchFromGitHub {
owner = "quickjs-ng";
repo = "quickjs";
rev = "v${finalAttrs.version}";
hash = "sha256-gULpJhOOmhzq2Ydl4soNBiiONtdt2T4sgcSqIBCo3SM=";
hash = "sha256-7IAkmlzgiPVd8yRv7LU5a7HWCB+eQk1Ur1KwZupwty0=";
};
outputs = [ "bin" "out" "dev" "doc" "info" ];
outputs = [
"out"
"bin"
"dev"
"doc"
"info"
];
nativeBuildInputs = [
cmake
@@ -25,18 +32,28 @@ stdenv.mkDerivation (finalAttrs: {
];
cmakeFlags = [
"-DBUILD_SHARED_LIBS=ON"
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
(lib.cmakeBool "BUILD_STATIC_QJS_EXE" stdenv.hostPlatform.isStatic)
];
env.NIX_CFLAGS_COMPILE = toString (lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
"-Wno-error=stringop-overflow"
]);
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
"-Wno-error=stringop-overflow"
]
);
strictDeps = true;
postBuild = ''
pushd ../doc
makeinfo *texi
popd
'';
postInstall = ''
(cd ../doc
makeinfo --output quickjs.info quickjs.texi
install -Dt $info/share/info/ quickjs.info)
pushd ../doc
install -Dm644 -t ''${!outputInfo}/share/info *info
popd
'';
passthru.tests = {
@@ -46,12 +63,12 @@ stdenv.mkDerivation (finalAttrs: {
};
};
meta = with lib; {
description = "Mighty JavaScript engine";
meta = {
homepage = "https://github.com/quickjs-ng/quickjs";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.all;
description = "Mighty JavaScript engine";
license = lib.licenses.mit;
mainProgram = "qjs";
maintainers = with lib.maintainers; [ AndersonTorres ];
platforms = lib.platforms.all;
};
})
+105 -37
View File
@@ -1,62 +1,130 @@
{ lib
, stdenv
, fetchurl
, texinfo
{
lib,
fetchurl,
stdenv,
testers,
texinfo,
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "quickjs";
version = "2024-01-13";
src = fetchurl {
url = "https://bellard.org/quickjs/quickjs-${version}.tar.xz";
url = "https://bellard.org/quickjs/quickjs-${finalAttrs.version}.tar.xz";
hash = "sha256-PEv4+JW/pUvrSGyNEhgRJ3Hs/FrDvhA2hR70FWghLgM=";
};
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace Makefile --replace "CONFIG_LTO=y" ""
'';
makeFlags = [ "PREFIX=${placeholder "out"}" ];
enableParallelBuilding = true;
outputs = [
"out"
"info"
];
nativeBuildInputs = [
texinfo
];
makeFlags = [ "PREFIX=$(out)" ];
doInstallCheck = true;
enableParallelBuilding = true;
strictDeps = true;
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace Makefile \
--replace "CONFIG_LTO=y" ""
'';
postBuild = ''
(cd doc
makeinfo *texi)
pushd doc
makeinfo *texi
popd
'';
postInstall = ''
(cd doc
install -Dt $out/share/doc *texi *info)
pushd doc
install -Dm644 -t ''${!outputInfo}/share/info *info
popd
'';
doInstallCheck = true;
installCheckPhase = ''
PATH="$out/bin:$PATH"
installCheckPhase = lib.concatStringsSep "\n" [
''
runHook preInstallCheck
''
''
PATH="$out/bin:$PATH"
''
# Programs exit with code 1 when testing help, so grep for a string
set +o pipefail
qjs --help 2>&1 | grep "QuickJS version"
qjscalc --help 2>&1 | grep "QuickJS version"
set -o pipefail
''
set +o pipefail
qjs --help 2>&1 | grep "QuickJS version"
qjscalc --help 2>&1 | grep "QuickJS version"
set -o pipefail
''
temp=$(mktemp).js
echo "console.log('Output from compiled program');" > "$temp"
set -o verbose
out=$(mktemp) && qjsc -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
out=$(mktemp) && qjsc -flto -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
'';
''
temp=$(mktemp).js
echo "console.log('Output from compiled program');" > "$temp"
set -o verbose
out=$(mktemp) && qjsc -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
out=$(mktemp) && qjsc -flto -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
''
meta = with lib; {
description = "Small and embeddable Javascript engine";
homepage = "https://bellard.org/quickjs/";
maintainers = with maintainers; [ stesie AndersonTorres ];
platforms = platforms.unix;
license = licenses.mit;
mainProgram = "qjs";
''
runHook postInstallCheck
''
];
passthru.tests = {
version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "qjs --help || true";
};
};
}
meta = {
homepage = "https://bellard.org/quickjs/";
description = "Small and embeddable Javascript engine";
longDescription = ''
QuickJS is a small and embeddable Javascript engine. It supports the
ES2023 specification including modules, asynchronous generators, proxies
and BigInt.
It optionally supports mathematical extensions such as big decimal
floating point numbers (BigDecimal), big binary floating point numbers
(BigFloat) and operator overloading.
Main Features:
- Small and easily embeddable: just a few C files, no external
dependency, 210 KiB of x86 code for a simple hello world program.
- Fast interpreter with very low startup time: runs the 76000 tests of
the ECMAScript Test Suite in less than 2 minutes on a single core of a
desktop PC. The complete life cycle of a runtime instance completes in
less than 300 microseconds.
- Almost complete ES2023 support including modules, asynchronous
generators and full Annex B support (legacy web compatibility).
- Passes nearly 100% of the ECMAScript Test Suite tests when selecting
the ES2023 features. A summary is available at Test262 Report.
- Can compile Javascript sources to executables with no external dependency.
- Garbage collection using reference counting (to reduce memory usage and
have deterministic behavior) with cycle removal.
- Mathematical extensions: BigDecimal, BigFloat, operator overloading,
bigint mode, math mode.
- Command line interpreter with contextual colorization implemented in
Javascript.
- Small built-in standard library with C library wrappers.
'';
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
stesie
AndersonTorres
];
mainProgram = "qjs";
platforms = lib.platforms.all;
};
})