Skip to content
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

Implement #427 #472

Closed
wants to merge 2 commits into from
Closed

Implement #427 #472

wants to merge 2 commits into from

Conversation

hnrgrgr
Copy link
Contributor

@hnrgrgr hnrgrgr commented Feb 1, 2018

No description provided.

@@ -12,8 +12,7 @@
(alias
((name runtest)
(deps (tests.mlt
(glob_files ${SCOPE_ROOT}/src/*.cmi)
(glob_files ${SCOPE_ROOT}/vendor/re/*.cmi)
(glob_files ${SCOPE_ROOT}/src/.jbuilder.objs/*.cmi)
Copy link
Collaborator

@bobot bobot Feb 1, 2018

Choose a reason for hiding this comment

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

Since writters of dune files needs to know about the location of the files we need to document it. However it could complicate automatic dune file migration if in a new version of the format/tool we change the destination directory. Is it really problematic? What are the solutions?

I would propose to export in some way the lib_obj_dir function if we had a syntax for calling builtin function: (glob_files ${lib_obj_dir ${SCOPE_ROOT}/src/ jbuilder}/*.cmi}). And it is even more complicated with private module. So perhaps a better possibility: (glob_cms ${SCOPE_ROOT}/src jbuilder *.cmi) which would also match the private directory if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the compatibility with current dune files, I just pushed a second patch where bar.cmi is a symlink towars .foo.objs/bar.cmi. But this is probably better to export a lib_obj_dir or glob_cms.

Copy link

Choose a reason for hiding this comment

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

We already have an alias to denote all the cmY files of a library, we could just document it.

But there are also users who are calling jbuilder build src/blah.cmo directly (this was mentioned in some ticket recently), so in any case the symlink method seems good for now.

| Cmi | Cmo -> extra_targets
| Cmx ->
Path.change_extension ~ext:ctx.ext_obj (Module.cm_file m ~obj_dir Cmx) :: extra_targets,
Path.change_extension ~ext:ctx.ext_obj (Module.cm_file m ~obj_dir:dir Cmx) :: extra_symlinks
Copy link

Choose a reason for hiding this comment

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

What about Module.obj_file ~obj_dir ~ext:ctx.ext_obj?

in
let old_dst = Module.cm_file m ~obj_dir:dir cm_kind in
if obj_dir <> dir then begin
SC.add_rule sctx ?sandbox (Build.symlink ~src:dst ~dst:old_dst) ;
Copy link

Choose a reason for hiding this comment

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

You can remove the ?sandbox for symlinks

in
let old_dst = Module.cm_file m ~obj_dir:dir cm_kind in
Copy link

Choose a reason for hiding this comment

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

This should do inside the if obj_dir ...

if obj_dir <> dir then begin
SC.add_rule sctx ?sandbox (Build.symlink ~src:dst ~dst:old_dst) ;
List.iter2 extra_targets extra_symlinks ~f:(fun src dst ->
SC.add_rule sctx ?sandbox (Build.symlink ~src ~dst))
Copy link

Choose a reason for hiding this comment

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

Instead of carefully building the two lists symmetrically, what about just building the list of targets as a string list (it would just be the filenames), then at the end we do:

let targets  = List.map target_filenames ~f:(Path.relative ~dir:obj_dir) in
let symlinks = List.map target_filenames ~f:(Path.relative ~dir) in
...

@@ -12,8 +12,7 @@
(alias
((name runtest)
(deps (tests.mlt
(glob_files ${SCOPE_ROOT}/src/*.cmi)
(glob_files ${SCOPE_ROOT}/vendor/re/*.cmi)
(glob_files ${SCOPE_ROOT}/src/.jbuilder.objs/*.cmi)
Copy link

Choose a reason for hiding this comment

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

We already have an alias to denote all the cmY files of a library, we could just document it.

But there are also users who are calling jbuilder build src/blah.cmo directly (this was mentioned in some ticket recently), so in any case the symlink method seems good for now.

@ghost
Copy link

ghost commented Feb 2, 2018

I'm a bit puzzled by the build error of Camomile on OSX:

      ocamlc Camomile/.camomile.objs/uChar.{cmo,cmt} (exit 2)
(cd _build/default && /Users/travis/ocaml/bin/ocamlc.opt
  -I Camomile -w -40 -g -bin-annot
  -I /Users/travis/ocaml/lib/ocaml -no-alias-deps
  -I Camomile/.camomile.objs
  -o Camomile/.camomile.objs/uChar.cmo
  -c -impl Camomile/uChar.ml)
File "Camomile/uChar.ml", line 1:
Error: Wrong file naming: /Users/travis/ocaml/lib/ocaml/uChar.cmi
contains the compiled interface for 
Uchar when UChar was expected

the compiler seems to be picking up the wrong cmi file

@ghost
Copy link

ghost commented Feb 2, 2018

jbuilder rules _build/default/Camomile/.camomile.objs/uChar.cmo might be useful to debug the actual rule that's generated

@ghost
Copy link

ghost commented Feb 6, 2018

I had a look at the Camomile build failure. I looked at the compiler code and when typing <file>.ml, the compiler looks for <module-name>.cmi in the load path. I would have thought that it would just derive the cmi filename from the -o option but no....

I guess the change of include paths somehow disturb this lookup. Sometimes we pass -I <stdlib-dir>, and filtering it out solves the issue. I'll create a PR to do this change.

@ghost ghost mentioned this pull request Feb 6, 2018
@ghost
Copy link

ghost commented Feb 7, 2018

The code has changed quite a bit and I realize it's not really fair to ask you to do the rebase work since I asked you about this in the first place, so I'm going to rebase and merge this feature manually.

@ghost
Copy link

ghost commented Feb 7, 2018

I manually merged this in master. The main change I did was to store artifacts of executables in a separate directory as well. I used .<first-executable-name>.eobjs for the object directory name.

@ghost ghost closed this Feb 7, 2018
This pull request was closed.
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.

2 participants