Add a --workspace option
This commit is contained in:
parent
ed0e7e3fc3
commit
bad68218b9
3
Makefile
3
Makefile
|
@ -15,6 +15,9 @@ uninstall:
|
||||||
|
|
||||||
reinstall: uninstall reinstall
|
reinstall: uninstall reinstall
|
||||||
|
|
||||||
|
all-supported-ocaml-versions:
|
||||||
|
$(BIN) build @install --workspace jbuild-workspace.dev
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf _build
|
rm -rf _build
|
||||||
|
|
||||||
|
|
54
bin/main.ml
54
bin/main.ml
|
@ -2,22 +2,19 @@ open Jbuilder
|
||||||
open Import
|
open Import
|
||||||
open Jbuilder_cmdliner.Cmdliner
|
open Jbuilder_cmdliner.Cmdliner
|
||||||
|
|
||||||
module Main = Jbuilder.Main
|
|
||||||
|
|
||||||
(* Things in src/ don't depend on cmdliner to speed up the bootstrap, so we set this
|
(* Things in src/ don't depend on cmdliner to speed up the bootstrap, so we set this
|
||||||
reference here *)
|
reference here *)
|
||||||
let () = suggest_function := Jbuilder_cmdliner.Cmdliner_suggest.value
|
let () = suggest_function := Jbuilder_cmdliner.Cmdliner_suggest.value
|
||||||
|
|
||||||
let (>>=) = Future.(>>=)
|
let (>>=) = Future.(>>=)
|
||||||
|
|
||||||
let create_log = Main.create_log
|
|
||||||
|
|
||||||
type common =
|
type common =
|
||||||
{ concurrency: int
|
{ concurrency : int
|
||||||
; debug_rules: bool
|
; debug_rules : bool
|
||||||
; debug_dep_path: bool
|
; debug_dep_path : bool
|
||||||
; debug_findlib: bool
|
; debug_findlib : bool
|
||||||
; dev_mode: bool
|
; dev_mode : bool
|
||||||
|
; workspace_file : string option
|
||||||
}
|
}
|
||||||
|
|
||||||
let set_common c =
|
let set_common c =
|
||||||
|
@ -27,6 +24,15 @@ let set_common c =
|
||||||
Clflags.debug_findlib := c.debug_findlib;
|
Clflags.debug_findlib := c.debug_findlib;
|
||||||
Clflags.dev_mode := c.dev_mode
|
Clflags.dev_mode := c.dev_mode
|
||||||
|
|
||||||
|
module Main = struct
|
||||||
|
include Jbuilder.Main
|
||||||
|
|
||||||
|
let setup common =
|
||||||
|
setup ?workspace_file:common.workspace_file ()
|
||||||
|
end
|
||||||
|
|
||||||
|
let create_log = Main.create_log
|
||||||
|
|
||||||
let copts_sect = "COMMON OPTIONS"
|
let copts_sect = "COMMON OPTIONS"
|
||||||
let help_secs =
|
let help_secs =
|
||||||
[ `S copts_sect
|
[ `S copts_sect
|
||||||
|
@ -38,12 +44,13 @@ let help_secs =
|
||||||
]
|
]
|
||||||
|
|
||||||
let common =
|
let common =
|
||||||
let make concurrency debug_rules debug_dep_path debug_findlib dev_mode =
|
let make concurrency debug_rules debug_dep_path debug_findlib dev_mode workspace_file =
|
||||||
{ concurrency
|
{ concurrency
|
||||||
; debug_rules
|
; debug_rules
|
||||||
; debug_dep_path
|
; debug_dep_path
|
||||||
; debug_findlib
|
; debug_findlib
|
||||||
; dev_mode
|
; dev_mode
|
||||||
|
; workspace_file
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
let docs = copts_sect in
|
let docs = copts_sect in
|
||||||
|
@ -53,7 +60,20 @@ let common =
|
||||||
let ddep_path = Arg.(value & flag & info ["ddep-path"] ~docs) in
|
let ddep_path = Arg.(value & flag & info ["ddep-path"] ~docs) in
|
||||||
let dfindlib = Arg.(value & flag & info ["dfindlib"] ~docs) in
|
let dfindlib = Arg.(value & flag & info ["dfindlib"] ~docs) in
|
||||||
let dev = Arg.(value & flag & info ["dev"] ~docs) in
|
let dev = Arg.(value & flag & info ["dev"] ~docs) in
|
||||||
Term.(const make $ concurrency $ drules $ ddep_path $ dfindlib $ dev)
|
let workspace_file =
|
||||||
|
Arg.(value
|
||||||
|
& opt (some file) None
|
||||||
|
& info ["workspace"] ~docs
|
||||||
|
~doc:"Use this specific workspace file instead of looking it up")
|
||||||
|
in
|
||||||
|
Term.(const make
|
||||||
|
$ concurrency
|
||||||
|
$ drules
|
||||||
|
$ ddep_path
|
||||||
|
$ dfindlib
|
||||||
|
$ dev
|
||||||
|
$ workspace_file
|
||||||
|
)
|
||||||
|
|
||||||
let installed_libraries =
|
let installed_libraries =
|
||||||
let doc = "Print out libraries installed on the system." in
|
let doc = "Print out libraries installed on the system." in
|
||||||
|
@ -84,9 +104,9 @@ let resolve_package_install setup pkg =
|
||||||
| Error () ->
|
| Error () ->
|
||||||
die "Unknown package %s!%s" pkg (hint pkg (String_map.keys setup.packages))
|
die "Unknown package %s!%s" pkg (hint pkg (String_map.keys setup.packages))
|
||||||
|
|
||||||
let build_package pkg =
|
let build_package common pkg =
|
||||||
Future.Scheduler.go ~log:(create_log ())
|
Future.Scheduler.go ~log:(create_log ())
|
||||||
(Main.setup () >>= fun setup ->
|
(Main.setup common >>= fun setup ->
|
||||||
Build_system.do_build_exn setup.build_system
|
Build_system.do_build_exn setup.build_system
|
||||||
[resolve_package_install setup pkg])
|
[resolve_package_install setup pkg])
|
||||||
|
|
||||||
|
@ -95,7 +115,7 @@ let build_package =
|
||||||
let name_ = Arg.info [] ~docv:"PACKAGE-NAME" in
|
let name_ = Arg.info [] ~docv:"PACKAGE-NAME" in
|
||||||
let go common pkg =
|
let go common pkg =
|
||||||
set_common common;
|
set_common common;
|
||||||
build_package pkg
|
build_package common pkg
|
||||||
in
|
in
|
||||||
( Term.(const go
|
( Term.(const go
|
||||||
$ common
|
$ common
|
||||||
|
@ -193,7 +213,7 @@ let build_targets =
|
||||||
let go common targets =
|
let go common targets =
|
||||||
set_common common;
|
set_common common;
|
||||||
Future.Scheduler.go ~log:(create_log ())
|
Future.Scheduler.go ~log:(create_log ())
|
||||||
(Main.setup () >>= fun setup ->
|
(Main.setup common >>= fun setup ->
|
||||||
let targets = resolve_targets setup targets in
|
let targets = resolve_targets setup targets in
|
||||||
Build_system.do_build_exn setup.build_system targets) in
|
Build_system.do_build_exn setup.build_system targets) in
|
||||||
( Term.(const go
|
( Term.(const go
|
||||||
|
@ -207,7 +227,7 @@ let runtest =
|
||||||
let go common dirs =
|
let go common dirs =
|
||||||
set_common common;
|
set_common common;
|
||||||
Future.Scheduler.go ~log:(create_log ())
|
Future.Scheduler.go ~log:(create_log ())
|
||||||
(Main.setup () >>= fun setup ->
|
(Main.setup common >>= fun setup ->
|
||||||
let targets =
|
let targets =
|
||||||
List.map dirs ~f:(fun dir ->
|
List.map dirs ~f:(fun dir ->
|
||||||
let dir = Path.(relative root) dir in
|
let dir = Path.(relative root) dir in
|
||||||
|
@ -243,7 +263,7 @@ let install_uninstall ~what =
|
||||||
set_common common;
|
set_common common;
|
||||||
let opam_installer = opam_installer () in
|
let opam_installer = opam_installer () in
|
||||||
Future.Scheduler.go ~log:(create_log ())
|
Future.Scheduler.go ~log:(create_log ())
|
||||||
(Main.setup () >>= fun setup ->
|
(Main.setup common >>= fun setup ->
|
||||||
let pkgs =
|
let pkgs =
|
||||||
match pkgs with
|
match pkgs with
|
||||||
| [] -> String_map.keys setup.packages
|
| [] -> String_map.keys setup.packages
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
;; Install the following opam switches, copy this file as
|
;; This file is used by `make all-supported-ocaml-versions`
|
||||||
;; jbuild-workspace and run:
|
|
||||||
;;
|
|
||||||
;; $ ./_build/default/bin/main.exe build @install
|
|
||||||
;;
|
|
||||||
;; This will build jbuilder against all these version of OCaml
|
|
||||||
|
|
||||||
(context ((switch 4.02.3)))
|
(context ((switch 4.02.3)))
|
||||||
(context ((switch 4.03.0)))
|
(context ((switch 4.03.0)))
|
||||||
(context ((switch 4.04.0)))
|
(context ((switch 4.04.0)))
|
||||||
|
|
|
@ -13,14 +13,15 @@ let package_install_file { packages; _ } pkg =
|
||||||
| None -> Error ()
|
| None -> Error ()
|
||||||
| Some p -> Ok (Path.relative p.path (p.name ^ ".install"))
|
| Some p -> Ok (Path.relative p.path (p.name ^ ".install"))
|
||||||
|
|
||||||
let setup ?filter_out_optional_stanzas_with_missing_deps ?workspace () =
|
let setup ?filter_out_optional_stanzas_with_missing_deps
|
||||||
|
?workspace ?(workspace_file="jbuild-workspace") () =
|
||||||
let conf = Jbuild_load.load () in
|
let conf = Jbuild_load.load () in
|
||||||
let workspace =
|
let workspace =
|
||||||
match workspace with
|
match workspace with
|
||||||
| Some w -> w
|
| Some w -> w
|
||||||
| None ->
|
| None ->
|
||||||
if Sys.file_exists "jbuild-workspace" then
|
if Sys.file_exists workspace_file then
|
||||||
Workspace.load "jbuild-workspace"
|
Workspace.load workspace_file
|
||||||
else
|
else
|
||||||
{ merlin_context = Some "default"; contexts = [Default] }
|
{ merlin_context = Some "default"; contexts = [Default] }
|
||||||
in
|
in
|
||||||
|
|
|
@ -13,6 +13,7 @@ val package_install_file : setup -> string -> (Path.t, unit) result
|
||||||
val setup
|
val setup
|
||||||
: ?filter_out_optional_stanzas_with_missing_deps:bool
|
: ?filter_out_optional_stanzas_with_missing_deps:bool
|
||||||
-> ?workspace:Workspace.t
|
-> ?workspace:Workspace.t
|
||||||
|
-> ?workspace_file:string
|
||||||
-> unit
|
-> unit
|
||||||
-> setup Future.t
|
-> setup Future.t
|
||||||
val external_lib_deps
|
val external_lib_deps
|
||||||
|
|
Loading…
Reference in New Issue