Skip to content

Commit

Permalink
Merge pull request #1375 from nojb/self_stubs_build_error_msg
Browse files Browse the repository at this point in the history
Better error message when (self_build_stubs_archive ...) and (c_names ...) or (cxx_names ...) used simultaneously
  • Loading branch information
nojb authored Oct 2, 2018
2 parents 7f9bbe9 + d51ba0f commit 3c87d6d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ next

- Integration with automatic formatters (#1252, fix #1201, @emillon)

- Better error message when using `(self_build_stubs_archive ...)` and
`(c_names ...)` or `(cxx_names ...)` simultaneously.
(#1375, fix #1306, @nojb)

1.3.0 (23/09/2018)
------------------

Expand Down
19 changes: 18 additions & 1 deletion src/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ module Library = struct
and wrapped = Wrapped.field
and optional = field_b "optional"
and self_build_stubs_archive =
field "self_build_stubs_archive" (option string) ~default:None
located (field "self_build_stubs_archive" (option string) ~default:None)
and no_dynlink = field_b "no_dynlink"
and no_keep_locs = field_b "no_keep_locs"
and sub_systems =
Expand Down Expand Up @@ -1069,6 +1069,23 @@ module Library = struct
It is inherited from the virtual library."
| _, _, _ -> ()
end;
let self_build_stubs_archive =
let loc, self_build_stubs_archive = self_build_stubs_archive in
let err =
match c_names, cxx_names, self_build_stubs_archive with
| _, _, None -> None
| (_ :: _), _, Some _ -> Some "c_names"
| _, (_ :: _), Some _ -> Some "cxx_names"
| [], [], _ -> None
in
match err with
| None ->
self_build_stubs_archive
| Some name ->
of_sexp_errorf loc
"A library cannot use (self_build_stubs_archive ...) \
and (%s ...) simultaneously." name
in
{ name
; public
; synopsis
Expand Down
10 changes: 10 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@
test-cases/github1231
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name github1306)
(deps (package dune) (source_tree test-cases/github1306))
(action
(chdir
test-cases/github1306
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name github1342)
(deps (package dune) (source_tree test-cases/github1342))
Expand Down Expand Up @@ -1002,6 +1010,7 @@
(alias github1019)
(alias github1099)
(alias github1231)
(alias github1306)
(alias github1342)
(alias github1372)
(alias github20)
Expand Down Expand Up @@ -1120,6 +1129,7 @@
(alias github1019)
(alias github1099)
(alias github1231)
(alias github1306)
(alias github1342)
(alias github1372)
(alias github20)
Expand Down
4 changes: 4 additions & 0 deletions test/blackbox-tests/test-cases/github1306/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name foo)
(c_names foo)
(self_build_stubs_archive (bar)))
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/github1306/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 1.0)
6 changes: 6 additions & 0 deletions test/blackbox-tests/test-cases/github1306/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$ dune build
File "dune", line 4, characters 1-33:
4 | (self_build_stubs_archive (bar)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: A library cannot use (self_build_stubs_archive ...) and (c_names ...) simultaneously.
[1]

0 comments on commit 3c87d6d

Please sign in to comment.