From 4b8faf8a84bb5ad2207e5ef5c079f4852c764335 Mon Sep 17 00:00:00 2001 From: Alistair Michael Date: Wed, 7 Feb 2024 15:06:28 +1000 Subject: [PATCH] use dune sites to install asl files --- asli.opam | 6 ++++-- bin/asli.ml | 21 ++++++++++++++++++++- bin/dune | 10 ++++++++-- dune | 22 ++++++++++++++++++++++ dune-project | 5 ++++- 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 dune diff --git a/asli.opam b/asli.opam index 2c87cf31..428c463b 100644 --- a/asli.opam +++ b/asli.opam @@ -16,7 +16,7 @@ license: "BSD-3-Clause" homepage: "https://github.com/alastairreid/asl-interpreter" bug-reports: "https://github.com/alastairreid/asl-interpreter/issues" depends: [ - "dune" {>= "2.5"} + "dune" {>= "2.8"} "ocaml" {>= "4.09"} "menhir" {build} "ott" {build & >= "0.31"} @@ -26,9 +26,11 @@ depends: [ "z3" {>= "4.8.7"} "pcre" "alcotest" {with-test} + "dune-site" + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/bin/asli.ml b/bin/asli.ml index 2d2dfbe4..7577dbc4 100644 --- a/bin/asli.ml +++ b/bin/asli.ml @@ -19,13 +19,25 @@ module TC = Tcheck module PP = Asl_parser_pp module AST = Asl_ast -let opt_prelude : string ref = ref "prelude.asl" +let opt_prelude : string ref = ref "" let opt_filenames : string list ref = ref [] let opt_print_version = ref false let opt_verbose = ref false let opt_debug_level = ref 0 + +let file_load_order = ["mra_tools/arch/regs.asl"; "mra_tools/types.asl"; "mra_tools/arch/arch.asl"; "mra_tools/arch/arch_instrs.asl"; + "mra_tools/arch/arch_decode.asl"; "mra_tools/support/aes.asl";"mra_tools/support/barriers.asl";"mra_tools/support/debug.asl"; + "mra_tools/support/feature.asl"; "mra_tools/support/hints.asl";"mra_tools/support/interrupts.asl"; "mra_tools/support/memory.asl"; + "mra_tools/support/stubs.asl"; "mra_tools/support/fetchdecode.asl"; "tests/override.asl";"tests/override.prj"] + + +let default_asl_files : string option = match (Res.Sites.aslfiles) with + | hd :: _ -> Some hd + | _ -> None + + let () = Printexc.register_printer (function | Value.EvalError (loc, msg) -> @@ -315,6 +327,13 @@ let _ = let main () = if !opt_print_version then Printf.printf "%s\n" version else begin + if (List.length !opt_filenames) == 0 then + (opt_filenames := match default_asl_files with + | Some s -> List.map (fun file -> (s) ^ "/" ^ (file)) file_load_order + | None -> []); + if (!opt_prelude == "") then opt_prelude := (match default_asl_files with + | Some s -> s ^ "/" + | None -> "") ^ "prelude.asl"; if !opt_verbose then List.iter print_endline banner; if !opt_verbose then print_endline "\nType :? for help"; let t = LoadASL.read_file !opt_prelude true !opt_verbose in diff --git a/bin/dune b/bin/dune index 94a55ab1..c293c274 100644 --- a/bin/dune +++ b/bin/dune @@ -1,10 +1,12 @@ + (executable (name asli) (public_name asli) (modes exe byte) - (modules asli) + (modules asli res) (flags (-cclib -lstdc++)) - (libraries libASL linenoise pprint pcre)) + (libraries libASL linenoise pprint pcre dune-site) + ) (executable (name testlexer) @@ -21,3 +23,7 @@ (modules processops) (flags (-cclib -lstdc++)) (libraries libASL unix)) + +(generate_sites_module + (module res) + (sites asli)) diff --git a/dune b/dune new file mode 100644 index 00000000..586df531 --- /dev/null +++ b/dune @@ -0,0 +1,22 @@ +(install + (files + (prelude.asl as prelude.asl ) + (mra_tools/arch/arch.asl as mra_tools/arch/arch.asl ) + (mra_tools/arch/arch_decode.asl as mra_tools/arch/arch_decode.asl ) + (mra_tools/arch/arch_instrs.asl as mra_tools/arch/arch_instrs.asl ) + (mra_tools/arch/regs.asl as mra_tools/arch/regs.asl ) + (mra_tools/support/aes.asl as mra_tools/support/aes.asl ) + (mra_tools/support/barriers.asl as mra_tools/support/barriers.asl ) + (mra_tools/support/debug.asl as mra_tools/support/debug.asl ) + (mra_tools/support/feature.asl as mra_tools/support/feature.asl ) + (mra_tools/support/fetchdecode.asl as mra_tools/support/fetchdecode.asl) + (mra_tools/support/hints.asl as mra_tools/support/hints.asl ) + (mra_tools/support/interrupts.asl as mra_tools/support/interrupts.asl ) + (mra_tools/support/memory.asl as mra_tools/support/memory.asl ) + (mra_tools/support/stubs.asl as mra_tools/support/stubs.asl ) + (mra_tools/types.asl as mra_tools/types.asl ) + (tests/override.asl as tests/override.asl ) + (tests/override.prj as tests/override.prj ) + ) + (section (site (asli aslfiles))) + ) diff --git a/dune-project b/dune-project index f1f07b1b..788c5923 100644 --- a/dune-project +++ b/dune-project @@ -1,7 +1,8 @@ -(lang dune 2.5) +(lang dune 2.8) (name asli) (version 0.2.0) +(using dune_site 0.1) (using menhir 2.0) (package @@ -24,7 +25,9 @@ ("z3" (>= "4.8.7")) "pcre" ("alcotest" :with-test) + "dune-site" ) + (sites (share aslfiles)) ) (license BSD-3-Clause)