Skip to content

Commit

Permalink
Allow for putting Unix-only files in subdirs
Browse files Browse the repository at this point in the history
This will allow avoiding a lot of CPP.
  • Loading branch information
Ericson2314 committed Oct 21, 2023
1 parent 1a73c39 commit 937cd65
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 19 deletions.
7 changes: 6 additions & 1 deletion local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ ERROR_SWITCH_ENUM = -Werror=switch-enum
$(foreach i, config.h $(wildcard src/lib*/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))

ifdef HOST_UNIX
$(foreach i, config.h $(wildcard src/lib*/unix/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))
endif

$(GCH): src/libutil/util.hh config.h

GCH_CXXFLAGS = -I src/libutil
GCH_CXXFLAGS = $(INCLUDE_libutil)
2 changes: 1 addition & 1 deletion src/libcmd/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ libcmd_DIR := $(d)

libcmd_SOURCES := $(wildcard $(d)/*.cc)

libcmd_CXXFLAGS += -I src/libutil -I src/libstore -I src/libexpr -I src/libmain -I src/libfetchers
libcmd_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libexpr -I src/libmain -I src/libfetchers

libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) -pthread

Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ libexpr_SOURCES := \
$(d)/lexer-tab.cc \
$(d)/parser-tab.cc

libexpr_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libmain -I src/libexpr
libexpr_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libfetchers -I src/libmain -I src/libexpr

libexpr_LIBS = libutil libstore libfetchers

Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/tests/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ libexpr-tests_SOURCES := \
$(wildcard $(d)/*.cc) \
$(wildcard $(d)/value/*.cc)

libexpr-tests_CXXFLAGS += -I src/libexpr -I src/libutil -I src/libstore -I src/libexpr/tests -I src/libfetchers
libexpr-tests_CXXFLAGS += -I src/libexpr $(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libexpr/tests -I src/libfetchers

libexpr-tests_LIBS = libstore-tests libutils-tests libexpr libutil libstore libfetchers

Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ libfetchers_DIR := $(d)

libfetchers_SOURCES := $(wildcard $(d)/*.cc)

libfetchers_CXXFLAGS += -I src/libutil -I src/libstore
libfetchers_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore)

libfetchers_LDFLAGS += -pthread

Expand Down
2 changes: 1 addition & 1 deletion src/libmain/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ libmain_DIR := $(d)

libmain_SOURCES := $(wildcard $(d)/*.cc)

libmain_CXXFLAGS += -I src/libutil -I src/libstore
libmain_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore)

libmain_LDFLAGS += $(OPENSSL_LIBS)

Expand Down
19 changes: 13 additions & 6 deletions src/libstore/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ libstore_LIBS = libutil

libstore_LDFLAGS += $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(SODIUM_LIBS) -pthread
ifdef HOST_LINUX
libstore_LDFLAGS += -ldl
libstore_LDFLAGS += -ldl
endif

$(foreach file,$(libstore_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/sandbox)))
Expand All @@ -28,7 +28,7 @@ ifeq ($(HAVE_SECCOMP), 1)
endif

libstore_CXXFLAGS += \
-I src/libutil -I src/libstore -I src/libstore/build \
$(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libstore/build \
-DNIX_PREFIX=\"$(prefix)\" \
-DNIX_STORE_DIR=\"$(storedir)\" \
-DNIX_DATA_DIR=\"$(datadir)\" \
Expand All @@ -55,14 +55,21 @@ endif

$(d)/local-store.cc: $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh

$(d)/build.cc:

clean-files += $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh

$(eval $(call install-file-in, $(d)/nix-store.pc, $(libdir)/pkgconfig, 0644))

$(foreach i, $(wildcard src/libstore/builtins/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix/builtins, 0644)))

$(foreach i, $(wildcard src/libstore/build/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix/build, 0644)))
ifdef HOST_UNIX
$(foreach i, $(wildcard src/libstore/unix/build/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix/build, 0644)))
endif

# Not for libnixstore itself, but for downstream libraries using libnixstore

INCLUDE_libstore := -I $(d)
ifdef HOST_UNIX
INCLUDE_libstore := -I $(d)/unix
endif
2 changes: 1 addition & 1 deletion src/libstore/tests/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ libstore-tests_INSTALL_DIR :=

libstore-tests_SOURCES := $(wildcard $(d)/*.cc)

libstore-tests_CXXFLAGS += -I src/libstore -I src/libutil
libstore-tests_CXXFLAGS += $(INCLUDE_libstore) $(INCLUDE_libutil)

libstore-tests_LIBS = libutil-tests libstore libutil

Expand Down
11 changes: 10 additions & 1 deletion src/libutil/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ libutil_NAME = libnixutil
libutil_DIR := $(d)

libutil_SOURCES := $(wildcard $(d)/*.cc)
ifdef HOST_UNIX
libutil_SOURCES := $(wildcard $(d)/unix/*.cc)
endif

libutil_LDFLAGS += -pthread $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(LIBARCHIVE_LIBS) $(BOOST_LDFLAGS) -lboost_context

ifeq ($(HAVE_LIBCPUID), 1)
libutil_LDFLAGS += -lcpuid
endif

# Not for libnixutil itself, but for downstream libraries using libnixutil

INCLUDE_libutil := -I $(d)
ifdef HOST_UNIX
INCLUDE_libutil := -I $(d)/unix
endif
2 changes: 1 addition & 1 deletion src/libutil/tests/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ libutil-tests_INSTALL_DIR :=

libutil-tests_SOURCES := $(wildcard $(d)/*.cc)

libutil-tests_CXXFLAGS += -I src/libutil
libutil-tests_CXXFLAGS += $(INCLUDE_libutil)

libutil-tests_LIBS = libutil

Expand Down
2 changes: 1 addition & 1 deletion src/nix/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nix_SOURCES := \
$(wildcard src/nix-instantiate/*.cc) \
$(wildcard src/nix-store/*.cc) \

nix_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libexpr -I src/libmain -I src/libcmd -I doc/manual
nix_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libfetchers -I src/libexpr -I src/libmain -I src/libcmd -I doc/manual

nix_LIBS = libexpr libmain libfetchers libstore libutil libcmd

Expand Down
2 changes: 1 addition & 1 deletion src/resolve-system-dependencies/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolve-system-dependencies_DIR := $(d)

resolve-system-dependencies_INSTALL_DIR := $(libexecdir)/nix

resolve-system-dependencies_CXXFLAGS += -I src/libutil -I src/libstore -I src/libmain
resolve-system-dependencies_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libmain

resolve-system-dependencies_LIBS := libstore libmain libutil

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/plugins/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ libplugintest_ALLOW_UNDEFINED := 1

libplugintest_EXCLUDE_FROM_LIBRARY_LIST := 1

libplugintest_CXXFLAGS := -I src/libutil -I src/libstore -I src/libexpr -I src/libfetchers
libplugintest_CXXFLAGS := $(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libexpr -I src/libfetchers
2 changes: 1 addition & 1 deletion tests/functional/test-libstoreconsumer/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test-libstoreconsumer_INSTALL_DIR :=
test-libstoreconsumer_SOURCES := \
$(wildcard $(d)/*.cc) \

test-libstoreconsumer_CXXFLAGS += -I src/libutil -I src/libstore
test-libstoreconsumer_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore)

test-libstoreconsumer_LIBS = libstore libutil

Expand Down

0 comments on commit 937cd65

Please sign in to comment.