Skip to content

Commit

Permalink
Merge pull request ocaml#12706 from shindere/merge-testsuite-sub-make…
Browse files Browse the repository at this point in the history
…files

Merge testsuite sub-makefiles in the root Makefile and harden build system
  • Loading branch information
shindere authored Nov 30, 2023
2 parents 982cf75 + c20c1ff commit d5b5c34
Show file tree
Hide file tree
Showing 23 changed files with 385 additions and 231 deletions.
127 changes: 127 additions & 0 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -9495,3 +9495,130 @@ ocamltest/variables.cmo : \
ocamltest/variables.cmx : \
ocamltest/variables.cmi
ocamltest/variables.cmi :
testsuite/lib/lib.cmo : \
testsuite/lib/lib.cmi
testsuite/lib/lib.cmx : \
testsuite/lib/lib.cmi
testsuite/lib/lib.cmi :
testsuite/lib/testing.cmo : \
testsuite/lib/testing.cmi
testsuite/lib/testing.cmx : \
testsuite/lib/testing.cmi
testsuite/lib/testing.cmi :
testsuite/tools/codegen_main.cmo : \
utils/profile.cmi \
testsuite/tools/parsecmmaux.cmi \
testsuite/tools/parsecmm.cmi \
testsuite/tools/lexcmm.cmi \
asmcomp/emitaux.cmi \
asmcomp/emit.cmi \
middle_end/compilenv.cmi \
utils/clflags.cmi \
asmcomp/asmgen.cmi \
testsuite/tools/codegen_main.cmi
testsuite/tools/codegen_main.cmx : \
utils/profile.cmx \
testsuite/tools/parsecmmaux.cmx \
testsuite/tools/parsecmm.cmx \
testsuite/tools/lexcmm.cmx \
asmcomp/emitaux.cmx \
asmcomp/emit.cmx \
middle_end/compilenv.cmx \
utils/clflags.cmx \
asmcomp/asmgen.cmx \
testsuite/tools/codegen_main.cmi
testsuite/tools/codegen_main.cmi :
testsuite/tools/expect.cmo : \
utils/warnings.cmi \
toplevel/toploop.cmi \
parsing/printast.cmi \
parsing/pprintast.cmi \
parsing/parsetree.cmi \
parsing/parse.cmi \
utils/misc.cmi \
driver/main_args.cmi \
parsing/location.cmi \
utils/load_path.cmi \
driver/compmisc.cmi \
driver/compenv.cmi \
utils/clflags.cmi \
typing/btype.cmi \
parsing/asttypes.cmi \
parsing/ast_mapper.cmi \
testsuite/tools/expect.cmi
testsuite/tools/expect.cmx : \
utils/warnings.cmx \
toplevel/toploop.cmx \
parsing/printast.cmx \
parsing/pprintast.cmx \
parsing/parsetree.cmi \
parsing/parse.cmx \
utils/misc.cmx \
driver/main_args.cmx \
parsing/location.cmx \
utils/load_path.cmx \
driver/compmisc.cmx \
driver/compenv.cmx \
utils/clflags.cmx \
typing/btype.cmx \
parsing/asttypes.cmi \
parsing/ast_mapper.cmx \
testsuite/tools/expect.cmi
testsuite/tools/expect.cmi : \
parsing/location.cmi
testsuite/tools/lexcmm.cmo : \
testsuite/tools/parsecmm.cmi \
utils/misc.cmi \
parsing/location.cmi \
lambda/lambda.cmi \
testsuite/tools/lexcmm.cmi
testsuite/tools/lexcmm.cmx : \
testsuite/tools/parsecmm.cmx \
utils/misc.cmx \
parsing/location.cmx \
lambda/lambda.cmx \
testsuite/tools/lexcmm.cmi
testsuite/tools/lexcmm.cmi : \
testsuite/tools/parsecmm.cmi
testsuite/tools/parsecmm.cmo : \
testsuite/tools/parsecmmaux.cmi \
utils/misc.cmi \
parsing/location.cmi \
lambda/lambda.cmi \
lambda/debuginfo.cmi \
utils/config.cmi \
asmcomp/cmm.cmi \
parsing/asttypes.cmi \
asmcomp/arch.cmi \
testsuite/tools/parsecmm.cmi
testsuite/tools/parsecmm.cmx : \
testsuite/tools/parsecmmaux.cmx \
utils/misc.cmx \
parsing/location.cmx \
lambda/lambda.cmx \
lambda/debuginfo.cmx \
utils/config.cmx \
asmcomp/cmm.cmx \
parsing/asttypes.cmi \
asmcomp/arch.cmx \
testsuite/tools/parsecmm.cmi
testsuite/tools/parsecmm.cmi : \
parsing/location.cmi \
lambda/lambda.cmi \
asmcomp/cmm.cmi
testsuite/tools/parsecmmaux.cmo : \
parsing/location.cmi \
lambda/lambda.cmi \
lambda/debuginfo.cmi \
middle_end/backend_var.cmi \
testsuite/tools/parsecmmaux.cmi
testsuite/tools/parsecmmaux.cmx : \
parsing/location.cmx \
lambda/lambda.cmx \
lambda/debuginfo.cmx \
middle_end/backend_var.cmx \
testsuite/tools/parsecmmaux.cmi
testsuite/tools/parsecmmaux.cmi : \
parsing/location.cmi \
lambda/debuginfo.cmi \
middle_end/backend_var.cmi
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ META
/ocamldoc/odoc_text_parser.ml
/ocamldoc/odoc_text_parser.mli
/ocamldoc/*.output
/ocamldoc/test_stdlib
/ocamldoc/test_latex
/ocamldoc/test

/ocamltest/.dep
/ocamltest/ocamltest
/ocamltest/ocamltest.opt
/ocamltest/ocamltest_config.ml
Expand Down Expand Up @@ -273,9 +269,8 @@ META

/testsuite/_retries


/testsuite/tools/codegen
/testsuite/tools/expect_test
/testsuite/tools/expect
/testsuite/tools/lexcmm.ml
/testsuite/tools/parsecmm.ml
/testsuite/tools/parsecmm.mli
Expand Down
6 changes: 3 additions & 3 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ Working version

### Build system:

- #12198, #12321, #12586, #12616: continue the merge of the sub-makefiles
into the root Makefile started with #11243, #11248, #11268, #11420
and #11675.
- #12198, #12321, #12586, #12616, #12706: continue the merge of the
sub-makefiles into the root Makefile started with #11243, #11248,
#11268, #11420 and #11675.
(Sébastien Hinderer, review by David Allsopp and Florian Angeletti)

- #12569, #12570: remove 'otherlibraries' as a prerequisite for 'runtop';
Expand Down
87 changes: 69 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ endif

OC_OCAMLDEPDIRS = $(VPATH)

OCAMLTEST_OPT=$(WITH_OCAMLTEST:=.opt)

# This list is passed to expunge, which accepts both uncapitalized and
# capitalized module names.
PERVASIVES=$(STDLIB_MODULES) outcometree topprinters topdirs toploop
Expand Down Expand Up @@ -543,14 +541,15 @@ $(foreach PROGRAM, $(OCAML_PROGRAMS),\
OCAML_BYTECODE_PROGRAMS = expunge \
$(TOOLS_BYT_PROGRAMS) \
$(addprefix tools/, cvt_emit make_opcodes ocamltex) \
debugger/ocamldebug
$(OPTIONAL_BYTECODE_TOOLS)

$(foreach PROGRAM, $(OCAML_BYTECODE_PROGRAMS),\
$(eval $(call OCAML_BYTECODE_PROGRAM,$(PROGRAM))))

# OCaml programs that are compiled only in native code

OCAML_NATIVE_PROGRAMS = ocamlnat tools/lintapidiff.opt
OCAML_NATIVE_PROGRAMS = \
ocamlnat tools/lintapidiff.opt $(OPTIONAL_NATIVE_TOOLS)

$(foreach PROGRAM, $(OCAML_NATIVE_PROGRAMS),\
$(eval $(call OCAML_NATIVE_PROGRAM,$(PROGRAM))))
Expand Down Expand Up @@ -580,11 +579,7 @@ $(COMPILERLIBS:=.cma): \

compilerlibs/ocamlcommon.cma: $(ALL_CONFIG_CMO)

OCAML_LIBRARIES = $(COMPILERLIBS)

ifeq "$(build_ocamldoc)" "true"
OCAML_LIBRARIES += ocamldoc/odoc_info
endif
OCAML_LIBRARIES = $(COMPILERLIBS) $(OPTIONAL_LIBRARIES)

$(foreach LIBRARY, $(OCAML_LIBRARIES),\
$(eval $(call OCAML_LIBRARY,$(LIBRARY))))
Expand Down Expand Up @@ -751,12 +746,12 @@ endif
# computed at configure time to keep track of which tools and libraries
# need to be built
$(MAKE) otherlibraries $(WITH_DEBUGGER) $(OCAMLDOC_TARGET) \
$(WITH_OCAMLTEST)
$(OCAMLTEST_TARGET)
$(MAKE) ocamlopt.opt
$(MAKE) otherlibrariesopt
$(MAKE) ocamllex.opt ocamltoolsopt ocamltoolsopt.opt \
$(OCAMLDOC_OPT_TARGET) \
$(OCAMLTEST_OPT) othertools ocamlnat
$(OCAMLTEST_OPT_TARGET) othertools ocamlnat
ifeq "$(build_libraries_manpages)" "true"
$(MAKE) manpages
endif
Expand Down Expand Up @@ -795,7 +790,7 @@ endif
all: coreall
$(MAKE) ocaml
$(MAKE) otherlibraries $(WITH_DEBUGGER) $(OCAMLDOC_TARGET) \
$(WITH_OCAMLTEST)
$(OCAMLTEST_TARGET)
$(MAKE) othertools
ifeq "$(build_libraries_manpages)" "true"
$(MAKE) manpages
Expand Down Expand Up @@ -1729,6 +1724,8 @@ ocamldoc/ocamldoc.opt$(EXE): ocamlc.opt ocamlyacc ocamllex

# OCamltest

ifeq "$(build_ocamltest)" "true"

# Libraries ocamltest depends on

ocamltest_LIBRARIES = \
Expand Down Expand Up @@ -1803,13 +1800,50 @@ $(ocamltest_DEP_FILES): $(DEPDIR)/ocamltest/%.$(D): ocamltest/%.c

ocamltest/%: CAMLC = $(BEST_OCAMLC) $(STDLIBFLAGS)

ocamltest: ocamltest/ocamltest$(EXE)
ocamltest: ocamltest/ocamltest$(EXE) \
testsuite/lib/lib.cmo testsuite/lib/testing.cma testsuite/tools/expect$(EXE)

testsuite/lib/%: VPATH += testsuite/lib

testing_SOURCES = testsuite/lib/testing.mli testsuite/lib/testing.ml
testing_LIBRARIES =

$(addprefix testsuite/lib/testing., cma cmxa): \
OC_COMMON_LINKFLAGS += -linkall

testsuite/tools/%: VPATH += testsuite/tools

expect_SOURCES = $(addprefix testsuite/tools/,expect.mli expect.ml)
expect_LIBRARIES = $(addprefix compilerlibs/,\
ocamlcommon ocamlbytecomp ocamltoplevel)

testsuite/tools/expect$(EXE): OC_BYTECODE_LINKFLAGS += -linkall

codegen_SOURCES = $(addprefix testsuite/tools/,\
parsecmmaux.mli parsecmmaux.ml \
parsecmm.mly \
lexcmm.mli lexcmm.mll \
codegen_main.mli codegen_main.ml)
codegen_LIBRARIES = $(addprefix compilerlibs/,ocamlcommon ocamloptcomp)

# The asmgen tests are not ported to MSVC64 yet, so make sure
# to compile the arch specific module they require only if necessary
ifeq "$(CCOMPTYPE)-$(ARCH)" "msvc-amd64"
asmgen_OBJECT =
else
asmgen_MODULE = testsuite/tools/asmgen_$(ARCH)
asmgen_SOURCE = $(asmgen_MODULE).S
asmgen_OBJECT = $(asmgen_MODULE).$(O)
$(asmgen_OBJECT): $(asmgen_SOURCE)
$(V_ASM)$(ASPP) $(OC_ASPPFLAGS) -o $@ $< || $(ASPP_ERROR)
endif

ocamltest/ocamltest$(EXE): OC_BYTECODE_LINKFLAGS += -custom

ocamltest/ocamltest$(EXE): ocamlc ocamlyacc ocamllex

ocamltest.opt: ocamltest/ocamltest.opt$(EXE)
ocamltest.opt: ocamltest/ocamltest.opt$(EXE) \
testsuite/lib/testing.cmxa $(asmgen_OBJECT) testsuite/tools/codegen$(EXE)

ocamltest/ocamltest.opt$(EXE): ocamlc.opt ocamlyacc ocamllex

Expand All @@ -1829,13 +1863,30 @@ ocamltest/ocamltest$(EXE) ocamltest/ocamltest.opt$(EXE): \
# -opaque to prevent errors compiling the other modules of ocamltest.
ocamltest/ocamltest_unix.%: \
OC_COMMON_COMPFLAGS += -opaque
else # ifeq "$(build_ocamltest)" "true"
ocamltest_TARGETS = ocamltest ocamltest.opt
.PHONY: $(ocamltest_TARGETS)
$(ocamltest_TARGETS):
@echo ocamltest is disabled
@echo To build it, run configure again with --enable-ocamltest
@false
endif # ifeq "$(build_ocamltest)" "true"

partialclean::
rm -rf ocamltest/ocamltest ocamltest/ocamltest.exe
rm -f ocamltest/ocamltest ocamltest/ocamltest.exe
rm -f ocamltest/ocamltest.opt ocamltest/ocamltest.opt.exe
rm -f $(addprefix ocamltest/,*.o *.obj *.cm*)
rm -rf $(ocamltest_GENERATED_FILES)
rm -f ocamltest.html
rm -f $(patsubst %.mll,%.ml, $(wildcard ocamltest/*.mll))
rm -f $(patsubst %.mly,%.ml, $(wildcard ocamltest/*.mly))
rm -f $(patsubst %.mly,%.mli, $(wildcard ocamltest/*.mly))
rm -f $(patsubst %.mly,%.output, $(wildcard ocamltest/*.mly))
rm -f ocamltest/ocamltest.html
rm -f $(addprefix testsuite/lib/*.,cm* o obj a lib)
rm -f $(addprefix testsuite/tools/*.,cm* o obj a lib)
rm -f testsuite/tools/codegen testsuite/tools/codegen.exe
rm -f testsuite/tools/expect testsuite/tools/expect.exe
rm -f testsuite/tools/lexcmm.ml
rm -f $(addprefix testsuite/tools/parsecmm., ml mli output)

# Documentation

Expand Down Expand Up @@ -2335,7 +2386,7 @@ depend: beforedepend
lambda file_formats middle_end/closure middle_end/flambda \
middle_end/flambda/base_types \
driver toplevel toplevel/byte toplevel/native lex tools debugger \
ocamldoc ocamltest; \
ocamldoc ocamltest testsuite/lib testsuite/tools; \
do \
$(OCAMLDEP) $(OC_OCAMLDEPFLAGS) -I $$d $(INCLUDES) \
$(OCAMLDEPFLAGS) $$d/*.mli $$d/*.ml \
Expand Down
8 changes: 8 additions & 0 deletions Makefile.build_config.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ build_ocamldoc = @build_ocamldoc@
build_libraries_manpages = @build_libraries_manpages@

OCAMLDOC_TARGET = @ocamldoc_target@
OCAMLTEST_TARGET = @ocamltest_target@

OCAMLDOC_OPT_TARGET = @ocamldoc_opt_target@
OCAMLTEST_OPT_TARGET = @ocamltest_opt_target@

build_ocamltest = @build_ocamltest@

build_ocamltex = @build_ocamltex@

Expand All @@ -48,6 +52,10 @@ lib_str = @lib_str@
lib_systhreads = @lib_systhreads@
lib_unix = @lib_unix@

OPTIONAL_LIBRARIES = @optional_libraries@
OPTIONAL_BYTECODE_TOOLS = @optional_bytecode_tools@
OPTIONAL_NATIVE_TOOLS = @optional_native_tools@

# Whether to install the native toplevel (ocamlnat)
INSTALL_OCAMLNAT = @install_ocamlnat@

Expand Down
2 changes: 1 addition & 1 deletion Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ RUNTIMED=@debug_runtime@
INSTRUMENTED_RUNTIME=@instrumented_runtime@
INSTRUMENTED_RUNTIME_LIBS=@instrumented_runtime_libs@
WITH_DEBUGGER=@with_debugger@
WITH_OCAMLTEST=@ocamltest@
ASM_CFI_SUPPORTED=@asm_cfi_supported@
WITH_FRAME_POINTERS=@frame_pointers@
HEADER_RESERVED_BITS=@reserved_header_bits@
Expand All @@ -230,6 +229,7 @@ NAKED_POINTERS=false

STDLIB_MANPAGES=@build_libraries_manpages@
WITH_OCAMLDOC=@with_ocamldoc@
WITH_OCAMLTEST=@ocamltest@

## Variables deprecated since OCaml 5.0

Expand Down
Loading

0 comments on commit d5b5c34

Please sign in to comment.