Skip to content

ocamldep -paths#146

Closed
gasche wants to merge 3 commits intoocaml:trunkfrom
gasche:ocamldep-paths
Closed

ocamldep -paths#146
gasche wants to merge 3 commits intoocaml:trunkfrom
gasche:ocamldep-paths

Conversation

@gasche
Copy link
Copy Markdown
Member

@gasche gasche commented Feb 15, 2015

This patch provides a preliminary implementation of the ocamldep -paths option proposed in discussion about the support of -no-alias-deps in ocamlbuild:
https://sympa.inria.fr/sympa/arc/caml-list/2015-02/msg00021.html

The idea is to return all module paths used in the module (except those that we know for sure are accesses to local modules). If the file uses Foo.Lib.blah, list Foo.Lib instead of just Foo (as the -modules option does).

I would strongly welcome any code review to confirm that the new implementation of ocamldep (which collect all module paths, then later returns only the root module names (as before) if -paths is not given) is equivalent to the previous one (that collected only root module names). I added a small testsuite to make sure no obvious, terrible mistake was done, but I don't think it tests much in term of functionality (if you know a better test case to include in the testsuite, I'm interested).

@darioteixeira
Copy link
Copy Markdown

@gasche: Travis is now complaining about + in the compiler version. I suspect that manual intervention is indeed required for a PR to show up as an OPAM compiler.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Feb 15, 2015

On the other hand, you can easily install any development repository as an opam switch by using my script opam-compiler-conf. Once it is in your $PATH somewhere:

git clone https://github.com/gasche/ocaml
cd ocaml
git checkout ocamldep-paths 
opam compiler-conf configure
make world.opt
opam compiler-conf install

(That is, of course, less convenient than the semi-official switches if you want other users to test it.)

@darioteixeira
Copy link
Copy Markdown

Yes, there's always the manual option, but OPAM has spoiled me... ;-)
I don't know who's in charge of blessing a new OPAM switch -- @avsm perhaps?

@darioteixeira
Copy link
Copy Markdown

I've adapted libfoobar to use OCamldep's new -paths option. It works as expected, though this is a very simple example.

I would like to take a shot at porting the more realistic Lambdoc oasification branch, though since many of its dependencies do not compile out-of-the-box with 4.03, it may take a while. (Alternatively, I may opt to complexify Libfoobar, mimicking the structure of Lambdoc but without introducing any external dependencies.)

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Feb 16, 2015

It should be trivial to backport the patch to the 4.02.1 branch to test on your code. Just ask if there is a conflict I can't think of right now, or if you don't feel comfortable enough with git to do it yourself.

@damiendoligez
Copy link
Copy Markdown
Member

@darioteixeira about the Travis build, that is/was a bug in OPAM, which should be fixed now (see OPAM#1999).

@avsm
Copy link
Copy Markdown
Member

avsm commented Feb 17, 2015

I've just uploaded new PPA snapshots of OPAM 1.2.1dev, so I'll submit a pull request to OCaml's Travis setup to use them once they've uploaded. That should fix the CI here.

@gasche gasche mentioned this pull request Mar 11, 2015
@darioteixeira
Copy link
Copy Markdown

Just an update on my progress on this front:

Instead of backporting the compiler changes to 4.02.1 or complexifying libfoobar, in the end I've opted for a different solution to test -paths in a "real" project: I took the oasification branch of Lambdoc and pruned away the bits that had external dependencies not compilable with 4.03. The resulting ocamldep-paths branch is mutilated and disfunctional, but that hardly matters since we just need it for testing the build system.

Anyway, though compilation from scratch works. Incremental compilation sometimes fails with an "inconsistent assumptions" error. This means there are still some corner cases I haven't considered and I'll have to take a closer look.

In related news, I went for a mixed approach in the oasification branch proper: I use module aliases and no-alias-deps only for referring to "packs" below on the dependency hierarchy. Within each hierarchical level I don't rely on this mechanism, which means the code compiles fine on 4.02 without any special tricks to avoid circular dependencies. Though this approach requires declaring module aliases on each module for intra-hierarchy references and is thus a bit more cumbersome, it's not too cumbersome because shortcuts can be used for inter-hierarchy references. It's not perfect, but it does have the advantage of being straightforward to understand and not requiring any dirty tricks postprocessing the output of OCamldep.

@darioteixeira
Copy link
Copy Markdown

Just a heads-up: the oasification branch of Lambdoc is the new master, and I've deleted the old branch.

@damiendoligez
Copy link
Copy Markdown
Member

I've relaunched the Travis build but it's still failing and I don't understand why.

@bobot bobot mentioned this pull request Nov 10, 2015
@damiendoligez damiendoligez added this to the 4.04-or-later milestone Jan 25, 2016
@damiendoligez damiendoligez removed this from the 4.04 milestone Aug 3, 2016
@mshinwell
Copy link
Copy Markdown
Contributor

@gasche Can you please decide what to do with this one? It's been unloved for 18 months.

@mshinwell
Copy link
Copy Markdown
Contributor

Still no comment for nearly another 3 months, so closing. This can always be reopened if someone has the time to work on it.

@mshinwell mshinwell closed this Mar 16, 2017
lthls added a commit to lthls/ocaml that referenced this pull request May 28, 2020
lthls added a commit to lthls/ocaml that referenced this pull request Sep 23, 2020
lthls added a commit to lthls/ocaml that referenced this pull request Sep 23, 2020
lthls added a commit to lthls/ocaml that referenced this pull request Sep 24, 2020
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Aug 10, 2021
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Oct 5, 2021
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
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.

5 participants