Skip to content

melange: interpret melc --where as a list of :-separated paths - #7176

Merged
rgrinberg merged 3 commits into
ocaml:mainfrom
anmonteiro:anmonteiro/merlin-melangelib
Feb 28, 2023
Merged

rgrinberg merged 3 commits into
ocaml:mainfrom
anmonteiro:anmonteiro/merlin-melangelib

Conversation

@anmonteiro

@anmonteiro anmonteiro commented Feb 24, 2023 •

Copy link
Copy Markdown
Collaborator

@anmonteiro
anmonteiro force-pushed the anmonteiro/merlin-melangelib branch from cfd1f55 to b19396f Compare February 24, 2023 06:55
@Alizter

Alizter commented Feb 24, 2023

Copy link
Copy Markdown
Collaborator

On cygwin will this be ; separated? For OCAMLPATH (and COQPATH) this is the case.

@anmonteiro

Copy link
Copy Markdown
Collaborator Author

That's a good idea. I'll change it

@rgrinberg rgrinberg added the melange Melange rules and generator label Feb 24, 2023
@anmonteiro
anmonteiro force-pushed the anmonteiro/merlin-melangelib branch from b19396f to 8925ad6 Compare February 24, 2023 19:01
@anmonteiro

Copy link
Copy Markdown
Collaborator Author

Changed to use Bin.path_sep.

@rgrinberg

Copy link
Copy Markdown
Member

I think you'd be better off just using ; everywhere.

@anmonteiro

Copy link
Copy Markdown
Collaborator Author

I think you'd be better off just using ; everywhere.

Why is that?

I think I'd prefer to stick to the PATH variable convention to avoid surprises.

@rgrinberg

Copy link
Copy Markdown
Member

To me, the bigger surprise is varying the path separator depending on the platform. In any case, it's just a suggestion.

in
Option.map
~f:(fun dirs ->
String.split ~on:Bin.path_sep dirs |> List.map ~f:Path.of_string)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this is a relative path, is it clear what it should be relative to?

@anmonteiro anmonteiro Feb 24, 2023 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Melange interprets it relative to the melc executable. But it shouldn't really be a relative path. That's a fallback mechanism.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

perhaps I should clarify: the result of melc --where is guaranteed to be an absolute path. So I believe dune doesn't have to worry about it being a relative path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If it can't be a relative path, perhaps the code shouldn't allow it. E.g. Path.External.of_string.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed to a Path.External.t in 44cf928

@anmonteiro
anmonteiro force-pushed the anmonteiro/merlin-melangelib branch from 44cf928 to 310797c Compare February 26, 2023 22:14
@anmonteiro
anmonteiro force-pushed the anmonteiro/merlin-melangelib branch from c29aebb to 9340ec2 Compare February 28, 2023 03:46

@jchavarri jchavarri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Comment on lines +35 to +40
Option.map
~f:(fun dirs ->
String.split ~on:Bin.path_sep dirs
|> List.map ~f:Path.External.of_string)
melange_dirs
|> Option.value ~default:[]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This would be more readable (imo) and consistent with code style above without Option functions:

match melange_dirs with
| None -> []
| Some dirs ->
  String.split ~on:Bin.path_sep dirs
  |> List.map ~f:Path.External.of_string

Comment thread src/dune_rules/merlin/merlin.ml Outdated
let+ dirs = Melange_binary.where sctx ~loc:None ~dir in
match dirs with
| [] -> (None, [])
| [ stdlib_dir ] -> (Some (Path.external_ stdlib_dir), [])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we are converting to Path.t here using external_ in this line and 482 below, would it make sense to just return Path.t list Memo.t from Melange_binary.where directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, Bin.parse_sep doesn't allow external paths either.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I changed it to use Bin.parse_sep.

Comment thread src/dune_rules/merlin/merlin.ml Outdated
match dirs with
| [] -> (None, [])
| [ stdlib_dir ] -> (Some (Path.external_ stdlib_dir), [])
| stdlib_dir :: extra_obj_dirs ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it a little weird that the first directory is being special cased?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree, and it might not necessarily be the stdlib if we're not careful, I think that might not matter though?

_
Signed-off-by: Rudi Grinberg <[email protected]>
@rgrinberg
rgrinberg force-pushed the anmonteiro/merlin-melangelib branch from 42a390c to e6dc5c2 Compare February 28, 2023 20:28
@rgrinberg
rgrinberg merged commit 497c0e3 into ocaml:main Feb 28, 2023
@anmonteiro
anmonteiro deleted the anmonteiro/merlin-melangelib branch February 28, 2023 20:37
jchavarri added a commit to jchavarri/dune that referenced this pull request Nov 15, 2023
* main: (56 commits)
  feature: add terminal ui backend based on NoTTY (ocaml#6996)
  doc(coq): update documentation about coqdep
  fix(rules): don't descend into automatic subdirs infinitely (ocaml#7208)
  benchmark: add warm run (ocaml#7198)
  test: vendored and public libs (ocaml#7197)
  test: use sh in concurrent test (ocaml#7205)
  fix: custom log file path (ocaml#7200)
  test(melange): add test exercising ocaml#7104 (ocaml#7204)
  test(melange): add a test that introduces rules in the target dir (ocaml#7196)
  test: duplicate packages in vendor dir (ocaml#7194)
  melange: interpret `melc --where` as a list of `:`-separated paths (ocaml#7176)
  perf: add synthetic benchmark (ocaml#7189)
  Test case for bug report (ocaml#6725)
  Add test illustrating ocaml#6575 (ocaml#6576)
  chore: add rule streaming proposal (ocaml#7195)
  test(stdlib): merge wrapped/unwrapped tests
  test: move all stdlib tests
  fix: allow unwrapped libraries with `(stdlib ..)`
  test: demonstrate crash in modules.ml when `(stdlib .. )` used with `(wrapped false)`
  fix(install): respect display options (ocaml#7116)
  ...
@Alizter Alizter added this to the 3.8.0 milestone Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

melange Melange rules and generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants