diff options
| author | ruki <[email protected]> | 2021-10-29 00:40:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-10-29 00:40:23 +0800 |
| commit | 557c4c790f5d932052f223127dca14860b03eabc (patch) | |
| tree | fcfa5468effc2157eaed06ca06a4e50f75b34249 /core/src | |
| parent | 2505c46acf19f66d92765854f0853d251be30506 (diff) | |
add git branch and commit
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/engine.c | 4 | ||||
| -rw-r--r-- | core/src/xmake/makefile | 7 | ||||
| -rw-r--r-- | core/src/xmake/xmake.config.h.in | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 0793f426e..f63e43ee1 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -906,7 +906,9 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c // init version string tb_char_t version_cstr[256] = {0}; - tb_snprintf(version_cstr, sizeof(version_cstr), "%u.%u.%u+%llu", version->major, version->minor, version->alter, version->build); + if (tb_strcmp(XM_CONFIG_VERSION_BRANCH, "") && tb_strcmp(XM_CONFIG_VERSION_COMMIT, "")) + tb_snprintf(version_cstr, sizeof(version_cstr), "%u.%u.%u+%s-%s", version->major, version->minor, version->alter, XM_CONFIG_VERSION_COMMIT, XM_CONFIG_VERSION_BRANCH); + else tb_snprintf(version_cstr, sizeof(version_cstr), "%u.%u.%u+%llu", version->major, version->minor, version->alter, version->build); lua_pushstring(engine->lua, version_cstr); lua_setglobal(engine->lua, "_VERSION"); diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 48eb51974..88bce5d1f 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -166,7 +166,12 @@ ifeq ($(RUNTIME),lua) xmake_INC_DIRS += ../lua/lua xmake_CXFLAGS += -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3 endif - +ifneq ($(BRANCH),) +xmake_CXFLAGS += -DXM_CONFIG_VERSION_BRANCH="\"$(BRANCH)\"" +endif +ifneq ($(COMMIT),) +xmake_CXFLAGS += -DXM_CONFIG_VERSION_COMMIT="\"$(COMMIT)\"" +endif # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/xmake/xmake.config.h.in b/core/src/xmake/xmake.config.h.in index d4c1f675a..a896b1335 100644 --- a/core/src/xmake/xmake.config.h.in +++ b/core/src/xmake/xmake.config.h.in @@ -7,5 +7,7 @@ #define XM_CONFIG_VERSION_MINOR ${VERSION_MINOR} #define XM_CONFIG_VERSION_ALTER ${VERSION_ALTER} #define XM_CONFIG_VERSION_BUILD ${VERSION_BUILD} +#define XM_CONFIG_VERSION_BRANCH "${GIT_BRANCH}" +#define XM_CONFIG_VERSION_COMMIT "${GIT_COMMIT}" #endif |
