From 3615b280f865afbbbd7db366fa1ae487ed7af85c Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 30 Jul 2018 11:47:35 +0200 Subject: [PATCH 01/13] Move Jsoo content to its own page Jsoo is about as independent as other features which have their own section Signed-off-by: Rudi Grinberg --- doc/dune-files.rst | 18 ++-------- doc/index.rst | 1 + doc/jsoo.rst | 83 ++++++++++++++++++++++++++++++++++++++++++++++ doc/usage.rst | 23 ------------- 4 files changed, 86 insertions(+), 39 deletions(-) create mode 100644 doc/jsoo.rst diff --git a/doc/dune-files.rst b/doc/dune-files.rst index 21ed5db5..df628bf6 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -1231,22 +1231,8 @@ follows: js_of_ocaml ----------- -In ``library`` and ``executables`` stanzas, you can specify js_of_ocaml options -using ``(js_of_ocaml ())``. - -```` are all optional: - -- ``(flags )`` to specify flags passed to ``js_of_ocaml``. This field - supports ``(:include ...)`` forms - -- ``(javascript_files ())`` to specify ``js_of_ocaml`` JavaScript - runtime files. - -```` is specified in the `Ordered set language`_. - -The default value for ``(flags ...)`` depends on the selected build -profile. The build profile ``dev`` (the default) will enable sourcemap -and the pretty JavaScript output. +A :ref:`dune-jsoo-field` exists in executable and libraries stanzas that allows +one to customize options relevant to jsoo. .. _user-actions: diff --git a/doc/index.rst b/doc/index.rst index 4e512049..c5b3e275 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -20,6 +20,7 @@ Welcome to dune's documentation! advanced-topics configurator menhir + jsoo faq known-issues migration diff --git a/doc/jsoo.rst b/doc/jsoo.rst new file mode 100644 index 00000000..b5c8664d --- /dev/null +++ b/doc/jsoo.rst @@ -0,0 +1,83 @@ +*********** +js_of_ocaml +*********** + +js_of_ocaml_ is a compiler from OCaml to JavaScript. The compiler works by +translating OCaml bytecode to JS files. From here on, we'll abbreviate +js_of_ocaml to jsoo. The compiler can be installed with opam: + +.. code:: bash + + $ opam install js_of_ocaml-compiler + +Compiling to JS +=============== + +Dune has full support building jsoo libraries and executables transparently. +There's no need to customize or enable anything to compile ocaml +libraries/executables to JS. + +To build a JS executable, just define an executable as you would normally. +Consider this example: + +.. code:: bash + + echo 'print_endline "hello from js"' > foo.ml + +With the following dune file: + +.. code:: scheme + + (executable (name foo)) + +And then request the ``.js`` target: + +.. code:: bash + + $ dune build ./foo.bc.js + $ node _build/default/foo.bc.js + hello from js + +Similar targets are created for libraries, but we recommend sticking to the +executable targets. + +.. _dune-jsoo-field: + +``js_of_ocaml`` field +===================== + +In ``library`` and ``executables`` stanzas, you can specify js_of_ocaml options +using ``(js_of_ocaml ())``. + +```` are all optional: + +- ``(flags )`` to specify flags passed to ``js_of_ocaml``. This field + supports ``(:include ...)`` forms + +- ``(javascript_files ())`` to specify ``js_of_ocaml`` JavaScript + runtime files. + +```` is specified in the `Ordered set language`_. + +The default value for ``(flags ...)`` depends on the selected build profile. The +build profile ``dev`` (the default) will enable sourcemap and the pretty +JavaScript output. + +Separate Compilation +==================== + +Dune supports two modes of compilation + +- Direct compilation of a bytecode program to JavaScript. This mode allows + js_of_ocaml to perform whole program deadcode elimination and whole program + inlining. + +- Separate compilation, where compilation units are compiled to JavaScript + separately and then linked together. This mode is useful during development as + it builds more quickly. + +The separate compilation mode will be selected when the build profile is +``dev``, which is the default. There is currently no other way to control this +behaviour. + +.. _js_of_ocaml: http://ocsigen.org/js_of_ocaml/ diff --git a/doc/usage.rst b/doc/usage.rst index 26eec414..ab021bbc 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -420,29 +420,6 @@ For rare cases where this is not what you want, you can force dune to use a different build contexts for merlin by adding the field ``(merlin)`` to this context. -Building JavaScript with js_of_ocaml -==================================== - -Dune knows how to generate a JavaScript version of an executable -(``.bc.js``) using the js_of_ocaml compiler (the ``js_of_ocaml-compiler`` -opam package must be installed). - -It supports two modes of compilation: - -- Direct compilation of a bytecode program to JavaScript. This mode allows - js_of_ocaml to perform whole program deadcode elimination and whole program - inlining. -- Separate compilation, where compilation units are compiled to JavaScript - separately and then linked together. This mode is useful during development as - it builds more quickly. - -The separate compilation mode will be selected when the build profile is -``dev``, which is the default. There is currently no other way to control this -behaviour. - -See the section about :ref:`dune-jsoo` for passing custom flags to the -js_of_ocaml compiler - Distributing Projects ===================== From 200f9d0a5241bc8844d1e79f29390c9bcd5dbfa1 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 20 Jul 2018 10:43:28 +0200 Subject: [PATCH 02/13] Add toplevel env stanza to workspace files Signed-off-by: Rudi Grinberg --- src/workspace.ml | 9 +++++++-- src/workspace.mli | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/workspace.ml b/src/workspace.ml index f4780297..a8408ac2 100644 --- a/src/workspace.ml +++ b/src/workspace.ml @@ -148,22 +148,25 @@ end type t = { merlin_context : string option ; contexts : Context.t list + ; env : Dune_env.Stanza.t option } include Versioned_file.Make(struct type t = unit end) let () = Lang.register syntax () let t ?x ?profile:cmdline_profile () = + field_o "env" Dune_env.Stanza.t >>= fun env -> field "profile" string ~default:Config.default_build_profile >>= fun profile -> let profile = Option.value cmdline_profile ~default:profile in multi_field "context" (Context.t ~profile ~x) >>= fun contexts -> let defined_names = ref String.Set.empty in - let { merlin_context; contexts } = + let { merlin_context; contexts; env } = let init = { merlin_context = None ; contexts = [] + ; env } in List.fold_left contexts ~init ~f:(fun t ctx -> @@ -178,7 +181,7 @@ let t ?x ?profile:cmdline_profile () = Loc.fail (Context.loc ctx) "you can only have one context for merlin" | Opam { merlin = true; _ }, None -> - { merlin_context = Some name; contexts = ctx :: t.contexts } + { merlin_context = Some name; contexts = ctx :: t.contexts; env = None } | _ -> { t with contexts = ctx :: t.contexts }) in @@ -200,6 +203,7 @@ let t ?x ?profile:cmdline_profile () = return { merlin_context ; contexts = List.rev contexts + ; env } let t ?x ?profile () = fields (t ?x ?profile ()) @@ -207,6 +211,7 @@ let t ?x ?profile () = fields (t ?x ?profile ()) let default ?x ?profile () = { merlin_context = Some "default" ; contexts = [Context.default ?x ?profile ()] + ; env = None } let load ?x ?profile p = diff --git a/src/workspace.mli b/src/workspace.mli index fa5fd6a4..9b3ec7d8 100644 --- a/src/workspace.mli +++ b/src/workspace.mli @@ -38,6 +38,7 @@ end type t = { merlin_context : string option ; contexts : Context.t list + ; env : Dune_env.Stanza.t option } val load : ?x:string -> ?profile:string -> Path.t -> t From c112516a67f27f6a777938069167f3609c19e9a0 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 20 Jul 2018 10:43:52 +0200 Subject: [PATCH 03/13] Add test setting env for workspace Signed-off-by: Rudi Grinberg --- .../test-cases/workspaces/workspace-env/dune-workspace | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace b/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace index 30a26e35..53fa33c9 100644 --- a/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace +++ b/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace @@ -1,5 +1,9 @@ (lang dune 1.0) +(env + (default + (ocamlc_flags (:standard -verbose)))) + (context (default (env From 8cda4349fae6d54c0b356511583b0deb84d25ee9 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 20 Jul 2018 11:59:23 +0200 Subject: [PATCH 04/13] Use toplevel env stanza from workspace file This should be the top most env stanza when it's available Signed-off-by: Rudi Grinberg --- src/context.ml | 30 ++++++++++++++++++++---------- src/context.mli | 3 ++- src/super_context.ml | 28 +++++++++++++++++----------- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/context.ml b/src/context.ml index d005a9a6..3f5f6358 100644 --- a/src/context.ml +++ b/src/context.ml @@ -26,7 +26,7 @@ type t = ; for_host : t option ; implicit : bool ; build_dir : Path.t - ; env_node : Dune_env.Stanza.t option + ; env_nodes : Dune_env.Stanza.t list ; path : Path.t list ; toplevel_path : Path.t option ; ocaml_bin : Path.t @@ -131,7 +131,7 @@ let ocamlpath_sep = else Bin.path_sep -let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets +let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets ~profile () = let opam_var_cache = Hashtbl.create 128 in (match kind with @@ -334,7 +334,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets ; kind ; profile ; merlin - ; env_node + ; env_nodes ; for_host = host ; build_dir ; path @@ -410,11 +410,11 @@ let create ~(kind : Kind.t) ~path ~env ~env_node ~name ~merlin ~targets let opam_config_var t var = opam_config_var ~env:t.env ~cache:t.opam_var_cache var -let default ?(merlin=true) ~env_node ~env ~targets () = - create ~kind:Default ~path:Bin.path ~env ~env_node ~name:"default" +let default ?(merlin=true) ~env_nodes ~env ~targets () = + create ~kind:Default ~path:Bin.path ~env ~env_nodes ~name:"default" ~merlin ~targets () -let create_for_opam ?root ~env ~env_node ~targets ~profile ~switch ~name +let create_for_opam ?root ~env ~env_nodes ~targets ~profile ~switch ~name ?(merlin=false) () = match Bin.opam with | None -> Utils.program_not_found "opam" @@ -452,16 +452,26 @@ let create_for_opam ?root ~env ~env_node ~targets ~profile ~switch ~name | Some s -> Bin.parse_path s in let env = Env.extend env ~vars in - create ~kind:(Opam { root; switch }) ~profile ~targets ~path ~env ~env_node + create ~kind:(Opam { root; switch }) ~profile ~targets ~path ~env ~env_nodes ~name ~merlin () -let create ?merlin ~env def = +let create ?merlin ?workspace_env ~env def = + let env_nodes = + match workspace_env with + | None -> Option.to_list + | Some s -> + begin function + | None -> [s] + | Some x -> [x; s] + end + in match (def : Workspace.Context.t) with | Default { targets; profile; env = env_node ; loc = _ } -> - default ~env ~env_node ~profile ~targets ?merlin () + default ~env ~env_nodes:(env_nodes env_node) ~profile ~targets ?merlin () | Opam { base = { targets ; profile ; env = env_node ; loc = _ } ; name; switch; root; merlin = _ } -> - create_for_opam ?root ~env_node ~env ~profile ~switch ~name ?merlin ~targets () + create_for_opam ?root ~env_nodes:(env_nodes env_node) ~env ~profile + ~switch ~name ?merlin ~targets () let which t s = which ~cache:t.which_cache ~path:t.path s diff --git a/src/context.mli b/src/context.mli index 7cf4fe37..88546438 100644 --- a/src/context.mli +++ b/src/context.mli @@ -51,7 +51,7 @@ type t = build_dir : Path.t ; (** env node that this context was initialized with *) - env_node : Dune_env.Stanza.t option + env_nodes : Dune_env.Stanza.t list ; (** [PATH] *) path : Path.t list @@ -125,6 +125,7 @@ val compare : t -> t -> Ordering.t val create : ?merlin:bool + -> ?workspace_env:Dune_env.Stanza.t -> env:Env.t -> Workspace.Context.t -> t list Fiber.t diff --git a/src/super_context.ml b/src/super_context.ml index 7dc19eff..3632bd68 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -612,18 +612,24 @@ let create } in let context_env_node = lazy ( - let config = - match context.env_node with - | Some s -> s - | None -> { loc = Loc.none; rules = [] } + let make ~inherit_from ~config = + { Env_node. + dir = context.build_dir + ; scope = Scope.DB.find_by_dir scopes context.build_dir + ; ocaml_flags = None + ; inherit_from + ; config + } in - { Env_node. - dir = context.build_dir - ; inherit_from = None - ; scope = Scope.DB.find_by_dir scopes context.build_dir - ; config - ; ocaml_flags = None - } + match context.env_nodes with + | [] -> + make ~config:{ loc = Loc.none; rules = [] } ~inherit_from:None + | [config] -> + make ~config ~inherit_from:None + | [context; workspace] -> + make ~config:context + ~inherit_from:(Some (lazy (make ~inherit_from:None ~config:workspace))) + | _::_::_::_ -> assert false ) in List.iter stanzas ~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } -> From 61d33114ee58cba37ecc49457545ba7cf52bf484 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 20 Jul 2018 14:02:14 +0200 Subject: [PATCH 05/13] Bump latest version to 1.1 And make this version a pre-req for the env field in workspaces Signed-off-by: Rudi Grinberg --- src/workspace.ml | 9 +++++++-- .../test-cases/workspaces/workspace-env/dune-project | 2 +- .../test-cases/workspaces/workspace-env/dune-workspace | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/workspace.ml b/src/workspace.ml index a8408ac2..ad1e5e4a 100644 --- a/src/workspace.ml +++ b/src/workspace.ml @@ -5,6 +5,11 @@ open Stanza.Of_sexp for simplicity *) let syntax = Stanza.syntax +let env_field = + field_o "env" + (Syntax.since syntax (1, 1) >>= fun () -> + Dune_env.Stanza.t) + module Context = struct module Target = struct type t = @@ -49,7 +54,7 @@ module Context = struct } let t ~profile = - field_o "env" Dune_env.Stanza.t >>= fun env -> + env_field >>= fun env -> field "targets" (list Target.t) ~default:[Target.Native] >>= fun targets -> field "profile" string ~default:profile @@ -155,7 +160,7 @@ include Versioned_file.Make(struct type t = unit end) let () = Lang.register syntax () let t ?x ?profile:cmdline_profile () = - field_o "env" Dune_env.Stanza.t >>= fun env -> + env_field >>= fun env -> field "profile" string ~default:Config.default_build_profile >>= fun profile -> let profile = Option.value cmdline_profile ~default:profile in diff --git a/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-project b/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-project index b2559fa0..6687faf2 100644 --- a/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-project +++ b/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-project @@ -1 +1 @@ -(lang dune 1.0) \ No newline at end of file +(lang dune 1.1) \ No newline at end of file diff --git a/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace b/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace index 53fa33c9..4042a1a4 100644 --- a/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace +++ b/test/blackbox-tests/test-cases/workspaces/workspace-env/dune-workspace @@ -1,4 +1,4 @@ -(lang dune 1.0) +(lang dune 1.1) (env (default From bd860d29e7f64f90ec75d0054fc3aa81686a1c41 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 20 Jul 2018 15:28:27 +0200 Subject: [PATCH 06/13] Pass the workspace env to context creation Signed-off-by: Rudi Grinberg --- src/main.ml | 3 ++- test/blackbox-tests/test-cases/workspaces/run.t | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.ml b/src/main.ml index 5e2a1a51..9a1ee474 100644 --- a/src/main.ml +++ b/src/main.ml @@ -73,7 +73,8 @@ let setup ?(log=Log.no_log) Fiber.parallel_map workspace.contexts ~f:(fun ctx_def -> let name = Workspace.Context.name ctx_def in - Context.create ctx_def ~env ~merlin:(workspace.merlin_context = Some name)) + Context.create ?workspace_env:workspace.env + ctx_def ~env ~merlin:(workspace.merlin_context = Some name)) >>= fun contexts -> let contexts = List.concat contexts in List.iter contexts ~f:(fun (ctx : Context.t) -> diff --git a/test/blackbox-tests/test-cases/workspaces/run.t b/test/blackbox-tests/test-cases/workspaces/run.t index 80b47f0a..8ca726cd 100644 --- a/test/blackbox-tests/test-cases/workspaces/run.t +++ b/test/blackbox-tests/test-cases/workspaces/run.t @@ -53,6 +53,6 @@ Workspaces also allow you to set the env for a context: Entering directory 'workspace-env' ( (flags (-w -40 -machin)) - (ocamlc_flags (-g)) + (ocamlc_flags (-g -verbose)) (ocamlopt_flags (-g)) ) From 2836a3c6b0fe2309b5b52e5cd7fb805101c45900 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 20 Jul 2018 16:03:44 +0200 Subject: [PATCH 07/13] Document the workspace level env stanza Signed-off-by: Rudi Grinberg --- CHANGES.md | 4 ++++ doc/usage.rst | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 065c4ac2..b72e2efa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ next passing in `--root` in conjunction with `--workspace` or `--config` would not work correctly (#997, @rgrinberg) +- Add support for customizing env nodes in workspace files. The `env` stanza is + now allowed in toplevel position in the workspace file, or for individual + contexts. This feature requires `(dune lang 1.1)` (#1038, @rgrinberg) + 1.0.1 (19/07/2018) ------------------ diff --git a/doc/usage.rst b/doc/usage.rst index 26eec414..9e09a68d 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -379,6 +379,13 @@ The build profile can be selected in the ``dune-workspace`` file by write a Note that the command line option ``--profile`` has precedence over this stanza. +env +~~~ + +The ``env`` stanza can be used to set the base environment for all contexts in +this workspace. This environment has the lowest precedence of all other ``env`` +stanzas. The syntax for this stanza is the same dune's :ref:`dune-env` stanza. + context ~~~~~~~ @@ -407,6 +414,10 @@ context or can be the description of an opam switch, as follows: context. This has precedence over the command line option ``--profile`` +- ``(env )`` to set the environment for a particular context. This is of + higher precedence than the toplevel ``env`` stanza in the workspace file. This + field the same options as the :ref:`dune-env` stanza. + Both ``(default ...)`` and ``(opam ...)`` accept a ``targets`` field in order to setup cross compilation. See :ref:`advanced-cross-compilation` for more information. From 024438e3ccdb0ce1966463a324c6e3d6ef6a57dd Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 30 Jul 2018 14:13:09 +0200 Subject: [PATCH 08/13] Represent env_nodes using a record rather than a list Signed-off-by: Rudi Grinberg --- src/context.ml | 22 +++++++++++++--------- src/context.mli | 9 ++++++++- src/super_context.ml | 8 ++++---- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/context.ml b/src/context.ml index 3f5f6358..31242d42 100644 --- a/src/context.ml +++ b/src/context.ml @@ -18,6 +18,13 @@ module Kind = struct ]) end +module Env_nodes = struct + type t = + { context: Dune_env.Stanza.t option + ; workspace: Dune_env.Stanza.t option + } +end + type t = { name : string ; kind : Kind.t @@ -26,7 +33,7 @@ type t = ; for_host : t option ; implicit : bool ; build_dir : Path.t - ; env_nodes : Dune_env.Stanza.t list + ; env_nodes : Env_nodes.t ; path : Path.t list ; toplevel_path : Path.t option ; ocaml_bin : Path.t @@ -456,14 +463,11 @@ let create_for_opam ?root ~env ~env_nodes ~targets ~profile ~switch ~name ~name ~merlin () let create ?merlin ?workspace_env ~env def = - let env_nodes = - match workspace_env with - | None -> Option.to_list - | Some s -> - begin function - | None -> [s] - | Some x -> [x; s] - end + let env_nodes context = + { Env_nodes. + context + ; workspace = workspace_env + } in match (def : Workspace.Context.t) with | Default { targets; profile; env = env_node ; loc = _ } -> diff --git a/src/context.mli b/src/context.mli index 88546438..954434c0 100644 --- a/src/context.mli +++ b/src/context.mli @@ -30,6 +30,13 @@ module Kind : sig type t = Default | Opam of Opam.t end +module Env_nodes : sig + type t = + { context: Dune_env.Stanza.t option + ; workspace: Dune_env.Stanza.t option + } +end + type t = { name : string ; kind : Kind.t @@ -51,7 +58,7 @@ type t = build_dir : Path.t ; (** env node that this context was initialized with *) - env_nodes : Dune_env.Stanza.t list + env_nodes : Env_nodes.t ; (** [PATH] *) path : Path.t list diff --git a/src/super_context.ml b/src/super_context.ml index 3632bd68..c4eb27b6 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -622,14 +622,14 @@ let create } in match context.env_nodes with - | [] -> + | { context = None; workspace = None } -> make ~config:{ loc = Loc.none; rules = [] } ~inherit_from:None - | [config] -> + | { context = Some config; workspace = None } + | { context = None; workspace = Some config } -> make ~config ~inherit_from:None - | [context; workspace] -> + | { context = Some context ; workspace = Some workspace } -> make ~config:context ~inherit_from:(Some (lazy (make ~inherit_from:None ~config:workspace))) - | _::_::_::_ -> assert false ) in List.iter stanzas ~f:(fun { Dir_with_jbuild. ctx_dir; scope; stanzas; _ } -> From f58bca1d069d32dad0a536dca1089ca637965bff Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Fri, 27 Jul 2018 12:55:11 +0200 Subject: [PATCH 09/13] ocamllex does not need the list of modules to be in a list Noticed this issue while finding another issue in #1056. Signed-off-by: Marek Kubica --- doc/dune-files.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dune-files.rst b/doc/dune-files.rst index 21ed5db5..8d7564c2 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -503,7 +503,7 @@ To use a different rule mode, use the long form: .. code:: scheme (ocamllex - (modules ()) + (modules ) (mode )) ocamlyacc From 371c863a324645f9ca8746032d6ce13b90b39518 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Fri, 27 Jul 2018 13:03:44 +0200 Subject: [PATCH 10/13] Parens not required Closes #1054 Closes #1056 Signed-off-by: Marek Kubica --- doc/dune-files.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dune-files.rst b/doc/dune-files.rst index 8d7564c2..b77d7886 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -488,7 +488,7 @@ stanza is rejected by dune: ocamllex -------- -``(ocamllex ())`` is essentially a shorthand for: +``(ocamllex )`` is essentially a shorthand for: .. code:: scheme From ed5f2c5b4046c30a7c291fe71fd40c00483d0e85 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Fri, 27 Jul 2018 13:06:00 +0200 Subject: [PATCH 11/13] ocamlyacc does not require parens either Signed-off-by: Marek Kubica --- doc/dune-files.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/dune-files.rst b/doc/dune-files.rst index b77d7886..c74dadc9 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -509,7 +509,7 @@ To use a different rule mode, use the long form: ocamlyacc --------- -``(ocamlyacc ())`` is essentially a shorthand for: +``(ocamlyacc )`` is essentially a shorthand for: .. code:: scheme @@ -524,7 +524,7 @@ To use a different rule mode, use the long form: .. code:: scheme (ocamlyacc - (modules ()) + (modules ) (mode )) menhir From 7af0af94ed35b792b0f7c9ecf130f11e621fbee0 Mon Sep 17 00:00:00 2001 From: cedlemo Date: Sun, 29 Jul 2018 18:44:25 +0200 Subject: [PATCH 12/13] doc: remove %{first-dep} in quick-start.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Le Moigne --- doc/quick-start.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/quick-start.rst b/doc/quick-start.rst index f9272534..2c62f441 100644 --- a/doc/quick-start.rst +++ b/doc/quick-start.rst @@ -136,7 +136,7 @@ Add this field to your ``library`` or ``executable`` stanzas: .. code:: scheme - (preprocess (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{first-dep}))) + (preprocess (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file}))) Additionally, if you are include a ``config.h`` file, you need to declare the dependency to this file via: @@ -154,7 +154,7 @@ Write this in your ``dune`` file: (rule (targets foo.ml) - (deps foo.cppo.ml ) + (deps (:first-dep foo.cppo.ml) ) (action (run %{bin:cppo} %{first-dep} -o %{targets}))) Defining a library with C stubs @@ -192,8 +192,8 @@ compilation and link flags. Write this ``dune`` file: (rule (targets c_flags.sexp c_library_flags.sexp) - (deps config/discover.exe) - (action (run %{first-dep} -ocamlc %{OCAMLC}))) + (deps (:discover config/discover.exe)) + (action (run %{discover} -ocamlc %{OCAMLC}))) Then create a ``config`` subdirectory and write this ``dune`` file: @@ -240,8 +240,8 @@ To generate a file ``foo.ml`` using a program from another directory: (rule (targets foo.ml) - (deps ../generator/gen.exe) - (action (run %{first-dep} -o %{targets}))) + (deps (:gen ../generator/gen.exe)) + (action (run %{gen} -o %{targets}))) Defining tests ============== @@ -252,8 +252,8 @@ Write this in your ``dune`` file: (alias (name runtest) - (deps my-test-program.exe) - (action (run %{first-dep}))) + (deps (:my-prog my-test-program.exe)) + (action (run %{my-prog}))) And run the tests with: From 772c1c05ac04d68b70f566cd04bdaae2c35f264e Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Mon, 30 Jul 2018 16:48:28 +0200 Subject: [PATCH 13/13] Do not rely on cat output in tests The error messages of `cat` can change a bit, for example if a different locale is set. This uses a shell test instead. Signed-off-by: Etienne Millon --- test/blackbox-tests/test-cases/dune-project-edition/run.t | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/blackbox-tests/test-cases/dune-project-edition/run.t b/test/blackbox-tests/test-cases/dune-project-edition/run.t index c527165c..311d7d88 100644 --- a/test/blackbox-tests/test-cases/dune-project-edition/run.t +++ b/test/blackbox-tests/test-cases/dune-project-edition/run.t @@ -1,6 +1,5 @@ - $ cat dune-project - cat: dune-project: No such file or directory - [1] + $ [ -e dune-project ] || echo File does not exist + File does not exist $ mkdir src $ echo '(alias (name runtest) (action (progn)))' > src/dune $ dune build