Browse Source
* added @deriving package * Add `system` node * show system is active on fnm lsremotes/origin/add-simple-redirecting-site
![gal@spitfire.co.il](/assets/img/avatar_default.png)
![GitHub](/assets/img/avatar_default.png)
56 changed files with 2732 additions and 3857 deletions
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
opam-version: "2.0" |
||||
maintainer: "martin@mjambon.com" |
||||
authors: ["Martin Jambon"] |
||||
homepage: "http://mjambon.com/cppo.html" |
||||
dev-repo: "git+https://github.com/mjambon/cppo.git" |
||||
bug-reports: "https://github.com/mjambon/cppo/issues" |
||||
license: "BSD-3-Clause" |
||||
|
||||
build: [ |
||||
["jbuilder" "subst" "-p" name] {pinned} |
||||
["jbuilder" "build" "-p" name "-j" jobs] |
||||
] |
||||
|
||||
depends: [ |
||||
"ocaml" |
||||
"jbuilder" {build & >= "1.0+beta10"} |
||||
"ocamlbuild" |
||||
"ocamlfind" |
||||
"cppo" {>= "1.6.0"} |
||||
] |
||||
synopsis: "ocamlbuild support for cppo, OCaml-friendly source preprocessor" |
||||
url { |
||||
src: "https://github.com/mjambon/cppo/archive/v1.6.0.tar.gz" |
||||
checksum: "md5=aee411b3546bc5d198c71ae9185cade4" |
||||
} |
@ -1,60 +1,58 @@
@@ -1,60 +1,58 @@
|
||||
opam-version: "2.0" |
||||
version: "4.1.0" |
||||
|
||||
synopsis: "Promises and event-driven I/O" |
||||
|
||||
license: "MIT" |
||||
homepage: "https://github.com/ocsigen/lwt" |
||||
doc: "https://ocsigen.org/lwt/manual/" |
||||
bug-reports: "https://github.com/ocsigen/lwt/issues" |
||||
|
||||
authors: [ |
||||
"Jérôme Vouillon" |
||||
"Jérémie Dimino" |
||||
] |
||||
maintainer: [ |
||||
"Anton Bachin <antonbachin@yahoo.com>" |
||||
"Mauricio Fernandez <mfp@acm.org>" |
||||
"Simon Cruanes <simon.cruanes.2007@m4x.org>" |
||||
] |
||||
authors: [ |
||||
"Jérôme Vouillon" |
||||
"Jérémie Dimino" |
||||
] |
||||
homepage: "https://github.com/ocsigen/lwt" |
||||
doc: "https://ocsigen.org/lwt/manual/" |
||||
bug-reports: "https://github.com/ocsigen/lwt/issues" |
||||
license: "LGPL with OpenSSL linking exception" |
||||
dev-repo: "git+https://github.com/ocsigen/lwt.git" |
||||
build: [ |
||||
[ "ocaml" "src/util/configure.ml" "-use-libev" "%{conf-libev:installed}%" ] |
||||
[ "jbuilder" "build" "-p" name "-j" jobs ] |
||||
] |
||||
|
||||
depends: [ |
||||
"ocaml" {>= "4.02.0"} |
||||
"cppo" {build & >= "1.1.0"} |
||||
"jbuilder" {build & >= "1.0+beta14"} |
||||
"ocamlfind" {build & >= "1.7.3-1"} |
||||
"result" |
||||
"dune" {build} |
||||
"mmap" # mmap is needed as long as Lwt supports OCaml < 4.06.0. |
||||
"ocaml" {>= "4.02.0"} |
||||
"result" # result is needed as long as Lwt supports OCaml 4.02. |
||||
"seq" # seq is needed as long as Lwt supports OCaml < 4.07.0. |
||||
|
||||
"bisect_ppx" {dev & >= "1.3.0"} |
||||
"ocamlfind" {dev & >= "1.7.3-1"} |
||||
] |
||||
depopts: [ |
||||
"base-threads" |
||||
"base-unix" |
||||
"conf-libev" |
||||
] |
||||
# In practice, Lwt requires OCaml >= 4.02.3, as that is a constraint of the |
||||
# dependency jbuilder. |
||||
messages: [ |
||||
"For the PPX, please install package lwt_ppx" |
||||
{!lwt_ppx:installed} |
||||
"For the Camlp4 syntax, please install package lwt_camlp4" |
||||
{camlp4:installed & !lwt_camlp4:installed} |
||||
"For Lwt_log and Lwt_daemon, please install package lwt_log" |
||||
{!lwt_log:installed} |
||||
|
||||
conflicts: [ |
||||
"ocaml-variants" {= "4.02.1+BER"} |
||||
] |
||||
|
||||
build: [ |
||||
["dune" "build" "-p" name "-j" jobs] |
||||
] |
||||
synopsis: "Promises, concurrency, and parallelized I/O" |
||||
description: """ |
||||
A promise is a value that may become determined in the future. |
||||
|
||||
description: "A promise is a value that may become determined in the future. |
||||
|
||||
Lwt provides typed, composable promises. Promises that are resolved by I/O are |
||||
resolved by Lwt in parallel. |
||||
|
||||
Meanwhile, OCaml code, including code creating and waiting on promises, runs in |
||||
a single thread by default. This reduces the need for locks or other |
||||
synchronization primitives. Code can be run in parallel on an opt-in basis.""" |
||||
conflicts: [ |
||||
"ocaml-variants" {= "4.02.1+BER"} |
||||
] |
||||
synchronization primitives. Code can be run in parallel on an opt-in basis." |
||||
|
||||
url { |
||||
src: "https://github.com/ocsigen/lwt/archive/4.1.0.tar.gz" |
||||
checksum: "md5=e919bee206f18b3d49250ecf9584fde7" |
||||
src: "https://github.com/ocsigen/lwt/archive/4.2.1.tar.gz" |
||||
checksum: "md5=9d648386ca0a9978eb9487de36b781cc" |
||||
} |
@ -1,30 +1,33 @@
@@ -1,30 +1,33 @@
|
||||
opam-version: "2.0" |
||||
version: "1.2.1" |
||||
maintainer: [ |
||||
"Anton Bachin <antonbachin@yahoo.com>" |
||||
] |
||||
|
||||
synopsis: "PPX syntax for Lwt, providing something similar to async/await from JavaScript" |
||||
|
||||
license: "MIT" |
||||
homepage: "https://github.com/ocsigen/lwt" |
||||
doc: "https://ocsigen.org/lwt/api/Ppx_lwt" |
||||
bug-reports: "https://github.com/ocsigen/lwt/issues" |
||||
|
||||
authors: [ |
||||
"Gabriel Radanne" |
||||
] |
||||
homepage: "https://github.com/ocsigen/lwt" |
||||
doc: "https://ocsigen.org/lwt/api/Ppx_lwt" |
||||
maintainer: [ |
||||
"Anton Bachin <antonbachin@yahoo.com>" |
||||
] |
||||
dev-repo: "git+https://github.com/ocsigen/lwt.git" |
||||
bug-reports: "https://github.com/ocsigen/lwt/issues" |
||||
license: "LGPL with OpenSSL linking exception" |
||||
|
||||
depends: [ |
||||
"ocaml" {>= "4.02.0"} |
||||
"jbuilder" {build & >= "1.0+beta14"} |
||||
"dune" {build} |
||||
"lwt" |
||||
"ocaml" {>= "4.02.0"} |
||||
"ocaml-migrate-parsetree" |
||||
"ppx_tools_versioned" {>= "5.0.1"} |
||||
] |
||||
|
||||
build: [ |
||||
["jbuilder" "build" "-p" name "-j" jobs] |
||||
["dune" "build" "-p" name "-j" jobs] |
||||
] |
||||
synopsis: |
||||
"PPX syntax for Lwt, providing something similar to async/await from JavaScript" |
||||
|
||||
url { |
||||
src: "https://github.com/ocsigen/lwt/archive/4.1.0.tar.gz" |
||||
checksum: "md5=e919bee206f18b3d49250ecf9584fde7" |
||||
src: "https://github.com/ocsigen/lwt/archive/4.2.0.tar.gz" |
||||
checksum: "md5=2ce7827948adc611319f9449e4519070" |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
opam-version: "2.0" |
||||
maintainer: "jeremie@dimino.org" |
||||
authors: ["Jérémie Dimino <jeremie@dimino.org>" "Anton Bachin" ] |
||||
homepage: "https://github.com/mirage/mmap" |
||||
bug-reports: "https://github.com/mirage/mmap/issues" |
||||
doc: "https://mirage.github.io/mmap/" |
||||
dev-repo: "git+https://github.com/mirage/mmap.git" |
||||
license: "LGPL 2.1 with linking exception" |
||||
build: [ |
||||
["dune" "build" "-p" name "-j" jobs] |
||||
] |
||||
depends: [ |
||||
"ocaml" {>= "4.02.3"} |
||||
"dune" {build & >= "1.6"} |
||||
] |
||||
synopsis: "File mapping functionality" |
||||
description: """ |
||||
This project provides a Mmap.map_file functions for mapping files in memory. |
||||
""" |
||||
url { |
||||
src: |
||||
"https://github.com/mirage/mmap/releases/download/v1.1.0/mmap-v1.1.0.tbz" |
||||
checksum: "md5=8c5d5fbc537296dc525867535fb878ba" |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
commit 40142bc941e6e308686e86be6fc2da92f346a22f
|
||||
Author: Kate <kit.ty.kate@disroot.org>
|
||||
Date: Tue Mar 19 16:29:06 2019 +0000
|
||||
|
||||
Remove awk from the set of checked unix tools as it's not used anywhere
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index d9b587c..20e8dca 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -184,7 +184,7 @@ echo "Configuring core..."
|
||||
|
||||
# Some standard Unix tools must be available:
|
||||
|
||||
-for tool in sed awk ocaml ocamlc uname rm make cat m4 dirname basename; do
|
||||
+for tool in sed ocaml ocamlc uname rm make cat m4 dirname basename; do
|
||||
if in_path $tool; then true; else
|
||||
echo "configure: $tool not in PATH; this is required" 1>&2
|
||||
exit 1
|
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
opam-version: "2.0" |
||||
maintainer: "whitequark <whitequark@whitequark.org>" |
||||
authors: [ "whitequark <whitequark@whitequark.org>" ] |
||||
license: "MIT" |
||||
homepage: "https://github.com/whitequark/ppx_deriving" |
||||
doc: "https://whitequark.github.io/ppx_deriving" |
||||
bug-reports: "https://github.com/whitequark/ppx_deriving/issues" |
||||
dev-repo: "git+https://github.com/whitequark/ppx_deriving.git" |
||||
tags: [ "syntax" ] |
||||
substs: [ "pkg/META" ] |
||||
build: [ |
||||
[ |
||||
"ocaml" |
||||
"pkg/build.ml" |
||||
"native=%{ocaml:native-dynlink}%" |
||||
"native-dynlink=%{ocaml:native-dynlink}%" |
||||
] |
||||
[ |
||||
"ocamlbuild" |
||||
"-classic-display" |
||||
"-use-ocamlfind" |
||||
"src_test/test_ppx_deriving.byte" |
||||
"--" |
||||
] {with-test} |
||||
[make "doc"] {with-doc} |
||||
] |
||||
depends: [ |
||||
"ocaml" {> "4.03.0"} |
||||
"ocamlbuild" {build} |
||||
"ocamlfind" {build & >= "1.6.0"} |
||||
"cppo" {build} |
||||
"cppo_ocamlbuild" {build} |
||||
"ocaml-migrate-parsetree" |
||||
"ppx_derivers" |
||||
"ppx_tools" {>= "4.02.3"} |
||||
"result" |
||||
"ounit" {with-test} |
||||
] |
||||
available: opam-version >= "1.2" |
||||
synopsis: "Type-driven code generation for OCaml >=4.02" |
||||
description: """ |
||||
ppx_deriving provides common infrastructure for generating |
||||
code based on type definitions, and a set of useful plugins |
||||
for common tasks.""" |
||||
url { |
||||
src: "https://github.com/ocaml-ppx/ppx_deriving/archive/v4.2.1.tar.gz" |
||||
checksum: "md5=2195fccf2a527c3ff9ec5b4e36e2f0a8" |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
opam-version: "2.0" |
||||
maintainer: "alain.frisch@lexifi.com" |
||||
authors: [ "Alain Frisch <alain.frisch@lexifi.com>" ] |
||||
license: "MIT" |
||||
homepage: "https://github.com/ocaml-ppx/ppx_tools" |
||||
bug-reports: "https://github.com/ocaml-ppx/ppx_tools/issues" |
||||
dev-repo: "git://github.com/ocaml-ppx/ppx_tools.git" |
||||
tags: [ "syntax" ] |
||||
build: [[make "all"]] |
||||
install: [[make "install"]] |
||||
remove: [["ocamlfind" "remove" "ppx_tools"]] |
||||
depends: [ |
||||
"ocaml" {>= "4.06.0" & < "4.08"} |
||||
"ocamlfind" {>= "1.5.0"} |
||||
] |
||||
synopsis: "Tools for authors of ppx rewriters and other syntactic tools" |
||||
flags: light-uninstall |
||||
url { |
||||
src: "https://github.com/ocaml-ppx/ppx_tools/archive/5.1+4.06.0.tar.gz" |
||||
checksum: "md5=6ba2e9690b1f579ba562b86022d1c308" |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
opam-version: "2.0" |
||||
maintainer: "simon.cruanes.2007@m4x.org" |
||||
authors: "Simon Cruanes" |
||||
homepage: "https://github.com/c-cube/seq/" |
||||
bug-reports: "https://github.com/c-cube/seq/issues" |
||||
license: "GPL" |
||||
tags: ["iterator" "seq" "pure" "list" "compatibility" "cascade"] |
||||
dev-repo: "git+https://github.com/c-cube/seq.git" |
||||
build: [make "build"] |
||||
install: [make "install"] |
||||
remove: [ "ocamlfind" "remove" "seq" ] |
||||
depends: [ |
||||
"ocaml" {< "4.07.0"} |
||||
"ocamlfind" {build} |
||||
"ocamlbuild" {build} |
||||
] |
||||
synopsis: |
||||
"Compatibility package for OCaml's standard iterator type starting from 4.07." |
||||
flags: light-uninstall |
||||
url { |
||||
src: "https://github.com/c-cube/seq/archive/0.1.tar.gz" |
||||
checksum: "md5=0e87f9709541ed46ecb6f414bc31458c" |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
opam-version: "2.0" |
||||
maintainer: "The stdlib-shims programmers" |
||||
authors: "The stdlib-shims programmers" |
||||
homepage: "https://github.com/ocaml/stdlib-shims" |
||||
doc: "https://ocaml.github.io/stdlib-shims/" |
||||
dev-repo: "git+https://github.com/ocaml/stdlib-shims.git" |
||||
bug-reports: "https://github.com/ocaml/stdlib-shims/issues" |
||||
tags: ["stdlib" "compatibility" "org:ocaml"] |
||||
license: ["typeof OCaml system"] |
||||
depends: [ |
||||
"dune" {build} |
||||
"ocaml" {>= "4.02.3"} |
||||
] |
||||
build: [ "dune" "build" "-p" name "-j" jobs ] |
||||
synopsis: "Backport some of the new stdlib features to older compiler" |
||||
description: """ |
||||
Backport some of the new stdlib features to older compiler, |
||||
such as the Stdlib module. |
||||
|
||||
This allows projects that require compatibility with older compiler to |
||||
use these new features in their code. |
||||
""" |
||||
url { |
||||
src: |
||||
"https://github.com/ocaml/stdlib-shims/releases/download/0.1.0/stdlib-shims-0.1.0.tbz" |
||||
checksum: "md5=12b5704eed70c6bff5ac39a16db1425d" |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
--- ./extend_helper.ml
|
||||
+++ ./extend_helper.ml
|
||||
@@ -1,13 +1,6 @@
|
||||
-(*pp cppo -V OCAML:`ocamlc -version` *)
|
||||
open Parsetree
|
||||
open Extend_protocol
|
||||
|
||||
-#if OCAML_VERSION < (4, 3, 0)
|
||||
-# define CONST_STRING Asttypes.Const_string
|
||||
-#else
|
||||
-# define CONST_STRING Parsetree.Pconst_string
|
||||
-#endif
|
||||
-
|
||||
(** Default implementation for [Reader_def.print_outcome] using
|
||||
[Oprint] from compiler-libs *)
|
||||
let print_outcome_using_oprint ppf = function
|
||||
@@ -28,7 +21,7 @@
|
||||
pstr_loc = Location.none;
|
||||
pstr_desc = Pstr_eval ({
|
||||
pexp_loc = Location.none;
|
||||
- pexp_desc = Pexp_constant (CONST_STRING (msg, None));
|
||||
+ pexp_desc = Pexp_constant (Asttypes.Const_string (msg, None));
|
||||
pexp_attributes = [];
|
||||
}, []);
|
||||
}]
|
||||
@@ -112,7 +105,7 @@
|
||||
let msg = match payload with
|
||||
| PStr [{
|
||||
pstr_desc = Pstr_eval ({
|
||||
- pexp_desc = Pexp_constant (CONST_STRING (msg, _));
|
||||
+ pexp_desc = Pexp_constant (Asttypes.Const_string (msg, _));
|
||||
}, _);
|
||||
}] -> msg
|
||||
| _ -> "Warning: extension produced an incorrect syntax-error node"
|
@ -0,0 +1,463 @@
@@ -0,0 +1,463 @@
|
||||
--- ./Makefile
|
||||
+++ ./Makefile
|
||||
@@ -213,7 +213,7 @@
|
||||
rm -f man/ocamlbuild.1
|
||||
|
||||
man/options_man.byte: src/ocamlbuild_pack.cmo
|
||||
- $(OCAMLC) $^ -I src man/options_man.ml -o man/options_man.byte
|
||||
+ $(OCAMLC) -I +unix unix.cma $^ -I src man/options_man.ml -o man/options_man.byte
|
||||
|
||||
clean::
|
||||
rm -f man/options_man.cm*
|
||||
--- ./src/command.ml
|
||||
+++ ./src/command.ml
|
||||
@@ -148,9 +148,10 @@
|
||||
let self = string_of_command_spec_with_calls call_with_tags call_with_target resolve_virtuals in
|
||||
let b = Buffer.create 256 in
|
||||
(* The best way to prevent bash from switching to its windows-style
|
||||
- * quote-handling is to prepend an empty string before the command name. *)
|
||||
+ * quote-handling is to prepend an empty string before the command name.
|
||||
+ * space seems to work, too - and the ouput is nicer *)
|
||||
if Sys.os_type = "Win32" then
|
||||
- Buffer.add_string b "''";
|
||||
+ Buffer.add_char b ' ';
|
||||
let first = ref true in
|
||||
let put_space () =
|
||||
if !first then
|
||||
@@ -260,7 +261,7 @@
|
||||
|
||||
let execute_many ?(quiet=false) ?(pretend=false) cmds =
|
||||
add_parallel_stat (List.length cmds);
|
||||
- let degraded = !*My_unix.is_degraded || Sys.os_type = "Win32" in
|
||||
+ let degraded = !*My_unix.is_degraded in
|
||||
let jobs = !jobs in
|
||||
if jobs < 0 then invalid_arg "jobs < 0";
|
||||
let max_jobs = if jobs = 0 then None else Some jobs in
|
||||
--- ./src/findlib.ml
|
||||
+++ ./src/findlib.ml
|
||||
@@ -66,9 +66,6 @@
|
||||
(fun command -> lexer & Lexing.from_string & run_and_read command)
|
||||
command
|
||||
|
||||
-let run_and_read command =
|
||||
- Printf.ksprintf run_and_read command
|
||||
-
|
||||
let rec query name =
|
||||
try
|
||||
Hashtbl.find packages name
|
||||
@@ -135,7 +132,8 @@
|
||||
with Not_found -> s
|
||||
|
||||
let list () =
|
||||
- List.map before_space (split_nl & run_and_read "%s list" ocamlfind)
|
||||
+ let cmd = Shell.quote_filename_if_needed ocamlfind ^ " list" in
|
||||
+ List.map before_space (split_nl & run_and_read cmd)
|
||||
|
||||
(* The closure algorithm is easy because the dependencies are already closed
|
||||
and sorted for each package. We only have to make the union. We could also
|
||||
--- ./src/main.ml
|
||||
+++ ./src/main.ml
|
||||
@@ -162,6 +162,9 @@
|
||||
Tags.mem "traverse" tags
|
||||
|| List.exists (Pathname.is_prefix path_name) !Options.include_dirs
|
||||
|| List.exists (Pathname.is_prefix path_name) target_dirs)
|
||||
+ && ((* beware: !Options.build_dir is an absolute directory *)
|
||||
+ Pathname.normalize !Options.build_dir
|
||||
+ <> Pathname.normalize (Pathname.pwd/path_name))
|
||||
end
|
||||
end
|
||||
end
|
||||
--- ./src/my_std.ml
|
||||
+++ ./src/my_std.ml
|
||||
@@ -271,13 +271,107 @@
|
||||
try Array.iter (fun x -> if x = basename then raise Exit) a; false
|
||||
with Exit -> true
|
||||
|
||||
+let command_plain = function
|
||||
+| [| |] -> 0
|
||||
+| margv ->
|
||||
+ let rec waitpid a b =
|
||||
+ match Unix.waitpid a b with
|
||||
+ | exception (Unix.Unix_error(Unix.EINTR,_,_)) -> waitpid a b
|
||||
+ | x -> x
|
||||
+ in
|
||||
+ let pid = Unix.(create_process margv.(0) margv stdin stdout stderr) in
|
||||
+ let pid', process_status = waitpid [] pid in
|
||||
+ assert (pid = pid');
|
||||
+ match process_status with
|
||||
+ | Unix.WEXITED n -> n
|
||||
+ | Unix.WSIGNALED _ -> 2 (* like OCaml's uncaught exceptions *)
|
||||
+ | Unix.WSTOPPED _ -> 127
|
||||
+
|
||||
+(* can't use Lexers because of circular dependency *)
|
||||
+let split_path_win str =
|
||||
+ let rec aux pos =
|
||||
+ try
|
||||
+ let i = String.index_from str pos ';' in
|
||||
+ let len = i - pos in
|
||||
+ if len = 0 then
|
||||
+ aux (succ i)
|
||||
+ else
|
||||
+ String.sub str pos (i - pos) :: aux (succ i)
|
||||
+ with Not_found | Invalid_argument _ ->
|
||||
+ let len = String.length str - pos in
|
||||
+ if len = 0 then [] else [String.sub str pos len]
|
||||
+ in
|
||||
+ aux 0
|
||||
+
|
||||
+let windows_shell = lazy begin
|
||||
+ let rec iter = function
|
||||
+ | [] -> [| "bash.exe" ; "--norc" ; "--noprofile" |]
|
||||
+ | hd::tl ->
|
||||
+ let dash = Filename.concat hd "dash.exe" in
|
||||
+ if Sys.file_exists dash then [|dash|] else
|
||||
+ let bash = Filename.concat hd "bash.exe" in
|
||||
+ if Sys.file_exists bash = false then iter tl else
|
||||
+ (* if sh.exe and bash.exe exist in the same dir, choose sh.exe *)
|
||||
+ let sh = Filename.concat hd "sh.exe" in
|
||||
+ if Sys.file_exists sh then [|sh|] else [|bash ; "--norc" ; "--noprofile"|]
|
||||
+ in
|
||||
+ split_path_win (try Sys.getenv "PATH" with Not_found -> "") |> iter
|
||||
+end
|
||||
+
|
||||
+let prep_windows_cmd cmd =
|
||||
+ (* workaround known ocaml bug, remove later *)
|
||||
+ if String.contains cmd '\t' && String.contains cmd ' ' = false then
|
||||
+ " " ^ cmd
|
||||
+ else
|
||||
+ cmd
|
||||
+
|
||||
+let run_with_shell = function
|
||||
+| "" -> 0
|
||||
+| cmd ->
|
||||
+ let cmd = prep_windows_cmd cmd in
|
||||
+ let shell = Lazy.force windows_shell in
|
||||
+ let qlen = Filename.quote cmd |> String.length in
|
||||
+ (* old versions of dash had problems with bs *)
|
||||
+ try
|
||||
+ if qlen < 7_900 then
|
||||
+ command_plain (Array.append shell [| "-ec" ; cmd |])
|
||||
+ else begin
|
||||
+ (* it can still work, if the called command is a cygwin tool *)
|
||||
+ let ch_closed = ref false in
|
||||
+ let file_deleted = ref false in
|
||||
+ let fln,ch =
|
||||
+ Filename.open_temp_file
|
||||
+ ~mode:[Open_binary]
|
||||
+ "ocamlbuildtmp"
|
||||
+ ".sh"
|
||||
+ in
|
||||
+ try
|
||||
+ let f_slash = String.map ( fun x -> if x = '\\' then '/' else x ) fln in
|
||||
+ output_string ch cmd;
|
||||
+ ch_closed:= true;
|
||||
+ close_out ch;
|
||||
+ let ret = command_plain (Array.append shell [| "-e" ; f_slash |]) in
|
||||
+ file_deleted:= true;
|
||||
+ Sys.remove fln;
|
||||
+ ret
|
||||
+ with
|
||||
+ | x ->
|
||||
+ if !ch_closed = false then
|
||||
+ close_out_noerr ch;
|
||||
+ if !file_deleted = false then
|
||||
+ (try Sys.remove fln with _ -> ());
|
||||
+ raise x
|
||||
+ end
|
||||
+ with
|
||||
+ | (Unix.Unix_error _) as x ->
|
||||
+ (* Sys.command doesn't raise an exception, so run_with_shell also won't
|
||||
+ raise *)
|
||||
+ Printexc.to_string x ^ ":" ^ cmd |> prerr_endline;
|
||||
+ 1
|
||||
+
|
||||
let sys_command =
|
||||
- match Sys.os_type with
|
||||
- | "Win32" -> fun cmd ->
|
||||
- if cmd = "" then 0 else
|
||||
- let cmd = "bash --norc -c " ^ Filename.quote cmd in
|
||||
- Sys.command cmd
|
||||
- | _ -> fun cmd -> if cmd = "" then 0 else Sys.command cmd
|
||||
+ if Sys.win32 then run_with_shell
|
||||
+ else fun cmd -> if cmd = "" then 0 else Sys.command cmd
|
||||
|
||||
(* FIXME warning fix and use Filename.concat *)
|
||||
let filename_concat x y =
|
||||
--- ./src/my_std.mli
|
||||
+++ ./src/my_std.mli
|
||||
@@ -69,3 +69,6 @@
|
||||
|
||||
val split_ocaml_version : (int * int * int * string) option
|
||||
(** (major, minor, patchlevel, rest) *)
|
||||
+
|
||||
+val windows_shell : string array Lazy.t
|
||||
+val prep_windows_cmd : string -> string
|
||||
--- ./src/ocamlbuild_executor.ml
|
||||
+++ ./src/ocamlbuild_executor.ml
|
||||
@@ -34,6 +34,8 @@
|
||||
job_stdin : out_channel;
|
||||
job_stderr : in_channel;
|
||||
job_buffer : Buffer.t;
|
||||
+ job_pid : int;
|
||||
+ job_tmp_file: string option;
|
||||
mutable job_dying : bool;
|
||||
};;
|
||||
|
||||
@@ -76,6 +78,61 @@
|
||||
in
|
||||
loop 0
|
||||
;;
|
||||
+
|
||||
+let open_process_full_win cmd env =
|
||||
+ let (in_read, in_write) = Unix.pipe () in
|
||||
+ let (out_read, out_write) = Unix.pipe () in
|
||||
+ let (err_read, err_write) = Unix.pipe () in
|
||||
+ Unix.set_close_on_exec in_read;
|
||||
+ Unix.set_close_on_exec out_write;
|
||||
+ Unix.set_close_on_exec err_read;
|
||||
+ let inchan = Unix.in_channel_of_descr in_read in
|
||||
+ let outchan = Unix.out_channel_of_descr out_write in
|
||||
+ let errchan = Unix.in_channel_of_descr err_read in
|
||||
+ let shell = Lazy.force Ocamlbuild_pack.My_std.windows_shell in
|
||||
+ let test_cmd =
|
||||
+ String.concat " " (List.map Filename.quote (Array.to_list shell)) ^
|
||||
+ "-ec " ^
|
||||
+ Filename.quote (Ocamlbuild_pack.My_std.prep_windows_cmd cmd) in
|
||||
+ let argv,tmp_file =
|
||||
+ if String.length test_cmd < 7_900 then
|
||||
+ Array.append
|
||||
+ shell
|
||||
+ [| "-ec" ; Ocamlbuild_pack.My_std.prep_windows_cmd cmd |],None
|
||||
+ else
|
||||
+ let fln,ch = Filename.open_temp_file ~mode:[Open_binary] "ocamlbuild" ".sh" in
|
||||
+ output_string ch (Ocamlbuild_pack.My_std.prep_windows_cmd cmd);
|
||||
+ close_out ch;
|
||||
+ let fln' = String.map (function '\\' -> '/' | c -> c) fln in
|
||||
+ Array.append
|
||||
+ shell
|
||||
+ [| "-c" ; fln' |], Some fln in
|
||||
+ let pid =
|
||||
+ Unix.create_process_env argv.(0) argv env out_read in_write err_write in
|
||||
+ Unix.close out_read;
|
||||
+ Unix.close in_write;
|
||||
+ Unix.close err_write;
|
||||
+ (pid, inchan, outchan, errchan,tmp_file)
|
||||
+
|
||||
+let close_process_full_win (pid,inchan, outchan, errchan, tmp_file) =
|
||||
+ let delete tmp_file =
|
||||
+ match tmp_file with
|
||||
+ | None -> ()
|
||||
+ | Some x -> try Sys.remove x with Sys_error _ -> () in
|
||||
+ let tmp_file_deleted = ref false in
|
||||
+ try
|
||||
+ close_in inchan;
|
||||
+ close_out outchan;
|
||||
+ close_in errchan;
|
||||
+ let res = snd(Unix.waitpid [] pid) in
|
||||
+ tmp_file_deleted := true;
|
||||
+ delete tmp_file;
|
||||
+ res
|
||||
+ with
|
||||
+ | x when tmp_file <> None && !tmp_file_deleted = false ->
|
||||
+ delete tmp_file;
|
||||
+ raise x
|
||||
+
|
||||
(* ***)
|
||||
(*** execute *)
|
||||
(* XXX: Add test for non reentrancy *)
|
||||
@@ -130,10 +187,16 @@
|
||||
(*** add_job *)
|
||||
let add_job cmd rest result id =
|
||||
(*display begin fun oc -> fp oc "Job %a is %s\n%!" print_job_id id cmd; end;*)
|
||||
- let (stdout', stdin', stderr') = open_process_full cmd env in
|
||||
+ let (pid,stdout', stdin', stderr', tmp_file) =
|
||||
+ if Sys.win32 then open_process_full_win cmd env else
|
||||
+ let a,b,c = open_process_full cmd env in
|
||||
+ -1,a,b,c,None
|
||||
+ in
|
||||
incr jobs_active;
|
||||
- set_nonblock (doi stdout');
|
||||
- set_nonblock (doi stderr');
|
||||
+ if not Sys.win32 then (
|
||||
+ set_nonblock (doi stdout');
|
||||
+ set_nonblock (doi stderr');
|
||||
+ );
|
||||
let job =
|
||||
{ job_id = id;
|
||||
job_command = cmd;
|
||||
@@ -143,7 +206,9 @@
|
||||
job_stdin = stdin';
|
||||
job_stderr = stderr';
|
||||
job_buffer = Buffer.create 1024;
|
||||
- job_dying = false }
|
||||
+ job_dying = false;
|
||||
+ job_tmp_file = tmp_file;
|
||||
+ job_pid = pid }
|
||||
in
|
||||
outputs := FDM.add (doi stdout') job (FDM.add (doi stderr') job !outputs);
|
||||
jobs := JS.add job !jobs;
|
||||
@@ -199,6 +264,7 @@
|
||||
try
|
||||
read fd u 0 (Bytes.length u)
|
||||
with
|
||||
+ | Unix.Unix_error(Unix.EPIPE,_,_) when Sys.win32 -> 0
|
||||
| Unix.Unix_error(e,_,_) ->
|
||||
let msg = error_message e in
|
||||
display (fun oc -> fp oc
|
||||
@@ -241,14 +307,19 @@
|
||||
decr jobs_active;
|
||||
|
||||
(* PR#5371: we would get EAGAIN below otherwise *)
|
||||
- clear_nonblock (doi job.job_stdout);
|
||||
- clear_nonblock (doi job.job_stderr);
|
||||
-
|
||||
+ if not Sys.win32 then (
|
||||
+ clear_nonblock (doi job.job_stdout);
|
||||
+ clear_nonblock (doi job.job_stderr);
|
||||
+ );
|
||||
do_read ~loop:true (doi job.job_stdout) job;
|
||||
do_read ~loop:true (doi job.job_stderr) job;
|
||||
outputs := FDM.remove (doi job.job_stdout) (FDM.remove (doi job.job_stderr) !outputs);
|
||||
jobs := JS.remove job !jobs;
|
||||
- let status = close_process_full (job.job_stdout, job.job_stdin, job.job_stderr) in
|
||||
+ let status =
|
||||
+ if Sys.win32 then
|
||||
+ close_process_full_win (job.job_pid, job.job_stdout, job.job_stdin, job.job_stderr, job.job_tmp_file)
|
||||
+ else
|
||||
+ close_process_full (job.job_stdout, job.job_stdin, job.job_stderr) in
|
||||
|
||||
let shown = ref false in
|
||||
|
||||
--- ./src/ocamlbuild_unix_plugin.ml
|
||||
+++ ./src/ocamlbuild_unix_plugin.ml
|
||||
@@ -48,12 +48,22 @@
|
||||
end
|
||||
|
||||
let run_and_open s kont =
|
||||
+ let s_orig = s in
|
||||
+ let s =
|
||||
+ (* Be consistent! My_unix.run_and_open uses My_std.sys_command and
|
||||
+ sys_command uses bash. *)
|
||||
+ if Sys.win32 = false then s else
|
||||
+ let l = match Lazy.force My_std.windows_shell |> Array.to_list with
|
||||
+ | hd::tl -> (Filename.quote hd)::tl
|
||||
+ | _ -> assert false in
|
||||
+ "\"" ^ (String.concat " " l) ^ " -ec " ^ Filename.quote (" " ^ s) ^ "\""
|
||||
+ in
|
||||
let ic = Unix.open_process_in s in
|
||||
let close () =
|
||||
match Unix.close_process_in ic with
|
||||
| Unix.WEXITED 0 -> ()
|
||||
| Unix.WEXITED _ | Unix.WSIGNALED _ | Unix.WSTOPPED _ ->
|
||||
- failwith (Printf.sprintf "Error while running: %s" s) in
|
||||
+ failwith (Printf.sprintf "Error while running: %s" s_orig) in
|
||||
let res = try
|
||||
kont ic
|
||||
with e -> (close (); raise e)
|
||||
--- ./src/options.ml
|
||||
+++ ./src/options.ml
|
||||
@@ -174,11 +174,24 @@
|
||||
build_dir := Filename.concat (Sys.getcwd ()) s
|
||||
else
|
||||
build_dir := s
|
||||
+
|
||||
+let slashify =
|
||||
+ if Sys.win32 then fun p -> String.map (function '\\' -> '/' | x -> x) p
|
||||
+ else fun p ->p
|
||||
+
|
||||
+let sb () =
|
||||
+ match Sys.os_type with
|
||||
+ | "Win32" ->
|
||||
+ (try set_binary_mode_out stdout true with _ -> ());
|
||||
+ | _ -> ()
|
||||
+
|
||||
+
|
||||
let spec = ref (
|
||||
let print_version () =
|
||||
+ sb ();
|
||||
Printf.printf "ocamlbuild %s\n%!" Ocamlbuild_config.version; raise Exit_OK
|
||||
in
|
||||
- let print_vnum () = print_endline Ocamlbuild_config.version; raise Exit_OK in
|
||||
+ let print_vnum () = sb (); print_endline Ocamlbuild_config.version; raise Exit_OK in
|
||||
Arg.align
|
||||
[
|
||||
"-version", Unit print_version , " Display the version";
|
||||
@@ -257,8 +270,8 @@
|
||||
"-build-dir", String set_build_dir, "<path> Set build directory (implies no-links)";
|
||||
"-install-lib-dir", Set_string Ocamlbuild_where.libdir, "<path> Set the install library directory";
|
||||
"-install-bin-dir", Set_string Ocamlbuild_where.bindir, "<path> Set the install binary directory";
|
||||
- "-where", Unit (fun () -> print_endline !Ocamlbuild_where.libdir; raise Exit_OK), " Display the install library directory";
|
||||
- "-which", String (fun cmd -> print_endline (find_tool cmd); raise Exit_OK), "<command> Display path to the tool command";
|
||||
+ "-where", Unit (fun () -> sb (); print_endline (slashify !Ocamlbuild_where.libdir); raise Exit_OK), " Display the install library directory";
|
||||
+ "-which", String (fun cmd -> sb (); print_endline (slashify (find_tool cmd)); raise Exit_OK), "<command> Display path to the tool command";
|
||||
"-ocamlc", set_cmd ocamlc, "<command> Set the OCaml bytecode compiler";
|
||||
"-plugin-ocamlc", set_cmd plugin_ocamlc, "<command> Set the OCaml bytecode compiler \
|
||||
used when building myocamlbuild.ml (only)";
|
||||
--- ./src/pathname.ml
|
||||
+++ ./src/pathname.ml
|
||||
@@ -84,6 +84,26 @@
|
||||
| x :: xs -> x :: normalize_list xs
|
||||
|
||||
let normalize x =
|
||||
+ let x =
|
||||
+ if Sys.win32 = false then
|
||||
+ x
|
||||
+ else
|
||||
+ let len = String.length x in
|
||||
+ let b = Bytes.create len in
|
||||
+ for i = 0 to pred len do
|
||||
+ match x.[i] with
|
||||
+ | '\\' -> Bytes.set b i '/'
|
||||
+ | c -> Bytes.set b i c
|
||||
+ done;
|
||||
+ if len > 1 then (
|
||||
+ let c1 = Bytes.get b 0 in
|
||||
+ let c2 = Bytes.get b 1 in
|
||||
+ if c2 = ':' && c1 >= 'a' && c1 <= 'z' &&
|
||||
+ ( len = 2 || Bytes.get b 2 = '/') then
|
||||
+ Bytes.set b 0 (Char.uppercase_ascii c1)
|
||||
+ );
|
||||
+ Bytes.unsafe_to_string b
|
||||
+ in
|
||||
if Glob.eval not_normal_form_re x then
|
||||
let root, paths = split x in
|
||||
join root (normalize_list paths)
|
||||
--- ./src/shell.ml
|
||||
+++ ./src/shell.ml
|
||||
@@ -24,12 +24,26 @@
|
||||
| 'a'..'z' | 'A'..'Z' | '0'..'9' | '.' | '-' | '/' | '_' | ':' | '@' | '+' | ',' -> loop (pos + 1)
|
||||
| _ -> false in
|
||||
loop 0
|
||||
+
|
||||
+let generic_quote quotequote s =
|
||||
+ let l = String.length s in
|
||||
+ let b = Buffer.create (l + 20) in
|
||||
+ Buffer.add_char b '\'';
|
||||
+ for i = 0 to l - 1 do
|
||||
+ if s.[i] = '\''
|
||||
+ then Buffer.add_string b quotequote
|
||||
+ else Buffer.add_char b s.[i]
|
||||
+ done;
|
||||
+ Buffer.add_char b '\'';
|
||||
+ Buffer.contents b
|
||||
+let unix_quote = generic_quote "'\\''"
|
||||
+
|
||||
let quote_filename_if_needed s =
|
||||
if is_simple_filename s then s
|
||||
(* We should probably be using [Filename.unix_quote] except that function
|
||||
* isn't exported. Users on Windows will have to live with not being able to
|
||||
* install OCaml into c:\o'caml. Too bad. *)
|
||||
- else if Sys.os_type = "Win32" then Printf.sprintf "'%s'" s
|
||||
+ else if Sys.os_type = "Win32" then unix_quote s
|
||||
else Filename.quote s
|
||||
let chdir dir =
|
||||
reset_filesys_cache ();
|
||||
@@ -37,7 +51,7 @@
|
||||
let run args target =
|
||||
reset_readdir_cache ();
|
||||
let cmd = String.concat " " (List.map quote_filename_if_needed args) in
|
||||
- if !*My_unix.is_degraded || Sys.os_type = "Win32" then
|
||||
+ if !*My_unix.is_degraded then
|
||||
begin
|
||||
Log.event cmd target Tags.empty;
|
||||
let st = sys_command cmd in
|
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
{ |
||||
"build": [ |
||||
[ |
||||
"bash", |
||||
"-c", |
||||
"#{os == 'windows' ? 'patch -p1 < ocamlbuild-0.14.0.patch' : 'true'}" |
||||
], |
||||
[ |
||||
"make", |
||||
"-f", |
||||
"configure.make", |
||||
"all", |
||||
"OCAMLBUILD_PREFIX=#{self.install}", |
||||
"OCAMLBUILD_BINDIR=#{self.bin}", |
||||
"OCAMLBUILD_LIBDIR=#{self.lib}", |
||||
"OCAMLBUILD_MANDIR=#{self.man}", |
||||
"OCAMLBUILD_NATIVE=true", |
||||
"OCAMLBUILD_NATIVE_TOOLS=true" |
||||
], |
||||
[ |
||||
"make", |
||||
"check-if-preinstalled", |
||||
"all", |
||||
"#{os == 'windows' ? 'install' : 'opam-install'}" |
||||
] |
||||
] |
||||
} |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
--- ./pkg/topkg.ml
|
||||
+++ ./pkg/topkg.ml
|
||||
@@ -152,7 +152,63 @@
|
||||
module Exts : Exts = struct
|
||||
let interface = [".mli"; ".cmi"; ".cmti"]
|
||||
let interface_opt = ".cmx" :: interface
|
||||
- let c_library = if Sys.win32 then [".lib"] else [".a"]
|
||||
+ let c_library =
|
||||
+ match Sys.win32 with
|
||||
+ | false -> [".a"]
|
||||
+ | true ->
|
||||
+ let input_line ch =
|
||||
+ try
|
||||
+ let s = input_line ch in
|
||||
+ let len = String.length s in
|
||||
+ if len > 0 && Sys.os_type = "Win32" && s.[len-1] = '\r' then
|
||||
+ Some (String.sub s 0 (pred len))
|
||||
+ else
|
||||
+ Some s
|
||||
+ with
|
||||
+ | End_of_file -> None
|
||||
+ in
|
||||
+ let rec get_ext_lib ch =
|
||||
+ match input_line ch with
|
||||
+ | None -> ".a"
|
||||
+ | Some s ->
|
||||
+ let len = String.length s in
|
||||
+ if len < 11 || s.[0] <> 'e' || String.sub s 0 9 <> "ext_lib: " then
|
||||
+ get_ext_lib ch
|
||||
+ else
|
||||
+ String.sub s 9 (len - 9)
|
||||
+ in
|
||||
+ let get_ext_lib fln =
|
||||
+ let ch = open_in fln in
|
||||
+ let ch_closed = ref false in
|
||||
+ try
|
||||
+ let res = get_ext_lib ch in
|
||||
+ ch_closed := true;
|
||||
+ close_in ch ;
|
||||
+ res
|
||||
+ with
|
||||
+ | x when !ch_closed = false ->
|
||||
+ close_in_noerr ch;
|
||||
+ raise x
|
||||
+ in
|
||||
+ let e_null = if Sys.win32 then " 2>NUL" else " 2>/dev/null" in
|
||||
+ let fln = Filename.temp_file "get_ext" ".txt" in
|
||||
+ let cleanup = lazy (try Sys.remove fln with Sys_error _ -> ()) in
|
||||
+ try
|
||||
+ let qfln = Filename.quote fln in
|
||||
+ let cmd = "ocamlfind ocamlc -config > " ^ qfln ^ e_null in
|
||||
+ let ec = Sys.command cmd in
|
||||
+ if ec <> 0 then (
|
||||
+ let cmd = "ocamlc -config > " ^ qfln ^ e_null in
|
||||
+ let ec = Sys.command cmd in
|
||||
+ if ec <> 0 then
|
||||
+ failwith (Printf.sprintf "couldn't call ocamlc -config");
|
||||
+ );
|
||||
+ let res = get_ext_lib fln in
|
||||
+ Lazy.force cleanup;
|
||||
+ [res]
|
||||
+ with
|
||||
+ | x -> Lazy.force cleanup; raise x
|
||||
+
|
||||
let c_dll_library = if Sys.win32 then [".dll"] else [".so"]
|
||||
let library = [".cma"; ".cmxa"; ".cmxs"] @ c_library
|
||||
let module_library = (interface_opt @ library)
|
||||
@@ -258,7 +314,9 @@
|
||||
let src, dst =
|
||||
if not auto then src, dst else
|
||||
let dst = match dst with
|
||||
- | None -> Some (Filename.basename src)
|
||||
+ | None ->
|
||||
+ let src = if Sys.os_type <> "Win32" then src else src ^ ".exe" in
|
||||
+ Some (Filename.basename src)
|
||||
| Some _ as dst -> dst
|
||||
in
|
||||
let src = if Env.native then src ^ ".native" else src ^ ".byte" in
|
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
{ |
||||
"build": [ |
||||
[ |
||||
"bash", |
||||
"-c", |
||||
"#{os == 'windows' ? 'patch -p1 < ppx_deriving-4.2.1.patch' : 'true'}" |
||||
], |
||||
[ |
||||
"ocaml", |
||||
"pkg/build.ml", |
||||
"native=true", |
||||
"native-dynlink=true" |
||||
] |
||||
] |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash |
||||
|
||||
echo "custom build" |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
PATH="$(pwd)":$PATH # simulating a custom `node` |
||||
|
||||
eval "$(fnm env --multi)" |
||||
fnm install 10 |
||||
fnm use 10 |
||||
fnm use system |
||||
|
||||
NVER="$(node -v)" |
||||
if [ "$NVER" != "custom build" ]; then |
||||
echo "Expected \`node -v\` to be resolved to the system Node.js, but got $NVER" |
||||
exit 1 |
||||
fi |
Loading…
Reference in new issue