Skip to content

Commit

Permalink
Move scripts into misc/scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
elegios committed Nov 22, 2024
1 parent c0822ee commit 5e6651a
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 1,192 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,38 @@ default: bootstrap
# directory, which should coincide with generated files
.PHONY: clean
clean:
bash -c 'mapfile -t args < <(misc/repo-ignored-files build); rm -rf "$${args[@]}"'
bash -c 'mapfile -t args < <(misc/scripts/repo-ignored-files build); rm -rf "$${args[@]}"'
find build -depth -type d -empty -delete


# The OCaml library and executables (`boot`)

.PHONY: boot
boot:
misc/with-tmp-dir dune build --root=src/boot/ --build-dir="{}" \
misc/scripts/with-tmp-dir dune build --root=src/boot/ --build-dir="{}" \
"&&" dune install --root=src/boot/ --build-dir="{}" --prefix=$(current_dir)/build ">/dev/null" "2>&1"
mv $(current_dir)"/build/bin/boot" build/$(BOOT_NAME)
rm -f $(current_dir)"/build/lib/boot/dune-package"

.PHONY: install-boot
install-boot:
misc/with-tmp-dir dune build --root=src/boot/ --build-dir="{}" \
misc/scripts/with-tmp-dir dune build --root=src/boot/ --build-dir="{}" \
"&&" dune install --root=src/boot/ --build-dir="{}" --prefix=$(prefix) --libdir=$(ocamllibdir) ">/dev/null 2>&1"

.PHONY: uninstall-boot
uninstall-boot:
misc/with-tmp-dir dune uninstall --root=src/boot --build-dir="{}" --prefix=$(prefix) --libdir=$(ocamllibdir) ">/dev/null 2>&1"
misc/scripts/with-tmp-dir dune uninstall --root=src/boot --build-dir="{}" --prefix=$(prefix) --libdir=$(ocamllibdir) ">/dev/null 2>&1"


## Formatting, checking and autoformatting respectively

.PHONY: lint
lint:
misc/with-tmp-dir dune fmt --root=src/boot/ --build-dir="{}"
misc/scripts/with-tmp-dir dune fmt --root=src/boot/ --build-dir="{}"

.PHONY: fix
fix:
misc/with-tmp-dir dune fmt --root=src/boot/ --build-dir="{}" --auto-promote
misc/scripts/with-tmp-dir dune fmt --root=src/boot/ --build-dir="{}" --auto-promote


# Bootstrapping the `mi` executable
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion misc/gen-tup-rules → misc/scripts/gen-tup-rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

DIR=$(dirname "$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )")
DIR=$(dirname "$(dirname "$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )")")
TARGETDIR=$(realpath --relative-to="$DIR" .)
cd "$DIR"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
80 changes: 63 additions & 17 deletions misc/test-spec.mc
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,15 @@ let _glob
_restrictToDir dir args.glob
else Some args.glob in
match glob with Some glob then
let globStr = strJoin "/" (cons "src" glob.dirs) in
let globStr = match glob.subdirs with IncludeSubs _
then concat globStr "/**"
else globStr in
let globStr = switch glob.file
case ExactFile f then join [globStr, "/", f]
case SuffixFile f then join [globStr, "/*", f]
let dir = [strJoin "/" (cons "src" glob.dirs)] in
let depth = match glob.subdirs with IncludeSubs _
then []
else ["-maxdepth", "1"] in
let name = switch glob.file
case ExactFile f then ["-name", f]
case SuffixFile f then ["-name", concat "\\*" f]
end in
let bashCmd = join ["\"for f in ", globStr, "; do echo \\$f; done\""] in
let res = sysRunCommand ["bash", "-O", "globstar", "-O", "nullglob", "-c", bashCmd] "" args.root in
let res = sysRunCommand (join [["find"], dir, depth, name]) "" args.root in
let stringToPath = lam s. OrigPath { path = match strSplit "/" s with dirs ++ [file] in (dirs, file) } in
let paths = init (strSplit "\n" res.stdout) in
let paths = match args.files with Some files
Expand Down Expand Up @@ -568,8 +567,8 @@ let testMain : [TestCollection] -> () = lam colls.
then "%2o"
else pathToString stderr in
let elideCat = match options.mode with TupRules _
then "$(ROOT)/misc/elide-cat"
else "misc/elide-cat" in
then "$(ROOT)/misc/scripts/elide-cat"
else "misc/scripts/elide-cat" in
let command = join
[ "{ ", command, "; } >'", stdoutStr, "' 2>'", stderrStr
, "' || { ", elideCat, " stdout '", stdoutStr, "'; ", elideCat, " stderr '", stderrStr, "'; false; }"
Expand Down Expand Up @@ -621,9 +620,9 @@ let testMain : [TestCollection] -> () = lam colls.
switch tasks.compile
case Dont _ then ()
case Fail _ then
run.f {input = src, cmd = "%m compile --test %i --exit-before", tag = "exe"}
run.f {input = src, cmd = "%m compile --disable-prune-utests --test %i --exit-before", tag = "exe"}
case Success _ then
let exe = run.m {input = src, cmd = "%m compile --test %i --output %o", tag = "exe"} in
let exe = run.m {input = src, cmd = "%m compile --disable-prune-utests --test %i --output %o", tag = "exe"} in
(switch tasks.run
case Dont _ then ()
case Fail _ then
Expand All @@ -634,9 +633,9 @@ let testMain : [TestCollection] -> () = lam colls.
(switch _minER tasks.run tasks.interpret
case Dont _ then ()
case Fail _ then
run.f {input = src, cmd = "%m eval --test %i", tag = "eval"}
run.f {input = src, cmd = "%m eval --disable-prune-utests --test %i", tag = "eval"}
case Success _ then
run.e {input = src, cmd = "%m eval --test %i", tag = "eval"}
run.e {input = src, cmd = "%m eval --disable-prune-utests --test %i", tag = "eval"}
end)
end
in
Expand Down Expand Up @@ -812,9 +811,30 @@ testMain
, "test/examples/test-prune-utests.mc"
]);

-- Files where interpretation is expected to fail
-- Files using externals not available in the interpreter
api.mark interpretFail (api.strsToPaths
[ "test/examples/utest.mc"
[ "stdlib/ext/file-ext.mc"
, "stdlib/ext/array-ext.mc"
, "stdlib/ext/async-ext.mc"
, "stdlib/ext/ext-test.mc"
, "stdlib/ext/dist-ext.mc"
, "stdlib/ext/local-search.mc"
, "stdlib/ext/math-ext.mc"
, "stdlib/ext/matrix-ext.mc"
, "stdlib/ext/toml-ext.mc"
, "test/examples/external/ext-list-map.mc"
, "test/examples/external/ext-list-concat-map.mc"
, "stdlib/multicore/atomic.mc"
, "stdlib/multicore/atomic.mc"
, "stdlib/multicore/channel.mc"
, "stdlib/multicore/thread.mc"
, "stdlib/multicore/thread-pool.mc"
, "stdlib/multicore/cond.mc"
, "stdlib/multicore/mutex.mc"
, "stdlib/multicore/pseq.mc"
, "stdlib/tuning/tune-options.mc"
, "stdlib/stats.mc"
, "stdlib/math.mc"
]);

-- Files that *should* fail to compile
Expand Down Expand Up @@ -988,6 +1008,32 @@ testMain
api.mark interpretFail (api.strsToPaths ["test/meta/recursive-let.mc"])
}

, { testColl "ipopt"
with checkCondition = lam.
if eqi 0 (command "ocamlfind query ipoptml &>/dev/null")
then ConditionsMet ()
-- TODO(vipa, 2024-11-22): This is technically incorrect, but
-- these tests are not run in the previous test suite, so we
-- ignore them like this
else ConditionsImpossible ()
, conditionalInclusions = lam api.
api.mark {defaultTasks with interpret = Fail ()}
(api.glob ["stdlib", "ipopt"] (IncludeSubs ()) (SuffixFile ".mc"))
}

, { testColl "sundials"
with checkCondition = lam.
if eqi 0 (command "ocamlfind query sundialsml &>/dev/null")
then ConditionsMet ()
-- TODO(vipa, 2024-11-22): This is technically incorrect, but
-- these tests are not run in the previous test suite, so we
-- ignore them like this
else ConditionsImpossible ()
, conditionalInclusions = lam api.
api.mark {defaultTasks with interpret = Fail ()}
(api.glob ["stdlib", "sundials"] (IncludeSubs ()) (SuffixFile ".mc"))
}

, { testColl "lrk"
with exclusions = lam api.
api.mark noTasks (api.glob ["test", "examples", "parser"] (IncludeSubs ()) (SuffixFile ".mc"))
Expand Down
2 changes: 1 addition & 1 deletion misc/watch
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

DIR=$(dirname "$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )")

"$DIR/misc/repo-files" | entr -rc "$DIR/misc/test" "$@"
"$DIR/misc/scripts/repo-files" | entr -rc "$DIR/misc/test" "$@"
2 changes: 1 addition & 1 deletion src/Tupdefault
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include_rules

run $(ROOT)/misc/gen-tup-rules
run $(ROOT)/misc/scripts/gen-tup-rules
119 changes: 2 additions & 117 deletions src/Tupfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,133 +5,18 @@ STDLIB := MCORE_LIBS=stdlib=$(ROOT)/src/stdlib OCAMLPATH=$(VARIANT_SRC)/lib${OCA
# NOTE(vipa, 2023-05-16): This is ugly, but appears stable and does
# seem to work
BOOT_LIB_FILES += lib/boot/META
BOOT_LIB_FILES += lib/boot/ast.ml
BOOT_LIB_FILES += lib/boot/boot.a
BOOT_LIB_FILES += lib/boot/boot.cma
BOOT_LIB_FILES += lib/boot/boot.cmi
BOOT_LIB_FILES += lib/boot/boot.cmt
BOOT_LIB_FILES += lib/boot/boot.cmx
BOOT_LIB_FILES += lib/boot/boot.cmxa
BOOT_LIB_FILES += lib/boot/boot.ml
BOOT_LIB_FILES += lib/boot/boot__Ast.cmi
BOOT_LIB_FILES += lib/boot/boot__Ast.cmt
BOOT_LIB_FILES += lib/boot/boot__Ast.cmx
BOOT_LIB_FILES += lib/boot/boot__Bootparser.cmi
BOOT_LIB_FILES += lib/boot/boot__Bootparser.cmt
BOOT_LIB_FILES += lib/boot/boot__Bootparser.cmx
BOOT_LIB_FILES += lib/boot/boot__Builtin.cmi
BOOT_LIB_FILES += lib/boot/boot__Builtin.cmt
BOOT_LIB_FILES += lib/boot/boot__Builtin.cmx
BOOT_LIB_FILES += lib/boot/boot__Deadcode.cmi
BOOT_LIB_FILES += lib/boot/boot__Deadcode.cmt
BOOT_LIB_FILES += lib/boot/boot__Deadcode.cmx
BOOT_LIB_FILES += lib/boot/boot__Eval.cmi
BOOT_LIB_FILES += lib/boot/boot__Eval.cmt
BOOT_LIB_FILES += lib/boot/boot__Eval.cmx
BOOT_LIB_FILES += lib/boot/boot__Ext.cmi
BOOT_LIB_FILES += lib/boot/boot__Ext.cmt
BOOT_LIB_FILES += lib/boot/boot__Ext.cmx
BOOT_LIB_FILES += lib/boot/boot__Exttest.cmi
BOOT_LIB_FILES += lib/boot/boot__Exttest.cmt
BOOT_LIB_FILES += lib/boot/boot__Exttest.cmx
BOOT_LIB_FILES += lib/boot/boot__Intrinsics.cmi
BOOT_LIB_FILES += lib/boot/boot__Intrinsics.cmt
BOOT_LIB_FILES += lib/boot/boot__Intrinsics.cmti
BOOT_LIB_FILES += lib/boot/boot__Intrinsics.cmx
BOOT_LIB_FILES += lib/boot/boot__Lexer.cmi
BOOT_LIB_FILES += lib/boot/boot__Lexer.cmt
BOOT_LIB_FILES += lib/boot/boot__Lexer.cmx
BOOT_LIB_FILES += lib/boot/boot__Mexpr.cmi
BOOT_LIB_FILES += lib/boot/boot__Mexpr.cmt
BOOT_LIB_FILES += lib/boot/boot__Mexpr.cmx
BOOT_LIB_FILES += lib/boot/boot__Mlang.cmi
BOOT_LIB_FILES += lib/boot/boot__Mlang.cmt
BOOT_LIB_FILES += lib/boot/boot__Mlang.cmx
BOOT_LIB_FILES += lib/boot/boot__Msg.cmi
BOOT_LIB_FILES += lib/boot/boot__Msg.cmt
BOOT_LIB_FILES += lib/boot/boot__Msg.cmx
BOOT_LIB_FILES += lib/boot/boot__Parser.cmi
BOOT_LIB_FILES += lib/boot/boot__Parser.cmt
BOOT_LIB_FILES += lib/boot/boot__Parser.cmti
BOOT_LIB_FILES += lib/boot/boot__Parser.cmx
BOOT_LIB_FILES += lib/boot/boot__Parserutils.cmi
BOOT_LIB_FILES += lib/boot/boot__Parserutils.cmt
BOOT_LIB_FILES += lib/boot/boot__Parserutils.cmx
BOOT_LIB_FILES += lib/boot/boot__Patterns.cmi
BOOT_LIB_FILES += lib/boot/boot__Patterns.cmt
BOOT_LIB_FILES += lib/boot/boot__Patterns.cmx
BOOT_LIB_FILES += lib/boot/boot__Pprint.cmi
BOOT_LIB_FILES += lib/boot/boot__Pprint.cmt
BOOT_LIB_FILES += lib/boot/boot__Pprint.cmx
BOOT_LIB_FILES += lib/boot/boot__Pyast.cmi
BOOT_LIB_FILES += lib/boot/boot__Pyast.cmt
BOOT_LIB_FILES += lib/boot/boot__Pyast.cmx
BOOT_LIB_FILES += lib/boot/boot__Pyffi.cmi
BOOT_LIB_FILES += lib/boot/boot__Pyffi.cmt
BOOT_LIB_FILES += lib/boot/boot__Pyffi.cmx
BOOT_LIB_FILES += lib/boot/boot__Pypprint.cmi
BOOT_LIB_FILES += lib/boot/boot__Pypprint.cmt
BOOT_LIB_FILES += lib/boot/boot__Pypprint.cmx
BOOT_LIB_FILES += lib/boot/boot__Repl.cmi
BOOT_LIB_FILES += lib/boot/boot__Repl.cmt
BOOT_LIB_FILES += lib/boot/boot__Repl.cmx
BOOT_LIB_FILES += lib/boot/boot__Rope.cmi
BOOT_LIB_FILES += lib/boot/boot__Rope.cmt
BOOT_LIB_FILES += lib/boot/boot__Rope.cmti
BOOT_LIB_FILES += lib/boot/boot__Rope.cmx
BOOT_LIB_FILES += lib/boot/boot__Symbolize.cmi
BOOT_LIB_FILES += lib/boot/boot__Symbolize.cmt
BOOT_LIB_FILES += lib/boot/boot__Symbolize.cmx
BOOT_LIB_FILES += lib/boot/boot__Symbutils.cmi
BOOT_LIB_FILES += lib/boot/boot__Symbutils.cmt
BOOT_LIB_FILES += lib/boot/boot__Symbutils.cmx
BOOT_LIB_FILES += lib/boot/boot__Tensor.cmi
BOOT_LIB_FILES += lib/boot/boot__Tensor.cmt
BOOT_LIB_FILES += lib/boot/boot__Tensor.cmti
BOOT_LIB_FILES += lib/boot/boot__Tensor.cmx
BOOT_LIB_FILES += lib/boot/boot__Ustring.cmi
BOOT_LIB_FILES += lib/boot/boot__Ustring.cmt
BOOT_LIB_FILES += lib/boot/boot__Ustring.cmti
BOOT_LIB_FILES += lib/boot/boot__Ustring.cmx
BOOT_LIB_FILES += lib/boot/boot__Utils.cmi
BOOT_LIB_FILES += lib/boot/boot__Utils.cmt
BOOT_LIB_FILES += lib/boot/boot__Utils.cmx
BOOT_LIB_FILES += lib/boot/bootparser.ml
BOOT_LIB_FILES += lib/boot/builtin.ml
BOOT_LIB_FILES += lib/boot/deadcode.ml
BOOT_LIB_FILES += lib/boot/eval.ml
BOOT_LIB_FILES += lib/boot/ext.ml
BOOT_LIB_FILES += lib/boot/exttest.ml
BOOT_LIB_FILES += lib/boot/intrinsics.ml
BOOT_LIB_FILES += lib/boot/intrinsics.mli
BOOT_LIB_FILES += lib/boot/lexer.ml
BOOT_LIB_FILES += lib/boot/mexpr.ml
BOOT_LIB_FILES += lib/boot/mlang.ml
BOOT_LIB_FILES += lib/boot/msg.ml
BOOT_LIB_FILES += lib/boot/opam
BOOT_LIB_FILES += lib/boot/parser.ml
BOOT_LIB_FILES += lib/boot/parser.mli
BOOT_LIB_FILES += lib/boot/parserutils.ml
BOOT_LIB_FILES += lib/boot/patterns.ml
BOOT_LIB_FILES += lib/boot/pprint.ml
BOOT_LIB_FILES += lib/boot/pyast.ml
BOOT_LIB_FILES += lib/boot/pyffi.ml
BOOT_LIB_FILES += lib/boot/pypprint.ml
BOOT_LIB_FILES += lib/boot/repl.ml
BOOT_LIB_FILES += lib/boot/rope.ml
BOOT_LIB_FILES += lib/boot/rope.mli
BOOT_LIB_FILES += lib/boot/symbolize.ml
BOOT_LIB_FILES += lib/boot/symbutils.ml
BOOT_LIB_FILES += lib/boot/tensor.ml
BOOT_LIB_FILES += lib/boot/tensor.mli
BOOT_LIB_FILES += lib/boot/ustring.ml
BOOT_LIB_FILES += lib/boot/ustring.mli
BOOT_LIB_FILES += lib/boot/utils.ml
BOOT_LIB_FILES += lib/boot/boot.cmxs

: |> ^b dune build^ ../misc/with-tmp-dir dune build --root=boot/ --build-dir="{}" "&&" cd . "&&" dune install --build-dir="{}" --prefix=\$(realpath $(VARIANT_SRC)) --root=boot/ ">/dev/null" "2>&1" "&&" mv $(VARIANT_SRC)/bin/boot %1o "&&" rm -rf $(VARIANT_SRC)/bin $(VARIANT_SRC)/lib/boot/dune-package |> mi-boot | $(BOOT_LIB_FILES) <boot-lib>
preload boot

: | mi-boot $(BOOT_LIB_FILES) |> $(STDLIB) echo $OCAMLPATH > %o |> ocamlpath.txt
: |> ^b dune build^ OCAMLRUNPARAM=b ../misc/scripts/with-tmp-dir dune build --root=boot/ --build-dir="{}" "&&" mv "{}/default/"{META.boot,lib/META} "&&" shopt -s nullglob "&&" ocamlfind install -destdir $(VARIANT_SRC)/lib boot "{}/default/lib/"{META,*.mli,*.cmi,*.cmo,*.cmx,*.cma,*.cmxa,*.a} "&&" mv "{}"/default/boot.exe %1o |> mi-boot | $(BOOT_LIB_FILES) <boot-lib>

: main/mi-lite.mc | mi-boot $(BOOT_LIB_FILES) |> ^ ./boot eval %f -- 0 %f %o^ $(STDLIB) ./%1i eval %f -- 0 %f %o |> mi-lite
: main/mi.mc | mi-lite $(BOOT_LIB_FILES) |> ^ ./mi-lite 1 %f %o^ $(STDLIB) ./%1i 1 %f %o |> mi1
Expand Down
Loading

0 comments on commit 5e6651a

Please sign in to comment.