diff options
author | David Allsopp <david.allsopp@metastack.com> | 2019-06-18 14:35:06 +0100 |
---|---|---|
committer | David Allsopp <david.allsopp@metastack.com> | 2019-06-18 14:43:51 +0100 |
commit | 5bb4b7b8caba64e34553c3dbb53caf3954d1648c (patch) | |
tree | bb0b94032d203914ca94e51551d84784ca84b06a | |
parent | a719baac557f5697cf6a769a77dd6fda6d8956a4 (diff) | |
download | ocaml-5bb4b7b8caba64e34553c3dbb53caf3954d1648c.tar.gz |
Move AST testing rules to Makefile.dev (#8743)
Makefile.dev is only included if a Git clone is detected.
make evaluates macros in target specifications when the Makefile is
read, which meant that the build-all-asts target caused `git ls-files`
to be called on every invocation of make. This tweaks it to be a
recursive call to make which puts the $(AST_FILES) macro in the recipe
where it is only evaluated when the target is requested.
(cherry picked from commit 93ee6b43b05783d56e3d8d984fb2503f5870807d)
-rw-r--r-- | HACKING.adoc | 4 | ||||
-rw-r--r-- | Makefile | 31 | ||||
-rw-r--r-- | Makefile.dev | 48 |
3 files changed, 55 insertions, 28 deletions
diff --git a/HACKING.adoc b/HACKING.adoc index 93c6e4fe67..3941a6f372 100644 --- a/HACKING.adoc +++ b/HACKING.adoc @@ -229,6 +229,10 @@ installation, the following targets may be of use: `make -C testsuite parallel`:: see link:testsuite/HACKING.adoc[] +Additionally, there are some developer specific targets in link:Makefile.dev[]. +These targets are automatically available when working in a Git clone of the +repository, but are not available from a tarball. + === Bootstrapping The OCaml compiler is bootstrapped. This means that @@ -1279,34 +1279,9 @@ partialclean:: beforedepend:: bytecomp/opcodes.ml -# Testing the parser -- see parsing/HACKING.adoc - -SOURCE_FILES=$(shell git ls-files '*.ml' '*.mli' | grep -v boot/menhir/parser) - -AST_FILES=$(addsuffix .ast,$(SOURCE_FILES)) - -build-all-asts: $(AST_FILES) - -CAMLC_DPARSETREE := \ - $(CAMLRUN) ./ocamlc -nostdlib -nopervasives \ - -stop-after parsing -dparsetree - -%.ml.ast: %.ml ocamlc - $(CAMLC_DPARSETREE) $< 2> $@ || exit 0 -# `|| exit 0` : some source files will fail to parse -# (for example, they are meant as toplevel scripts -# rather than source files, or are parse-error tests), -# we ignore the failure in that case - -%.mli.ast: %.mli ocamlc - $(CAMLC_DPARSETREE) $< 2> $@ || exit 0 - -.PHONY: list-all-asts -list-all-asts: - @for f in $(AST_FILES); do echo "'$$f'"; done - -partialclean:: - rm -f $(AST_FILES) +ifneq "$(wildcard .git)" "" +include Makefile.dev +endif # Default rules diff --git a/Makefile.dev b/Makefile.dev new file mode 100644 index 0000000000..de69a1bf8f --- /dev/null +++ b/Makefile.dev @@ -0,0 +1,48 @@ +#************************************************************************** +#* * +#* OCaml * +#* * +#* Gabriel Scherer, projet Parsifal, INRIA Saclay * +#* * +#* Copyright 2018 Institut National de Recherche en Informatique et * +#* en Automatique. * +#* * +#* All rights reserved. This file is distributed under the terms of * +#* the GNU Lesser General Public License version 2.1, with the * +#* special exception on linking described in the file LICENSE. * +#* * +#************************************************************************** + +# Developer-only rules, included in Makefile when a Git repository is detected. + +# Testing the parser -- see parsing/HACKING.adoc + +SOURCE_FILES=$(shell git ls-files '*.ml' '*.mli' | grep -v boot/menhir/parser) + +AST_FILES=$(addsuffix .ast,$(SOURCE_FILES)) + +build-all-asts: +# Recursive invocation ensures that `git ls-files` is not executed on every +# invocation of make + @$(MAKE) --no-print-directory $(AST_FILES) + +CAMLC_DPARSETREE := \ + $(CAMLRUN) ./ocamlc -nostdlib -nopervasives \ + -stop-after parsing -dparsetree + +%.ml.ast: %.ml ocamlc + $(CAMLC_DPARSETREE) $< 2> $@ || exit 0 +# `|| exit 0` : some source files will fail to parse +# (for example, they are meant as toplevel scripts +# rather than source files, or are parse-error tests), +# we ignore the failure in that case + +%.mli.ast: %.mli ocamlc + $(CAMLC_DPARSETREE) $< 2> $@ || exit 0 + +.PHONY: list-all-asts +list-all-asts: + @for f in $(AST_FILES); do echo "'$$f'"; done + +partialclean:: + rm -f $(AST_FILES) |