Skip to content

Commit 3c87d6d

Browse files
authored
Merge pull request #1375 from nojb/self_stubs_build_error_msg
Better error message when (self_build_stubs_archive ...) and (c_names ...) or (cxx_names ...) used simultaneously
2 parents 7f9bbe9 + d51ba0f commit 3c87d6d

File tree

6 files changed

+43
-1
lines changed

6 files changed

+43
-1
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ next
1717

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

20+
- Better error message when using `(self_build_stubs_archive ...)` and
21+
`(c_names ...)` or `(cxx_names ...)` simultaneously.
22+
(#1375, fix #1306, @nojb)
23+
2024
1.3.0 (23/09/2018)
2125
------------------
2226

src/dune_file.ml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ module Library = struct
10021002
and wrapped = Wrapped.field
10031003
and optional = field_b "optional"
10041004
and self_build_stubs_archive =
1005-
field "self_build_stubs_archive" (option string) ~default:None
1005+
located (field "self_build_stubs_archive" (option string) ~default:None)
10061006
and no_dynlink = field_b "no_dynlink"
10071007
and no_keep_locs = field_b "no_keep_locs"
10081008
and sub_systems =
@@ -1069,6 +1069,23 @@ module Library = struct
10691069
It is inherited from the virtual library."
10701070
| _, _, _ -> ()
10711071
end;
1072+
let self_build_stubs_archive =
1073+
let loc, self_build_stubs_archive = self_build_stubs_archive in
1074+
let err =
1075+
match c_names, cxx_names, self_build_stubs_archive with
1076+
| _, _, None -> None
1077+
| (_ :: _), _, Some _ -> Some "c_names"
1078+
| _, (_ :: _), Some _ -> Some "cxx_names"
1079+
| [], [], _ -> None
1080+
in
1081+
match err with
1082+
| None ->
1083+
self_build_stubs_archive
1084+
| Some name ->
1085+
of_sexp_errorf loc
1086+
"A library cannot use (self_build_stubs_archive ...) \
1087+
and (%s ...) simultaneously." name
1088+
in
10721089
{ name
10731090
; public
10741091
; synopsis

test/blackbox-tests/dune.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@
287287
test-cases/github1231
288288
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
289289

290+
(alias
291+
(name github1306)
292+
(deps (package dune) (source_tree test-cases/github1306))
293+
(action
294+
(chdir
295+
test-cases/github1306
296+
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
297+
290298
(alias
291299
(name github1342)
292300
(deps (package dune) (source_tree test-cases/github1342))
@@ -1002,6 +1010,7 @@
10021010
(alias github1019)
10031011
(alias github1099)
10041012
(alias github1231)
1013+
(alias github1306)
10051014
(alias github1342)
10061015
(alias github1372)
10071016
(alias github20)
@@ -1120,6 +1129,7 @@
11201129
(alias github1019)
11211130
(alias github1099)
11221131
(alias github1231)
1132+
(alias github1306)
11231133
(alias github1342)
11241134
(alias github1372)
11251135
(alias github20)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(library
2+
(name foo)
3+
(c_names foo)
4+
(self_build_stubs_archive (bar)))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(lang dune 1.0)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$ dune build
2+
File "dune", line 4, characters 1-33:
3+
4 | (self_build_stubs_archive (bar)))
4+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
Error: A library cannot use (self_build_stubs_archive ...) and (c_names ...) simultaneously.
6+
[1]

0 commit comments

Comments
 (0)