Add clean subcommand (#89)
This commit is contained in:
parent
469e1ff744
commit
91d03de221
3
Makefile
3
Makefile
|
@ -22,7 +22,8 @@ all-supported-ocaml-versions:
|
||||||
$(BIN) build @install @runtest --workspace jbuild-workspace.dev --root .
|
$(BIN) build @install @runtest --workspace jbuild-workspace.dev --root .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf _build
|
-$(BIN) clean
|
||||||
|
-rm -f ./boot.exe
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
cd doc && sphinx-build . _build
|
cd doc && sphinx-build . _build
|
||||||
|
|
19
bin/main.ml
19
bin/main.ml
|
@ -426,6 +426,24 @@ let runtest =
|
||||||
$ Arg.(value & pos_all string ["."] name_))
|
$ Arg.(value & pos_all string ["."] name_))
|
||||||
, Term.info "runtest" ~doc ~man)
|
, Term.info "runtest" ~doc ~man)
|
||||||
|
|
||||||
|
let clean =
|
||||||
|
let doc = "Clean the project." in
|
||||||
|
let man =
|
||||||
|
[ `S "DESCRIPTION"
|
||||||
|
; `P {|Removes files added by jbuilder such as _build, <package>.install, and .merlin|}
|
||||||
|
; `Blocks help_secs
|
||||||
|
]
|
||||||
|
in
|
||||||
|
let go common =
|
||||||
|
begin
|
||||||
|
set_common common ~targets:[];
|
||||||
|
Build_system.all_targets_ever_built () |> List.iter ~f:Path.unlink_no_err;
|
||||||
|
Path.(rm_rf (append root (of_string "_build")))
|
||||||
|
end
|
||||||
|
in
|
||||||
|
( Term.(const go $ common)
|
||||||
|
, Term.info "clean" ~doc ~man)
|
||||||
|
|
||||||
let format_external_libs libs =
|
let format_external_libs libs =
|
||||||
String_map.bindings libs
|
String_map.bindings libs
|
||||||
|> List.map ~f:(fun (name, kind) ->
|
|> List.map ~f:(fun (name, kind) ->
|
||||||
|
@ -776,6 +794,7 @@ let all =
|
||||||
; external_lib_deps
|
; external_lib_deps
|
||||||
; build_targets
|
; build_targets
|
||||||
; runtest
|
; runtest
|
||||||
|
; clean
|
||||||
; install
|
; install
|
||||||
; uninstall
|
; uninstall
|
||||||
; exec
|
; exec
|
||||||
|
|
|
@ -8,6 +8,7 @@ let commands =
|
||||||
; "install"
|
; "install"
|
||||||
; "installed-libraries"
|
; "installed-libraries"
|
||||||
; "runtest"
|
; "runtest"
|
||||||
|
; "clean"
|
||||||
; "uninstall"
|
; "uninstall"
|
||||||
; "exec"
|
; "exec"
|
||||||
; "subst"
|
; "subst"
|
||||||
|
|
|
@ -561,6 +561,13 @@ module Trace = struct
|
||||||
trace
|
trace
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let all_targets_ever_built () =
|
||||||
|
if Sys.file_exists Trace.file then
|
||||||
|
let trace = Trace.load () in
|
||||||
|
Hashtbl.fold trace ~init:[] ~f:(fun ~key ~data:_ acc -> key :: acc)
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
|
||||||
let create ~contexts ~file_tree ~rules =
|
let create ~contexts ~file_tree ~rules =
|
||||||
let all_source_files =
|
let all_source_files =
|
||||||
File_tree.fold file_tree ~init:Pset.empty ~f:(fun dir acc ->
|
File_tree.fold file_tree ~init:Pset.empty ~f:(fun dir acc ->
|
||||||
|
|
|
@ -61,3 +61,7 @@ val build_rules
|
||||||
-> ?recursive:bool (* default false *)
|
-> ?recursive:bool (* default false *)
|
||||||
-> Path.t list
|
-> Path.t list
|
||||||
-> Rule.t list Future.t
|
-> Rule.t list Future.t
|
||||||
|
|
||||||
|
val all_targets_ever_built
|
||||||
|
: unit
|
||||||
|
-> Path.t list
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
open Import
|
open Import
|
||||||
|
|
||||||
(** In the current worksapce (anything under the current project root) *)
|
(** In the current workspace (anything under the current project root) *)
|
||||||
module Local : sig
|
module Local : sig
|
||||||
type t
|
type t
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue