diff --git a/bin/jbuild b/bin/jbuild index 13db3926..025dbff1 100644 --- a/bin/jbuild +++ b/bin/jbuild @@ -3,8 +3,6 @@ (libraries (unix jbuilder jbuilder_cmdliner)) (preprocess no_preprocessing))) -(provides (jbuilder (file main.exe))) - (install ((section bin) (files ((main.exe as jbuilder))))) diff --git a/src/artifacts.ml b/src/artifacts.ml index 6e7a015c..bfddaa88 100644 --- a/src/artifacts.ml +++ b/src/artifacts.ml @@ -44,7 +44,7 @@ let create context stanzas = let binary t name = if String_set.mem name t.local_bins then - Ok (Path.relative (Config.local_install_dir ~context:t.context.name) name) + Ok (Path.relative (Config.local_install_bin_dir ~context:t.context.name) name) else match String_map.find name t.provides with | Some p -> Ok p @@ -60,8 +60,8 @@ let binary t name = let file_of_lib ?(use_provides=false) t ~lib ~file = if String_set.mem lib t.local_libs then let lib_install_dir = - Path.relative (Config.local_install_dir ~context:t.context.name) - (Findlib.root_package_name lib) + Config.local_install_lib_dir ~context:t.context.name + ~package:(Findlib.root_package_name lib) in Ok (Path.relative lib_install_dir file) else diff --git a/src/artifacts.mli b/src/artifacts.mli index 67fc07ca..fa303fec 100644 --- a/src/artifacts.mli +++ b/src/artifacts.mli @@ -1,8 +1,3 @@ -(** [Named_artifact] provides a way to reference artifacts in jbuild rules without having - to hardcode their exact locations. These named artifacts will be looked up - appropriately (in the tree, or for the public release, possibly in the PATH or in - findlib). *) - open! Import type t diff --git a/src/build.ml b/src/build.ml index 4542699a..eb9d523a 100644 --- a/src/build.ml +++ b/src/build.ml @@ -294,7 +294,19 @@ let symlink ~src ~dst = else path src >>> create_file ~target:dst (fun () -> - Unix.symlink (Path.to_string src) (Path.to_string dst)) + let src = + if Path.is_root dst then + Path.to_string src + else + Path.reach ~from:(Path.parent dst) src + in + let dst = Path.to_string dst in + begin + match Unix.lstat dst with + | exception _ -> () + | _ -> Sys.remove dst + end; + Unix.symlink src dst) let touch target = create_file ~target (fun _ -> diff --git a/src/config.ml b/src/config.ml index 7e01ed50..2697ee1d 100644 --- a/src/config.ml +++ b/src/config.ml @@ -1,5 +1,13 @@ open! Import let local_install_dir = - let dir = Path.(relative root) "install" in + let dir = Path.(relative root) "_build/install" in fun ~context -> Path.relative dir context + +let local_install_bin_dir ~context = + Path.relative (local_install_dir ~context) "bin" + +let local_install_lib_dir ~context ~package = + Path.relative + (Path.relative (local_install_dir ~context) "lib") + package diff --git a/src/config.mli b/src/config.mli index 073ef3d6..c7d7f39a 100644 --- a/src/config.mli +++ b/src/config.mli @@ -4,3 +4,6 @@ open! Import (** Local installation directory *) val local_install_dir : context:string -> Path.t + +val local_install_bin_dir : context:string -> Path.t +val local_install_lib_dir : context:string -> package:string -> Path.t diff --git a/src/jbuild_types.ml b/src/jbuild_types.ml index d608d82c..d2e88e07 100644 --- a/src/jbuild_types.ml +++ b/src/jbuild_types.ml @@ -576,7 +576,7 @@ module Rule = struct (Chdir (str "${ROOT}", Run (str "${bin:ocamllex}", - [str "-q"; str "-o"; str dst; str src]))) + [str "-q"; str "-o"; str "${@}"; str "${<}"]))) }) let ocamllex_vjs = ocamllex_v1 @@ -592,7 +592,7 @@ module Rule = struct (Chdir (str "${ROOT}", Run (str "${bin:ocamlyacc}", - [str src]))) + [str "${<}"]))) }) let ocamlyacc_vjs = ocamlyacc_v1 diff --git a/src/main.ml b/src/main.ml index c512def2..8312f6fb 100644 --- a/src/main.ml +++ b/src/main.ml @@ -85,6 +85,9 @@ let report_error ?(map_fname=fun x->x) ppf exn ~backtrace = Description: %s\n\ Backtrace:\n\ %s" msg bt + | Unix.Unix_error (err, func, fname) -> + Format.fprintf ppf "@{Error@}: %s: %s: %s\n" + func fname (Unix.error_message err) | _ -> let s = Printexc.to_string exn in let bt = Printexc.raw_backtrace_to_string backtrace in @@ -121,8 +124,9 @@ let bootstrap () = let main () = let anon s = raise (Arg.Bad (Printf.sprintf "don't know what to do with %s\n" s)) in Arg.parse - [ "-j" , Set_int Clflags.concurrency, "JOBS concurrency" - ; "--dev", Set Clflags.dev_mode , " set development mode" + [ "-j" , Set_int Clflags.concurrency, "JOBS concurrency" + ; "--dev" , Set Clflags.dev_mode , " set development mode" + ; "--debug-rules", Set Clflags.debug_rules , " print out rules" ] anon "Usage: boot.exe [-j JOBS] [--dev]\nOptions are:"; Future.Scheduler.go ~log:(create_log ())