Guest User

Untitled

a guest
Feb 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. diff -urpwN flexdll/Makefile flexdll.new/Makefile
  2. --- flexdll/Makefile 2008-11-17 10:22:55.000000000 +0100
  3. +++ flexdll.new/Makefile 2008-11-17 13:24:21.635908700 +0100
  4. @@ -28,10 +28,10 @@ build_mingw: flexdll_mingw.o flexdll_ini
  5.  
  6. OBJS = version.ml coff.ml cmdline.ml flexlink_cmd.ml reloc.ml
  7.  
  8. -flexlink.exe: $(OBJS)
  9. +flexlink.exe: $(OBJS) runprocess.o
  10. @echo Building flexlink.exe with TOOLCHAIN=$(TOOLCHAIN)
  11. rm -f flexlink.exe
  12. - $(OCAMLOPT) -o flexlink.exe $(LINKFLAGS) $(OBJS)
  13. + $(OCAMLOPT) -o flexlink.exe $(LINKFLAGS) $(OBJS) runprocess.o
  14.  
  15. flexdll_msvc.obj: flexdll.h flexdll.c
  16. $(MSVCC) -c /Fo"flexdll_msvc.obj" flexdll.c
  17. @@ -45,6 +45,9 @@ flexdll_mingw.o: flexdll.h flexdll.c
  18. flexdll_initer_mingw.o: flexdll_initer.c
  19. $(MINCC) -c -o flexdll_initer_mingw.o flexdll_initer.c
  20.  
  21. +runprocess.o: runprocess.c
  22. + $(OCAMLOPT) -I $(shell ocamlc -where) -c -o $@ $<
  23. +
  24. flexdll_initer_cygwin.o: flexdll_initer.c
  25. $(CYGCC) -c -o flexdll_initer_cygwin.o flexdll_initer.c
  26.  
  27. diff -urpwN flexdll/reloc.ml flexdll.new/reloc.ml
  28. --- flexdll/reloc.ml 2008-11-17 10:22:35.000000000 +0100
  29. +++ flexdll.new/reloc.ml 2008-11-17 13:23:22.900030100 +0100
  30. @@ -13,6 +13,8 @@
  31. open Coff
  32. open Cmdline
  33.  
  34. +external run_process : string -> string -> int = "run_process"
  35. +
  36. let search_path = ref []
  37. let default_libs = ref []
  38.  
  39. @@ -88,12 +90,13 @@ let build_diversion lst =
  40. "@" ^ responsefile
  41.  
  42. let alternate_cmd_exe = ref false
  43. +let program = ref ""
  44.  
  45. let quote_files use_response_file lst =
  46. let s =
  47. String.concat " "
  48. (List.map (fun f -> if f = "" then f else Filename.quote f) lst) in
  49. - if String.length s >= 4096 then
  50. + if String.length s >= 512 then
  51. if use_response_file then Filename.quote (build_diversion lst)
  52. else (alternate_cmd_exe := true; s)
  53. else
  54. @@ -766,6 +769,7 @@ let build_dll link_exe output_file files
  55. temp_file "dyndll_implib" ".lib"
  56. in
  57. let _impexp = add_temp (Filename.chop_suffix implib ".lib" ^ ".exp") in
  58. + program := "link";
  59. Printf.sprintf
  60. "link /nologo %s%s%s%s%s /implib:%s /out:%s /defaultlib:msvcrt.lib /subsystem:%s %s %s %s"
  61. (if !verbose >= 2 then "/verbose " else "")
  62. @@ -786,6 +790,7 @@ let build_dll link_exe output_file files
  63. files descr
  64. extra_args
  65. | `CYGWIN ->
  66. + program := "gcc";
  67. Printf.sprintf
  68. "gcc %s%s -L. %s %s -o %s %s %s %s"
  69. (if link_exe = `EXE then "" else "-shared ")
  70. @@ -797,6 +802,7 @@ let build_dll link_exe output_file files
  71. files
  72. extra_args
  73. | `MINGW ->
  74. + program := "gcc";
  75. Printf.sprintf
  76. "gcc -mno-cygwin %s%s -L. %s %s -o %s %s %s %s %s"
  77. (if link_exe = `EXE then "" else "-shared ")
  78. @@ -809,6 +815,7 @@ let build_dll link_exe output_file files
  79. (if !implib then "-Wl,--out-implib=" ^ Filename.quote (Filename.chop_extension output_file ^ ".a") else "")
  80. extra_args
  81. | `LIGHTLD ->
  82. + program := "ld";
  83. no_merge_manifest := true;
  84. Printf.sprintf
  85. "ld %s%s -o %s %s %s %s %s"
  86. @@ -834,7 +841,7 @@ let build_dll link_exe output_file files
  87. Unix.putenv "COMSPEC" Sys.executable_name;
  88. Unix.putenv "FLEXLINK_COMSPEC" "1";
  89. end;
  90. - if Sys.command cmd_quiet <> 0 then begin
  91. + if run_process !program cmd_quiet <> 0 then begin
  92. if cmd <> cmd_quiet then ignore (Sys.command cmd);
  93. failwith "Error during linking\n"
  94. end;
  95. diff -urpwN flexdll/runprocess.c flexdll.new/runprocess.c
  96. --- flexdll/runprocess.c 1970-01-01 01:00:00.000000000 +0100
  97. +++ flexdll.new/runprocess.c 2008-11-17 13:24:14.291970700 +0100
  98. @@ -0,0 +1,43 @@
  99. +#include <windows.h>
  100. +#include <caml/mlvalues.h>
  101. +#include <caml/fail.h>
  102. +
  103. +/* from osdeps.h */
  104. +extern char * caml_search_exe_in_path(char * name);
  105. +
  106. +value run_process(value cmd, value cmdline)
  107. +{
  108. + PROCESS_INFORMATION pi;
  109. + STARTUPINFO si;
  110. + char * exefile, * envp = NULL;
  111. + int flags;
  112. + DWORD status;
  113. +
  114. + exefile = search_exe_in_path(String_val(cmd));
  115. +
  116. + /* Prepare stdin/stdout/stderr redirection */
  117. + GetStartupInfo(&si);
  118. +
  119. + /* If we do not have a console window, then we must create one
  120. + before running the process (keep it hidden for apparence).
  121. + Also one must suppress spurious flags in si.dwFlags.
  122. + Otherwise the redirections are ignored.
  123. + If we are starting a GUI application, the newly created
  124. + console should not matter. */
  125. + flags = CREATE_NEW_CONSOLE;
  126. + si.dwFlags = STARTF_USESHOWWINDOW;
  127. + si.wShowWindow = SW_HIDE;
  128. + /* Create the process */
  129. + if (! CreateProcess(exefile, String_val(cmdline), NULL, NULL,
  130. + TRUE, flags, envp, NULL, &si, &pi)) {
  131. + failwith("run_process");
  132. + }
  133. + WaitForSingleObject( pi.hProcess, INFINITE );
  134. + if (! GetExitCodeProcess(pi.hProcess, &status)) {
  135. + failwith("run_process");
  136. + }
  137. + CloseHandle( pi.hProcess );
  138. + CloseHandle( pi.hThread );
  139. + return Val_long( status );
  140. +
  141. +}
  142. diff -urpwN flexdll/version.ml flexdll.new/version.ml
  143. --- flexdll/version.ml 2008-11-13 18:44:01.000000000 +0100
  144. +++ flexdll.new/version.ml 2008-11-17 13:24:40.620769700 +0100
  145. @@ -1 +1 @@
  146. -let version = "0.11"
  147. +let version = "0.12"
Add Comment
Please, Sign In to add comment