Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -urpwN flexdll/Makefile flexdll.new/Makefile
- --- flexdll/Makefile 2008-11-17 10:22:55.000000000 +0100
- +++ flexdll.new/Makefile 2008-11-17 13:24:21.635908700 +0100
- @@ -28,10 +28,10 @@ build_mingw: flexdll_mingw.o flexdll_ini
- OBJS = version.ml coff.ml cmdline.ml flexlink_cmd.ml reloc.ml
- -flexlink.exe: $(OBJS)
- +flexlink.exe: $(OBJS) runprocess.o
- @echo Building flexlink.exe with TOOLCHAIN=$(TOOLCHAIN)
- rm -f flexlink.exe
- - $(OCAMLOPT) -o flexlink.exe $(LINKFLAGS) $(OBJS)
- + $(OCAMLOPT) -o flexlink.exe $(LINKFLAGS) $(OBJS) runprocess.o
- flexdll_msvc.obj: flexdll.h flexdll.c
- $(MSVCC) -c /Fo"flexdll_msvc.obj" flexdll.c
- @@ -45,6 +45,9 @@ flexdll_mingw.o: flexdll.h flexdll.c
- flexdll_initer_mingw.o: flexdll_initer.c
- $(MINCC) -c -o flexdll_initer_mingw.o flexdll_initer.c
- +runprocess.o: runprocess.c
- + $(OCAMLOPT) -I $(shell ocamlc -where) -c -o $@ $<
- +
- flexdll_initer_cygwin.o: flexdll_initer.c
- $(CYGCC) -c -o flexdll_initer_cygwin.o flexdll_initer.c
- diff -urpwN flexdll/reloc.ml flexdll.new/reloc.ml
- --- flexdll/reloc.ml 2008-11-17 10:22:35.000000000 +0100
- +++ flexdll.new/reloc.ml 2008-11-17 13:23:22.900030100 +0100
- @@ -13,6 +13,8 @@
- open Coff
- open Cmdline
- +external run_process : string -> string -> int = "run_process"
- +
- let search_path = ref []
- let default_libs = ref []
- @@ -88,12 +90,13 @@ let build_diversion lst =
- "@" ^ responsefile
- let alternate_cmd_exe = ref false
- +let program = ref ""
- let quote_files use_response_file lst =
- let s =
- String.concat " "
- (List.map (fun f -> if f = "" then f else Filename.quote f) lst) in
- - if String.length s >= 4096 then
- + if String.length s >= 512 then
- if use_response_file then Filename.quote (build_diversion lst)
- else (alternate_cmd_exe := true; s)
- else
- @@ -766,6 +769,7 @@ let build_dll link_exe output_file files
- temp_file "dyndll_implib" ".lib"
- in
- let _impexp = add_temp (Filename.chop_suffix implib ".lib" ^ ".exp") in
- + program := "link";
- Printf.sprintf
- "link /nologo %s%s%s%s%s /implib:%s /out:%s /defaultlib:msvcrt.lib /subsystem:%s %s %s %s"
- (if !verbose >= 2 then "/verbose " else "")
- @@ -786,6 +790,7 @@ let build_dll link_exe output_file files
- files descr
- extra_args
- | `CYGWIN ->
- + program := "gcc";
- Printf.sprintf
- "gcc %s%s -L. %s %s -o %s %s %s %s"
- (if link_exe = `EXE then "" else "-shared ")
- @@ -797,6 +802,7 @@ let build_dll link_exe output_file files
- files
- extra_args
- | `MINGW ->
- + program := "gcc";
- Printf.sprintf
- "gcc -mno-cygwin %s%s -L. %s %s -o %s %s %s %s %s"
- (if link_exe = `EXE then "" else "-shared ")
- @@ -809,6 +815,7 @@ let build_dll link_exe output_file files
- (if !implib then "-Wl,--out-implib=" ^ Filename.quote (Filename.chop_extension output_file ^ ".a") else "")
- extra_args
- | `LIGHTLD ->
- + program := "ld";
- no_merge_manifest := true;
- Printf.sprintf
- "ld %s%s -o %s %s %s %s %s"
- @@ -834,7 +841,7 @@ let build_dll link_exe output_file files
- Unix.putenv "COMSPEC" Sys.executable_name;
- Unix.putenv "FLEXLINK_COMSPEC" "1";
- end;
- - if Sys.command cmd_quiet <> 0 then begin
- + if run_process !program cmd_quiet <> 0 then begin
- if cmd <> cmd_quiet then ignore (Sys.command cmd);
- failwith "Error during linking\n"
- end;
- diff -urpwN flexdll/runprocess.c flexdll.new/runprocess.c
- --- flexdll/runprocess.c 1970-01-01 01:00:00.000000000 +0100
- +++ flexdll.new/runprocess.c 2008-11-17 13:24:14.291970700 +0100
- @@ -0,0 +1,43 @@
- +#include <windows.h>
- +#include <caml/mlvalues.h>
- +#include <caml/fail.h>
- +
- +/* from osdeps.h */
- +extern char * caml_search_exe_in_path(char * name);
- +
- +value run_process(value cmd, value cmdline)
- +{
- + PROCESS_INFORMATION pi;
- + STARTUPINFO si;
- + char * exefile, * envp = NULL;
- + int flags;
- + DWORD status;
- +
- + exefile = search_exe_in_path(String_val(cmd));
- +
- + /* Prepare stdin/stdout/stderr redirection */
- + GetStartupInfo(&si);
- +
- + /* If we do not have a console window, then we must create one
- + before running the process (keep it hidden for apparence).
- + Also one must suppress spurious flags in si.dwFlags.
- + Otherwise the redirections are ignored.
- + If we are starting a GUI application, the newly created
- + console should not matter. */
- + flags = CREATE_NEW_CONSOLE;
- + si.dwFlags = STARTF_USESHOWWINDOW;
- + si.wShowWindow = SW_HIDE;
- + /* Create the process */
- + if (! CreateProcess(exefile, String_val(cmdline), NULL, NULL,
- + TRUE, flags, envp, NULL, &si, &pi)) {
- + failwith("run_process");
- + }
- + WaitForSingleObject( pi.hProcess, INFINITE );
- + if (! GetExitCodeProcess(pi.hProcess, &status)) {
- + failwith("run_process");
- + }
- + CloseHandle( pi.hProcess );
- + CloseHandle( pi.hThread );
- + return Val_long( status );
- +
- +}
- diff -urpwN flexdll/version.ml flexdll.new/version.ml
- --- flexdll/version.ml 2008-11-13 18:44:01.000000000 +0100
- +++ flexdll.new/version.ml 2008-11-17 13:24:40.620769700 +0100
- @@ -1 +1 @@
- -let version = "0.11"
- +let version = "0.12"
Add Comment
Please, Sign In to add comment