Skip to content

Commit 5d5b25f

Browse files
authored
Merge pull request #9611 from obsidiansystems/fix-cross-configure
Split `--disable-tests`, fix cross builds
2 parents b1c559e + 7feabf7 commit 5d5b25f

File tree

9 files changed

+92
-94
lines changed

9 files changed

+92
-94
lines changed

Makefile

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,33 @@ makefiles = \
2424
misc/upstart/local.mk
2525
endif
2626

27-
ifeq ($(ENABLE_BUILD)_$(ENABLE_TESTS), yes_yes)
27+
ifeq ($(ENABLE_UNIT_TESTS), yes)
2828
makefiles += \
2929
tests/unit/libutil/local.mk \
3030
tests/unit/libutil-support/local.mk \
3131
tests/unit/libstore/local.mk \
3232
tests/unit/libstore-support/local.mk \
3333
tests/unit/libexpr/local.mk \
3434
tests/unit/libexpr-support/local.mk
35+
else
36+
.PHONY: check
37+
check:
38+
@echo "Unit tests are disabled. Configure without '--disable-unit-tests', or avoid calling 'make check'."
39+
@exit 1
3540
endif
3641

37-
ifeq ($(ENABLE_TESTS), yes)
42+
ifeq ($(ENABLE_FUNCTIONAL_TESTS), yes)
3843
makefiles += \
3944
tests/functional/local.mk \
4045
tests/functional/ca/local.mk \
4146
tests/functional/dyn-drv/local.mk \
4247
tests/functional/test-libstoreconsumer/local.mk \
4348
tests/functional/plugins/local.mk
4449
else
45-
makefiles += \
46-
mk/disable-tests.mk
50+
.PHONY: installcheck
51+
installcheck:
52+
@echo "Functional tests are disabled. Configure without '--disable-functional-tests', or avoid calling 'make installcheck'."
53+
@exit 1
4754
endif
4855

4956
OPTIMIZE = 1
@@ -59,9 +66,22 @@ include mk/lib.mk
5966

6067
# Must be included after `mk/lib.mk` so rules refer to variables defined
6168
# by the library. Rules are not "lazy" like variables, unfortunately.
62-
ifeq ($(ENABLE_BUILD), yes)
69+
ifeq ($(ENABLE_DOC_GEN),yes)
6370
$(eval $(call include-sub-makefile, doc/manual/local.mk))
71+
else
72+
.PHONY: manual-html manpages
73+
manual-html manpages:
74+
@echo "Generated docs are disabled. Configure without '--disable-doc-gen', or avoid calling 'make manpages' and 'make manual-html'."
75+
@exit 1
6476
endif
77+
78+
ifeq ($(ENABLE_INTERNAL_API_DOCS),yes)
6579
$(eval $(call include-sub-makefile, doc/internal-api/local.mk))
80+
else
81+
.PHONY: internal-api-html
82+
internal-api-html:
83+
@echo "Internal API docs are disabled. Configure with '--enable-internal-api-docs', or avoid calling 'make internal-api-html'."
84+
@exit 1
85+
endif
6686

6787
GLOBAL_CXXFLAGS += -g -Wall -include $(buildprefix)config.h -std=c++2a -I src

Makefile.config.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ CXXFLAGS = @CXXFLAGS@
99
CXXLTO = @CXXLTO@
1010
EDITLINE_LIBS = @EDITLINE_LIBS@
1111
ENABLE_BUILD = @ENABLE_BUILD@
12+
ENABLE_DOC_GEN = @ENABLE_DOC_GEN@
13+
ENABLE_FUNCTIONAL_TESTS = @ENABLE_FUNCTIONAL_TESTS@
14+
ENABLE_INTERNAL_API_DOCS = @ENABLE_INTERNAL_API_DOCS@
1215
ENABLE_S3 = @ENABLE_S3@
13-
ENABLE_TESTS = @ENABLE_TESTS@
16+
ENABLE_UNIT_TESTS = @ENABLE_UNIT_TESTS@
1417
GTEST_LIBS = @GTEST_LIBS@
1518
HAVE_LIBCPUID = @HAVE_LIBCPUID@
1619
HAVE_SECCOMP = @HAVE_SECCOMP@
@@ -36,12 +39,10 @@ checkbindir = @checkbindir@
3639
checklibdir = @checklibdir@
3740
datadir = @datadir@
3841
datarootdir = @datarootdir@
39-
doc_generate = @doc_generate@
4042
docdir = @docdir@
4143
embedded_sandbox_shell = @embedded_sandbox_shell@
4244
exec_prefix = @exec_prefix@
4345
includedir = @includedir@
44-
internal_api_docs = @internal_api_docs@
4546
libdir = @libdir@
4647
libexecdir = @libexecdir@
4748
localstatedir = @localstatedir@

configure.ac

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,38 @@ AC_ARG_ENABLE(build, AS_HELP_STRING([--disable-build],[Do not build nix]),
138138
ENABLE_BUILD=$enableval, ENABLE_BUILD=yes)
139139
AC_SUBST(ENABLE_BUILD)
140140

141-
# Building without tests is useful for bootstrapping with a smaller footprint
141+
# Building without unit tests is useful for bootstrapping with a smaller footprint
142142
# or running the tests in a separate derivation. Otherwise, we do compile and
143143
# run them.
144-
AC_ARG_ENABLE(tests, AS_HELP_STRING([--disable-tests],[Do not build the tests]),
145-
ENABLE_TESTS=$enableval, ENABLE_TESTS=yes)
146-
AC_SUBST(ENABLE_TESTS)
144+
145+
AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--disable-unit-tests],[Do not build the tests]),
146+
ENABLE_UNIT_TESTS=$enableval, ENABLE_UNIT_TESTS=$ENABLE_BUILD)
147+
AC_SUBST(ENABLE_UNIT_TESTS)
148+
149+
AS_IF(
150+
[test "$ENABLE_BUILD" == "no" && test "$ENABLE_UNIT_TESTS" == "yes"],
151+
[AC_MSG_ERROR([Cannot enable unit tests when building overall is disabled. Please do not pass '--enable-unit-tests' or do not pass '--disable-build'.])])
152+
153+
AC_ARG_ENABLE(functional-tests, AS_HELP_STRING([--disable-functional-tests],[Do not build the tests]),
154+
ENABLE_FUNCTIONAL_TESTS=$enableval, ENABLE_FUNCTIONAL_TESTS=yes)
155+
AC_SUBST(ENABLE_FUNCTIONAL_TESTS)
156+
157+
# documentation generation switch
158+
AC_ARG_ENABLE(doc-gen, AS_HELP_STRING([--disable-doc-gen],[disable documentation generation]),
159+
ENABLE_DOC_GEN=$enableval, ENABLE_DOC_GEN=$ENABLE_BUILD)
160+
AC_SUBST(ENABLE_DOC_GEN)
161+
162+
AS_IF(
163+
[test "$ENABLE_BUILD" == "no" && test "$ENABLE_GENERATED_DOCS" == "yes"],
164+
[AC_MSG_ERROR([Cannot enable generated docs when building overall is disabled. Please do not pass '--enable-doc-gen' or do not pass '--disable-build'.])])
147165

148166
# Building without API docs is the default as Nix' C++ interfaces are internal and unstable.
149-
AC_ARG_ENABLE(internal_api_docs, AS_HELP_STRING([--enable-internal-api-docs],[Build API docs for Nix's internal unstable C++ interfaces]),
150-
internal_api_docs=$enableval, internal_api_docs=no)
151-
AC_SUBST(internal_api_docs)
167+
AC_ARG_ENABLE(internal-api-docs, AS_HELP_STRING([--enable-internal-api-docs],[Build API docs for Nix's internal unstable C++ interfaces]),
168+
ENABLE_INTERNAL_API_DOCS=$enableval, ENABLE_INTERNAL_API_DOCS=no)
169+
AC_SUBST(ENABLE_INTERNAL_API_DOCS)
152170

153171
AS_IF(
154-
[test "$ENABLE_BUILD" == "yes" || test "$ENABLE_TEST" == "yes"],
172+
[test "$ENABLE_FUNCTIONAL_TESTS" == "yes" || test "$ENABLE_DOC_GEN" == "yes"],
155173
[NEED_PROG(jq, jq)])
156174

157175
AS_IF([test "$ENABLE_BUILD" == "yes"],[
@@ -317,7 +335,7 @@ if test "$gc" = yes; then
317335
AC_DEFINE(HAVE_BOEHMGC, 1, [Whether to use the Boehm garbage collector.])
318336
fi
319337
320-
AS_IF([test "$ENABLE_TESTS" == "yes"],[
338+
AS_IF([test "$ENABLE_UNIT_TESTS" == "yes"],[
321339
322340
# Look for gtest.
323341
PKG_CHECK_MODULES([GTEST], [gtest_main])
@@ -349,11 +367,6 @@ AC_LANG_POP(C++)
349367
# Look for nlohmann/json.
350368
PKG_CHECK_MODULES([NLOHMANN_JSON], [nlohmann_json >= 3.9])
351369
352-
# documentation generation switch
353-
AC_ARG_ENABLE(doc-gen, AS_HELP_STRING([--disable-doc-gen],[disable documentation generation]),
354-
doc_generate=$enableval, doc_generate=yes)
355-
AC_SUBST(doc_generate)
356-
357370
358371
# Look for lowdown library.
359372
PKG_CHECK_MODULES([LOWDOWN], [lowdown >= 0.9.0], [CXXFLAGS="$LOWDOWN_CFLAGS $CXXFLAGS"])

doc/internal-api/local.mk

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
.PHONY: internal-api-html
2-
3-
ifeq ($(internal_api_docs), yes)
4-
51
$(docdir)/internal-api/html/index.html $(docdir)/internal-api/latex: $(d)/doxygen.cfg
62
mkdir -p $(docdir)/internal-api
73
{ cat $< ; echo "OUTPUT_DIRECTORY=$(docdir)/internal-api" ; } | doxygen -
84

95
# Generate the HTML API docs for Nix's unstable internal interfaces.
6+
.PHONY: internal-api-html
107
internal-api-html: $(docdir)/internal-api/html/index.html
11-
12-
else
13-
14-
# Make a nicer error message
15-
internal-api-html:
16-
@echo "Internal API docs are disabled. Configure with '--enable-internal-api-docs', or avoid calling 'make internal-api-html'."
17-
@exit 1
18-
19-
endif

doc/manual/local.mk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
ifeq ($(doc_generate),yes)
2-
31
# The version of Nix used to generate the doc. Can also be
42
# `$(nix_INSTALL_PATH)` or just `nix` (to grap ambient from the `PATH`),
53
# if one prefers.
@@ -180,6 +178,8 @@ manual-html: $(docdir)/manual/index.html
180178
install: $(docdir)/manual/index.html
181179

182180
# Generate 'nix' manpages.
181+
.PHONY: manpages
182+
manpages: $(mandir)/man1/nix3-manpages
183183
install: $(mandir)/man1/nix3-manpages
184184
man: doc/manual/generated/man1/nix3-manpages
185185
all: doc/manual/generated/man1/nix3-manpages
@@ -225,5 +225,3 @@ $(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/anchors.jq $(d)/
225225
@rm -rf $(DESTDIR)$(docdir)/manual
226226
@mv $(DESTDIR)$(docdir)/manual.tmp/html $(DESTDIR)$(docdir)/manual
227227
@rm -rf $(DESTDIR)$(docdir)/manual.tmp
228-
229-
endif

doc/manual/src/contributing/hacking.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ You can also build Nix for one of the [supported platforms](#platforms).
6767
## Makefile variables
6868

6969
- `ENABLE_BUILD=yes` to enable building the C++ code.
70-
- `ENABLE_TESTS=yes` to enable building the tests.
70+
- `ENABLE_DOC_GEN=yes` to enable building the documentation (manual, man pages, etc.).
71+
- `ENABLE_FUNCTIONAL_TESTS=yes` to enable building the functional tests.
72+
- `ENABLE_UNIT_TESTS=yes` to enable building the unit tests.
7173
- `OPTIMIZE=1` to enable optimizations.
72-
- `doc_generate=yes` to enable building the documentation (manual, man pages, etc.).
7374

7475
The docs can take a while to build, so you may want to disable this for local development.
7576

doc/manual/src/installation/prerequisites-source.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
This is an optional dependency and can be disabled
7373
by providing a `--disable-cpuid` to the `configure` script.
7474

75-
- Unless `./configure --disable-tests` is specified, GoogleTest (GTest) and
75+
- Unless `./configure --disable-unit-tests` is specified, GoogleTest (GTest) and
7676
RapidCheck are required, which are available at
7777
<https://google.github.io/googletest/> and
7878
<https://github.com/emil-e/rapidcheck> respectively.

mk/disable-tests.mk

Lines changed: 0 additions & 12 deletions
This file was deleted.

package.nix

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,6 @@ let
104104
inherit doBuild doCheck doInstallCheck;
105105
};
106106

107-
filesets = {
108-
baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
109-
110-
configureFiles = fileset.unions [
111-
./.version
112-
./configure.ac
113-
./m4
114-
# TODO: do we really need README.md? It doesn't seem used in the build.
115-
./README.md
116-
];
117-
118-
topLevelBuildFiles = fileset.unions [
119-
./local.mk
120-
./Makefile
121-
./Makefile.config.in
122-
./mk
123-
];
124-
125-
functionalTestFiles = fileset.unions [
126-
./tests/functional
127-
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
128-
];
129-
};
130-
131107
mkDerivation =
132108
if withCoverageChecks
133109
then
@@ -151,32 +127,44 @@ mkDerivation (finalAttrs: let
151127
# to be run later, requiresthe unit tests to be built.
152128
buildUnitTests = doCheck || installUnitTests;
153129

154-
anySortOfTesting = buildUnitTests || doInstallCheck;
155-
156130
in {
157131
inherit pname version;
158132

159133
src =
160134
let
161-
135+
baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
162136
in
163137
fileset.toSource {
164138
root = ./.;
165-
fileset = fileset.intersect filesets.baseFiles (fileset.unions ([
166-
filesets.configureFiles
167-
filesets.topLevelBuildFiles
168-
./doc/internal-api
139+
fileset = fileset.intersect baseFiles (fileset.unions ([
140+
# For configure
141+
./.version
142+
./configure.ac
143+
./m4
144+
# TODO: do we really need README.md? It doesn't seem used in the build.
145+
./README.md
146+
# For make, regardless of what we are building
147+
./local.mk
148+
./Makefile
149+
./Makefile.config.in
150+
./mk
151+
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
169152
] ++ lib.optionals doBuild [
170153
./boehmgc-coroutine-sp-fallback.diff
171154
./doc
172155
./misc
173156
./precompiled-headers.h
174157
./src
175-
./tests/unit
176158
./COPYING
177159
./scripts/local.mk
178-
] ++ lib.optionals anySortOfTesting [
179-
filesets.functionalTestFiles
160+
] ++ lib.optionals buildUnitTests [
161+
./doc/manual
162+
] ++ lib.optionals enableInternalAPIDocs [
163+
./doc/internal-api
164+
] ++ lib.optionals buildUnitTests [
165+
./tests/unit
166+
] ++ lib.optionals doInstallCheck [
167+
./tests/functional
180168
]));
181169
};
182170

@@ -277,7 +265,8 @@ in {
277265
configureFlags = [
278266
"--sysconfdir=/etc"
279267
(lib.enableFeature doBuild "build")
280-
(lib.enableFeature anySortOfTesting "tests")
268+
(lib.enableFeature buildUnitTests "unit-tests")
269+
(lib.enableFeature doInstallCheck "functional-tests")
281270
(lib.enableFeature enableInternalAPIDocs "internal-api-docs")
282271
(lib.enableFeature enableManual "doc-gen")
283272
(lib.enableFeature installUnitTests "install-unit-tests")
@@ -310,10 +299,7 @@ in {
310299
'';
311300

312301
postInstall = lib.optionalString doBuild (
313-
''
314-
mkdir -p $doc/nix-support
315-
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
316-
'' + lib.optionalString stdenv.hostPlatform.isStatic ''
302+
lib.optionalString stdenv.hostPlatform.isStatic ''
317303
mkdir -p $out/nix-support
318304
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
319305
'' + lib.optionalString stdenv.isDarwin ''
@@ -322,7 +308,10 @@ in {
322308
$out/lib/libboost_context.dylib \
323309
$out/lib/libnixutil.dylib
324310
''
325-
) + lib.optionalString enableInternalAPIDocs ''
311+
) + lib.optionalString enableManual ''
312+
mkdir -p ''${!outputDoc}/nix-support
313+
echo "doc manual ''${!outputDoc}/share/doc/nix/manual" >> ''${!outputDoc}/nix-support/hydra-build-products
314+
'' + lib.optionalString enableInternalAPIDocs ''
326315
mkdir -p ''${!outputDoc}/nix-support
327316
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> ''${!outputDoc}/nix-support/hydra-build-products
328317
'';

0 commit comments

Comments
 (0)