cbqn: add enableReplxx option

This commit is contained in:
Narazaki, Shuji 2022-12-02 04:06:49 +09:00
parent cc620a6e59
commit efbce7d4aa
2 changed files with 39 additions and 4 deletions

View File

@ -4,11 +4,13 @@
, genBytecode ? false
, bqn-path ? null
, mbqn-source ? null
, enableReplxx ? false
, libffi
, pkg-config
}:
let
# TODO: these submodules should be separated libraries
cbqn-bytecode-files = fetchFromGitHub {
name = "cbqn-bytecode-files";
owner = "dzaima";
@ -16,6 +18,13 @@ let
rev = "3df8ae563a626ff7ae0683643092f0c3bc2481e5";
hash = "sha256:0rh9qp1bdm9aa77l0kn9n4jdy08gl6l7898lncskxiq9id6xvyb8";
};
replxx-submodule = fetchFromGitHub {
name = "replxx-submodule";
owner = "dzaima";
repo = "replxx";
rev = "ba94c293caad52486df8712e808783df9a8f4501";
hash = "sha256-pMLvURksj/5k5b6BTwWxjomoROMOE5+GRjyaoqu/iYE=";
};
in
assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
@ -26,8 +35,8 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub {
owner = "dzaima";
repo = "CBQN";
rev = "dbc7c83f7085d05e87721bedf1ee38931f671a8e";
hash = "sha256:0nal1fs9y7nyx4d5q1qw868lxk7mivzw2y16wc3hw97pq4qf0dpb";
rev = "49c0d9a355698f54fff2c0caa177e2b341fabb45";
hash = "sha256-jm2ZzFxhr9o4nFR2rjYJz/4GH+WFnfU4QDovrOPI3jQ=";
};
nativeBuildInputs = [
@ -47,7 +56,8 @@ stdenv.mkDerivation rec {
makeFlags = [
"CC=${stdenv.cc.targetPrefix}cc"
];
]
++ lib.optional enableReplxx "REPLXX=1";
preBuild = ''
# Purity: avoids git downloading bytecode files
@ -56,7 +66,15 @@ stdenv.mkDerivation rec {
${bqn-path} ./build/genRuntime ${mbqn-source} build/bytecodeLocal/
'' else ''
cp ${cbqn-bytecode-files}/src/gen/{compiles,explain,formatter,runtime0,runtime1,src} build/bytecodeLocal/gen/
'');
'')
+ lib.optionalString enableReplxx ''
cp -r ${replxx-submodule} build/replxxLocal/
''
# Need to adjust ld flags for darwin manually
# https://github.com/dzaima/CBQN/issues/26
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
makeFlagsArray+=(LD_LIBS="-ldl -lffi")
'';
installPhase = ''
runHook preInstall

View File

@ -15762,7 +15762,9 @@ with pkgs;
mbqn = callPackage ../development/interpreters/bqn/mlochbaum-bqn { };
cbqn = cbqn-bootstrap.phase2;
cbqn-replxx = cbqn-bootstrap.phase2-replxx;
cbqn-standalone = cbqn-bootstrap.phase0;
cbqn-standalone-replxx = cbqn-bootstrap.phase0-replxx;
# Below, the classic self-bootstrapping process
cbqn-bootstrap = lib.dontRecurseIntoAttrs {
@ -15787,6 +15789,14 @@ with pkgs;
mbqn-source = null;
};
phase0-replxx = callPackage ../development/interpreters/bqn/cbqn {
inherit (cbqn-bootstrap) stdenv;
genBytecode = false;
bqn-path = null;
mbqn-source = null;
enableReplxx = true;
};
phase1 = callPackage ../development/interpreters/bqn/cbqn {
inherit (cbqn-bootstrap) mbqn-source stdenv;
genBytecode = true;
@ -15798,6 +15808,13 @@ with pkgs;
genBytecode = true;
bqn-path = "${buildPackages.cbqn-bootstrap.phase1}/bin/cbqn";
};
phase2-replxx = callPackage ../development/interpreters/bqn/cbqn {
inherit (cbqn-bootstrap) mbqn-source stdenv;
genBytecode = true;
bqn-path = "${buildPackages.cbqn-bootstrap.phase1}/bin/cbqn";
enableReplxx = true;
};
};
dbqn = callPackage ../development/interpreters/bqn/dzaima-bqn {