-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track original source location in lib_info/dune_package #1750
Conversation
src/lib_info.ml
Outdated
match Path.drop_build_context dir with | ||
| None -> None | ||
| Some src_dir -> | ||
Some Path.(of_string (to_absolute_filename (in_source (to_string src_dir)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird and maybe can be done easier but Path
is confusing for me at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in_source (to_string src_dir)
should be the identity, you can replace it by src_dir
The idea is fine, but how do we control which sources to use in the .merlin file? If a package is installed via opam, then the original source dir will be ephemeral. |
I thought maybe if profile is set to “release” (-p is passed) we don’t
populate “orig_src_dir” in dune package metadata.
On Thu, 10 Jan 2019 at 19:45, Rudi Grinberg ***@***.***> wrote:
The idea is fine, but how do we control which sources to use in the
.merlin file? If a package is installed via opam, then the original source
dir will be ephemeral.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1750 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAB3glYuDiW0e-A-boEyUD1GUD3DyZJtks5vB24dgaJpZM4Z5bvw>
.
--
Andrey Popp / [email protected]
|
What about controlling this behaviour with a command line switch/environment variable? In practice, we probably don't want to store these paths by default as it will hurt reproducibility, but esy could enable it via the environment variable. |
Won't such option be overly specific? Doesn't dune already have |
Given that you need to go through editing the opam file, I think that makes the feature not very useful. So it makes it even more of an option that only esy would configure. |
539dd2c
to
e73162c
Compare
I proceeded with not emitting I had to add a sanitisation step for blackbox test which replaces test's root path with |
(modules ((name Y) (obj_name c__Y) (visibility public) (impl))) | ||
(wrapped true))) | ||
|
||
Build with "release" profile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new test case but diff doesn't make it obvious.
@@ -330,6 +332,8 @@ Include variants and implementation information in dune-package | |||
(name foo.vlib) | |||
(kind normal) | |||
(virtual) | |||
(orig_src_dir | |||
$TESTCASE_ROOT/dune-package-info/vlib) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's ok this breaks on the next line here.
fdb164f
to
297926c
Compare
It just occurred to me that it's possible to implement this feature without touching dune-package at all. The only reason why dune doesn't know that some external packages are actually local is because they get filtered out by |
What does it mean "actually local" — being a part of the same workspace? Then this isn't the case always in esy: it allows you to link packages from outside:
|
I see. So my suggestion wouldn't work after all. Would it be possible for esy to just pass the linked packages to dune somehow? Changing dune-package is a touchy issue for us, so I'd prefer that we refrained from doing so unless we really had no other way. |
Instead of changing
|
BTW, when a package is pinned via opam, the build still happens in a temporary directory, so the value that would be stored here wouldn't be useful. It seems to me that using an environment variable is the best option here. It's true that this is a very specific setting, but on the other hand most of the time storing the original source directory doesn't make sense. Even if we store it in a separate .dev file, it still doesn't feel right to install such files with temporary paths. |
Ok, makes sense. What would be the name/value of such environment variable? Something like (using
|
Hm... on a second thought I'm not sure how esy would be able to construct such |
Ok, sorry for the noise, I think now you meant controlling that behaviour as passing a boolean flag via environment. I agree, that could work. What would be the name of such environment variable? |
Yep, that's what I meant. I suggest |
@diml thanks! Will update this PR with that. |
This is ready for review. |
It's a bit annoying to introduce another environment variable for this. Why can't this setting live in the workspace file? |
@rgrinberg the only reason I can think of is that users will need to configure |
It will not be necessary [1] |
@rgrinberg I guess before that we could manually set |
Hold on, one big advantage of using specific environment variables is that it makes composition easy. For instance, I believe that it is now generally accepted that @rgrinberg why is it annoying to introduce new environment variables? |
I have to chime in here to say that some kind of env var does seem better to me (than the alternative) because it's something package authors can't know to configure - only the package manager knows what's linked for the purposes of dev vs. release. I don't have many opinions on exactly what the env var looks like, but this is the one remaining feature blocking a very great monorepo workflow for esy and dune which allows you to "absorb" external packages into your local monorepo temporarily while developing. |
54b8cc5
to
dda8f43
Compare
Thanks for the feedback @diml, I believe I've addressed all points. |
The reason why I wanted to started with a workspace option is that it avoids having to remember which vars can be overridden via the environment. On the other hand, there's nothing wrong with an individual env var even if there a workspace the option. |
Yh that's true. In this case, I expect that this variable will be set by another tool most of the time. |
@andreypopp thanks, just one last point I missed during the first review, otherwise it looks good. |
80910cb
to
3d54e26
Compare
This allows to communicate original source locations so we can construct `.merlin` files with `S` directives pointing right to them for installed libs. This is useful when lib is opam-pinned or esy-linked. I think we can set `orig_src_dir` to `None` for all other installed packages (based on profile?). Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
This replaces test case root with $TESTCASE_ROOT token against which we can match in expectations. Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Use `--store-orig-source-dir` command line flag (or `DUNE_STORE_ORIG_SOURCE_DIR` env var) as suggested by @diml. Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
Signed-off-by: Andrey Popp <[email protected]>
3d54e26
to
6560587
Compare
Thanks for another round of feedback @diml, I believe I've address these points too. Also rebased on top of the current |
Thanks, LGTM |
Thanks! |
CHANGES: - Second step of the deprecation of jbuilder: the `jbuilder` binary now emits a warning on every startup and both `jbuilder` and `dune` emit warnings when encountering `jbuild` files (ocaml/dune#1752, @diml) - Change the layout of build artifacts inside _build. The new layout enables optimizations that depend on the presence of `.cmx` files of private modules (ocaml/dune#1676, @bobot) - Fix merlin handling of private module visibility (ocaml/dune#1653 @bobot) - unstable-fmt: use boxes to wrap some lists (ocaml/dune#1608, fix ocaml/dune#1153, @emillon, thanks to @rgrinberg) - skip directories when looking up programs in the PATH (ocaml/dune#1628, fixes ocaml/dune#1616, @diml) - Use `lsof` on macOS to implement `--stats` (ocaml/dune#1636, fixes ocaml/dune#1634, @xclerc) - Generate `dune-package` files for every package. These files are installed and read instead of `META` files whenever they are available (ocaml/dune#1329, @rgrinberg) - Fix preprocessing for libraries with `(include_subdirs ..)` (ocaml/dune#1624, fix ocaml/dune#1626, @nojb, @rgrinberg) - Do not generate targets for archive that don't match the `modes` field. (ocaml/dune#1632, fix ocaml/dune#1617, @rgrinberg) - When executing actions, open files lazily and close them as soon as possible in order to reduce the maximum number of file descriptors opened by Dune (ocaml/dune#1635, ocaml/dune#1643, fixes ocaml/dune#1633, @jonludlam, @rgrinberg, @diml) - Reimplement the core of Dune using a new generic memoization system (ocaml/dune#1489, @rudihorn, @diml) - Replace the broken cycle detection algorithm by a state of the art one from [this paper](https://doi.org/10.1145/2756553) (ocaml/dune#1489, @rudihorn) - Get the correct environment node for multi project workspaces (ocaml/dune#1648, @rgrinberg) - Add `dune compute` to call internal memoized functions (ocaml/dune#1528, @rudihorn, @diml) - Add `--trace-file` option to trace dune internals (ocaml/dune#1639, fix ocaml/dune#1180, @emillon) - Add `--no-print-directory` (borrowed from GNU make) to suppress `Entering directory` messages. (ocaml/dune#1668, @dra27) - Remove `--stats` and track fd usage in `--trace-file` (ocaml/dune#1667, @emillon) - Add virtual libraries feature and enable it by default (ocaml/dune#1430 fixes ocaml/dune#921, @rgrinberg) - Fix handling of Control+C in watch mode (ocaml/dune#1678, fixes ocaml/dune#1671, @diml) - Look for jsoo runtime in the same dir as the `js_of_ocaml` binary when the ocamlfind package is not available (ocaml/dune#1467, @nojb) - Make the `seq` package available for OCaml >= 4.07 (ocaml/dune#1714, @rgrinberg) - Add locations to error messages where a rule fails to generate targets and rules that require files outside the build/source directory. (ocaml/dune#1708, fixes ocaml/dune#848, @rgrinberg) - Let `Configurator` handle `sizeof` (in addition to negative numbers). (ocaml/dune#1726, fixes ocaml/dune#1723, @Chris00) - Fix an issue causing menhir generated parsers to fail to build in some cases. The fix is to systematically use `-short-paths` when calling `ocamlc -i` (ocaml/dune#1743, fix ocaml/dune#1504, @diml) - Never raise when printing located errors. The code that would print the location excerpts was prone to raising. (ocaml/dune#1744, fix ocaml/dune#1736, @rgrinberg) - Add a `dune upgrade` command for upgrading jbuilder projects to Dune (ocaml/dune#1749, @diml) - When automatically creating a `dune-project` file, insert the detected name in it (ocaml/dune#1749, @diml) - Add `(implicit_transitive_deps <bool>)` mode to dune projects. When this mode is turned off, transitive dependencies are not accessible. Only listed dependencies are directly accessible. (ocaml/dune#1734, ocaml/dune#430, @rgrinberg, @hnrgrgr) - Add `toplevel` stanza. This stanza is used to define toplevels with libraries already preloaded. (ocaml/dune#1713, @rgrinberg) - Generate `.merlin` files that account for normal preprocessors defined using a subset of the `action` language. (ocaml/dune#1768, @rgrinberg) - Emit `(orig_src_dir <path>)` metadata in `dune-package` for dune packages built with `--store-orig-source-dir` command line flag (also controlled by `DUNE_STORE_ORIG_SOURCE_DIR` env variable). This is later used to generate `.merlin` with `S`-directives pointed to original source locations and thus allowing merlin to see those. (ocaml/dune#1750, @andreypopp) - Improve the behavior of `dune promote` when the files to be promoted have been deleted. (ocaml/dune#1775, fixes ocaml/dune#1772, @diml) - unstable-fmt: preserve comments (ocaml/dune#1766, @emillon) - Pass flags correctly when using `staged_pps` (ocaml/dune#1779, fixes ocaml/dune#1774, @diml) - Fix an issue with the use of `(mode promote)` in the menhir stanza. It was previously causing intermediate *mock* files to be promoted (ocaml/dune#1783, fixes ocaml/dune#1781, @diml) - unstable-fmt: ignore files using OCaml syntax (ocaml/dune#1784, @emillon) - Configurator: Add `which` function to replace the `which` command line utility in a cross platform way. (ocaml/dune#1773, fixes ocaml/dune#1705, @Chris00) - Make configurator append paths to `$PKG_CONFIG_PATH` on macOS. Previously it was prepending paths and thus `$PKG_CONFIG_PATH` set by users could have been overridden by homebrew installed libraries (ocaml/dune#1785, @andreypopp) - Disallow c/cxx sources that share an object file in the same stubs archive. This means that `foo.c` and `foo.cpp` can no longer exist in the same library. (ocaml/dune#1788, @rgrinberg) - Forbid use of `%{targets}` (or `${@}` in jbuild files) inside preprocessing actions (ocaml/dune#1812, fixes ocaml/dune#1811, @diml) - Add `DUNE_PROFILE` environment variable to easily set the profile. (ocaml/dune#1806, @rgrinberg) - Deprecate the undocumented `(no_keep_locs)` field. It was only necessary until virtual libraries were supported (ocaml/dune#1822, fix ocaml/dune#1816, @diml) - Rename `unstable-fmt` to `format-dune-file` and remove its `--inplace` option. (ocaml/dune#1821, @emillon). - Autoformatting: `(using fmt 1.1)` will also format dune files (ocaml/dune#1821, @emillon). - Autoformatting: record dependencies on `.ocamlformat-ignore` files (ocaml/dune#1824, fixes ocaml/dune#1793, @emillon)
This allows to communicate original source locations between installed (dune) libraries so we can construct
.merlin
files withS
directives pointing right to them for installed libs. Thus allowing merlin to see original sources.This is useful when lib is opam-pinned or esy-linked. I think we can set
orig_src_dir
toNone
for all other installed packages (based on profile?).