Skip to content

Commit

Permalink
support --prelude to make aslp.nix pwd-independent.
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Sep 5, 2023
1 parent f948a9c commit fdd23b7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion asli.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ocamlPackages.buildDunePackage {
doCheck = lib.versionAtLeast ocaml.version "4.09";

configurePhase = ''
sed -i 's|`opam config var ott:share`|${pkgs.ott.out + "/share/ott"}|' ./libASL/dune
export ASLI_OTT=${pkgs.ott.out + "/share/ott"}
mkdir -p $out/asl
cp -rv prelude.asl mra_tools tests $out/asl
'';
Expand Down
2 changes: 2 additions & 0 deletions aslp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
ASL_PATH=${asli}/asl
cd ${asli}/bin
makeBinaryWrapper "$(pwd)/asli" $out/bin/aslp \
--append-flags --prelude \
--append-flags $ASL_PATH/prelude.asl \
--append-flags $ASL_PATH/prelude.asl \
--append-flags $ASL_PATH/mra_tools/arch/regs.asl \
--append-flags $ASL_PATH/mra_tools/types.asl \
Expand Down
4 changes: 3 additions & 1 deletion bin/asli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module TC = Tcheck
module PP = Asl_parser_pp
module AST = Asl_ast

let opt_prelude : string ref = ref "prelude.asl"
let opt_filenames : string list ref = ref []
let opt_print_version = ref false
let opt_verbose = ref false
Expand Down Expand Up @@ -284,6 +285,7 @@ let options = Arg.align ([
( "-x", Arg.Set_int opt_debug_level, " Debugging output");
( "-v", Arg.Set opt_verbose, " Verbose output");
( "--version", Arg.Set opt_print_version, " Print version");
( "--prelude", Arg.Set_string opt_prelude," ASL prelude file (default: ./prelude.asl)");
] )

let version = "ASL 0.2.0 alpha"
Expand Down Expand Up @@ -311,7 +313,7 @@ let main () =
else begin
if !opt_verbose then List.iter print_endline banner;
if !opt_verbose then print_endline "\nType :? for help";
let t = LoadASL.read_file "prelude.asl" true !opt_verbose in
let t = LoadASL.read_file !opt_prelude true !opt_verbose in
let ts = List.map (fun filename ->
if Utils.endswith filename ".spec" then begin
LoadASL.read_spec filename !opt_verbose
Expand Down
2 changes: 1 addition & 1 deletion libASL/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(progn
(run ott -aux_style_rules false -tex_wrap true -quotient_rules false -i asl.ott -o asl_parser_head.mly -o asl_lexer.mll -o asl_ast.ml)
(run mv asl_parser_head_pp.ml asl_parser_pp.ml)
(with-stdout-to asl_parser_tail.mly (bash "grep -v '^%%' `opam config var ott:share`/menhir_library_extra.mly"))
(with-stdout-to asl_parser_tail.mly (bash "OTT=${ASLI_OTT:-$(opam config var ott:share)}; grep -v '^%%' $OTT/menhir_library_extra.mly"))
(with-stdout-to asl_parser.mly (run cat asl_parser_head.mly asl_parser_tail.mly)))))

(library
Expand Down
20 changes: 20 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [ pkgs.opam pkgs.ocaml pkgs.ott pkgs.ocamlPackages.merlin pkgs.ocamlPackages.ocaml-lsp pkgs.ocamlformat ];

inputsFrom = [ pkgs.asli ];

shellHook = ''
export DEBUG=1
export OPAMSWITCH=nix-shell-asli
CAML_LD_PREV=$CAML_LD_LIBRARY_PATH
opam init --no-setup
opam switch create $OPAMSWITCH ocaml-system
eval $(opam env)
export ASLI_OTT=${pkgs.ott}/share/ott
export CAML_LD_LIBRARY_PATH=$CAML_LD_PREV:$CAML_LD_LIBRARY_PATH
'';
}

0 comments on commit fdd23b7

Please sign in to comment.