From e832b7230dbf85156dafd20bdb5cb12969bf4315 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 5 Apr 2018 12:03:52 +0800 Subject: [PATCH 1/6] Add public_name's to all dune sub libraries These will all live under the jbuilder package --- src/configurator/jbuild | 1 + src/ocaml-config/jbuild | 1 + src/stdune/caml/jbuild | 1 + src/stdune/jbuild | 1 + src/usexp/jbuild | 4 +++- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/configurator/jbuild b/src/configurator/jbuild index 2b696467..2b11a82f 100644 --- a/src/configurator/jbuild +++ b/src/configurator/jbuild @@ -1,5 +1,6 @@ (library ((name configurator) + (public_name jbuilder.configurator) (libraries (stdune ocaml_config)) (flags (:standard -safe-string (:include flags/flags.sexp))) (preprocess no_preprocessing))) diff --git a/src/ocaml-config/jbuild b/src/ocaml-config/jbuild index df51c131..af200578 100644 --- a/src/ocaml-config/jbuild +++ b/src/ocaml-config/jbuild @@ -2,5 +2,6 @@ (library ((name ocaml_config) + (public_name jbuilder.ocaml_config) (libraries (stdune usexp)) (synopsis "Interpret the output of 'ocamlc -config'"))) diff --git a/src/stdune/caml/jbuild b/src/stdune/caml/jbuild index 1886d286..b8cfb6d7 100644 --- a/src/stdune/caml/jbuild +++ b/src/stdune/caml/jbuild @@ -1,3 +1,4 @@ (library ((name caml) + (public_name jbuilder.caml) (synopsis "Wrapped version of the OCaml stdlib"))) diff --git a/src/stdune/jbuild b/src/stdune/jbuild index 36e4eaa0..d6a2a3ca 100644 --- a/src/stdune/jbuild +++ b/src/stdune/jbuild @@ -1,4 +1,5 @@ (library ((name stdune) + (public_name jbuilder.stdune) (synopsis "Standard library of Dune") (libraries (caml unix)))) diff --git a/src/usexp/jbuild b/src/usexp/jbuild index 2c10cbe2..89e3240c 100644 --- a/src/usexp/jbuild +++ b/src/usexp/jbuild @@ -1,6 +1,8 @@ (jbuild_version 1) -(library ((name usexp))) +(library + ((name usexp) + (public_name jbuilder.usexp))) (rule (with-stdout-to table.ml.gen (run gen/gen_parser_automaton.exe))) From ab9b27830497f8b02ddb2c1f74782ea4e26fd637 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 5 Apr 2018 12:12:59 +0800 Subject: [PATCH 2/6] Add actual test suite for configurator --- test/blackbox-tests/jbuild | 10 ++++++++++ .../test-cases/configurator/config/jbuild | 5 +++++ .../test-cases/configurator/config/run.ml | 6 ++++++ test/blackbox-tests/test-cases/configurator/run.t | 2 ++ 4 files changed, 23 insertions(+) create mode 100644 test/blackbox-tests/test-cases/configurator/config/jbuild create mode 100644 test/blackbox-tests/test-cases/configurator/config/run.ml create mode 100644 test/blackbox-tests/test-cases/configurator/run.t diff --git a/test/blackbox-tests/jbuild b/test/blackbox-tests/jbuild index 01edbb92..becfd2ea 100644 --- a/test/blackbox-tests/jbuild +++ b/test/blackbox-tests/jbuild @@ -459,3 +459,13 @@ (progn (run ${exe:cram.exe} run.t) (diff? run.t run.t.corrected)))))) + +(alias + ((name runtest) + (deps ((package jbuilder) + (files_recursively_in test-cases/configurator))) + (action + (chdir test-cases/configurator + (progn + (run ${exe:cram.exe} run.t) + (diff? run.t run.t.corrected)))))) diff --git a/test/blackbox-tests/test-cases/configurator/config/jbuild b/test/blackbox-tests/test-cases/configurator/config/jbuild new file mode 100644 index 00000000..0f63b54a --- /dev/null +++ b/test/blackbox-tests/test-cases/configurator/config/jbuild @@ -0,0 +1,5 @@ +(jbuild_version 1) + +(executable + ((name run) + (libraries (jbuilder.configurator)))) diff --git a/test/blackbox-tests/test-cases/configurator/config/run.ml b/test/blackbox-tests/test-cases/configurator/config/run.ml new file mode 100644 index 00000000..e7e39784 --- /dev/null +++ b/test/blackbox-tests/test-cases/configurator/config/run.ml @@ -0,0 +1,6 @@ +let () = + Configurator.main ~name:"config" (fun t -> + match Configurator.ocaml_config_var t "version" with + | None -> failwith "version is absent" + | Some _ -> print_endline "version is present" + ) diff --git a/test/blackbox-tests/test-cases/configurator/run.t b/test/blackbox-tests/test-cases/configurator/run.t new file mode 100644 index 00000000..5a57e654 --- /dev/null +++ b/test/blackbox-tests/test-cases/configurator/run.t @@ -0,0 +1,2 @@ + $ jbuilder exec config/run.exe + version is present From 8ee13dde4d570608eb0d8a25b7d8f4cfab93e896 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 5 Apr 2018 12:20:20 +0800 Subject: [PATCH 3/6] Test compiling C program --- .../test-cases/configurator/c_test/jbuild | 5 +++++ .../test-cases/configurator/c_test/run.ml | 15 +++++++++++++++ test/blackbox-tests/test-cases/configurator/run.t | 1 + 3 files changed, 21 insertions(+) create mode 100644 test/blackbox-tests/test-cases/configurator/c_test/jbuild create mode 100644 test/blackbox-tests/test-cases/configurator/c_test/run.ml diff --git a/test/blackbox-tests/test-cases/configurator/c_test/jbuild b/test/blackbox-tests/test-cases/configurator/c_test/jbuild new file mode 100644 index 00000000..0f63b54a --- /dev/null +++ b/test/blackbox-tests/test-cases/configurator/c_test/jbuild @@ -0,0 +1,5 @@ +(jbuild_version 1) + +(executable + ((name run) + (libraries (jbuilder.configurator)))) diff --git a/test/blackbox-tests/test-cases/configurator/c_test/run.ml b/test/blackbox-tests/test-cases/configurator/c_test/run.ml new file mode 100644 index 00000000..dc3a9f08 --- /dev/null +++ b/test/blackbox-tests/test-cases/configurator/c_test/run.ml @@ -0,0 +1,15 @@ + +let () = + Configurator.main ~name:"c_test" (fun t -> + let c_result = + Configurator.c_test t {c| +#include +int main() +{ + printf("Hello, World!"); + return 0; +} +|c} in + assert c_result; + print_endline "Successfully compiled c program" + ) diff --git a/test/blackbox-tests/test-cases/configurator/run.t b/test/blackbox-tests/test-cases/configurator/run.t index 5a57e654..f726170a 100644 --- a/test/blackbox-tests/test-cases/configurator/run.t +++ b/test/blackbox-tests/test-cases/configurator/run.t @@ -1,2 +1,3 @@ $ jbuilder exec config/run.exe version is present + $ jbuilder exec c_test/run.exe \ No newline at end of file From fb8d40016589fd7e08a28d5a6b160b11addd60f1 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 5 Apr 2018 12:32:58 +0800 Subject: [PATCH 4/6] Add formatting to configurator tests --- test/blackbox-tests/test-cases/configurator/run.t | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/blackbox-tests/test-cases/configurator/run.t b/test/blackbox-tests/test-cases/configurator/run.t index f726170a..b72a34b9 100644 --- a/test/blackbox-tests/test-cases/configurator/run.t +++ b/test/blackbox-tests/test-cases/configurator/run.t @@ -1,3 +1,8 @@ +Show that config values are present $ jbuilder exec config/run.exe version is present - $ jbuilder exec c_test/run.exe \ No newline at end of file + +We're able to compile C program sucessfully + $ jbuilder exec c_test/run.exe + Successfully compiled c program + From 148835967e24e5816ebcb15cd61572cbdfe83166 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 5 Apr 2018 12:33:15 +0800 Subject: [PATCH 5/6] Add tests for import defines --- .../test-cases/configurator/import-define/jbuild | 5 +++++ .../test-cases/configurator/import-define/run.ml | 15 +++++++++++++++ test/blackbox-tests/test-cases/configurator/run.t | 3 +++ 3 files changed, 23 insertions(+) create mode 100644 test/blackbox-tests/test-cases/configurator/import-define/jbuild create mode 100644 test/blackbox-tests/test-cases/configurator/import-define/run.ml diff --git a/test/blackbox-tests/test-cases/configurator/import-define/jbuild b/test/blackbox-tests/test-cases/configurator/import-define/jbuild new file mode 100644 index 00000000..0f63b54a --- /dev/null +++ b/test/blackbox-tests/test-cases/configurator/import-define/jbuild @@ -0,0 +1,5 @@ +(jbuild_version 1) + +(executable + ((name run) + (libraries (jbuilder.configurator)))) diff --git a/test/blackbox-tests/test-cases/configurator/import-define/run.ml b/test/blackbox-tests/test-cases/configurator/import-define/run.ml new file mode 100644 index 00000000..42a9ab20 --- /dev/null +++ b/test/blackbox-tests/test-cases/configurator/import-define/run.ml @@ -0,0 +1,15 @@ +let () = + let module C_define = Configurator.C_define in + Configurator.main ~name:"c_test" (fun t -> + assert ( + C_define.import t + ~includes:["caml/config.h"] + [ "CAML_CONFIG_H", C_define.Type.Switch + ; "Page_log", C_define.Type.Int + ] = + [ "CAML_CONFIG_H", C_define.Value.Switch true + ; "Page_log", Int 12 + ] + ); + print_endline "Successfully import #define's" + ) diff --git a/test/blackbox-tests/test-cases/configurator/run.t b/test/blackbox-tests/test-cases/configurator/run.t index b72a34b9..9fbda06e 100644 --- a/test/blackbox-tests/test-cases/configurator/run.t +++ b/test/blackbox-tests/test-cases/configurator/run.t @@ -6,3 +6,6 @@ We're able to compile C program sucessfully $ jbuilder exec c_test/run.exe Successfully compiled c program +Importing #define's from code is successful + $ jbuilder exec import-define/run.exe + Successfully import #define's From bd528215561bb1bf02c53d3064d8bcacc351434f Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 10 Apr 2018 22:10:54 +0700 Subject: [PATCH 6/6] Mark internal (unstable) libraries as such Add an internal description in the synopsis and also a comment in the ocamldoc --- src/ocaml-config/jbuild | 2 +- src/ocaml-config/ocaml_config.mli | 4 +++- src/stdune/caml/caml.ml | 2 ++ src/stdune/caml/jbuild | 2 +- src/stdune/jbuild | 2 +- src/usexp/jbuild | 1 + src/usexp/usexp.mli | 4 +++- 7 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ocaml-config/jbuild b/src/ocaml-config/jbuild index af200578..3fa057e4 100644 --- a/src/ocaml-config/jbuild +++ b/src/ocaml-config/jbuild @@ -4,4 +4,4 @@ ((name ocaml_config) (public_name jbuilder.ocaml_config) (libraries (stdune usexp)) - (synopsis "Interpret the output of 'ocamlc -config'"))) + (synopsis "[Internal] Interpret the output of 'ocamlc -config'"))) diff --git a/src/ocaml-config/ocaml_config.mli b/src/ocaml-config/ocaml_config.mli index 793377e5..fbdbb92b 100644 --- a/src/ocaml-config/ocaml_config.mli +++ b/src/ocaml-config/ocaml_config.mli @@ -1,4 +1,6 @@ -(** Represent the output of [ocamlc -config] *) +(** Represent the output of [ocamlc -config]. + + This library is internal to jbuilder and guarantees no API stability. *) open Stdune diff --git a/src/stdune/caml/caml.ml b/src/stdune/caml/caml.ml index 82dc6ca9..a43c1037 100644 --- a/src/stdune/caml/caml.ml +++ b/src/stdune/caml/caml.ml @@ -1,3 +1,5 @@ +(** This library is internal to jbuilder and guarantees no API stability. *) + module Filename = Filename module String = String module Char = Char diff --git a/src/stdune/caml/jbuild b/src/stdune/caml/jbuild index b8cfb6d7..04b16834 100644 --- a/src/stdune/caml/jbuild +++ b/src/stdune/caml/jbuild @@ -1,4 +1,4 @@ (library ((name caml) (public_name jbuilder.caml) - (synopsis "Wrapped version of the OCaml stdlib"))) + (synopsis "[Internal] Wrapped version of the OCaml stdlib"))) diff --git a/src/stdune/jbuild b/src/stdune/jbuild index d6a2a3ca..b1f82de0 100644 --- a/src/stdune/jbuild +++ b/src/stdune/jbuild @@ -1,5 +1,5 @@ (library ((name stdune) (public_name jbuilder.stdune) - (synopsis "Standard library of Dune") + (synopsis "[Internal] Standard library of Dune") (libraries (caml unix)))) diff --git a/src/usexp/jbuild b/src/usexp/jbuild index 89e3240c..53b46ee9 100644 --- a/src/usexp/jbuild +++ b/src/usexp/jbuild @@ -2,6 +2,7 @@ (library ((name usexp) + (synopsis "[Internal] S-expression library") (public_name jbuilder.usexp))) (rule diff --git a/src/usexp/usexp.mli b/src/usexp/usexp.mli index 5fa3a242..27e03dc7 100644 --- a/src/usexp/usexp.mli +++ b/src/usexp/usexp.mli @@ -1,4 +1,6 @@ -(** Parsing of s-expressions *) +(** Parsing of s-expressions. + + This library is internal to jbuilder and guarantees no API stability.*) module Atom : sig type t = private A of string [@@unboxed]