Skip to content

Format dune files in core#3536

Merged
nojb merged 5 commits intoocaml:masterfrom
nojb:format_dune_files_in_core
Jun 12, 2020
Merged

Format dune files in core#3536
nojb merged 5 commits intoocaml:masterfrom
nojb:format_dune_files_in_core

Conversation

@nojb
Copy link
Collaborator

@nojb nojb commented Jun 8, 2020

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nojb
Copy link
Collaborator Author

nojb commented Jun 9, 2020

LGTM!

Thanks! I will update the tests and add a Changes entry.

@ghost
Copy link

ghost commented Jun 9, 2020

BTW, thinking about it ideally we would do the formatting via an action. i.e. instead of having the build action be Write_file (<file>, <formatted-contents>), it would be Format_dune_file <input>. This way the contents of the file doesn't appear in the build rule which then has a smaller memory footprint, which could matter for large builds.

@nojb
Copy link
Collaborator Author

nojb commented Jun 9, 2020

BTW, thinking about it ideally we would do the formatting via an action. i.e. instead of having the build action be Write_file (<file>, <formatted-contents>), it would be Format_dune_file <input>. This way the contents of the file doesn't appear in the build rule which then has a smaller memory footprint, which could matter for large builds.

Got it. This means adding a new constructor the Action.t type, right?

@ghost
Copy link

ghost commented Jun 9, 2020

Yep, that's exactly what it means

@nojb
Copy link
Collaborator Author

nojb commented Jun 9, 2020

I pushed a commit with this change.

, Dune_lang.Syntax.since Stanza.syntax (2, 6) >>> t >>| fun t ->
No_infer t )
; ( "format-dune-file"
, Dune_lang.Syntax.since Stanza.syntax (2, 7) >>>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I versioned the action, even though it is not supposed to be used by users.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, we don't need to parse it. We do that for a few other private actions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I took this out.

| Dynamic_run _ -> true
| System _ -> true
| Bash _ -> true
| Format_dune_file _ -> memoize
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure about this one.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems good

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically this means that:

  • the action would not be sandboxed (no need since we don't run external commands)
  • the result would go in the shared cache
  • the result would go in the distributed shared cache

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks!

@nojb nojb force-pushed the format_dune_files_in_core branch from eb8d75b to 8c0a8f8 Compare June 9, 2020 11:59
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all good, thanks!

@nojb nojb closed this Jun 9, 2020
@nojb nojb reopened this Jun 9, 2020
@nojb nojb force-pushed the format_dune_files_in_core branch from 8c0a8f8 to 44525a4 Compare June 9, 2020 14:25
@nojb nojb closed this Jun 9, 2020
@nojb nojb reopened this Jun 9, 2020
@nojb
Copy link
Collaborator Author

nojb commented Jun 9, 2020

Travis seems to have disappeared...

@ghost
Copy link

ghost commented Jun 9, 2020

There was one build queued but with the wrong commit number, I just canceled it. Though the build of master seems to be broken because of ppx_expect, looking at it now

nojb added 4 commits June 9, 2020 21:31
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
Signed-off-by: Nicolás Ojeda Bär <[email protected]>
@nojb nojb force-pushed the format_dune_files_in_core branch from 44525a4 to 54335e3 Compare June 9, 2020 19:31
@nojb nojb closed this Jun 12, 2020
@nojb nojb reopened this Jun 12, 2020
@nojb nojb merged commit 882023b into ocaml:master Jun 12, 2020
@nojb nojb deleted the format_dune_files_in_core branch June 12, 2020 11:35
@nojb
Copy link
Collaborator Author

nojb commented Jun 12, 2020

CI green, merging. Thanks @jeremiedimino for fixing the CI!

@ghost
Copy link

ghost commented Jun 12, 2020

No problem!

rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Aug 14, 2020
…lugin, dune-private-libs and dune-glob (2.7.0)

CHANGES:

- Write intermediate files in a `.mdx` folder for each `mdx` stanza
  to prevent the corresponding actions to be executed as part of the `@all`
  alias (ocaml/dune#3659, @NathanReb)

- Read Coq flags from `env` (ocaml/dune#3547 , fixes ocaml/dune#3486, @gares)

- Allow bisect_ppx to be enabled/disabled via dune-workspace. (ocaml/dune#3404,
  @stephanieyou)

- Formatting of dune files is now done in the executing dune process instead of
  in a separate process. (ocaml/dune#3536, @nojb)

- Add a `--debug-artifact-substution` flag to help debug problem with
  version not being captured by `dune-build-info` (ocaml/dune#3589,
  @jeremiedimino)

- Allow the use of the `context_name` variable in the `enabled_if` fields of
  executable(s) and install stanzas. (ocaml/dune#3568, fixes ocaml/dune#3566, @voodoos)

- Fix compatibility with OCaml 4.12.0 when compiling empty archives; no .a file
  is generated. (ocaml/dune#3576, @dra27)

- `$ dune utop` no longer tries to load optional libraries that are unavailable
  (ocaml/dune#3612, fixes ocaml/dune#3188, @anuragsoni)

- Fix dune-build-info on 4.10.0+flambda (ocaml/dune#3599, @emillon, @jeremiedimino).

- Allow multiple libraries with `inline_tests` to be defined in the same
  directory (ocaml/dune#3621, @rgrinberg)

- Run exit hooks in jsoo separate compilation mode (ocaml/dune#3626, fixes ocaml/dune#3622,
  @rgrinberg)

- Add (alias ...), (mode ...) fields to (copy_fields ...) stanza (ocaml/dune#3631, @nojb)

- (copy_files ...) now supports copying files from outside the workspace using
  absolute file names (ocaml/dune#3639, @nojb)

- Dune does not use `ocamlc` as an intermediary to call C compiler anymore.
  Configuration flags `ocamlc_cflags` and `ocamlc_cppflags` are always prepended
  to the compiler arguments. (ocaml/dune#3565, fixes ocaml/dune#3346, @voodoos)

- Revert the build optimization in ocaml/dune#2268. This optimization slows down building
  individual executables when they're part of an `executables` stanza group
  (ocaml/dune#3644, @rgrinberg)

- Use `{dev}` rather than `{pinned}` in the generated `.opam` file. (ocaml/dune#3647,
  @kit-ty-kate)

- Insert correct extension name when editing `dune-project` files. Previously,
  dune would just insert the stanza name. (ocaml/dune#3649, fixes ocaml/dune#3624, @rgrinberg)

- Fix crash when evaluating an `mdx` stanza that depends on unavailable
  packages. (ocaml/dune#3650, @craigfe)

- Fix typo in `cache-check-probablity` field in dune config files. This field
  now requires 2.7 as it wasn't usable before this version. (ocaml/dune#3652, @edwintorok)

- Add `"odoc" {with-doc}` to the dependencies in the generated `.opam` files.
  (ocaml/dune#3667, @kit-ty-kate)

- Do not allow user actions to capture dune's stdin (ocaml/dune#3677, fixes ocaml/dune#3672,
  @rgrinberg)

- `(subdir ...)` stanzas can now appear in dune files used via `(include ...)`.
  (ocaml/dune#3676, @nojb)
rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Aug 14, 2020
…lugin, dune-private-libs and dune-glob (2.7.0)

CHANGES:

- Write intermediate files in a `.mdx` folder for each `mdx` stanza
  to prevent the corresponding actions to be executed as part of the `@all`
  alias (ocaml/dune#3659, @NathanReb)

- Read Coq flags from `env` (ocaml/dune#3547 , fixes ocaml/dune#3486, @gares)

- Add instrumentation framework to toggle instrumentation by `bisect_ppx`,
  `landmarks`, etc, via dune-workspace and/or the command-line. (ocaml/dune#3404, ocaml/dune#3526
  @stephanieyou, @nojb)

- Formatting of dune files is now done in the executing dune process instead of
  in a separate process. (ocaml/dune#3536, @nojb)

- Add a `--debug-artifact-substution` flag to help debug problem with
  version not being captured by `dune-build-info` (ocaml/dune#3589,
  @jeremiedimino)

- Allow the use of the `context_name` variable in the `enabled_if` fields of
  executable(s) and install stanzas. (ocaml/dune#3568, fixes ocaml/dune#3566, @voodoos)

- Fix compatibility with OCaml 4.12.0 when compiling empty archives; no .a file
  is generated. (ocaml/dune#3576, @dra27)

- `$ dune utop` no longer tries to load optional libraries that are unavailable
  (ocaml/dune#3612, fixes ocaml/dune#3188, @anuragsoni)

- Fix dune-build-info on 4.10.0+flambda (ocaml/dune#3599, @emillon, @jeremiedimino).

- Allow multiple libraries with `inline_tests` to be defined in the same
  directory (ocaml/dune#3621, @rgrinberg)

- Run exit hooks in jsoo separate compilation mode (ocaml/dune#3626, fixes ocaml/dune#3622,
  @rgrinberg)

- Add (alias ...), (mode ...) fields to (copy_fields ...) stanza (ocaml/dune#3631, @nojb)

- (copy_files ...) now supports copying files from outside the workspace using
  absolute file names (ocaml/dune#3639, @nojb)

- Dune does not use `ocamlc` as an intermediary to call C compiler anymore.
  Configuration flags `ocamlc_cflags` and `ocamlc_cppflags` are always prepended
  to the compiler arguments. (ocaml/dune#3565, fixes ocaml/dune#3346, @voodoos)

- Revert the build optimization in ocaml/dune#2268. This optimization slows down building
  individual executables when they're part of an `executables` stanza group
  (ocaml/dune#3644, @rgrinberg)

- Use `{dev}` rather than `{pinned}` in the generated `.opam` file. (ocaml/dune#3647,
  @kit-ty-kate)

- Insert correct extension name when editing `dune-project` files. Previously,
  dune would just insert the stanza name. (ocaml/dune#3649, fixes ocaml/dune#3624, @rgrinberg)

- Fix crash when evaluating an `mdx` stanza that depends on unavailable
  packages. (ocaml/dune#3650, @craigfe)

- Fix typo in `cache-check-probablity` field in dune config files. This field
  now requires 2.7 as it wasn't usable before this version. (ocaml/dune#3652, @edwintorok)

- Add `"odoc" {with-doc}` to the dependencies in the generated `.opam` files.
  (ocaml/dune#3667, @kit-ty-kate)

- Do not allow user actions to capture dune's stdin (ocaml/dune#3677, fixes ocaml/dune#3672,
  @rgrinberg)

- `(subdir ...)` stanzas can now appear in dune files used via `(include ...)`.
  (ocaml/dune#3676, @nojb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dune build @fmt should use the current executable instead of looking for it in PATH

1 participant