diff --git a/Makefile b/Makefile index 4f60d0d8b..d9efc8154 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,9 @@ makefiles = \ src/libexpr/local.mk \ src/libcmd/local.mk \ src/nix/local.mk \ + src/libutil/c/local.mk \ + src/libstore/c/local.mk \ + src/libexpr/c/local.mk \ src/resolve-system-dependencies/local.mk \ scripts/local.mk \ misc/bash/local.mk \ diff --git a/doc/external-api/doxygen.cfg.in b/doc/external-api/doxygen.cfg.in index 19350b2c6..d78188900 100644 --- a/doc/external-api/doxygen.cfg.in +++ b/doc/external-api/doxygen.cfg.in @@ -36,9 +36,9 @@ GENERATE_LATEX = NO # so they can expand variables despite configure variables. INPUT = \ - src/libutil \ - src/libexpr \ - src/libstore + src/libutil/c \ + src/libexpr/c \ + src/libstore/c FILE_PATTERNS = nix_api_*.h diff --git a/local.mk b/local.mk index f48eb63ee..9a1ed50df 100644 --- a/local.mk +++ b/local.mk @@ -2,7 +2,7 @@ GLOBAL_CXXFLAGS += -Wno-deprecated-declarations -Werror=switch # Allow switch-enum to be overridden for files that do not support it, usually because of dependency headers. ERROR_SWITCH_ENUM = -Werror=switch-enum -$(foreach i, config.h $(wildcard src/lib*/*.hh) $(wildcard src/lib*/*.h), \ +$(foreach i, config.h $(wildcard src/lib*/*.hh) $(wildcard src/lib*/*.h $(filter-out %_internal.h, $(wildcard src/lib*/c/*.h))), \ $(eval $(call install-file-in, $(i), $(includedir)/nix, 0644))) $(GCH): src/libutil/util.hh config.h diff --git a/src/libexpr/c/local.mk b/src/libexpr/c/local.mk new file mode 100644 index 000000000..d2f01c0a9 --- /dev/null +++ b/src/libexpr/c/local.mk @@ -0,0 +1,19 @@ +libraries += libexprc + +libexprc_NAME = libnixexprc + +libexprc_DIR := $(d) + +libexprc_SOURCES := \ + $(wildcard $(d)/*.cc) \ + +libexprc_CXXFLAGS += -I src/libutil -Isrc/libfetchers -I src/libstore -I src/libstorec -I src/libexpr -I src/libutil/c -I src/libstore/c + +libexprc_LIBS = libutil libutilc libstorec libexpr + +libexprc_LDFLAGS += -pthread + +$(eval $(call install-file-in, $(d)/nix-expr-c.pc, $(libdir)/pkgconfig, 0644)) + +libexprc_FORCE_INSTALL := 1 + diff --git a/src/libexpr/c/nix-expr-c.pc.in b/src/libexpr/c/nix-expr-c.pc.in new file mode 100644 index 000000000..897773f20 --- /dev/null +++ b/src/libexpr/c/nix-expr-c.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Nix +Description: Nix Package Manager - C API +Version: @PACKAGE_VERSION@ +Requires: nix-store-c +Libs: -L${libdir} -lnixexprc +Cflags: -I${includedir}/nix diff --git a/src/libexpr/nix_api_expr.cc b/src/libexpr/c/nix_api_expr.cc similarity index 100% rename from src/libexpr/nix_api_expr.cc rename to src/libexpr/c/nix_api_expr.cc diff --git a/src/libexpr/nix_api_expr.h b/src/libexpr/c/nix_api_expr.h similarity index 100% rename from src/libexpr/nix_api_expr.h rename to src/libexpr/c/nix_api_expr.h diff --git a/src/libexpr/nix_api_expr_internal.h b/src/libexpr/c/nix_api_expr_internal.h similarity index 100% rename from src/libexpr/nix_api_expr_internal.h rename to src/libexpr/c/nix_api_expr_internal.h diff --git a/src/libexpr/nix_api_external.cc b/src/libexpr/c/nix_api_external.cc similarity index 100% rename from src/libexpr/nix_api_external.cc rename to src/libexpr/c/nix_api_external.cc diff --git a/src/libexpr/nix_api_external.h b/src/libexpr/c/nix_api_external.h similarity index 100% rename from src/libexpr/nix_api_external.h rename to src/libexpr/c/nix_api_external.h diff --git a/src/libexpr/nix_api_value.cc b/src/libexpr/c/nix_api_value.cc similarity index 100% rename from src/libexpr/nix_api_value.cc rename to src/libexpr/c/nix_api_value.cc diff --git a/src/libexpr/nix_api_value.h b/src/libexpr/c/nix_api_value.h similarity index 100% rename from src/libexpr/nix_api_value.h rename to src/libexpr/c/nix_api_value.h diff --git a/src/libstore/c/local.mk b/src/libstore/c/local.mk new file mode 100644 index 000000000..35e2bd63d --- /dev/null +++ b/src/libstore/c/local.mk @@ -0,0 +1,17 @@ +libraries += libstorec + +libstorec_NAME = libnixstorec + +libstorec_DIR := $(d) + +libstorec_SOURCES := $(wildcard $(d)/*.cc) + +libstorec_LIBS = libutil libstore libutilc + +libstorec_LDFLAGS += -pthread + +libstorec_CXXFLAGS += -I src/libutil -I src/libstore -I src/libutil/c + +$(eval $(call install-file-in, $(d)/nix-store-c.pc, $(libdir)/pkgconfig, 0644)) + +libstorec_FORCE_INSTALL := 1 diff --git a/src/libstore/c/nix-store-c.pc.in b/src/libstore/c/nix-store-c.pc.in new file mode 100644 index 000000000..563bd2f94 --- /dev/null +++ b/src/libstore/c/nix-store-c.pc.in @@ -0,0 +1,9 @@ +prefix=@prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Nix +Description: Nix Package Manager - C API +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -lnixstorec -lnixutilc +Cflags: -I${includedir}/nix diff --git a/src/libstore/nix_api_store.cc b/src/libstore/c/nix_api_store.cc similarity index 100% rename from src/libstore/nix_api_store.cc rename to src/libstore/c/nix_api_store.cc diff --git a/src/libstore/nix_api_store.h b/src/libstore/c/nix_api_store.h similarity index 100% rename from src/libstore/nix_api_store.h rename to src/libstore/c/nix_api_store.h diff --git a/src/libstore/nix_api_store_internal.h b/src/libstore/c/nix_api_store_internal.h similarity index 100% rename from src/libstore/nix_api_store_internal.h rename to src/libstore/c/nix_api_store_internal.h diff --git a/src/libutil/c/local.mk b/src/libutil/c/local.mk new file mode 100644 index 000000000..fe156e7f3 --- /dev/null +++ b/src/libutil/c/local.mk @@ -0,0 +1,15 @@ +libraries += libutilc + +libutilc_NAME = libnixutilc + +libutilc_DIR := $(d) + +libutilc_SOURCES := $(wildcard $(d)/*.cc) + +libutilc_CXXFLAGS += -I src/libutil + +libutilc_LIBS = libutil + +libutilc_LDFLAGS += -pthread + +libutilc_FORCE_INSTALL := 1 diff --git a/src/libutil/nix_api_util.cc b/src/libutil/c/nix_api_util.cc similarity index 100% rename from src/libutil/nix_api_util.cc rename to src/libutil/c/nix_api_util.cc diff --git a/src/libutil/nix_api_util.h b/src/libutil/c/nix_api_util.h similarity index 100% rename from src/libutil/nix_api_util.h rename to src/libutil/c/nix_api_util.h diff --git a/src/libutil/nix_api_util_internal.h b/src/libutil/c/nix_api_util_internal.h similarity index 100% rename from src/libutil/nix_api_util_internal.h rename to src/libutil/c/nix_api_util_internal.h diff --git a/tests/unit/libutil/local.mk b/tests/unit/libutil/local.mk index 536607322..0d0acd4c0 100644 --- a/tests/unit/libutil/local.mk +++ b/tests/unit/libutil/local.mk @@ -22,7 +22,7 @@ libutil-tests_EXTRA_INCLUDES = \ libutil-tests_CXXFLAGS += $(libutil-tests_EXTRA_INCLUDES) -libutil-tests_LIBS = libutil-test-support libutil +libutil-tests_LIBS = libutil-test-support libutil libutilc libutil-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS)