PR#6733: ocamlbuild .{byte,native}.so targets and runtime_variant(X) flag

(Peter Zotov)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16105 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Gabriel Scherer 2015-05-10 05:51:25 +00:00
parent 691aabb723
commit 65bb607cd7
5 changed files with 40 additions and 1 deletions

View File

@ -179,6 +179,11 @@ OCamlbuild:
(Peter Zotov)
- PR#6720: pass -g to C compilers when tag 'debug' is set
(Peter Zotov, Gabriel Scherer)
- PR#6733: add .byte.so and .native.so targets to pass
-output-obj -cclib -shared.
(Peter Zotov)
- PR#6733: "runtime_variant(X)" to pass -runtime-variant X option.
(Peter Zotov)
- PR#6774: new menhir-specific flags "only_tokens" and "external_tokens(Foo)"
(François Pottier)

View File

@ -156,7 +156,7 @@ let byte_compile_ocaml_interf mli cmi env build =
let compile_ocaml_interf mli cmi env build =
let mli = env mli and cmi = env cmi in
prepare_compile build mli;
let tags = tags_of_pathname mli++"interf" in
let tags = tags_of_pathname mli++"interf" in
let comp_c = if Tags.mem "native" tags then ocamlopt_c else ocamlc_c in
comp_c tags mli cmi
@ -266,6 +266,9 @@ let byte_link = byte_link_gen ocamlc_link_prog
let byte_output_obj = byte_link_gen ocamlc_link_prog
(fun tags -> tags++"ocaml"++"link"++"byte"++"output_obj")
let byte_output_shared = byte_link_gen ocamlc_link_prog
(fun tags -> tags++"ocaml"++"link"++"byte"++"output_obj"++"output_shared")
let byte_library_link = byte_link_gen byte_lib_linker byte_lib_linker_tags
let byte_debug_link_gen =
@ -286,6 +289,9 @@ let native_link x = native_link_gen ocamlopt_link_prog
let native_output_obj x = native_link_gen ocamlopt_link_prog
(fun tags -> tags++"ocaml"++"link"++"native"++"output_obj") x
let native_output_shared x = native_link_gen ocamlopt_link_prog
(fun tags -> tags++"ocaml"++"link"++"native"++"output_obj"++"output_shared") x
let native_library_link x =
native_link_gen native_lib_linker native_lib_linker_tags x

View File

@ -43,11 +43,13 @@ val link_gen :
string -> string -> Rule.action
val byte_link : string -> string -> Rule.action
val byte_output_obj : string -> string -> Rule.action
val byte_output_shared : string -> string -> Rule.action
val byte_library_link : string -> string -> Rule.action
val byte_debug_link : string -> string -> Rule.action
val byte_debug_library_link : string -> string -> Rule.action
val native_link : string -> string -> Rule.action
val native_output_obj : string -> string -> Rule.action
val native_output_shared : string -> string -> Rule.action
val native_library_link : string -> string -> Rule.action
val native_shared_library_link : ?tags:(string list) -> string -> string -> Rule.action
val native_profile_link : string -> string -> Rule.action

View File

@ -61,7 +61,9 @@ let x_p_dll = "%.p"-.-ext_dll;;
(* -output-obj targets *)
let x_byte_c = "%.byte.c";;
let x_byte_o = "%.byte"-.-ext_obj;;
let x_byte_so = "%.byte"-.-ext_dll;;
let x_native_o = "%.native"-.-ext_obj;;
let x_native_so = "%.native"-.-ext_dll;;
rule "target files"
~dep:"%.itarget"
@ -221,6 +223,15 @@ rule "ocaml: cmo* -> byte.c"
~dep:"%.cmo"
(Ocaml_compiler.byte_output_obj "%.cmo" x_byte_c);;
rule "ocaml: cmo* -> byte.(so|dll|dylib)"
~prod:x_byte_so
~dep:"%.cmo"
~doc:"The foo.byte.so target, or foo.byte.dll under Windows, \
or foo.byte.dylib under Mac OS X will produce a shared library file
by passing the -output-obj and -cclib -shared options \
to the OCaml compiler. See also foo.native.{so,dll,dylib}."
(Ocaml_compiler.byte_output_shared "%.cmo" x_byte_so);;
rule "ocaml: p.cmx* & p.o* -> p.native"
~prod:"%.p.native"
~deps:["%.p.cmx"; x_p_o]
@ -239,6 +250,11 @@ rule "ocaml: cmx* & o* -> native.(o|obj)"
~deps:["%.cmx"; x_o]
(Ocaml_compiler.native_output_obj "%.cmx" x_native_o);;
rule "ocaml: cmx* & o* -> native.(so|dll|dylib)"
~prod:x_native_so
~deps:["%.cmx"; x_o]
(Ocaml_compiler.native_output_shared "%.cmx" x_native_so);;
rule "ocaml: mllib & d.cmo* -> d.cma"
~prod:"%.d.cma"
~dep:"%.mllib"
@ -639,6 +655,8 @@ let () =
(fun param -> S [A "-open"; A param]);
pflag ["ocaml"; "compile"] "open"
(fun param -> S [A "-open"; A param]);
pflag ["ocaml"; "link"] "runtime_variant"
(fun param -> S [A "-runtime-variant"; A param]);
()
let camlp4_flags camlp4s =
@ -693,6 +711,7 @@ flag ["c"; "debug"; "compile"] (A "-g");
flag ["c"; "debug"; "link"] (A "-g");
flag ["ocaml"; "link"; "native"; "output_obj"] (A"-output-obj");;
flag ["ocaml"; "link"; "byte"; "output_obj"] (A"-output-obj");;
flag ["ocaml"; "link"; "output_shared"] & (S[A"-cclib"; A"-shared"]);;
flag ["ocaml"; "dtypes"; "compile"] (A "-dtypes");;
flag ["ocaml"; "annot"; "compile"] (A "-annot");;
flag ["ocaml"; "annot"; "pack"] (A "-annot");;

View File

@ -160,6 +160,13 @@ let () = test "OutputObj"
~tree:[T.f "hello.ml" ~content:"print_endline \"Hello, World!\""]
~targets:("hello.byte.o",["hello.byte.c";"hello.native.o"]) ();;
let () = test "OutputShared"
~options:[`no_ocamlfind]
~description:"output_shared targets for native and bytecode (PR #6733)"
~tree:[T.f "hello.ml" ~content:"print_endline \"Hello, World!\"";
T.f "_tags" ~content:"<*.so>: runtime_variant(_pic)"]
~targets:("hello.byte.so",["hello.native.so"]) ();;
let () = test "StrictSequenceFlag"
~options:[`no_ocamlfind; `quiet]
~description:"strict_sequence tag"