Ajout option /link /subsystem:console pour Windows/msvc et meilleur traitement des options /link passees via -ccopt

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7405 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2006-05-09 16:00:36 +00:00
parent b479c352b3
commit 536dfe0d7c
4 changed files with 18 additions and 17 deletions

View File

@ -265,7 +265,7 @@ let call_linker file_list startup_file output_name =
(List.rev_map Ccomp.expand_libname !Clflags.ccobjs))
(Filename.quote runtime_lib)
c_lib
(String.concat " " (List.rev !Clflags.ccopts))
(Ccomp.make_link_options !Clflags.ccopts)
else
Printf.sprintf "%s /out:%s %s %s"
Config.native_partial_linker

View File

@ -464,7 +464,7 @@ let build_custom_runtime prim_name exec_name =
(List.rev_map Ccomp.expand_libname !Clflags.ccobjs))
(Filename.quote (Ccomp.expand_libname "-lcamlrun"))
Config.bytecomp_c_libraries
(String.concat " " (List.rev !Clflags.ccopts))) in
(Ccomp.make_link_options !Clflags.ccopts)) in
(* C compiler doesn't clean up after itself. Note that the .obj
file is created in the current working directory. *)
remove_file

View File

@ -47,19 +47,6 @@ let quote_files lst =
else s
let compile_file name =
match Config.ccomp_type with
| "mrc" ->
let qname = Filename.quote name in
let includes = (Clflags.std_include_dir ()) @ !Clflags.include_dirs
in
let args =
Printf.sprintf " %s %s -i %s"
(String.concat " " (List.rev_map Filename.quote !Clflags.ccopts))
(String.concat "," (List.rev_map Filename.quote includes))
qname
in
command ("mrc " ^ args ^ " -o " ^ qname ^ ".x")
| "cc" | "msvc" ->
command
(Printf.sprintf
"%s -c %s %s %s %s"
@ -69,14 +56,13 @@ let compile_file name =
(List.rev_map (fun dir -> "-I" ^ dir) !Clflags.include_dirs))
(Clflags.std_include_flag "-I")
(Filename.quote name))
| _ -> assert false
let create_archive archive file_list =
Misc.remove_file archive;
let quoted_archive = Filename.quote archive in
match Config.ccomp_type with
"msvc" ->
command(Printf.sprintf "link /lib /nologo /debugtype:cv /out:%s %s"
command(Printf.sprintf "link /lib /nologo /out:%s %s"
quoted_archive (quote_files file_list))
| _ ->
let r1 =
@ -97,3 +83,17 @@ let expand_libname name =
with Not_found ->
libname
end
(* Handling of msvc's /link options *)
let make_link_options optlist =
let rec split linkopts otheropts = function
| [] -> String.concat " " otheropts
^ " /link /subsystem:console "
^ String.concat " " linkopts
| opt :: rem ->
if String.length opt >= 5 && String.sub opt 0 5 = "/link"
then split (String.sub opt 5 (String.length opt - 5) :: linkopts)
otheropts rem
else split linkopts (opt :: otheropts) rem
in split [] [] optlist

View File

@ -20,3 +20,4 @@ val compile_file: string -> int
val create_archive: string -> string list -> int
val expand_libname: string -> string
val quote_files: string list -> string
val make_link_options: string list -> string