Skip to content

Commit

Permalink
Merge pull request #3618 from dra27/dune
Browse files Browse the repository at this point in the history
Port build system to Dune
  • Loading branch information
rjbou committed Oct 25, 2018
2 parents a2781ff + 031faeb commit ea334b4
Show file tree
Hide file tree
Showing 87 changed files with 680 additions and 648 deletions.
18 changes: 11 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ src_ext/extlib/
src_ext/mccs/
src_ext/re/
src_ext/ocamlgraph/
src_ext/jbuilder/
src_ext/dune-local/
src_ext/result/
src_ext/opam-file-format/
src_ext/camlp4
Expand All @@ -28,7 +28,7 @@ src_ext/*.tar.gz
src_ext/archives/*
src_ext/*.*download
src_ext/*.pkgbuild
src_ext/jbuild-ignore
src_ext/dune
Opam.Runtime.*/
*.tar.bz2
*.annot
Expand Down Expand Up @@ -66,12 +66,16 @@ config.log
config.status
aclocal.m4
autom4te.cache
src/ocaml-flags-configure.sexp
src/*/.merlin
src/client/manifest.inc
src/client/opamManifest.inc
src/client/*.dll
src/stubs/jbuild
src/tools/opam-putenv.inc
src/client/linking.sexp
src/core/developer
src/core/version
src/manifest/dune
src/manifest/install.inc
src/stubs/cc64
src/stubs/dune
src/stubs/c-flags.sexp
# doc
doc/dev-manual/*aux
doc/dev-manual/*.html
Expand Down
2 changes: 1 addition & 1 deletion .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ init-bootstrap () {
eval $(opam env)
# extlib is installed, since UChar.cmi causes problems with the search
# order. See also the removal of uChar and uTF8 in src_ext/jbuild-extlib-src
opam install cohttp-lwt-unix ssl cmdliner dose3 cudf.0.9 opam-file-format re extlib 'jbuilder>=1.0+beta19' 'mccs>=1.1+5' --yes
opam install cohttp-lwt-unix ssl cmdliner dose3 cudf.0.9 opam-file-format re extlib dune 'mccs>=1.1+5' --yes
fi
rm -f "$OPAMBSROOT"/log/*
}
Expand Down
79 changes: 41 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,52 @@ endif
all: opam opam-installer
@

ifeq ($(JBUILDER),)
JBUILDER_FILE = src_ext/jbuilder/_build/install/default/bin/jbuilder$(EXE)
ifeq ($(DUNE),)
DUNE_EXE = src_ext/dune-local/_build/install/default/bin/dune$(EXE)
ifeq ($(shell command -v cygpath 2>/dev/null),)
JBUILDER := $(JBUILDER_FILE)
DUNE := $(DUNE_EXE)
else
JBUILDER := $(shell echo "$(JBUILDER_FILE)" | cygpath -f - -a)
DUNE := $(shell echo "$(DUNE_EXE)" | cygpath -f - -a)
endif
else
JBUILDER_FILE=
DUNE_EXE=
endif

OPAMINSTALLER = ./opam-installer$(EXE)

ALWAYS:
@

JBUILDER_DEP = $(JBUILDER_FILE)
DUNE_DEP = $(DUNE_EXE)
JBUILDER_ARGS ?=
DUNE_ARGS ?= $(JBUILDER_ARGS)
DUNE_PROFILE ?= release

src_ext/jbuilder/_build/install/default/bin/jbuilder$(EXE): src_ext/jbuilder.stamp
cd src_ext/jbuilder && ocaml bootstrap.ml && ./boot.exe
src_ext/dune-local/_build/install/default/bin/dune$(EXE): src_ext/dune-local.stamp
cd src_ext/dune-local && ocaml bootstrap.ml && ./boot.exe --release

src_ext/jbuilder.stamp:
$(MAKE) -C src_ext jbuilder.stamp
src_ext/dune-local.stamp:
$(MAKE) -C src_ext dune-local.stamp

jbuilder: $(JBUILDER_DEP)
@$(JBUILDER) build $(JBUILDER_ARGS) @install
dune: $(DUNE_DEP)
@$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) @install

opam: $(JBUILDER_DEP) opam.install
opam: $(DUNE_DEP) opam.install
$(LN_S) -f _build/default/src/client/opamMain.exe $@$(EXE)
ifneq ($(MANIFEST_ARCH),)
@mkdir -p Opam.Runtime.$(MANIFEST_ARCH)
@cp -f src/client/Opam.Runtime.$(MANIFEST_ARCH).manifest Opam.Runtime.$(MANIFEST_ARCH)/
@cd Opam.Runtime.$(MANIFEST_ARCH) && $(LN_S) -f ../src/client/libstdc++-6.dll .
@cd Opam.Runtime.$(MANIFEST_ARCH) && $(LN_S) -f ../src/client/libwinpthread-1.dll .
@cd Opam.Runtime.$(MANIFEST_ARCH) && $(LN_S) -f ../src/client/$(RUNTIME_GCC_S).dll .
@cp -f src/manifest/Opam.Runtime.$(MANIFEST_ARCH).manifest Opam.Runtime.$(MANIFEST_ARCH)/
@cd Opam.Runtime.$(MANIFEST_ARCH) && $(LN_S) -f ../_build/install/default/bin/Opam.Runtime.$(MANIFEST_ARCH)/libstdc++-6.dll .
@cd Opam.Runtime.$(MANIFEST_ARCH) && $(LN_S) -f ../_build/install/default/bin/Opam.Runtime.$(MANIFEST_ARCH)/libwinpthread-1.dll .
@cd Opam.Runtime.$(MANIFEST_ARCH) && $(LN_S) -f ../_build/install/default/bin/Opam.Runtime.$(MANIFEST_ARCH)/$(RUNTIME_GCC_S).dll .
endif

opam-installer: $(JBUILDER_DEP)
$(JBUILDER) build $(JBUILDER_ARGS) src/tools/opam_installer.exe
opam-installer: $(DUNE_DEP)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) src/tools/opam_installer.exe
$(LN_S) -f _build/default/src/tools/opam_installer.exe $@$(EXE)

opam-admin.top: $(JBUILDER_DEP)
$(JBUILDER) build $(JBUILDER_ARGS) src/tools/opam_admin_top.bc
opam-admin.top: $(DUNE_DEP)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) src/tools/opam_admin_top.bc
$(LN_S) -f _build/default/src/tools/opam_admin_top.bc $@$(EXE)

lib-ext:
Expand All @@ -73,8 +76,8 @@ clean:
distclean: clean clean-ext
rm -rf autom4te.cache bootstrap
rm -f Makefile.config config.log config.status aclocal.m4
rm -f src/*.META src/*/.merlin src/stubs/jbuild src/client/*.dll
rm -f src/tools/opam-putenv.inc src/client/manifest.inc src/client/opamManifest.inc
rm -f src/*.META src/*/.merlin src/manifest/dune src/manifest/install.inc src/stubs/dune src/stubs/cc64 src/ocaml-flags-configure.sexp
rm -f src/client/linking.sexp src/stubs/c-flags.sexp src/core/developer src/core/version

OPAMINSTALLER_FLAGS = --prefix "$(DESTDIR)$(prefix)"
OPAMINSTALLER_FLAGS += --mandir "$(DESTDIR)$(mandir)"
Expand All @@ -93,15 +96,15 @@ ifneq ($(LIBINSTALL_DIR),)
OPAMINSTALLER_FLAGS += --libdir "$(LIBINSTALL_DIR)"
endif

opam-devel.install: $(JBUILDER_DEP)
$(JBUILDER) build $(JBUILDER_ARGS) -p opam opam.install
opam-devel.install: $(DUNE_DEP)
$(DUNE) build $(DUNE_ARGS) -p opam opam.install
sed -e "s/bin:/libexec:/" opam.install > $@

opam-%.install: $(JBUILDER_DEP)
$(JBUILDER) build $(JBUILDER_ARGS) -p opam-$* $@
opam-%.install: $(DUNE_DEP)
$(DUNE) build $(DUNE_ARGS) -p opam-$* $@

opam.install: $(JBUILDER_DEP)
$(JBUILDER) build $(JBUILDER_ARGS) opam-installer.install opam.install
opam.install: ALWAYS $(DUNE_DEP)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) opam-installer.install opam.install

opam-actual.install: opam.install man
@echo 'bin: [' > $@
Expand All @@ -119,11 +122,11 @@ opam-actual.install: opam.install man

OPAMLIBS = core format solver repository state client

opam-%: $(JBUILDER_DEP)
$(JBUILDER) build $(JBUILDER_ARGS) opam-$*.install
opam-%: $(DUNE_DEP)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) opam-$*.install

opam-lib: $(JBUILDER_DEP)
$(JBUILDER) build $(JBUILDER_ARGS) $(patsubst %,opam-%.install,$(OPAMLIBS))
opam-lib: $(DUNE_DEP)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) $(patsubst %,opam-%.install,$(OPAMLIBS))

installlib-%: opam-installer opam-%.install
$(if $(wildcard src_ext/lib/*),\
Expand All @@ -134,7 +137,7 @@ installlib-%: opam-installer opam-%.install
uninstalllib-%: opam-installer opam-%.install
$(OPAMINSTALLER) -u $(OPAMINSTALLER_FLAGS) opam-$*.install

libinstall: $(JBUILDER_DEP) opam-admin.top $(OPAMLIBS:%=installlib-%)
libinstall: $(DUNE_DEP) opam-admin.top $(OPAMLIBS:%=installlib-%)
@

install: opam-actual.install
Expand All @@ -148,12 +151,12 @@ uninstall: opam-actual.install
$(OPAMINSTALLER) -u $(OPAMINSTALLER_FLAGS) $<

checker:
$(JBUILDER) build src/tools/opam_check.exe
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) src/tools/opam_check.exe

.PHONY: tests tests-local tests-git
tests: $(JBUILDER_DEP)
$(JBUILDER) build opam.install src/tools/opam_check.exe
$(JBUILDER) runtest --force --no-buffer $(JBUILDER_ARGS) src/ tests/
tests: $(DUNE_DEP)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) opam.install src/tools/opam_check.exe
$(DUNE) runtest --force --no-buffer --profile=$(DUNE_PROFILE) $(DUNE_ARGS) src/ tests/

# tests-local, tests-git
tests-%:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OCAMLFIND = @OCAMLFIND@
OCAML = @OCAML@
OCAMLC = @OCAMLC@
OCAMLOPT = @OCAMLOPT@
JBUILDER = @JBUILDER@
DUNE = @DUNE@
LN_S = @LN_S@

EXE = @EXE@
Expand Down
2 changes: 1 addition & 1 deletion appveyor_build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ set CYGWIN_UPGRADE_REQUIRED=0
for %%P in (%CYGWIN_PACKAGES%) do call :CheckPackage %%P
call :UpgradeCygwin

rem Use dra27 jbuilder/ocaml-mccs/flexdll for native ports
rem Use dra27 flexdll for native ports
if "%OCAML_PORT%" neq "" git apply appveyor.patch

set INSTALLED_URL=
Expand Down
Loading

0 comments on commit ea334b4

Please sign in to comment.