Skip to content

Commit 409bdce

Browse files
authored
Support building with dune (#49)
1 parent 839c1cc commit 409bdce

16 files changed

+385
-167
lines changed

.github/workflows/build.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: build
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
name: ${{ matrix.name }}
6+
runs-on: ${{ matrix.os }}
7+
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
include:
12+
- name: closure-nnp-local
13+
config: --enable-stack-allocation
14+
os: ubuntu-latest
15+
ocamlparam: ''
16+
check_arch: true
17+
18+
- name: flambda-local
19+
config: --enable-flambda --enable-stack-allocation
20+
os: ubuntu-latest
21+
22+
- name: i386
23+
config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
24+
os: ubuntu-latest
25+
ocamlparam: ''
26+
boot_config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
27+
boot_cachekey: 32bit
28+
29+
env:
30+
J: "3"
31+
32+
steps:
33+
- name: Install GNU parallel
34+
if: matrix.os == 'macos-latest'
35+
run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install parallel
36+
37+
- name: Install GCC 32-bit libraries
38+
if: matrix.name == 'i386'
39+
run: |
40+
sudo apt-get install gcc-multilib gfortran-multilib
41+
42+
- name: Checkout the ocaml-jst repo
43+
uses: actions/checkout@master
44+
with:
45+
path: 'ocaml-jst'
46+
47+
- name: Cache OCaml 4.12 and dune
48+
uses: actions/cache@v1
49+
id: cache
50+
with:
51+
path: ${{ github.workspace }}/ocaml-412/_install
52+
key: ${{ matrix.os }}-cache-ocaml-412-dune-341-bits-${{ matrix.boot_cachekey }}
53+
54+
- name: Checkout OCaml 4.12
55+
uses: actions/checkout@master
56+
if: steps.cache.outputs.cache-hit != 'true'
57+
with:
58+
repository: 'ocaml/ocaml'
59+
path: 'ocaml-412'
60+
ref: '4.12'
61+
62+
- name: Setup 32-bit C compiler
63+
if: matrix.name == 'i386' && steps.cache.outputs.cache-hit != 'true'
64+
run: |
65+
mkdir -p ocaml-412/_install/bin
66+
{ echo '#!/bin/sh'; echo 'exec gcc -m32 "$@"'; } > ocaml-412/_install/bin/cc32
67+
chmod +x ocaml-412/_install/bin/cc32
68+
69+
- name: Build OCaml 4.12
70+
if: steps.cache.outputs.cache-hit != 'true'
71+
working-directory: ocaml-412
72+
run: |
73+
export PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH
74+
./configure --prefix=$GITHUB_WORKSPACE/ocaml-412/_install ${{ matrix.boot_config }}
75+
make -j $J world.opt
76+
make install
77+
# Remove unneeded parts to shrink cache file
78+
rm -rf $GITHUB_WORKSPACE/ocaml-412/_install/{lib/ocaml/compiler-libs,lib/ocaml/expunge,bin/*.byte}
79+
80+
- name: Checkout dune github repo
81+
uses: actions/checkout@master
82+
if: steps.cache.outputs.cache-hit != 'true'
83+
with:
84+
repository: 'ocaml/dune'
85+
ref: '3.4.1'
86+
path: 'dune'
87+
88+
- name: Build dune
89+
working-directory: dune
90+
if: steps.cache.outputs.cache-hit != 'true'
91+
run: |
92+
PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH make release
93+
cp dune.exe $GITHUB_WORKSPACE/ocaml-412/_install/bin/dune
94+
95+
- name: Configure OCaml
96+
working-directory: ocaml-jst
97+
run: |
98+
export PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH
99+
autoconf
100+
./configure \
101+
--prefix=$GITHUB_WORKSPACE/_install \
102+
${{ matrix.config }}
103+
104+
- name: Build, install and test ocaml-jst
105+
working-directory: ocaml-jst
106+
run: |
107+
export PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH
108+
make -f Makefile.jst runtest-upstream
109+
env:
110+
BUILD_OCAMLPARAM: ${{ matrix.ocamlparam }}

.github/workflows/main.yml

-107
This file was deleted.

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ _build
5656
/ocamlopt.opt
5757
/ocamlnat
5858
/dirs-to-ignore.inc
59+
/dune-project
60+
/*.sexp
61+
/_install
62+
/_runtest
5963

6064
# specific files and patterns in sub-directories
6165

HACKING.jst.adoc

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
= Hacking on ocaml-jst
2+
3+
ocaml-jst has a dune-based build system which is different from
4+
upstream OCaml. To get started, you'll need a working install of OCaml
5+
4.12 and dune, e.g. via OPAM:
6+
7+
$ opam switch create 4.12.0
8+
$ eval $(opam env)
9+
$ opam install dune
10+
11+
You should also install merlin:
12+
13+
$ opam install merlin
14+
15+
and follow its instructions for how to set up your editor.
16+
17+
Once you have OCaml and dune, you can build and test ocaml-jst with:
18+
19+
$ ./configure --prefix=/where/to/install
20+
$ make -f Makefile.jst runtest-upstream
21+
22+
Other useful Makefile targets are:
23+
24+
$ make -f Makefile.jst compiler
25+
26+
to build without running the testsuite, or:
27+
28+
$ make -f Makefile.jst hacking
29+
30+
to start a continuously polling build of the compiler.

Makefile.common-jst

+6-1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ runtest-upstream: _install
241241
mkdir _runtest/tools
242242
ln -s ../_install/bin/ocamlmklib.byte _runtest/tools/ocamlmklib
243243
ln -s ../_install/bin/ocamlobjinfo.byte _runtest/tools/ocamlobjinfo
244+
# ocamldoc
245+
rm _runtest/ocamldoc
246+
mkdir _runtest/ocamldoc
247+
ln -s ../../_install/bin/ocamldoc.byte _runtest/ocamldoc/ocamldoc
248+
cp $(main_build)/$(ocamldir)/ocamldoc/.odoc_lib.objs/byte/*.cm* _runtest/ocamldoc
244249
# ocamltest itself
245250
mkdir _runtest/ocamltest
246251
cp $(main_build)/$(ocamldir)/ocamltest/ocamltest.byte _runtest/ocamltest/ocamltest
@@ -277,4 +282,4 @@ runtest-upstream: _install
277282
# This target is like a polling version of upstream "make ocamlopt"
278283
.PHONY: hacking
279284
hacking: _build/_bootinstall
280-
$(dune) build $(ws_boot) -w boot_ocamlopt.exe
285+
$(dune) build $(ws_boot) -w $(boot_ocamlopt)

Makefile.config.in

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ STDLIB_MANPAGES=@stdlib_manpages@
247247
NAKED_POINTERS=@naked_pointers@
248248
INTEL_JCC_BUG_CFLAGS=@intel_jcc_bug_cflags@
249249
STACK_ALLOCATION=@stack_allocation@
250+
DUNE=@dune@
250251

251252
### Native command to build ocamlrun.exe
252253

Makefile.jst

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
SHELL = /usr/bin/env bash
2+
include Makefile.config
3+
export ARCH
4+
5+
6+
ifeq ($(shell test -x '$(DUNE)' || echo fail), fail)
7+
$(error Dune not found. Run ./configure --with-dune=/path/to/dune.exe (See HACKING.jst))
8+
endif
9+
10+
dune = $(DUNE)
11+
12+
ifeq ($(shell which ocamlopt >& /dev/null || echo fail), fail)
13+
$(error ocamlopt not found. See HACKING.jst)
14+
endif
15+
16+
boot_ocamlc = main_native.exe
17+
boot_ocamlopt = optmain_native.exe
18+
boot_ocamlmklib = tools/ocamlmklib.exe
19+
boot_ocamldep = tools/ocamldep.exe
20+
boot_ocamlobjinfo = tools/objinfo.exe
21+
ocamldir = .
22+
#toplevels_installed = top opttop
23+
toplevels_installed = top
24+
25+
26+
dune-project: dune-project.jst
27+
cp $^ $@
28+
29+
duneconf/jst-extra.inc:
30+
echo '(include ../jst.dune)' > $@
31+
32+
include Makefile.common-jst

0 commit comments

Comments
 (0)