diff --git a/.gitignore b/.gitignore index 60ec2724..849751ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,36 +1,8 @@ -# general patterns - -*.o -*.a -*.so -*.obj -*.lib -*.dll -*.cm[ioxat] -*.cmx[as] -*.cmti -*.annot -*.exe -*.exe.manifest -.depend -.depend.nt -.DS_Store -*.out -*.out.dSYM -/tmp/ +/_build ocamlbuild.install -Makefile.config /bootstrap/src /bootstrap/_build* -/src/ocamlbuild_config.ml -/src/lexers.ml -/src/glob_lexer.ml -/ocamlbuild.byte -/ocamlbuild.native - -/man/ocamlbuild.1 -/man/ocamlbuild.options.1 -/man/options_man.byte +.merlin diff --git a/.merlin b/.merlin deleted file mode 100644 index a8d098ba..00000000 --- a/.merlin +++ /dev/null @@ -1,3 +0,0 @@ -S src -S bootstrap -B . diff --git a/.travis.yml b/.travis.yml index 84ea2832..3003cdcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,23 +2,22 @@ language: c os: linux env: - OCAML_VERSION=4.03.0 - - OCAML_VERSION=4.04.0 + - OCAML_VERSION=4.04.2 + - OCAML_VERSION=4.05.0 + - OCAML_VERSION=4.06.1 install: - echo "yes" | sudo add-apt-repository ppa:avsm/ocaml42+opam12 - sudo apt-get update -qq - sudo apt-get install -qq opam - export OPAMYES=1 - opam init --compiler=${OCAML_VERSION} - - opam install ocamlfind camlp4 menhir + - opam install ocamlfind camlp4 menhir jbuilder cppo script: - eval `opam config env` # First, run our own testsuite. Do this *before* any ocamlbuild is installed globally, # to check that we don't have a spurious dependency on a global ocamlbuild. - VERBOSE=1 make test - # Second, bootstrap ourselves using the freshly built binaries, as a more complex - # exercise than the testsuite alone. - - OCAMLBUILD=$(pwd)/ocamlbuild.native make -C bootstrap - # Third, verify that installation works, and a variety of downstream opam packages + # Second, verify that installation works, and a variety of downstream opam packages # still install. - make distclean - opam pin add -n -k path ocamlbuild . diff --git a/Makefile b/Makefile index 9b5f929a..9f75755f 100644 --- a/Makefile +++ b/Makefile @@ -14,223 +14,39 @@ # see 'check-if-preinstalled' target CHECK_IF_PREINSTALLED ?= true -# this configuration file is generated from configure.make -include Makefile.config - -ifeq ($(OCAML_NATIVE_TOOLS), true) -OCAMLC ?= ocamlc.opt -OCAMLOPT ?= ocamlopt.opt -OCAMLDEP ?= ocamldep.opt -OCAMLLEX ?= ocamllex.opt -else -OCAMLC ?= ocamlc -OCAMLOPT ?= ocamlopt -OCAMLDEP ?= ocamldep -OCAMLLEX ?= ocamllex -endif +JBUILDER ?= jbuilder -CP ?= cp -COMPFLAGS ?= -w L -w R -w Z -I src -I +unix -safe-string -bin-annot -LINKFLAGS ?= -I +unix -I src - -PACK_CMO= $(addprefix src/,\ - const.cmo \ - loc.cmo \ - discard_printf.cmo \ - signatures.cmi \ - my_std.cmo \ - my_unix.cmo \ - tags.cmo \ - display.cmo \ - log.cmo \ - shell.cmo \ - bool.cmo \ - glob_ast.cmo \ - glob_lexer.cmo \ - glob.cmo \ - lexers.cmo \ - param_tags.cmo \ - command.cmo \ - ocamlbuild_config.cmo \ - ocamlbuild_where.cmo \ - slurp.cmo \ - options.cmo \ - pathname.cmo \ - configuration.cmo \ - flags.cmo \ - hygiene.cmo \ - digest_cache.cmo \ - resource.cmo \ - rule.cmo \ - solver.cmo \ - report.cmo \ - tools.cmo \ - fda.cmo \ - findlib.cmo \ - ocaml_arch.cmo \ - ocaml_utils.cmo \ - ocaml_dependencies.cmo \ - ocaml_compiler.cmo \ - ocaml_tools.cmo \ - ocaml_specific.cmo \ - exit_codes.cmo \ - plugin.cmo \ - hooks.cmo \ - main.cmo \ - ) - -EXTRA_CMO=$(addprefix src/,\ - ocamlbuild_plugin.cmo \ - ocamlbuild_executor.cmo \ - ocamlbuild_unix_plugin.cmo \ - ) - -PACK_CMX=$(PACK_CMO:.cmo=.cmx) -EXTRA_CMX=$(EXTRA_CMO:.cmo=.cmx) -EXTRA_CMI=$(EXTRA_CMO:.cmo=.cmi) - -INSTALL_LIB=\ - src/ocamlbuildlib.cma \ - src/ocamlbuild.cmo \ - src/ocamlbuild_pack.cmi \ - $(EXTRA_CMO:.cmo=.cmi) - -INSTALL_LIB_OPT=\ - src/ocamlbuildlib.cmxa src/ocamlbuildlib$(EXT_LIB) \ - src/ocamlbuild.cmx src/ocamlbuild$(EXT_OBJ) \ - src/ocamlbuild_pack.cmx \ - $(EXTRA_CMO:.cmo=.cmx) $(EXTRA_CMO:.cmo=$(EXT_OBJ)) - -INSTALL_LIBDIR=$(DESTDIR)$(LIBDIR) -INSTALL_BINDIR=$(DESTDIR)$(BINDIR) -INSTALL_MANDIR=$(DESTDIR)$(MANDIR) - -INSTALL_SIGNATURES=\ - src/signatures.mli \ - src/signatures.cmi \ - src/signatures.cmti +all: + $(JBUILDER) build @install -ifeq ($(OCAML_NATIVE), true) -all: byte native man -else -all: byte man -endif +byte: all # compatibility alias -byte: ocamlbuild.byte src/ocamlbuildlib.cma - # ocamlbuildlight.byte ocamlbuildlightlib.cma -native: ocamlbuild.native src/ocamlbuildlib.cmxa +native: all # compatibility alias allopt: all # compatibility alias distclean:: clean -# The executables - -ocamlbuild.byte: src/ocamlbuild_pack.cmo $(EXTRA_CMO) src/ocamlbuild.cmo - $(OCAMLC) $(LINKFLAGS) -o $@ unix.cma $^ - -ocamlbuildlight.byte: src/ocamlbuild_pack.cmo src/ocamlbuildlight.cmo - $(OCAMLC) $(LINKFLAGS) -o $@ $^ - -ocamlbuild.native: src/ocamlbuild_pack.cmx $(EXTRA_CMX) src/ocamlbuild.cmx - $(OCAMLOPT) $(LINKFLAGS) -o $@ unix.cmxa $^ - -# The libraries - -src/ocamlbuildlib.cma: src/ocamlbuild_pack.cmo $(EXTRA_CMO) - $(OCAMLC) -a -o $@ $^ - -src/ocamlbuildlightlib.cma: src/ocamlbuild_pack.cmo src/ocamlbuildlight.cmo - $(OCAMLC) -a -o $@ $^ - -src/ocamlbuildlib.cmxa: src/ocamlbuild_pack.cmx $(EXTRA_CMX) - $(OCAMLOPT) -a -o $@ $^ - -# The packs - -# Build artifacts are first placed into tmp/ to avoid a race condition -# described in https://caml.inria.fr/mantis/view.php?id=4991. - -src/ocamlbuild_pack.cmo: $(PACK_CMO) - mkdir -p tmp - $(OCAMLC) -pack $^ -o tmp/ocamlbuild_pack.cmo - mv tmp/ocamlbuild_pack.cmi src/ocamlbuild_pack.cmi - mv tmp/ocamlbuild_pack.cmo src/ocamlbuild_pack.cmo - -src/ocamlbuild_pack.cmi: src/ocamlbuild_pack.cmo - -src/ocamlbuild_pack.cmx: $(PACK_CMX) - mkdir -p tmp - $(OCAMLOPT) -pack $^ -o tmp/ocamlbuild_pack.cmx - mv tmp/ocamlbuild_pack.cmx src/ocamlbuild_pack.cmx - mv tmp/ocamlbuild_pack$(EXT_OBJ) src/ocamlbuild_pack$(EXT_OBJ) - -# The lexers - -src/lexers.ml: src/lexers.mll - $(OCAMLLEX) src/lexers.mll -clean:: - rm -f src/lexers.ml -beforedepend:: src/lexers.ml - -src/glob_lexer.ml: src/glob_lexer.mll - $(OCAMLLEX) src/glob_lexer.mll -clean:: - rm -f src/glob_lexer.ml -beforedepend:: src/glob_lexer.ml - -# The config file - -configure: - $(MAKE) -f configure.make all - -# proxy rule for rebuilding configuration files directly from the main Makefile -Makefile.config src/ocamlbuild_config.ml: - $(MAKE) -f configure.make $@ - clean:: - $(MAKE) -f configure.make clean - -distclean:: - $(MAKE) -f configure.make distclean - -beforedepend:: src/ocamlbuild_config.ml + $(JBUILDER) clean # man page -man: man/ocamlbuild.1 +man: _build/install/default/man/man1/ocamlbuild.1 -man/ocamlbuild.1: man/ocamlbuild.header.1 man/ocamlbuild.options.1 man/ocamlbuild.footer.1 - cat $^ > man/ocamlbuild.1 +_build/install/default/man/man1/ocamlbuild.1: + $(JBUILDER) build man/ocamlbuild.1 man/ocamlbuild.options.1: man/options_man.byte ./man/options_man.byte > man/ocamlbuild.options.1 -clean:: - rm -f man/ocamlbuild.options.1 - -distclean:: - 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 - -clean:: - rm -f man/options_man.cm* - rm -f man/options_man.byte -ifdef EXT_OBJ - rm -f man/options_man$(EXT_OBJ) -endif - # Testing test-%: testsuite/%.ml all - cd testsuite && ocaml $(CURDIR)/$< - -test: test-internal test-findlibonly test-external + $(JBUILDER) build testsuite/runtest-$* -clean:: - rm -rf testsuite/_test_* +test: all + $(JBUILDER) runtest --no-buffer --display=short # Installation @@ -266,47 +82,18 @@ else install-bin: install-bin-byte endif -install-bin-opam: - echo 'bin: [' >> ocamlbuild.install - echo ' "ocamlbuild.byte" {"ocamlbuild.byte"}' >> ocamlbuild.install -ifeq ($(OCAML_NATIVE), true) - echo ' "ocamlbuild.native" {"ocamlbuild.native"}' >> ocamlbuild.install - echo ' "ocamlbuild.native" {"ocamlbuild"}' >> ocamlbuild.install -else - echo ' "ocamlbuild.byte" {"ocamlbuild"}' >> ocamlbuild.install -endif - echo ']' >> ocamlbuild.install - echo >> ocamlbuild.install - install-lib-basics: mkdir -p $(INSTALL_LIBDIR)/ocamlbuild $(CP) META $(INSTALL_SIGNATURES) $(INSTALL_LIBDIR)/ocamlbuild -install-lib-basics-opam: - echo ' "opam"' >> ocamlbuild.install - echo ' "META"' >> ocamlbuild.install - for lib in $(INSTALL_SIGNATURES); do \ - echo " \"$$lib\" {\"$$(basename $$lib)\"}" >> ocamlbuild.install; \ - done - install-lib-byte: mkdir -p $(INSTALL_LIBDIR)/ocamlbuild $(CP) $(INSTALL_LIB) $(INSTALL_LIBDIR)/ocamlbuild -install-lib-byte-opam: - for lib in $(INSTALL_LIB); do \ - echo " \"$$lib\" {\"$$(basename $$lib)\"}" >> ocamlbuild.install; \ - done - install-lib-native: mkdir -p $(INSTALL_LIBDIR)/ocamlbuild $(CP) $(INSTALL_LIB_OPT) $(INSTALL_LIBDIR)/ocamlbuild -install-lib-native-opam: - for lib in $(INSTALL_LIB_OPT); do \ - echo " \"$$lib\" {\"$$(basename $$lib)\"}" >> ocamlbuild.install; \ - done - ifeq ($(OCAML_NATIVE), true) install-lib: install-lib-basics install-lib-byte install-lib-native else @@ -322,33 +109,10 @@ else META $(INSTALL_SIGNATURES) $(INSTALL_LIB) endif -install-lib-opam: - echo 'lib: [' >> ocamlbuild.install - $(MAKE) install-lib-basics-opam - $(MAKE) install-lib-byte-opam -ifeq ($(OCAML_NATIVE), true) - $(MAKE) install-lib-native-opam -endif - echo ']' >> ocamlbuild.install - echo >> ocamlbuild.install - install-man: mkdir -p $(INSTALL_MANDIR)/man1 cp man/ocamlbuild.1 $(INSTALL_MANDIR)/man1/ocamlbuild.1 -install-man-opam: - echo 'man: [' >> ocamlbuild.install - echo ' "man/ocamlbuild.1" {"man1/ocamlbuild.1"}' >> ocamlbuild.install - echo ']' >> ocamlbuild.install - echo >> ocamlbuild.install - -install-doc-opam: - echo 'doc: [' >> ocamlbuild.install - echo ' "LICENSE"' >> ocamlbuild.install - echo ' "Changes"' >> ocamlbuild.install - echo ' "Readme.md"' >> ocamlbuild.install - echo ']' >> ocamlbuild.install - uninstall-bin: rm $(BINDIR)/ocamlbuild rm $(BINDIR)/ocamlbuild.byte @@ -395,15 +159,7 @@ findlib-install: check-if-preinstalled findlib-uninstall: uninstall-bin uninstall-lib-findlib opam-install: check-if-preinstalled - $(MAKE) ocamlbuild.install - -ocamlbuild.install: - rm -f ocamlbuild.install - touch ocamlbuild.install - $(MAKE) install-bin-opam - $(MAKE) install-lib-opam - $(MAKE) install-man-opam - $(MAKE) install-doc-opam + $(JBUILDER) build ocamlbuild.install check-if-preinstalled: ifeq ($(CHECK_IF_PREINSTALLED), true) @@ -416,43 +172,6 @@ ifeq ($(CHECK_IF_PREINSTALLED), true) fi endif -# The generic rules - -%.cmo: %.ml - $(OCAMLC) $(COMPFLAGS) -c $< - -%.cmi: %.mli - $(OCAMLC) $(COMPFLAGS) -c $< - -%.cmx: %.ml - $(OCAMLOPT) -for-pack Ocamlbuild_pack $(COMPFLAGS) -c $< - -clean:: - rm -rf tmp/ - rm -f src/*.cm* *.cm* -ifdef EXT_OBJ - rm -f src/*$(EXT_OBJ) *$(EXT_OBJ) -endif -ifdef EXT_LIB - rm -f src/*$(EXT_LIB) *$(EXT_LIB) -endif - rm -f test/test2/vivi.ml - -distclean:: - rm -f ocamlbuild.byte ocamlbuild.native - rm -f ocamlbuild.install - -# The dependencies - -depend: beforedepend - $(OCAMLDEP) -I src src/*.mli src/*.ml > .depend - -$(EXTRA_CMI): src/ocamlbuild_pack.cmi -$(EXTRA_CMO): src/ocamlbuild_pack.cmo src/ocamlbuild_pack.cmi -$(EXTRA_CMX): src/ocamlbuild_pack.cmx src/ocamlbuild_pack.cmi - -include .depend - -.PHONY: all allopt beforedepend clean configure +.PHONY: all allopt beforedepend clean configure test .PHONY: install installopt installopt_really depend diff --git a/bootstrap/Makefile b/bootstrap/Makefile deleted file mode 100644 index c78de5b3..00000000 --- a/bootstrap/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -OCAMLBUILD ?= ocamlbuild - -all: stage2 - -setup: - $(MAKE) -C .. clean - $(MAKE) -C .. src/ocamlbuild_config.ml - ln -sf ../src - mkdir -p bin - -stage1: setup - @echo "BOOTSTRAP (1): building local ocamlbuild from '$(OCAMLBUILD)'" - @$(OCAMLBUILD) -build-dir _build_stage1 bootstrap.otarget - -stage2: stage1 - @echo "BOOTSTRAP (2): building local ocamlbuild from local ocamlbuild" - @_build_stage1/src/ocamlbuild.native -build-dir _build_stage2 bootstrap.otarget - -clean: - @$(OCAMLBUILD) -clean - @$(OCAMLBUILD) -build-dir _build_stage1 -clean - @$(OCAMLBUILD) -build-dir _build_stage2 -clean - @rm -f src - @rm -f bin/ocamlbuild_{stage1,stage2}.native - @rmdir bin - diff --git a/bootstrap/_tags b/bootstrap/_tags deleted file mode 100644 index cecc1436..00000000 --- a/bootstrap/_tags +++ /dev/null @@ -1,27 +0,0 @@ -######################################################################### -# # -# OCaml # -# # -# Nicolas Pouillard, projet Gallium, INRIA Rocquencourt # -# # -# Copyright 2007 Institut National de Recherche en Informatique et # -# en Automatique. All rights reserved. This file is distributed # -# under the terms of the GNU Library General Public License, with # -# the special exception on linking described in file ../LICENSE. # -# # -######################################################################### - -# OCamlbuild tags file -true: debug -"src": include -<**/*.ml> or <**/*.mli>: warn_L, warn_R, warn_Z, annot -"src/discard_printf.ml": rectypes -"ocamlbuildlib.cma" or "ocamlbuildlightlib.cma": linkall -<**/*.byte> or <**/*.native> or <**/*.top>: use_unix -"ocamlbuildlight.byte": -use_unix, nopervasives -<**/*.cmx>: for-pack(Ocamlbuild_pack) -<**/{ocamlbuild_{pack,unix_plugin,plugin,executor},ppcache}{,.p}.cmx>: -for-pack(Ocamlbuild_pack) - -# we have several build stages using different build directories, -# so each build must ignore each other's build dir. -<_build*>: -traverse diff --git a/bootstrap/bootstrap.itarget b/bootstrap/bootstrap.itarget deleted file mode 100644 index cc7fba65..00000000 --- a/bootstrap/bootstrap.itarget +++ /dev/null @@ -1,9 +0,0 @@ -ocamlbuild_pack.cmo -ocamlbuild_pack.cmx -ocamlbuildlightlib.cma -ocamlbuildlib.cma -ocamlbuild.top -ocamlbuild.docdir/index.html -src/ocamlbuildlight.byte -src/ocamlbuild.byte -src/ocamlbuild.native diff --git a/bootstrap/myocamlbuild.ml b/bootstrap/myocamlbuild.ml deleted file mode 100644 index b810d136..00000000 --- a/bootstrap/myocamlbuild.ml +++ /dev/null @@ -1,8 +0,0 @@ -(* You cannot use a myocamlbuild.ml here: depending on - OCamlbuild_plugin will link with both the local library and the - installed version, and you will have weird build errors as soon as - their signatures differ. - - This is an unfortunate side-effect of using ocamlbuild to build its - own plugin: it is too clever to *not* link with the local library. -*) diff --git a/bootstrap/ocamlbuild.mltop b/bootstrap/ocamlbuild.mltop deleted file mode 100644 index 767ed32c..00000000 --- a/bootstrap/ocamlbuild.mltop +++ /dev/null @@ -1,4 +0,0 @@ -Ocamlbuild_pack -Ocamlbuild_plugin -Ocamlbuild_unix_plugin -Ocamlbuild_executor diff --git a/bootstrap/ocamlbuild.odocl b/bootstrap/ocamlbuild.odocl deleted file mode 100644 index 10256992..00000000 --- a/bootstrap/ocamlbuild.odocl +++ /dev/null @@ -1,41 +0,0 @@ -Log -My_unix -My_std -Signatures -Shell -Display -Command -Configuration -Discard_printf -Flags -Hygiene -Options -Pathname -Report -Resource -Rule -Slurp -Solver -Tags -Tools -Fda -Ocaml_specific -Ocaml_arch -Ocamlbuild_where -Ocamlbuild_config -Lexers -Glob -Bool -Glob_ast -Glob_lexer -Plugin -Main -Hooks -Ocaml_utils -Ocaml_tools -Ocaml_compiler -Ocaml_dependencies -Exit_codes -Digest_cache -Ocamlbuild_plugin -Findlib diff --git a/bootstrap/ocamlbuild_pack.mlpack b/bootstrap/ocamlbuild_pack.mlpack deleted file mode 100644 index a04a1a4d..00000000 --- a/bootstrap/ocamlbuild_pack.mlpack +++ /dev/null @@ -1,43 +0,0 @@ -Const -Loc -Log -My_unix -My_std -Signatures -Shell -Display -Command -Configuration -Discard_printf -Flags -Hygiene -Options -Pathname -Report -Resource -Rule -Slurp -Solver -Tags -Tools -Fda -Ocaml_specific -Ocaml_arch -Ocamlbuild_where -Ocamlbuild_config -Lexers -Glob -Bool -Glob_ast -Glob_lexer -Plugin -Main -Hooks -Ocaml_utils -Ocaml_tools -Ocaml_compiler -Ocaml_dependencies -Exit_codes -Digest_cache -Findlib -Param_tags diff --git a/bootstrap/ocamlbuildlib.mllib b/bootstrap/ocamlbuildlib.mllib deleted file mode 100644 index 767ed32c..00000000 --- a/bootstrap/ocamlbuildlib.mllib +++ /dev/null @@ -1,4 +0,0 @@ -Ocamlbuild_pack -Ocamlbuild_plugin -Ocamlbuild_unix_plugin -Ocamlbuild_executor diff --git a/bootstrap/ocamlbuildlightlib.mllib b/bootstrap/ocamlbuildlightlib.mllib deleted file mode 100644 index dc38da3d..00000000 --- a/bootstrap/ocamlbuildlightlib.mllib +++ /dev/null @@ -1,2 +0,0 @@ -Ocamlbuild_pack -Ocamlbuild_plugin diff --git a/configure.make b/configure.make index ab585cd8..392d2931 100644 --- a/configure.make +++ b/configure.make @@ -55,8 +55,6 @@ else OCAML_NATIVE ?= true endif -OCAML_NATIVE_TOOLS ?= $(OCAML_NATIVE) - all: Makefile.config src/ocamlbuild_config.ml clean: @@ -79,7 +77,6 @@ Makefile.config: echo "EXE=$(EXE)"; \ echo ;\ echo "OCAML_NATIVE=$(OCAML_NATIVE)"; \ - echo "OCAML_NATIVE_TOOLS=$(OCAML_NATIVE_TOOLS)"; \ echo "NATDYNLINK=$(NATDYNLINK)"; \ echo "SUPPORT_SHARED_LIBRARIES=$(SUPPORTS_SHARED_LIBRARIES)"; \ echo ;\ @@ -97,7 +94,6 @@ src/ocamlbuild_config.ml: echo 'let ocaml_libdir = "$(abspath $(OCAML_LIBDIR))"'; \ echo 'let libdir_abs = "$(abspath $(OCAMLBUILD_LIBDIR))"'; \ echo 'let ocaml_native = $(OCAML_NATIVE)'; \ - echo 'let ocaml_native_tools = $(OCAML_NATIVE_TOOLS)'; \ echo 'let supports_shared_libraries = $(SUPPORTS_SHARED_LIBRARIES)';\ echo 'let a = "$(A)"'; \ echo 'let o = "$(O)"'; \ diff --git a/man/jbuild b/man/jbuild new file mode 100644 index 00000000..4efe4852 --- /dev/null +++ b/man/jbuild @@ -0,0 +1,19 @@ +(jbuild_version 1) + +(rule + (with-stdout-to ocamlbuild.1 + (progn (cat ${path:ocamlbuild.header.1}) + (cat ${path:ocamlbuild.options.1}) + (cat ${path:ocamlbuild.footer.1})))) + +(rule (with-stdout-to ocamlbuild.options.1 (run ${path:options_man.exe}))) + +(executable + ((name options_man) + (libraries (ocamlbuild.pack)) + (flags (-w L -w R -w Z -safe-string)) + (modes (byte)))) + +(install + ((section man) + (files ((ocamlbuild.1 as man1/ocamlbuild.1))))) diff --git a/opam b/ocamlbuild.opam similarity index 70% rename from opam rename to ocamlbuild.opam index de779664..1b7cdbea 100644 --- a/opam +++ b/ocamlbuild.opam @@ -15,18 +15,11 @@ bug-reports: "https://github.com/ocaml/ocamlbuild/issues" doc: "https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc" build: [ - [make "-f" "configure.make" "all" - "OCAMLBUILD_PREFIX=%{prefix}%" - "OCAMLBUILD_BINDIR=%{bin}%" - "OCAMLBUILD_LIBDIR=%{lib}%" - "OCAMLBUILD_MANDIR=%{man}%" - "OCAML_NATIVE=%{ocaml-native}%" - "OCAML_NATIVE_TOOLS=%{ocaml-native}%"] [make "check-if-preinstalled" "all" "opam-install"] ] available: [ocaml-version >= "4.03"] -depends: [ ] +depends: [ "jbuilder" {>= "1.0+beta19.1"} "cppo" {>= "1.6.0"} ] conflicts: [ "base-ocamlbuild" "ocamlfind" {< "1.6.2"} diff --git a/scripts/cat.ml b/scripts/cat.ml deleted file mode 100644 index 762438c4..00000000 --- a/scripts/cat.ml +++ /dev/null @@ -1,13 +0,0 @@ - - -let () = - let cin = open_in Sys.argv.(1) in - begin try - while true do - print_endline (input_line cin) - done; - with - | End_of_file -> () - | _ -> () - end; - close_in cin diff --git a/src/jbuild b/src/jbuild new file mode 100644 index 00000000..553b460b --- /dev/null +++ b/src/jbuild @@ -0,0 +1,67 @@ +(jbuild_version 1) + +(library + ((name ocamlbuild_pack) + (public_name ocamlbuild.pack) + (libraries (unix)) + (modules (:standard ocamlbuild_config \ ocamlbuild_executor ocamlbuildlight ocamlbuild ocamlbuild_plugin ocamlbuild_unix_plugin ppcache)) + (flags (-w L -w R -w Z -safe-string)) + (modules_without_implementation (signatures)))) + +; This has to be done by hand, because we need myocamlbuild_config.ml to be +; #use_mod'able in the testsuite +(rule + (with-stdout-to ocamlbuild_config.ml + (run ${bin:cppo} + -D "BINDIR ${read:bindir.probed}" + -D "LIBDIR ${read:libdir.probed}" + -D "LIBDIR_ABS ${read:libdir.probed}" + -D "OCAMLLIB ${ocaml_where}" + -D "EXT_LIB ${ext_lib}" + -D "EXT_OBJ ${ext_obj}" + -D "EXT_SO ${ext_dll}" + -D "EXT_EXE ${ext_exe}" + -D "ARCH ${ocaml-config:architecture}" + -D "VERSION ${read:../VERSION}" ${path:ocamlbuild_config.ml.in}))) + +(ocamllex (glob_lexer lexers)) + +; We seem, ahem, to have broken ${ocaml_bin} at some point... +(rule + (ignore-stderr (with-stdout-to bindir.probed (system "opam config var bin || echo ${OCAMLC}")))) + +(rule + (ignore-stderr (with-stdout-to libdir.probed (system "opam config var lib || ocamlfind printconf destdir || echo ${ocaml_where}")))) + +(library + ((name ocamlbuildlib) + (public_name ocamlbuild) + (libraries (ocamlbuild.pack)) + (modules (ocamlbuild_plugin ocamlbuild_executor ocamlbuild_unix_plugin)) + (flags (-w L -w R -w Z -safe-string)) + (wrapped false))) + +(executable + ((name ocamlbuildlight) + (public_name ocamlbuildlight.byte) + (libraries (ocamlbuild.pack unix)) + (flags (-w L -w R -w Z -safe-string)) + (modes (byte)) + (modules (ocamlbuildlight)))) + +(executable + ((name ocamlbuild) + (public_name ocamlbuild) + (libraries (ocamlbuildlib unix)) + (flags (-w L -w R -w Z -safe-string)) + (modes (native byte)) + (modules (ocamlbuild)))) + +(install + ((section bin) + (files ((ocamlbuild.bc as ocamlbuild.byte) (ocamlbuild.exe as ocamlbuild.native))))) + +; Ahem... +(install + ((section lib) + (files (ocamlbuild.cmo ocamlbuild.cmx ocamlbuild.o)))) diff --git a/src/ocamlbuild_config.ml.in b/src/ocamlbuild_config.ml.in new file mode 100644 index 00000000..5c78d6e3 --- /dev/null +++ b/src/ocamlbuild_config.ml.in @@ -0,0 +1,38 @@ +(***********************************************************************) +(* *) +(* ocamlbuild *) +(* *) +(* Nicolas Pouillard, Berke Durak, projet Gallium, INRIA Rocquencourt *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with *) +(* the special exception on linking described in file ../LICENSE. *) +(* *) +(***********************************************************************) + +(* This file used to be generated by `make -f configure.make`, but is now + pre-processed with cppo with values determined by Dune. *) +(* Temporary fix on basename - Dune may have passed ocamlc binary path. + Continue to respect ocamlbuild's arm-gnawing need to be buildable without + Unix. *) +let bindir = + let d = STRINGIFY(BINDIR) in + if Sys.file_exists d then + try Sys.readdir d |> ignore; d + with _ -> + Filename.dirname d + else d +let libdir = STRINGIFY(LIBDIR) +let ocaml_libdir = STRINGIFY(OCAMLLIB) +let libdir_abs = STRINGIFY(LIBDIR_ABS) +let ocaml_native = STRINGIFY(ARCH) <> "none" +(* @@DRA This should be probed from Makefile.config (Dune feature?) *) +let supports_shared_libraries = true +let strip_dot s = String.sub s 1 (String.length s - 1) +let a = strip_dot STRINGIFY(EXT_LIB) +let o = strip_dot STRINGIFY(EXT_OBJ) +let so = strip_dot STRINGIFY(EXT_SO) +let ext_dll = STRINGIFY(EXT_SO) +let exe = STRINGIFY(EXT_EXE) +let version = STRINGIFY(VERSION) diff --git a/src/plugin.ml b/src/plugin.ml index 451f7ece..8ef4e1cb 100644 --- a/src/plugin.ml +++ b/src/plugin.ml @@ -91,7 +91,7 @@ module Make(U:sig end) = "cma", "cmo", !Options.plugin_ocamlc, "byte" in - let (unix_spec, ocamlbuild_lib_spec, ocamlbuild_module_spec) = + let (unix_spec, ocamlbuild_lib_spec, ocamlbuild_pack_spec, ocamlbuild_module_spec) = let use_light_mode = not !Options.native_plugin && !*My_unix.is_degraded in @@ -177,10 +177,10 @@ module Make(U:sig end) = else if use_light_mode then `Nothing else `Lib "unix" in - let ocamlbuild_lib = - if use_ocamlfind_pkgs then `Package "ocamlbuild" - else if use_light_mode then `Local_lib "ocamlbuildlightlib" - else `Local_lib "ocamlbuildlib" in + let (ocamlbuild_lib, ocamlbuild_pack) = + if use_ocamlfind_pkgs then (`Package "ocamlbuild", `Nothing) + else if use_light_mode then (`Local_lib "ocamlbuildlightlib", `Nothing) (* @@DRA TODO *) + else (`Local_lib "ocamlbuildlib", `Local_lib "pack/ocamlbuild_pack") in let ocamlbuild_module = if use_light_mode then `Local_mod "ocamlbuildlight" @@ -199,10 +199,11 @@ module Make(U:sig end) = | `Nothing -> N | `Package pkg -> S[A "-package"; A pkg] | `Lib lib -> P (lib -.- cma) - | `Local_lib llib -> S [A "-I"; A dir; P (in_dir (llib -.- cma))] + | `Local_lib llib -> + S [A "-I"; A (dir/(Filename.dirname llib)); P (in_dir (llib -.- cma))] | `Local_mod lmod -> P (in_dir (lmod -.- cmo)) in - (spec unix_lib, spec ocamlbuild_lib, spec ocamlbuild_module) + (spec unix_lib, spec ocamlbuild_lib, spec ocamlbuild_pack, spec ocamlbuild_module) in let plugin_tags = @@ -232,7 +233,7 @@ module Make(U:sig end) = a .cmo that also relies on them), but before the main plugin source file and ocamlbuild's initialization. *) Cmd(S[compiler; - unix_spec; ocamlbuild_lib_spec; + unix_spec; ocamlbuild_pack_spec; ocamlbuild_lib_spec; T plugin_tags; plugin_config; P plugin_file; ocamlbuild_module_spec; diff --git a/testsuite/jbuild b/testsuite/jbuild new file mode 100644 index 00000000..cadd7e57 --- /dev/null +++ b/testsuite/jbuild @@ -0,0 +1,35 @@ +(jbuild_version 1) + +(rule + ((targets (runtest-internal)) + (deps ((universe) ../src/ocamlbuild_config.ml internal.ml internal_test_header.ml ocamlbuild_test.ml)) + (action (progn (setenv OCAML_COLOR never (run ocaml internal.ml)) + (with-stdout-to ${@} (echo 42)))))) + +(rule + ((targets (runtest-findlibonly)) + (deps ((universe) ../src/ocamlbuild_config.ml findlibonly.ml findlibonly_test_header.ml internal_test_header.ml ocamlbuild_test.ml)) + (action (progn (setenv OCAML_COLOR never (run ocaml findlibonly.ml)) + (with-stdout-to ${@} (echo 42)))))) + +(rule + ((targets (runtest-external)) + (deps ((universe) ../src/ocamlbuild_config.ml external.ml external_test_header.ml findlibonly_test_header.ml internal_test_header.ml ocamlbuild_test.ml)) + (action (progn (setenv OCAML_COLOR never (run ocaml external.ml)) + (with-stdout-to ${@} (echo 42)))))) + +(rule + ((targets (runtest-seq-findlibonly)) + (deps ((universe) runtest-internal findlibonly.ml findlibonly_test_header.ml)) + (action (progn (setenv OCAML_COLOR never (run ocaml findlibonly.ml)) + (with-stdout-to ${@} (echo 42)))))) + +(rule + ((targets (runtest-seq-external)) + (deps ((universe) runtest-seq-findlibonly external.ml external_test_header.ml)) + (action (progn (setenv OCAML_COLOR never (run ocaml external.ml)) + (with-stdout-to ${@} (echo 42)))))) + +(alias + ((name runtest) + (deps (runtest-seq-external)))) diff --git a/testsuite/ocamlbuild_test.ml b/testsuite/ocamlbuild_test.ml index f135b507..af080ac7 100644 --- a/testsuite/ocamlbuild_test.ml +++ b/testsuite/ocamlbuild_test.ml @@ -444,10 +444,10 @@ let run ~root = let test_tree = Filename.dirname (Sys.argv.(0)) in let test_tree = if test_tree = "." then Sys.getcwd () else test_tree in let build_tree = Filename.dirname test_tree in - let ocamlbuild = Filename.concat build_tree "ocamlbuild.byte" in + let ocamlbuild = Filename.concat build_tree "../install/default/bin/ocamlbuild.byte" in let testsuite_opts = [ - (`install_bin_dir build_tree); - (`install_lib_dir (Filename.concat build_tree "src")); + (`install_bin_dir (Filename.concat build_tree "../install/default/bin")); + (`install_lib_dir (Filename.concat build_tree "../install/default/lib/ocamlbuild")); ] in let verbose =