From c9e224c52ad249e7ebbeb77f9c46dc8f085fe56e Mon Sep 17 00:00:00 2001 From: Ulrik Date: Fri, 1 Nov 2019 17:53:44 +0100 Subject: [PATCH 1/7] Install needed folders for snapshot --- package.json | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 719b5aa920b8..0dbe57e0c20b 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,49 @@ "make -j world.opt" ], "install": [ - "make install" + "make install", + [ + "cp", + "-r", + "-f", + "#{self.root / 'utils'}", + "#{self.install / 'utils'}" + ], + [ + "cp", + "-r", + "-f", + "#{self.root / 'parsing'}", + "#{self.install / 'parsing'}" + ], + [ + "cp", + "-r", + "-f", + "#{self.root / 'typing'}", + "#{self.install / 'typing'}" + ], + [ + "cp", + "-r", + "-f", + "#{self.root / 'bytecomp'}", + "#{self.install / 'bytecomp'}" + ], + [ + "cp", + "-r", + "-f", + "#{self.root / 'driver'}", + "#{self.install / 'driver'}" + ], + [ + "cp", + "-r", + "-f", + "#{self.root / 'tools'}", + "#{self.install / 'tools'}" + ] ], "buildsInSource": true, "exportedEnv": { From d21f1d32b529180628d7c6a5d0a8b213124b4c51 Mon Sep 17 00:00:00 2001 From: Ulrik Strid Date: Sat, 2 Nov 2019 22:47:57 +0100 Subject: [PATCH 2/7] Copy things from esy-ocaml --- clone-flexdll | 16 ++++++++++++++++ configure-windows | 34 ++++++++++++++++++++++++++++++++++ esy-build | 24 ++++++++++++++++++++++++ esy-configure | 29 +++++++++++++++++++++++++++++ package.json | 7 ++----- 5 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 clone-flexdll create mode 100644 configure-windows create mode 100644 esy-build create mode 100644 esy-configure diff --git a/clone-flexdll b/clone-flexdll new file mode 100644 index 000000000000..fbeb13c607ae --- /dev/null +++ b/clone-flexdll @@ -0,0 +1,16 @@ +#! /bin/sh + +# clone-flexdll +# +# Brings in flexdll, if necessary + +if [ -d "flexdll" ]; then + echo "[Flexdll] Already present, no need to clone." +else + echo "[Flexdll] Cloning..." + git clone https://github.com/esy-ocaml/flexdll.git + cd flexdll + git checkout f84baaeae463f96f9582883a9cfb7dd1096757ff + cd .. + echo "[Flexdll] Clone successful!" +fi diff --git a/configure-windows b/configure-windows new file mode 100644 index 000000000000..ae6ca8ce6672 --- /dev/null +++ b/configure-windows @@ -0,0 +1,34 @@ +#! /bin/sh + +# configure-windows +# +# Creates a native Windows MingW build, based on: +# https://github.com/ocaml/ocaml/blob/trunk/README.win32.adoc + + +export prefix=C:/ocamlmgw64 +while : ; do + case "$1" in + "") break;; + -prefix|--prefix) + prefix=$2; shift;; + esac + shift +done + +echo "[configure-windows] Prefix path: $prefix" + +echo "[configure-windows] Copying architecture headers." +cp config/m-nt.h byterun/caml/m.h +cp config/s-nt.h byterun/caml/s.h + +# TODO: Differentiate based on architecture - use 'Makefile.mingw' for 32-bit environments +echo "[configure-windows] Bringing over mingw64 Makefile." +cp config/Makefile.mingw64 config/Makefile + +echo "[configure-windows] Replace prefix path with: $prefix." +sed -i "s#PREFIX=C:/ocamlmgw64#PREFIX=$prefix#g" config/Makefile + +echo "[configure-windows] Setting up flexdll" +./clone-flexdll +make flexdll diff --git a/esy-build b/esy-build new file mode 100644 index 000000000000..789edc99874e --- /dev/null +++ b/esy-build @@ -0,0 +1,24 @@ +#! /bin/bash + +# esy-build +# +# Wrapper to execute appropriate build strategy, based on platform + +set -u +set -e +set -o pipefail + +case "$(uname -s)" in + CYGWIN*|MINGW32*|MSYS*) + echo "[esy-build] Detected windows environment..." + make -j1 world.opt + make flexlink.opt + ;; + *) + echo "[esy-build] Detected OSX / Linux environment" + make -j4 world.opt + ;; +esac + +# Common build steps +make install diff --git a/esy-configure b/esy-configure new file mode 100644 index 000000000000..85a8d2da80c1 --- /dev/null +++ b/esy-configure @@ -0,0 +1,29 @@ +#! /bin/bash + +# esy-configure +# +# Wrapper to delegate to configuration to the +# appropriate `configure` strategy based on the active platform. +# +# Today, OCaml has separate build strategies: +# - Linux, OSX, Cygwin (gcc) - https://github.com/ocaml/ocaml/blob/trunk/INSTALL.adoc +# - Windows, Cygin (mingw) - https://github.com/ocaml/ocaml/blob/trunk/README.win32.adoc +# +# We want `esy` to work cross-platform, so this is a shim script that will delegate to the +# appropriate script depending on the platform. We assume that if the platform is `CYGWIN` +# that the `mingw` (native executable) strategy is desired. + +set -u +set -e +set -o pipefail + +case "$(uname -s)" in + CYGWIN*|MINGW32*|MSYS*) + echo "[esy-configure] Detected windows environment..." + ./configure-windows "$@" + ;; + *) + echo "[esy-configure] Detected OSX / Linux environment" + ./configure "$@" + ;; +esac diff --git a/package.json b/package.json index 0dbe57e0c20b..c6f8e1ad05c3 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,8 @@ "description": "BuckleScript's OCaml Compiler as an npm Package", "esy": { "build": [ - "./configure -no-cfi -prefix $cur__install", - "make -j world.opt" - ], - "install": [ - "make install", + "./esy-configure -no-cfi -prefix #{self.install}", + "./esy-build", [ "cp", "-r", From 91694f18ef6d07bc0db750d41e7b162b6d239769 Mon Sep 17 00:00:00 2001 From: Ulrik Date: Sun, 3 Nov 2019 10:03:54 +0100 Subject: [PATCH 3/7] Make esy build files executable --- clone-flexdll | 0 configure-windows | 0 esy-build | 0 esy-configure | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 clone-flexdll mode change 100644 => 100755 configure-windows mode change 100644 => 100755 esy-build mode change 100644 => 100755 esy-configure diff --git a/clone-flexdll b/clone-flexdll old mode 100644 new mode 100755 diff --git a/configure-windows b/configure-windows old mode 100644 new mode 100755 diff --git a/esy-build b/esy-build old mode 100644 new mode 100755 diff --git a/esy-configure b/esy-configure old mode 100644 new mode 100755 From 1cb9da636d52d5f00b137ded83d822d25c6e028c Mon Sep 17 00:00:00 2001 From: Ulrik Strid Date: Sun, 3 Nov 2019 21:20:44 +0100 Subject: [PATCH 4/7] Remove flexdll as it fails at install --- flexdll | 1 - 1 file changed, 1 deletion(-) delete mode 160000 flexdll diff --git a/flexdll b/flexdll deleted file mode 160000 index 7f565ef8647a..000000000000 --- a/flexdll +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7f565ef8647a16e6a2cd2b30c8e6a4894558eaaa From e049040da506cc6a7021454c83b89b09a2a2357e Mon Sep 17 00:00:00 2001 From: Ulrik Strid Date: Sun, 3 Nov 2019 21:35:39 +0100 Subject: [PATCH 5/7] Port fixes from esy-ocaml --- .gitattributes | 4 ++++ config/Makefile.mingw64 | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 0d7fefb049cf..882d913f2003 100644 --- a/.gitattributes +++ b/.gitattributes @@ -103,7 +103,11 @@ yacc/*.[ch] ocaml-typo=long-line,very-long-line,unused-prop *.precheck text eol=lf *.runner text eol=lf +clone-flexdll text eol=lf configure text eol=lf +configure-windows text eol=lf +esy-configure text eol=lf +esy-build text eol=lf config/auto-aux/hasgot text eol=lf config/auto-aux/hasgot2 text eol=lf config/auto-aux/runtest text eol=lf diff --git a/config/Makefile.mingw64 b/config/Makefile.mingw64 index 0466e63c0b60..8403fef58af1 100644 --- a/config/Makefile.mingw64 +++ b/config/Makefile.mingw64 @@ -32,7 +32,7 @@ BINDIR=$(PREFIX)/bin BYTERUN=ocamlrun ### Where to install the standard library -LIBDIR=$(PREFIX)/lib +LIBDIR=$(PREFIX)/lib/ocaml ### Where to install the stub DLLs STUBLIBDIR=$(LIBDIR)/stublibs From 020f84fd0b51b1487d4586980347e123b69eaef5 Mon Sep 17 00:00:00 2001 From: Ulrik Strid Date: Mon, 4 Nov 2019 16:45:59 +0100 Subject: [PATCH 6/7] Remove .gitmodules --- .gitmodules | 3 --- package.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index dca1e0d28f7a..000000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "flexdll"] - path = flexdll - url = https://github.com/alainfrisch/flexdll.git diff --git a/package.json b/package.json index c6f8e1ad05c3..9ecacf29905f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "BuckleScript's OCaml Compiler as an npm Package", "esy": { "build": [ - "./esy-configure -no-cfi -prefix #{self.install}", + "./esy-configure -no-cfi -prefix $cur__target", "./esy-build", [ "cp", From d6dd2a814dfda47c270acc7fc77154cba210afb8 Mon Sep 17 00:00:00 2001 From: Ulrik Strid Date: Tue, 19 Nov 2019 13:35:43 +0100 Subject: [PATCH 7/7] Use #{self.install} instead of $cur__target --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ecacf29905f..c6f8e1ad05c3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "BuckleScript's OCaml Compiler as an npm Package", "esy": { "build": [ - "./esy-configure -no-cfi -prefix $cur__target", + "./esy-configure -no-cfi -prefix #{self.install}", "./esy-build", [ "cp",