From 49cf73a5eefb8339aaf6a561eb46067bdc031ae5 Mon Sep 17 00:00:00 2001 From: lucas Date: Wed, 6 Jul 2022 12:34:36 +0800 Subject: [PATCH 1/2] add submodules for external dependencies --- .gitmodules | 6 ++++++ Makefile | 14 ++++++++++++-- base/json_fwd.h | 2 +- config.mk | 1 + external/Makefile | 15 +++++++++++++++ external/json | 1 + external/mosquitto | 1 + 7 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 100644 external/Makefile create mode 160000 external/json create mode 160000 external/mosquitto diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d7ed451 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "external/mosquitto"] + path = external/mosquitto + url = https://gitee.com/cpp-master/mosquitto.git +[submodule "external/json"] + path = external/json + url = https://gitee.com/cpp-master/json.git diff --git a/Makefile b/Makefile index 727af72..7e9995a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include build_env.mk -.PHONY: all clean distclean +.PHONY: all clean distclean depend CCFLAGS := -Wall @@ -24,13 +24,23 @@ export CC CXX CFLAGS CXXFLAGS LDFLAGS APPS_DIR include config.mk -all test: + +all test: depend @for i in $(app_y); do \ [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ done +depend: + @for i in $(depends_y); do \ + [ ! -d $$i ] || $(MAKE) -C $$i || exit $$? ; \ + [ ! -d $$i ] || $(MAKE) -C $$i install || exit $$? ; \ + done + clean: -rm -rf $(OUTPUT_DIR) distclean: clean + @for i in $(depends_y); do \ + [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ + done -rm -rf $(STAGING_DIR) $(INSTALL_DIR) diff --git a/base/json_fwd.h b/base/json_fwd.h index b158fc6..55e94a8 100644 --- a/base/json_fwd.h +++ b/base/json_fwd.h @@ -1,7 +1,7 @@ #ifndef TBOX_BASE_JSON_H_20211227 #define TBOX_BASE_JSON_H_20211227 -#include +#include //! 如果找到不该文件,则从 github 下载: //! https://github.com/nlohmann/json/blob/v3.10.4/include/nlohmann/json_fwd.hpp diff --git a/config.mk b/config.mk index 7b1b536..570bfa1 100644 --- a/config.mk +++ b/config.mk @@ -1,3 +1,4 @@ +depends_y += external app_y += base app_y += util app_y += event diff --git a/external/Makefile b/external/Makefile new file mode 100644 index 0000000..ed3b966 --- /dev/null +++ b/external/Makefile @@ -0,0 +1,15 @@ +HOST ?= +Make ?= make -j$(shell nproc) + +.PHONY: all clean distclean install + +all: + $(Make) -C mosquitto || exit $$? + +clean distclean: + $(Make) -C mosquitto clean || exit $$? + +install: all + install -d $(STAGING_INCLUDE)/nlohmann + install ./json/single_include/nlohmann/json.hpp $(STAGING_INCLUDE)/nlohmann/json.hpp + make -C mosquitto install prefix=$(STAGING_DIR) DESTDIR=$(STAGING_DIR)/dest || exit $$? diff --git a/external/json b/external/json new file mode 160000 index 0000000..7d361ec --- /dev/null +++ b/external/json @@ -0,0 +1 @@ +Subproject commit 7d361ec8efa8abf7bc126c2487389cfcc3469551 diff --git a/external/mosquitto b/external/mosquitto new file mode 160000 index 0000000..02182af --- /dev/null +++ b/external/mosquitto @@ -0,0 +1 @@ +Subproject commit 02182aff6598319e64a56eea13241fb0fb985dd6 -- Gitee From 7e02a7d1cf6e6950bcd4838786ce4e375da3746e Mon Sep 17 00:00:00 2001 From: lucas Date: Wed, 6 Jul 2022 20:10:31 +0800 Subject: [PATCH 2/2] rollback json_fwd --- base/json_fwd.h | 2 +- external/Makefile | 6 +++++- external/json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/base/json_fwd.h b/base/json_fwd.h index 55e94a8..b158fc6 100644 --- a/base/json_fwd.h +++ b/base/json_fwd.h @@ -1,7 +1,7 @@ #ifndef TBOX_BASE_JSON_H_20211227 #define TBOX_BASE_JSON_H_20211227 -#include +#include //! 如果找到不该文件,则从 github 下载: //! https://github.com/nlohmann/json/blob/v3.10.4/include/nlohmann/json_fwd.hpp diff --git a/external/Makefile b/external/Makefile index ed3b966..a1dfdcd 100644 --- a/external/Makefile +++ b/external/Makefile @@ -11,5 +11,9 @@ clean distclean: install: all install -d $(STAGING_INCLUDE)/nlohmann + install -d $(STAGING_LIB) install ./json/single_include/nlohmann/json.hpp $(STAGING_INCLUDE)/nlohmann/json.hpp - make -C mosquitto install prefix=$(STAGING_DIR) DESTDIR=$(STAGING_DIR)/dest || exit $$? + install ./json/include/nlohmann/json_fwd.hpp $(STAGING_INCLUDE)/nlohmann/json_fwd.hpp + make -C mosquitto install DESTDIR=$(STAGING_DIR)/mosquitto || exit $$? + cp -af $(STAGING_DIR)/mosquitto/usr/local/include/* $(STAGING_INCLUDE) + cp -af $(STAGING_DIR)/mosquitto/usr/local/lib/* $(STAGING_LIB) diff --git a/external/json b/external/json index 7d361ec..db78ac1 160000 --- a/external/json +++ b/external/json @@ -1 +1 @@ -Subproject commit 7d361ec8efa8abf7bc126c2487389cfcc3469551 +Subproject commit db78ac1d7716f56fc9f1b030b715f872f93964e4 -- Gitee