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

Fix workspace lookup in conjunction with --root #997

Merged
merged 7 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
next
----

- Fix lookup of command line specified files when `--root` is given. Previously,
passing in `--root` in conjunction with `--workspace` or `--config` would not
work correctly (#997, @rgrinberg)

1.0.0 (10/07/2018)
------------------

Expand Down
43 changes: 33 additions & 10 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,39 @@ open Fiber.O
bootstrap, so we set this reference here *)
let () = suggest_function := Cmdliner_suggest.value

module Arg = struct
include Arg

let package_name =
Arg.conv ((fun p -> Ok (Package.Name.of_string p)), Package.Name.pp)

module Path : sig
type t
val path : t -> Path.t
val arg : t -> string

val conv : t conv
end = struct
type t = string

let path p = Path.of_filename_relative_to_initial_cwd p
let arg s = s

let conv = Arg.conv ((fun p -> Ok p), Format.pp_print_string)
end

let path = Path.conv
Copy link

Choose a reason for hiding this comment

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

Can we have let file = path as well? Just to make sure we don't use the wrong thing

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


[@@@ocaml.warning "-32"]
let file = path
end

type common =
{ debug_dep_path : bool
; debug_findlib : bool
; debug_backtraces : bool
; profile : string option
; workspace_file : string option
; workspace_file : Arg.Path.t option
; root : string
; target_prefix : string
; only_packages : Package.Name.Set.t option
Expand Down Expand Up @@ -83,8 +110,7 @@ module Main = struct
let setup ~log ?external_lib_deps_mode common =
setup
~log
?workspace_file:(
Option.map common.workspace_file ~f:Path.of_string)
?workspace_file:(Option.map ~f:Arg.Path.path common.workspace_file)
?only_packages:common.only_packages
?external_lib_deps_mode
?x:common.x
Expand Down Expand Up @@ -186,9 +212,6 @@ let find_root () =
in
(dir, to_cwd)

let package_name =
Arg.conv ((fun p -> Ok (Package.Name.of_string p)), Package.Name.pp)

let common_footer =
`Blocks
[ `S "BUGS"
Expand Down Expand Up @@ -255,7 +278,7 @@ let common =
let orig_args =
List.concat
[ dump_opt "--profile" profile
; dump_opt "--workspace" workspace_file
; dump_opt "--workspace" (Option.map ~f:Arg.Path.arg workspace_file)
; orig
]
in
Expand Down Expand Up @@ -432,7 +455,7 @@ let common =
in
let workspace_file =
Arg.(value
& opt (some file) None
& opt (some path) None
& info ["workspace"] ~docs ~docv:"FILE"
~doc:"Use this specific workspace file instead of looking it up.")
in
Expand Down Expand Up @@ -469,7 +492,7 @@ let common =
let config_file =
let config_file =
Arg.(value
& opt (some file) None
& opt (some path) None
& info ["config-file"] ~docs ~docv:"FILE"
~doc:"Load this configuration file instead of the default one.")
in
Expand All @@ -482,7 +505,7 @@ let common =
let merge config_file no_config =
match config_file, no_config with
| None , false -> `Ok (None , Default)
| Some fn, false -> `Ok (Some "--config-file", This (Path.of_string fn))
| Some fn, false -> `Ok (Some "--config-file", This (Arg.Path.path fn))
| None , true -> `Ok (Some "--no-config" , No_config)
| Some _ , true -> incompatible "--no-config" "--config-file"
in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(lang dune 1.0)

(context (does-not-exist))
(context (default))
3 changes: 1 addition & 2 deletions test/blackbox-tests/test-cases/workspaces/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ analogously, jbuilder will ignore it
specifying the workspace file is possible:

$ dune build --root custom-workspace --workspace custom-workspace/dune-workspace.dev
Error: workspace file custom-workspace/dune-workspace.dev does not exist
[1]
Entering directory 'custom-workspace'

Workspaces let you set custom profiles

Expand Down