From 0c08c77794db24f3eda510a137da4b9097996b21 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 9 Aug 2019 15:55:07 +0700 Subject: [PATCH 1/2] Add test for .c file and @check alias Signed-off-by: Rudi Grinberg --- test/blackbox-tests/test-cases/check-alias/lib/bar.c | 3 +++ test/blackbox-tests/test-cases/check-alias/lib/dune | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/blackbox-tests/test-cases/check-alias/lib/bar.c diff --git a/test/blackbox-tests/test-cases/check-alias/lib/bar.c b/test/blackbox-tests/test-cases/check-alias/lib/bar.c new file mode 100644 index 00000000000..d21e894b05f --- /dev/null +++ b/test/blackbox-tests/test-cases/check-alias/lib/bar.c @@ -0,0 +1,3 @@ +int bla () { + return 0; +} diff --git a/test/blackbox-tests/test-cases/check-alias/lib/dune b/test/blackbox-tests/test-cases/check-alias/lib/dune index 951d9286b6d..fcbf409c592 100644 --- a/test/blackbox-tests/test-cases/check-alias/lib/dune +++ b/test/blackbox-tests/test-cases/check-alias/lib/dune @@ -1,2 +1,3 @@ (library - (name foo)) \ No newline at end of file + (name foo) + (c_names bar)) From a44dba50ce90bb10546ca93759b4ed6bc45576a4 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 9 Aug 2019 12:23:29 +0700 Subject: [PATCH 2/2] Compile stubs for @check Without this, errors in C/C++ sources would be ignored when building @check Signed-off-by: Rudi Grinberg --- CHANGES.md | 2 ++ src/check_rules.ml | 6 ++++++ src/check_rules.mli | 6 ++++++ src/lib_rules.ml | 1 + test/blackbox-tests/test-cases/check-alias/run.t | 1 + 5 files changed, 16 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 7c261dadac3..415521b79f4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -86,6 +86,8 @@ presence of directories with only sub-directories and no files (#2514, fixes #2499, @diml) +- Include building stubs in `@check` rules. (@rgrinberg, #2530) + 1.11.0 (23/07/2019) ------------------- diff --git a/src/check_rules.ml b/src/check_rules.ml index 952c88257c6..424c9f9c6a5 100644 --- a/src/check_rules.ml +++ b/src/check_rules.ml @@ -25,3 +25,9 @@ let add_obj_dir sctx ~obj_dir = (Alias.check ~dir:(Obj_dir.dir obj_dir)) ~dyn_deps Path.Set.empty + +let add_files sctx ~dir files = + if (Super_context.context sctx).merlin then + let alias = Alias.check ~dir in + let files = Path.Set.of_list files in + Rules.Produce.Alias.add_deps alias files diff --git a/src/check_rules.mli b/src/check_rules.mli index f100d81341d..089edf7e671 100644 --- a/src/check_rules.mli +++ b/src/check_rules.mli @@ -1,3 +1,9 @@ open Stdune val add_obj_dir : Super_context.t -> obj_dir:Path.Build.t Obj_dir.t -> unit + +val add_files + : Super_context.t + -> dir:Path.Build.t + -> Path.t list + -> unit diff --git a/src/lib_rules.ml b/src/lib_rules.ml index 67b3a2422a1..bfba3cbc6b5 100644 --- a/src/lib_rules.ml +++ b/src/lib_rules.ml @@ -251,6 +251,7 @@ let build_stubs lib ~sctx ~dir ~expander ~requires ~dir_contents else [] in + Check_rules.add_files sctx ~dir lib_o_files; match vlib_stubs_o_files @ lib_o_files with | [] -> () | o_files -> build_self_stubs lib ~sctx ~dir ~expander ~o_files diff --git a/test/blackbox-tests/test-cases/check-alias/run.t b/test/blackbox-tests/test-cases/check-alias/run.t index bb0fb3385ef..f394121cc2a 100644 --- a/test/blackbox-tests/test-cases/check-alias/run.t +++ b/test/blackbox-tests/test-cases/check-alias/run.t @@ -6,6 +6,7 @@ $ dune build --root lib @check --display short && ls lib/.merlin Entering directory 'lib' + ocamlc bar$ext_obj ocamldep .foo.objs/foo.ml.d ocamlc .foo.objs/byte/foo.{cmi,cmo,cmt} lib/.merlin