From e6c1ca8b6062eeed1a0ca980754888014a1a07ca Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Mon, 4 Mar 2024 18:39:14 +0800 Subject: [PATCH] Share version number among qmake, xmake and shell scripts (#233) * share version number among qmake, xmake and shell scripts * use symlink for xmake inclusion --- BUILD.md | 1 + BUILD_cn.md | 1 + RedPandaIDE/RedPandaIDE.pro | 4 +--- RedPandaIDE/xmake.lua | 8 ++++++-- version.inc | 2 ++ version.lua | 1 + xmake.lua | 5 +++-- 7 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 version.inc create mode 120000 version.lua diff --git a/BUILD.md b/BUILD.md index eeda888d..2c653000 100644 --- a/BUILD.md +++ b/BUILD.md @@ -11,6 +11,7 @@ Recommended development environments: * Debugger integration with Qt. To setup development environment in Visual Studio Code: +0. (Windows only) Enable Developer Mode in Windows Settings, and enable `core.symlinks` in Git (`git config core.symlinks true`). 1. Install [xmake](https://xmake.io/) and [XMake extension](https://marketplace.visualstudio.com/items?itemName=tboox.xmake-vscode). 2. Install [C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) for language and debugging support. 3. Optionally install [clangd](https://clangd.llvm.org/) and [clangd extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) for better analysis. diff --git a/BUILD_cn.md b/BUILD_cn.md index 7321cf68..d8409c56 100644 --- a/BUILD_cn.md +++ b/BUILD_cn.md @@ -11,6 +11,7 @@ * 调试器的 Qt 集成。 设置 Visual Studio Code 开发环境的步骤: +0. 在 Windows 设置中,启用 “开发人员模式”。启用 Git 的 `core.symlinks` 选项(`git config core.symlinks true`)。 1. 安装 [xmake](https://xmake.io/) 和 [XMake 扩展](https://marketplace.visualstudio.com/items?itemName=tboox.xmake-vscode)。 2. 安装 [C/C++ 扩展](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) 以支持语言和调试功能。 3. 根据需要安装 [clangd](https://clangd.llvm.org/) 和 [clangd 扩展](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd)以获得更好的代码分析能力。 diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 74f96eb2..6791f371 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -15,9 +15,7 @@ CONFIG += ENABLE_SDCC APP_NAME = RedPandaCPP -APP_VERSION = 2.27 - -APP_VERSION_SUFFIX = alpha +include(../version.inc) # TEST_VERSION = beta2 system(git rev-list HEAD --count): TEST_VERSION = $$system(git rev-list HEAD --count) diff --git a/RedPandaIDE/xmake.lua b/RedPandaIDE/xmake.lua index c872f085..e4649b6c 100644 --- a/RedPandaIDE/xmake.lua +++ b/RedPandaIDE/xmake.lua @@ -12,8 +12,12 @@ target("RedPandaIDE") add_options("app-name", "prefix", "libexecdir") add_options("lua-addon", "sdcc", "vcs") - if TEST_VERSION ~= nil then - add_defines('REDPANDA_CPP_VERSION="' .. APP_VERSION .. '-' .. TEST_VERSION .. '"') + if APP_VERSION_SUFFIX ~= "" then + add_defines('APP_VERSION_SUFFIX="' .. APP_VERSION_SUFFIX .. '"') + end + + if TEST_VERSION ~= "" then + add_defines('REDPANDA_CPP_VERSION="' .. APP_VERSION .. '.' .. TEST_VERSION .. '"') else add_defines('REDPANDA_CPP_VERSION="' .. APP_VERSION .. '"') end diff --git a/version.inc b/version.inc new file mode 100644 index 00000000..efee97ba --- /dev/null +++ b/version.inc @@ -0,0 +1,2 @@ +APP_VERSION="2.27" +APP_VERSION_SUFFIX="alpha" diff --git a/version.lua b/version.lua new file mode 120000 index 00000000..6e77de0c --- /dev/null +++ b/version.lua @@ -0,0 +1 @@ +version.inc \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index fdb97792..7a7dab48 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,5 +1,6 @@ -APP_VERSION = "2.26" -TEST_VERSION = "alpha8" +includes("./version.lua") + +TEST_VERSION = "$(shell git rev-list HEAD --count)" add_rules("mode.debug", "mode.release") set_warnings("all", "extra", "pedantic")