fix ocamllex/ocamlyacc rules

This commit is contained in:
Jeremie Dimino 2017-03-01 11:27:58 +00:00
parent 6e25a7dfe5
commit c3228ee95e
8 changed files with 36 additions and 16 deletions

View File

@ -3,8 +3,6 @@
(libraries (unix jbuilder jbuilder_cmdliner)) (libraries (unix jbuilder jbuilder_cmdliner))
(preprocess no_preprocessing))) (preprocess no_preprocessing)))
(provides (jbuilder (file main.exe)))
(install (install
((section bin) ((section bin)
(files ((main.exe as jbuilder))))) (files ((main.exe as jbuilder)))))

View File

@ -44,7 +44,7 @@ let create context stanzas =
let binary t name = let binary t name =
if String_set.mem name t.local_bins then 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 else
match String_map.find name t.provides with match String_map.find name t.provides with
| Some p -> Ok p | Some p -> Ok p
@ -60,8 +60,8 @@ let binary t name =
let file_of_lib ?(use_provides=false) t ~lib ~file = let file_of_lib ?(use_provides=false) t ~lib ~file =
if String_set.mem lib t.local_libs then if String_set.mem lib t.local_libs then
let lib_install_dir = let lib_install_dir =
Path.relative (Config.local_install_dir ~context:t.context.name) Config.local_install_lib_dir ~context:t.context.name
(Findlib.root_package_name lib) ~package:(Findlib.root_package_name lib)
in in
Ok (Path.relative lib_install_dir file) Ok (Path.relative lib_install_dir file)
else else

View File

@ -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 open! Import
type t type t

View File

@ -294,7 +294,19 @@ let symlink ~src ~dst =
else else
path src >>> path src >>>
create_file ~target:dst (fun () -> 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 = let touch target =
create_file ~target (fun _ -> create_file ~target (fun _ ->

View File

@ -1,5 +1,13 @@
open! Import open! Import
let local_install_dir = 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 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

View File

@ -4,3 +4,6 @@ open! Import
(** Local installation directory *) (** Local installation directory *)
val local_install_dir : context:string -> Path.t 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

View File

@ -576,7 +576,7 @@ module Rule = struct
(Chdir (Chdir
(str "${ROOT}", (str "${ROOT}",
Run (str "${bin:ocamllex}", Run (str "${bin:ocamllex}",
[str "-q"; str "-o"; str dst; str src]))) [str "-q"; str "-o"; str "${@}"; str "${<}"])))
}) })
let ocamllex_vjs = ocamllex_v1 let ocamllex_vjs = ocamllex_v1
@ -592,7 +592,7 @@ module Rule = struct
(Chdir (Chdir
(str "${ROOT}", (str "${ROOT}",
Run (str "${bin:ocamlyacc}", Run (str "${bin:ocamlyacc}",
[str src]))) [str "${<}"])))
}) })
let ocamlyacc_vjs = ocamlyacc_v1 let ocamlyacc_vjs = ocamlyacc_v1

View File

@ -85,6 +85,9 @@ let report_error ?(map_fname=fun x->x) ppf exn ~backtrace =
Description: %s\n\ Description: %s\n\
Backtrace:\n\ Backtrace:\n\
%s" msg bt %s" msg bt
| Unix.Unix_error (err, func, fname) ->
Format.fprintf ppf "@{<error>Error@}: %s: %s: %s\n"
func fname (Unix.error_message err)
| _ -> | _ ->
let s = Printexc.to_string exn in let s = Printexc.to_string exn in
let bt = Printexc.raw_backtrace_to_string backtrace in let bt = Printexc.raw_backtrace_to_string backtrace in
@ -121,8 +124,9 @@ let bootstrap () =
let main () = let main () =
let anon s = raise (Arg.Bad (Printf.sprintf "don't know what to do with %s\n" s)) in let anon s = raise (Arg.Bad (Printf.sprintf "don't know what to do with %s\n" s)) in
Arg.parse Arg.parse
[ "-j" , Set_int Clflags.concurrency, "JOBS concurrency" [ "-j" , Set_int Clflags.concurrency, "JOBS concurrency"
; "--dev", Set Clflags.dev_mode , " set development mode" ; "--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:"; anon "Usage: boot.exe [-j JOBS] [--dev]\nOptions are:";
Future.Scheduler.go ~log:(create_log ()) Future.Scheduler.go ~log:(create_log ())