diff --git a/CHANGES.md b/CHANGES.md index e1e50262..e803d29b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,9 @@ next - Fix a crash when using an invalid alias name (#762, fixes #761, @diml) +- Fix a crash when using c files from another directory (#758, fixes + #734, @diml) + 1.0+beta20 (10/04/2018) ----------------------- diff --git a/src/jbuild.ml b/src/jbuild.ml index 55202713..f139ff31 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -72,6 +72,23 @@ let relative_file sexp = of_sexp_error sexp "relative filename expected"; fn +let c_name, cxx_name = + let make what ext sexp = + let s = string sexp in + if match s with + | "" | "." | ".." -> true + | _ -> Filename.basename s <> s then + of_sexp_errorf sexp + "%S is not a valid %s name.\n\ + Hint: To use %s files from another directory, use a \ + (copy_files /*.c) stanza instead." + s what what ext + else + s + in + (make "C" "c", + make "C++" "cpp") + module Scope_info = struct module Name = struct type t = string option @@ -706,8 +723,8 @@ module Library = struct field "ppx_runtime_libraries" (list (located string)) ~default:[] >>= fun ppx_runtime_libraries -> field_oslu "c_flags" >>= fun c_flags -> field_oslu "cxx_flags" >>= fun cxx_flags -> - field "c_names" (list string) ~default:[] >>= fun c_names -> - field "cxx_names" (list string) ~default:[] >>= fun cxx_names -> + field "c_names" (list c_name) ~default:[] >>= fun c_names -> + field "cxx_names" (list cxx_name) ~default:[] >>= fun cxx_names -> field_oslu "library_flags" >>= fun library_flags -> field_oslu "c_library_flags" >>= fun c_library_flags -> field "virtual_deps" (list (located string)) ~default:[] >>= fun virtual_deps -> diff --git a/test/blackbox-tests/test-cases/github734/run.t b/test/blackbox-tests/test-cases/github734/run.t index 43fbffc5..b4f4505a 100644 --- a/test/blackbox-tests/test-cases/github734/run.t +++ b/test/blackbox-tests/test-cases/github734/run.t @@ -1,28 +1,5 @@ $ jbuilder build @foo - Internal error, please report upstream including the contents of _build/log. - Description: - ("Build_system.get_collector called on closed directory" - (dir _build/default/src/stubs)) - Backtrace: - Raised at file "src/stdune/exn.ml", line 32, characters 5-10 - Called from file "src/build_system.ml", line 1503, characters 18-47 - Called from file "src/gen_rules.ml", line 495, characters 4-516 - Called from file "list.ml", line 82, characters 20-23 - Called from file "src/gen_rules.ml", line 643, characters 8-94 - Called from file "src/stdune/exn.ml", line 21, characters 8-11 - Re-raised at file "src/stdune/exn.ml", line 23, characters 30-37 - Called from file "src/gen_rules.ml", line 959, characters 13-72 - Called from file "src/stdune/list.ml", line 13, characters 10-13 - Called from file "src/gen_rules.ml", line 955, characters 4-777 - Called from file "src/gen_rules.ml", line 994, characters 19-30 - Called from file "src/build_system.ml", line 889, characters 6-62 - Called from file "src/build_system.ml", line 865, characters 6-59 - Re-raised at file "src/build_system.ml", line 876, characters 6-17 - Called from file "src/build_system.ml" (inlined), line 833, characters 32-63 - Called from file "src/build_system.ml", line 843, characters 4-24 - Called from file "src/build_interpret.ml", line 101, characters 24-40 - Called from file "src/build_interpret.ml", line 60, characters 31-43 - Called from file "src/build_interpret.ml", line 60, characters 31-43 - Called from file "src/build_system.ml", line 1215, characters 10-108 - Called from file "src/fiber/fiber.ml", line 359, characters 6-13 + File "src/dune", line 4, characters 12-19: + Error: "stubs/x" is not a valid C name. + Hint: To use C files from another directory, use a (copy_files /*.c) stanza instead. [1]