Add a -p/--for-release-of-packages command line argument

`-p pkgs` is the equivalent of `--root . --only-packages pkgs`
This commit is contained in:
Jeremie Dimino 2017-04-04 16:56:14 +01:00 committed by Jérémie Dimino
parent eb68c98f01
commit 72550dc3e0
3 changed files with 39 additions and 8 deletions

View File

@ -110,7 +110,6 @@ let help_secs =
let common = let common =
let make let make
concurrency concurrency
only_packages
debug_rules debug_rules
debug_actions debug_actions
debug_dep_path debug_dep_path
@ -118,7 +117,7 @@ let common =
dev_mode dev_mode
verbose verbose
workspace_file workspace_file
root (root, only_packages)
= =
let root, to_cwd = let root, to_cwd =
match root with match root with
@ -209,13 +208,42 @@ let common =
& opt (some dir) None & opt (some dir) None
& info ["root"] ~docs ~docv:"DIR" & info ["root"] ~docs ~docv:"DIR"
~doc:{|Use this directory as workspace root instead of guessing it. ~doc:{|Use this directory as workspace root instead of guessing it.
Note that this option doesn't change the interpretation of Note that this option doesn't change the interpretation of
targets given on the command line. It is only intended targets given on the command line. It is only intended
for scripts.|}) for scripts.|})
in in
let for_release = "for-release-of-packages" in
let frop =
Arg.(value
& opt (some string) None
& info ["p"; for_release] ~docs ~docv:"PACKAGES"
~doc:{|Shorthand for $(b,--root . --only-packages PACKAGE).|})
in
let root_and_only_packages =
let merge root only_packages release =
match release, root, only_packages with
| Some _, Some _, _ ->
`Error (true,
sprintf
"Cannot use %s and --root simultaneously"
for_release)
| Some _, _, Some _ ->
`Error (true,
sprintf
"Cannot use %s and --only-packages simultaneously"
for_release)
| Some pkgs, None, None ->
`Ok (Some ".", Some pkgs)
| None, _, _ ->
`Ok (root, only_packages)
in
Term.(ret (const merge
$ root
$ only_packages
$ frop))
in
Term.(const make Term.(const make
$ concurrency $ concurrency
$ only_packages
$ drules $ drules
$ dactions $ dactions
$ ddep_path $ ddep_path
@ -223,7 +251,7 @@ let common =
$ dev $ dev
$ verbose $ verbose
$ workspace_file $ workspace_file
$ root $ root_and_only_packages
) )
let installed_libraries = let installed_libraries =

View File

@ -1178,9 +1178,12 @@ You should set the =build:= field of your =<package>.opam= file as
follows: follows:
#+begin_src #+begin_src
build: [["jbuilder" "build" "--only-packages" "<package>" "--root" "." "-j" jobs "@install"]] build: [["jbuilder" "build" "-p" "<package>" "-j" jobs]]
#+end_src #+end_src
=-p pkg= is a shorthand for =--root . --only-packages pkg=. =-p= is
the short version of =--for-release-of-packages=.
This has the following effects: This has the following effects:
- it tells jbuilder to build everything that is installable and to - it tells jbuilder to build everything that is installable and to
ignore packages other than =<package>= defined in your project ignore packages other than =<package>= defined in your project

View File

@ -24,7 +24,7 @@ let setup ?(log=Log.no_log) ?filter_out_optional_stanzas_with_missing_deps
String_set.iter set ~f:(fun pkg -> String_set.iter set ~f:(fun pkg ->
if not (String_map.mem pkg conf.packages) then if not (String_map.mem pkg conf.packages) then
die "@{<error>Error@}: I don't know about package %s \ die "@{<error>Error@}: I don't know about package %s \
(passed through --only-packages)%s" (passed through --only-packages/--release)%s"
pkg (hint pkg (String_map.keys conf.packages)))); pkg (hint pkg (String_map.keys conf.packages))));
let workspace = let workspace =
match workspace with match workspace with