Skip to content

Commit c88e65c

Browse files
committed
Copy things from esy-ocaml
1 parent 68e181a commit c88e65c

File tree

5 files changed

+105
-5
lines changed

5 files changed

+105
-5
lines changed

clone-flexdll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/sh
2+
3+
# clone-flexdll
4+
#
5+
# Brings in flexdll, if necessary
6+
7+
if [ -d "flexdll" ]; then
8+
echo "[Flexdll] Already present, no need to clone."
9+
else
10+
echo "[Flexdll] Cloning..."
11+
git clone https://github.com/esy-ocaml/flexdll.git
12+
cd flexdll
13+
git checkout f84baaeae463f96f9582883a9cfb7dd1096757ff
14+
cd ..
15+
echo "[Flexdll] Clone successful!"
16+
fi

configure-windows

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /bin/sh
2+
3+
# configure-windows
4+
#
5+
# Creates a native Windows MingW build, based on:
6+
# https://github.com/ocaml/ocaml/blob/trunk/README.win32.adoc
7+
8+
9+
export prefix=C:/ocamlmgw64
10+
while : ; do
11+
case "$1" in
12+
"") break;;
13+
-prefix|--prefix)
14+
prefix=$2; shift;;
15+
esac
16+
shift
17+
done
18+
19+
echo "[configure-windows] Prefix path: $prefix"
20+
21+
echo "[configure-windows] Copying architecture headers."
22+
cp config/m-nt.h byterun/caml/m.h
23+
cp config/s-nt.h byterun/caml/s.h
24+
25+
# TODO: Differentiate based on architecture - use 'Makefile.mingw' for 32-bit environments
26+
echo "[configure-windows] Bringing over mingw64 Makefile."
27+
cp config/Makefile.mingw64 config/Makefile
28+
29+
echo "[configure-windows] Replace prefix path with: $prefix."
30+
sed -i "s#PREFIX=C:/ocamlmgw64#PREFIX=$prefix#g" config/Makefile
31+
32+
echo "[configure-windows] Setting up flexdll"
33+
./clone-flexdll
34+
make flexdll

esy-build

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#! /bin/bash
2+
3+
# esy-build
4+
#
5+
# Wrapper to execute appropriate build strategy, based on platform
6+
7+
set -u
8+
set -e
9+
set -o pipefail
10+
11+
case "$(uname -s)" in
12+
CYGWIN*|MINGW32*|MSYS*)
13+
echo "[esy-build] Detected windows environment..."
14+
make -j1 world.opt
15+
make flexlink.opt
16+
;;
17+
*)
18+
echo "[esy-build] Detected OSX / Linux environment"
19+
make -j4 world.opt
20+
;;
21+
esac
22+
23+
# Common build steps
24+
make install

esy-configure

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /bin/bash
2+
3+
# esy-configure
4+
#
5+
# Wrapper to delegate to configuration to the
6+
# appropriate `configure` strategy based on the active platform.
7+
#
8+
# Today, OCaml has separate build strategies:
9+
# - Linux, OSX, Cygwin (gcc) - https://github.com/ocaml/ocaml/blob/trunk/INSTALL.adoc
10+
# - Windows, Cygin (mingw) - https://github.com/ocaml/ocaml/blob/trunk/README.win32.adoc
11+
#
12+
# We want `esy` to work cross-platform, so this is a shim script that will delegate to the
13+
# appropriate script depending on the platform. We assume that if the platform is `CYGWIN`
14+
# that the `mingw` (native executable) strategy is desired.
15+
16+
set -u
17+
set -e
18+
set -o pipefail
19+
20+
case "$(uname -s)" in
21+
CYGWIN*|MINGW32*|MSYS*)
22+
echo "[esy-configure] Detected windows environment..."
23+
./configure-windows "$@"
24+
;;
25+
*)
26+
echo "[esy-configure] Detected OSX / Linux environment"
27+
./configure "$@"
28+
;;
29+
esac

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
"description": "BuckleScript's OCaml Compiler as an npm Package",
55
"esy": {
66
"build": [
7-
"./configure -no-cfi -prefix $cur__install",
8-
"make -j world.opt"
9-
],
10-
"install": [
11-
"make install",
7+
"./esy-configure -no-cfi -prefix #{self.install}",
8+
"./esy-build",
129
[
1310
"cp",
1411
"-r",

0 commit comments

Comments
 (0)