Skip to content

Commit

Permalink
#26 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakadu committed Mar 16, 2012
1 parent d8417c0 commit ea40c0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 6 additions & 3 deletions bin/brb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ open Common


let () =
let only_deps = ref false and force_build = ref false in
let only_deps = ref false and force_build = ref false and dont_clear_tmp = ref true in
let specs = [("--only-deps", Arg.Set only_deps,
"Act on dependencies only, ignoring project sources");
("--force", Arg.Set force_build,
"Force build, even if the '_dep' directory already exists")]
"Force build, even if the '_dep' directory already exists");
("--dont-clear-tmp", Arg.Set dont_clear_tmp,
"Don't remove sources of successfully builded dependencies")]
in

let scmd = SubCommand.make
~name:"build"
~synopsis:"Build the project in the current directory"
~help:("Assumes that '_dep' directory doesn't exist or contains\n" ^
"*already* built dependencies, listed in 'brb.conf'.")
(fun () -> Barbra.build ~only_deps:!only_deps ~force_build:!force_build)
(fun () -> Barbra.build ~clear_tmp:(not !dont_clear_tmp)
~only_deps:!only_deps ~force_build:!force_build)
in SubCommand.(register { scmd with specs = specs })
and () = SubCommand.register & SubCommand.make
~name:"clean"
Expand Down
15 changes: 8 additions & 7 deletions src/barbra.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ include Global

(* Internal. *)

let build_deps = let rec go = function
let build_deps ?(clear_tmp=true) =
let rec go = function
| [] -> Log.info "Dependencies built successfully!"
| ({ name; package; _ } as dep) :: conf ->
let go_temp_dir project_path =
Expand Down Expand Up @@ -61,10 +62,10 @@ let build_deps = let rec go = function
~patches:dep.patches
in

Log.info "Removing successfully built %S" project_path;
(* Note(gds): Kakadu recommends to allow user to decide:
remove bundled temporary files or not. *)
let () = Fs_util.remove_directory_recursive project_path in
let () = if clear_tmp then (
Log.info "Removing successfully built %S" project_path;
Fs_util.remove_directory_recursive project_path
) in
go & { dep with package = Installed } :: conf
| Installed | Recipe _ ->
go conf
Expand All @@ -88,12 +89,12 @@ let cleanup () =
if Filew.is_directory dep_dir then
Fs_util.remove_directory_recursive dep_dir

let build ~only_deps ~force_build =
let build ?(clear_tmp=true) ~only_deps ~force_build =
let open Config in
let { deps; _ } = resolve (from_file (base_dir </> brb_conf)) in
if not (Filew.is_directory dep_dir) || force_build then begin
cleanup ();
build_deps deps;
build_deps ~clear_tmp deps;
if not only_deps then
build_project ()
end
Expand Down

0 comments on commit ea40c0a

Please sign in to comment.