Skip to content

Commit

Permalink
Add [preprocess_action] to [preprocess]
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahbeckford committed Mar 12, 2024
1 parent 2b817be commit f7ae74a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Add `copy_with_source_directive` which implements the `copy#` action.
* Add `flags` and `ocamlc_flags` to complement existing `ocamlopt_flags`.
Type has changed but not a breaking change since `ocamlopt_flags` was previously unusable (lacked type constructor).
* Add `preprocess_action` to `preprocess`

## 0.1.3

Expand Down
30 changes: 17 additions & 13 deletions src/dsl/dune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
supports parameterized strings. For example, if you were using the ["dkml-dune-dsl-show"] interpreter and configured
it with a JSON parameter file, you could use [`Split "{{#libraries}} {{library}} {{/libraries}}"] and
the ["dkml-dune-dsl-show"] interpreter would:
+ concatenate all of the [libraries] JSON array from the JSON parameter file into a space separated list of libraries
+ [`Split] would then split the space separated list of libraries into the individual libraries.
*)
Expand Down Expand Up @@ -64,14 +64,14 @@ module type SYM = sig

val install : [ `Install ] repr list -> [ `Stanza ] repr
(** [install] copies freshly built artifacts from the workspace to the system.
The install stanza takes three pieces of information:
+ the list of files to install
+ the package to attach these files. (This field is optional if your project contains a single package.)
+ the {!section} in which the files will be installed
See {!section-Install} for how to specify the three pieces of information.
See {!section-Install} for how to specify the three pieces of information.
*)

val pragma : string -> [ `Stanza ] repr -> [ `Stanza ] repr
Expand Down Expand Up @@ -139,7 +139,7 @@ module type SYM = sig
The mapping between the raw Dune expressions and the DSL (OCaml) is:
* [template] is a string template, like ["%{ocaml-config:system}"]
* [not] is the
* [not] is the
*)

val template : string -> [ `BooleanLanguage ] repr
Expand Down Expand Up @@ -196,11 +196,11 @@ module type SYM = sig

val glob_files : string -> [ `Dep ] repr
(** [glob_files glob] depends on all files matched by [glob].
You can use globs to declare dependencies on a set of files. Note that globs will
match files that exist in the source tree as well as buildable targets, so for instance you
can depend on ["*.cmi"].
The glob syntax is interpreted as follows:
- ["\\<char>"] matches exactly ["<char>"], even if it’s a special character (["*"], ["?"], ...).
Expand Down Expand Up @@ -281,22 +281,22 @@ module type SYM = sig
val public_name : string -> [< `Executable | `Library ] repr
(** [public_name] is the name under which the library can be referred as a dependency when it is installed outside of
the current workspace, or is the name of the executable when it is installed outside of the current workspace.
{b [public_name] for Libraries}
Without a [(public_name ...)] field the library won’t be installed by Dune. The public name
must start with the package name it’s part of and optionally followed by a dot, then anything else you want.
{b [public_name] for Executables}
Without a [(public_name ...)] field the executable won’t be installed by Dune.
Without a [(public_name ...)] field the executable won’t be installed by Dune.
*)

val name : string -> [< `Executable | `Library ] repr
(** [name] is the module name that contains the executable’s main entry point, or the real name of the library.
{b [name] for Libraries}
It determines the names of the archive files generated for the library as well as the module name under
which the library will be available, unless [(wrapped false)] is used (see {!wrapped}). It must be a
valid OCaml module name, but it doesn’t need to start with an uppercase letter.
Expand Down Expand Up @@ -448,6 +448,10 @@ module type SYM = sig
+ second step of code generation in parallel with compilation
*)

val preprocess_action : [ `Action ] repr -> [ `PreprocessSpec ] repr
(** [preprocess_action <action>] is an action that reads the file given as a dependency named
["input-file"] and outputs the preprocessed file on its standard output. *)

val future_syntax : [ `PreprocessSpec ] repr
(** [future_syntax] is equivalent to {!no_preprocessing} when using one of the most recent
versions of the compiler. When using an older one, it is a shim preprocessor that backports
Expand Down Expand Up @@ -531,14 +535,14 @@ module type SYM = sig
is enabled after variant resolution if no suitable implementation has been found. *)

(** {3:Executables Executables Only}
As of this version there are no executable-only clauses. *)

(** {3:Install Install} *)

val section : string -> [ `Install ] repr
(** [section "share"] is the section in which the files will be installed.
The following sections are available:
- ["lib"] installs by default to ["/lib/<pkgname>/"]
Expand All @@ -557,7 +561,7 @@ module type SYM = sig
- ["misc"] requires files to specify an absolute destination. It will only work when used with opam and the user will be prompted before the installation when it's done via opam. It is deprecated.
The following sections are not yet available in Dune DSL:
- ["(site (<package> <site>))"] installs in the <site> directory of <package>. If the prefix isn't the same as the one used when installing <package>, <package> won't find the files.
- ["(site (<package> <site>))"] installs in the <site> directory of <package>. If the prefix isn't the same as the one used when installing <package>, <package> won't find the files.
*)

val install_package : string -> [ `Install ] repr
Expand Down
2 changes: 2 additions & 0 deletions src/show/DkmlDuneDslShow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ module I : DkmlDuneDsl.Dune.SYM with type 'a repr = args -> out = struct
(* Dune does not accept empty-arg (preprocess (staged_pps)) so we remove it *)
_vararg_of_splittable_string ~none_when_empty:() ~args "staged_pps" l

let preprocess_action a args = _list [ _atom "action"; a args ]

let future_syntax _args = _atom "future_syntax"

(** {4 Ordered Sets} *)
Expand Down

0 comments on commit f7ae74a

Please sign in to comment.