Skip to content

Commit

Permalink
tweak: gtirb-semantics wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Jan 4, 2024
1 parent 33282d0 commit 5752cc4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
12 changes: 9 additions & 3 deletions asli.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
ocamlPackages
}:


ocamlPackages.buildDunePackage rec {
let self = ocamlPackages.buildDunePackage {
pname = "asli";
version = "unstable-2023-09-18";

Expand All @@ -33,9 +32,16 @@ ocamlPackages.buildDunePackage rec {

outputs = [ "out" ];

passthru = {
prelude = "${self.out}/share/asli/prelude.asl";
mra_tools = "${self.out}/share/asli/mra_tools";
dir = "${self.out}/share/asli";
};

meta = {
homepage = "https://github.com/UQ-PAC/aslp";
description = "ASL partial evaluator to extract semantics from ARM's MRA.";
maintainers = [ "Kait Lam <[email protected]>" ];
};
}
};
in self
26 changes: 19 additions & 7 deletions gtirb-semantics.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
ocamlPackages,
protobuf,
asli,
ocaml-hexstring
ocaml-hexstring,
writeScript,
makeWrapper,
}:

ocamlPackages.buildDunePackage rec {
Expand All @@ -21,15 +23,25 @@ ocamlPackages.buildDunePackage rec {

checkInputs = [ ];
buildInputs = [ asli ocaml-hexstring ocamlPackages.ocaml-protoc-plugin ];
nativeBuildInputs = [ protobuf ocamlPackages.ocaml-protoc-plugin ];
nativeBuildInputs = [ makeWrapper protobuf ocamlPackages.ocaml-protoc-plugin ];
propagatedBuildInputs = (with ocamlPackages; [ base64 ]);
doCheck = lib.versionAtLeast ocaml.version "4.09";

configurePhase = ''
runHook preConfigure
# ocaml_protoc=${ocamlPackages.ocaml-protoc-plugin.out}/bin/protoc-gen-ocaml
# substituteInPlace
runHook postConfigure
wrapper = writeScript "gtirb-semantics-wrapper" ''
# wrapper script for gtirb_semantics through Nix.
# inserts required ASLI arguments and passes through the input/output arguments.
prog="$(dirname "$0")"/_gtirb_semantics
input="$1"
shift
echo '$' "$(basename "$prog")" "$input" $(basename ${asli.prelude}) $(basename ${asli.mra_tools})/ $(basename ${asli.dir})/ "$@" >&2
"$prog" "$input" ${asli.prelude} ${asli.mra_tools} ${asli.dir} "$@"
'';

postInstall = ''
mv -v $out/bin/{,_}gtirb_semantics
cp -v ${wrapper} $out/bin/gtirb-semantics
'';

meta = {
Expand Down

0 comments on commit 5752cc4

Please sign in to comment.