mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-02 10:14:09 +00:00
Merge pull request #140319 from AndersonTorres/new-bqn
BQN updates bqn (aka mbqn) and dbqn included, plus updated cbqn
This commit is contained in:
commit
3c5ac430ca
@ -9,7 +9,7 @@ index a5f3d75..f617e25 100644
|
||||
- @echo "Copying precompiled bytecode from the bytecode branch"
|
||||
- git checkout remotes/origin/bytecode src/gen/{compiler,formatter,runtime0,runtime1,src}
|
||||
- git reset src/gen/{compiler,formatter,runtime0,runtime1,src}
|
||||
+ echo "src/gen/ files retrieved externally"
|
||||
+ @echo "src/gen/ files retrieved externally"
|
||||
${bd}/load.o: src/gen/customRuntime
|
||||
|
||||
-include $(bd)/*.d
|
||||
|
@ -1,33 +1,30 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, genBytecode ? false
|
||||
, bqn-path ? null
|
||||
, mbqn-source ? null
|
||||
}:
|
||||
|
||||
let
|
||||
mlochbaum-bqn = fetchFromGitHub {
|
||||
owner = "mlochbaum";
|
||||
repo = "BQN";
|
||||
rev = "97cbdc67fe6a9652c42daefadd658cc41c1e5ae3";
|
||||
hash = "sha256-F2Bv3n3C7zAhqKCMB6hT2iIWTjEqFdLBMyX6/w7V1SY=";
|
||||
cbqn-bytecode-files = fetchFromGitHub {
|
||||
name = "cbqn-bytecode-files";
|
||||
owner = "dzaima";
|
||||
repo = "CBQN";
|
||||
rev = "94bb312d20919f942eabed3dca33c514de3c3227";
|
||||
hash = "sha256-aFw5/F7/sYkYmxAnGeK8EwkoVrbEcjuJAD9YT+iW9Rw=";
|
||||
};
|
||||
in
|
||||
assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "cbqn";
|
||||
version = "0.0.0+unstable=2021-09-29";
|
||||
pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone";
|
||||
version = "0.0.0+unstable=2021-10-01";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "dzaima";
|
||||
repo = "CBQN";
|
||||
rev = "1c83483d5395e097f60de299274ebe0df590217e";
|
||||
hash = "sha256-C34DpXab08mBm2oCQuaeq4fJPtQ5rVa/HlpL/nB9XjQ=";
|
||||
};
|
||||
|
||||
cbqn-bytecode = fetchFromGitHub {
|
||||
owner = "dzaima";
|
||||
repo = "CBQN";
|
||||
rev = "fdf0b93409d68d5ffd86c5670db27c240e6039e0";
|
||||
hash = "sha256-A0zvpg+G37WNgyfrJuc5rH6L7Wntdbrz8pYEPreqgKE=";
|
||||
rev = "3725bd58c758a749653080319766a33169551536";
|
||||
hash = "sha256-xWp64inFZRqGGTrH6Hqbj7aA0vYPyd+FdetowTMTjPs=";
|
||||
};
|
||||
|
||||
dontConfigure = true;
|
||||
@ -42,17 +39,16 @@ stdenv.mkDerivation rec {
|
||||
'';
|
||||
|
||||
preBuild =
|
||||
if bqn-path == null
|
||||
if genBytecode
|
||||
then ''
|
||||
cp ${cbqn-bytecode}/src/gen/{compiler,formatter,runtime0,runtime1,src} src/gen/
|
||||
${bqn-path} genRuntime ${mbqn-source}
|
||||
''
|
||||
else ''
|
||||
${bqn-path} genRuntime ${mlochbaum-bqn}
|
||||
cp ${cbqn-bytecode-files}/src/gen/{compiler,formatter,runtime0,runtime1,src} src/gen/
|
||||
'';
|
||||
|
||||
makeFlags = [
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
"single-o3"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
@ -70,9 +66,10 @@ stdenv.mkDerivation rec {
|
||||
homepage = "https://github.com/dzaima/CBQN/";
|
||||
description = "BQN implementation in C";
|
||||
license = licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [ AndersonTorres ];
|
||||
maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica ];
|
||||
platforms = platforms.all;
|
||||
priority = if genBytecode then 0 else 10;
|
||||
};
|
||||
}
|
||||
# TODO: factor BQN
|
||||
# TODO: test suite (dependent on BQN from mlochbaum)
|
||||
# TODO: factor and version cbqn-bytecode-files
|
||||
# TODO: test suite
|
||||
|
71
pkgs/development/interpreters/bqn/dzaima-bqn/default.nix
Normal file
71
pkgs/development/interpreters/bqn/dzaima-bqn/default.nix
Normal file
@ -0,0 +1,71 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, jdk
|
||||
, makeWrapper
|
||||
, buildNativeImage ? true
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "dbqn" + lib.optionalString buildNativeImage "-native";
|
||||
version = "0.0.0+unstable=2021-10-02";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "dzaima";
|
||||
repo = "BQN";
|
||||
rev = "d6bd66d26a89b8e9f956ec4f6b6bc5dcb5861a09";
|
||||
hash = "sha256-BLRep7OGHfDFowIAsBS19PTzgIhrdKMnO2JSjKuwGYo=";
|
||||
};
|
||||
|
||||
buildInputs = lib.optional (!buildNativeImage) jdk;
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
] ++ lib.optional buildNativeImage jdk;
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir -p output
|
||||
javac --release 8 -encoding UTF-8 -d ./output $(find src -name '*.java')
|
||||
(cd output; jar cvfe ../BQN.jar BQN.Main *)
|
||||
rm -fr output
|
||||
'' + lib.optionalString buildNativeImage ''
|
||||
native-image --report-unsupported-elements-at-runtime \
|
||||
-J-Dfile.encoding=UTF-8 -jar BQN.jar dbqn
|
||||
'' + ''
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
|
||||
'' + (if buildNativeImage then ''
|
||||
mv dbqn $out/bin
|
||||
'' else ''
|
||||
mkdir -p $out/share/${pname}
|
||||
mv BQN.jar $out/share/${pname}/
|
||||
|
||||
makeWrapper "${lib.getBin jdk}/bin/java" "$out/bin/dbqn" \
|
||||
--add-flags "-jar $out/share/${pname}/BQN.jar"
|
||||
'') + ''
|
||||
ln -s $out/bin/dbqn $out/bin/bqn
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/dzaima/BQN";
|
||||
description = "A BQN implementation in Java" + lib.optionalString buildNativeImage ", compiled as a native image";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ AndersonTorres sternenseemann ];
|
||||
inherit (jdk.meta) platforms;
|
||||
priority = if buildNativeImage then 10 else 0;
|
||||
};
|
||||
}
|
||||
# TODO: Processing app
|
||||
# TODO: minimalistic JDK
|
@ -0,0 +1,12 @@
|
||||
diff -Naur source-old/bqn.js source-new/bqn.js
|
||||
--- source-old/bqn.js 1969-12-31 21:00:01.000000000 -0300
|
||||
+++ source-new/bqn.js 2021-10-03 01:28:00.268998916 -0300
|
||||
@@ -4,7 +4,7 @@
|
||||
let path = require('path');
|
||||
let fs = require('fs');
|
||||
|
||||
-let bqn = require("./docs/bqn.js");
|
||||
+let bqn = require("@libbqn@");
|
||||
module.exports = bqn;
|
||||
let {fmt,fmtErr,sysvals,sysargs,makebqn,makerepl}=bqn;
|
||||
let {has,list,str,unstr,dynsys,req1str,makens}=bqn.util;
|
64
pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix
Normal file
64
pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix
Normal file
@ -0,0 +1,64 @@
|
||||
{ lib
|
||||
, stdenvNoCC
|
||||
, fetchFromGitHub
|
||||
, makeWrapper
|
||||
, nodejs
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
pname = "bqn";
|
||||
version = "0.0.0+unstable=2021-10-01";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "mlochbaum";
|
||||
repo = "BQN";
|
||||
rev = "b3d68f730d48ccb5e3b3255f9010c95bf9f86e22";
|
||||
hash = "sha256-Tkgwz7+d25svmjRsXFUQq0S/73QJU+BKSNeGqpUcBTQ=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
buildInputs = [ nodejs ];
|
||||
|
||||
patches = [
|
||||
# Creates a @libbqn@ substitution variable
|
||||
./001-libbqn-path.patch
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin $out/share/${pname}
|
||||
cp bqn.js $out/share/${pname}/bqn.js
|
||||
cp docs/bqn.js $out/share/${pname}/libbqn.js
|
||||
|
||||
makeWrapper "${lib.getBin nodejs}/bin/node" "$out/bin/mbqn" \
|
||||
--add-flags "$out/share/${pname}/bqn.js"
|
||||
|
||||
ln -s $out/bin/mbqn $out/bin/bqn
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
fixupPhase = ''
|
||||
runHook preFixup
|
||||
|
||||
substituteInPlace $out/share/${pname}/bqn.js \
|
||||
--subst-var-by "libbqn" "$out/share/${pname}/libbqn.js"
|
||||
|
||||
runHook postFixup
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/mlochbaum/BQN/";
|
||||
description = "The original BQN implementation in Javascript";
|
||||
license = licenses.isc;
|
||||
maintainers = with maintainers; [ AndersonTorres ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
# TODO: install docs and other stuff
|
@ -12850,16 +12850,50 @@ with pkgs;
|
||||
babashka = callPackage ../development/interpreters/clojure/babashka.nix { };
|
||||
|
||||
# BQN interpreters and compilers
|
||||
cbqn = cbqn-phase2;
|
||||
# And the classic bootstrapping process
|
||||
cbqn-phase0 = callPackage ../development/interpreters/bqn/cbqn {
|
||||
bqn-path = null;
|
||||
|
||||
mbqn = callPackage ../development/interpreters/bqn/mlochbaum-bqn { };
|
||||
|
||||
cbqn = cbqn-bootstrap.phase2;
|
||||
cbqn-standalone = cbqn-bootstrap.phase0;
|
||||
|
||||
# Below, the classic self-bootstrapping process
|
||||
cbqn-bootstrap = lib.dontRecurseIntoAttrs {
|
||||
# use clang here since it emits less speculative warnings;
|
||||
# however, avoid its building in cross compilations
|
||||
stdenv =
|
||||
if stdenv.hostPlatform == stdenv.buildPlatform
|
||||
then clangStdenv
|
||||
else stdenv;
|
||||
mbqn-source = buildPackages.mbqn.src;
|
||||
|
||||
phase0 = callPackage ../development/interpreters/bqn/cbqn {
|
||||
inherit (cbqn-bootstrap) stdenv;
|
||||
genBytecode = false;
|
||||
bqn-path = null;
|
||||
mbqn-source = null;
|
||||
};
|
||||
|
||||
phase1 = callPackage ../development/interpreters/bqn/cbqn {
|
||||
inherit (cbqn-bootstrap) stdenv mbqn-source;
|
||||
genBytecode = true;
|
||||
bqn-path = "${buildPackages.cbqn-bootstrap.phase0}/bin/cbqn";
|
||||
};
|
||||
|
||||
phase2 = callPackage ../development/interpreters/bqn/cbqn {
|
||||
inherit (cbqn-bootstrap) stdenv mbqn-source;
|
||||
genBytecode = true;
|
||||
bqn-path = "${buildPackages.cbqn-bootstrap.phase1}/bin/cbqn";
|
||||
};
|
||||
};
|
||||
cbqn-phase1 = callPackage ../development/interpreters/bqn/cbqn {
|
||||
bqn-path = "${cbqn-phase0}/bin/bqn";
|
||||
|
||||
dbqn = callPackage ../development/interpreters/bqn/dzaima-bqn {
|
||||
buildNativeImage = false;
|
||||
stdenv = stdenvNoCC;
|
||||
jdk = jre;
|
||||
};
|
||||
cbqn-phase2 = callPackage ../development/interpreters/bqn/cbqn {
|
||||
bqn-path = "${cbqn-phase1}/bin/bqn";
|
||||
dbqn-native = callPackage ../development/interpreters/bqn/dzaima-bqn {
|
||||
buildNativeImage = true;
|
||||
jdk = graalvm11-ce;
|
||||
};
|
||||
|
||||
chibi = callPackage ../development/interpreters/chibi { };
|
||||
|
Loading…
Reference in New Issue
Block a user