This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,4 @@
(lang dune 3.8)
(package
(name hello))

View file

@ -0,0 +1,3 @@
(executable
(name x)
(libraries foo))

View file

@ -0,0 +1,14 @@
(library
(name foo)
(private_modules privmod)
(modules privmod)
(instrumentation
(backend hello)))
(library
(name bar)
(modules file)
(instrumentation
(backend hello)))
(include_subdirs unqualified)

View file

@ -0,0 +1,13 @@
(library
(name hello_ppx)
(public_name hello.ppx)
(kind ppx_rewriter)
(ppx_runtime_libraries hello)
(libraries ppxlib)
(modules hello_ppx))
(library
(public_name hello)
(modules hello)
(instrumentation.backend
(ppx hello.ppx)))

View file

@ -0,0 +1 @@
let hello s = print_endline (Printf.sprintf "Hello from %s!" s)

View file

@ -0,0 +1,41 @@
open Ast_helper
open Longident
let place = ref None
let file = ref None
let read_file () =
match !file with
| None -> "<none>"
| Some s ->
let ic = open_in s in
begin match input_line ic with
| exception End_of_file ->
close_in ic;
"<none>"
| s ->
close_in ic;
s
end
let impl str =
let arg =
match !place with
| None -> Exp.ident (Location.mknoloc (Lident "__MODULE__"))
| Some s -> Exp.constant (Const.string (Printf.sprintf "%s (%s)" s (read_file ())))
in
Str.eval
(Exp.apply (Exp.ident (Location.mknoloc (Ldot (Lident "Hello", "hello"))))
[Nolabel, arg]) :: str
open Ppxlib
let () =
Driver.add_arg "-place" (Arg.String (fun s -> place := Some s))
~doc:"PLACE where to say hello from";
Driver.add_arg "-file" (Arg.String (fun s -> file := Some s))
~doc:"Add info from file"
let () =
Driver.register_transformation_using_ocaml_current_ast ~impl "hello"

View file

@ -0,0 +1,142 @@
$ ocamlc_where="$(ocamlc -where)"
$ export BUILD_PATH_PREFIX_MAP="/OCAMLC_WHERE=$ocamlc_where:$BUILD_PATH_PREFIX_MAP"
$ ocamlfind_libs="$(ocamlfind printconf path | while read line; do printf lib=${line}:; done)"
$ export BUILD_PATH_PREFIX_MAP="$ocamlfind_libs:$BUILD_PATH_PREFIX_MAP"
Here we test that instrumentation processing is not passed to merlin by setting
up a project with instrumentation and testing checking the merlin config.
$ dune build --instrument-with hello ./lib/.merlin-conf/lib-foo ./lib/.merlin-conf/lib-bar --profile release
$ dune ocaml merlin dump-config $PWD/lib
Bar: _build/default/lib/bar
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.bar.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(UNIT_NAME bar))
Bar: _build/default/lib/bar.ml-gen
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.bar.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(UNIT_NAME bar))
File: _build/default/lib/subdir/file
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.bar.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(FLG (-open Bar))
(UNIT_NAME bar__File))
File: _build/default/lib/subdir/file.ml
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.bar.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(FLG (-open Bar))
(UNIT_NAME bar__File))
Foo: _build/default/lib/foo
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.foo.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(UNIT_NAME foo))
Foo: _build/default/lib/foo.ml-gen
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.foo.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(UNIT_NAME foo))
Privmod: _build/default/lib/privmod
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.foo.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(FLG (-open Foo))
(UNIT_NAME foo__Privmod))
Privmod: _build/default/lib/privmod.ml
((INDEX $TESTCASE_ROOT/_build/default/exe/.x.eobjs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.bar.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/lib/.foo.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello.objs/cctx.ocaml-index)
(INDEX $TESTCASE_ROOT/_build/default/ppx/.hello_ppx.objs/cctx.ocaml-index)
(STDLIB /OCAMLC_WHERE)
(SOURCE_ROOT $TESTCASE_ROOT)
(EXCLUDE_QUERY_DIR)
(B $TESTCASE_ROOT/_build/default/lib/.foo.objs/byte)
(B $TESTCASE_ROOT/_build/default/ppx/.hello.objs/byte)
(S $TESTCASE_ROOT/lib)
(S $TESTCASE_ROOT/lib/subdir)
(S $TESTCASE_ROOT/ppx)
(FLG (-w -40 -g))
(FLG (-open Foo))
(UNIT_NAME foo__Privmod))