diff options
| author | ruki <[email protected]> | 2017-08-24 18:12:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-08-24 18:12:19 +0800 |
| commit | 35e1d95ced10a2311e9ee96030b8aeb7a2e4bf8b (patch) | |
| tree | c254218406e38a8faf0505d9b8a0fd30b14e342b | |
| parent | 7187dc72fa1909168213283ecd651fed35c1daae (diff) | |
support build version
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | docs/manual.md | 6 | ||||
| -rw-r--r-- | docs/zh/manual.md | 6 | ||||
| -rw-r--r-- | xmake/actions/config/configheader.lua | 6 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 18 |
5 files changed, 35 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 624d6509c..5912aa45c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Support 24bits truecolors for `cprint()` * Support `@loader_path` and `$ORIGIN` for `add_rpathdirs()` +* Improve `set_version("x.x.x", {build = "%Y%m%d%H%M"})` and add build version ## v2.1.6 @@ -347,6 +348,7 @@ * 改进`cprint()`,支持24位真彩色输出 * 对`add_rpathdirs()`增加对`@loader_path`和`$ORIGIN`的内置变量支持,提供可迁移动态库加载 +* 改进`set_version("x.x.x", {build = "%Y%m%d%H%M"})` 支持buildversion设置 ## v2.1.6 diff --git a/docs/manual.md b/docs/manual.md index 9d0cf5b46..0427b85cf 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -320,6 +320,12 @@ For example: #define TB_CONFIG_VERSION_BUILD 201510220917 ``` +We can set build version in v2.1.7 version: + +```lua +set_version("1.5.1", {build = "%Y%m%d%H%M"}) +``` + ##### set_xmakever ###### Set minimal xmake version diff --git a/docs/zh/manual.md b/docs/zh/manual.md index fc9bad30e..6c8fe5e4a 100644 --- a/docs/zh/manual.md +++ b/docs/zh/manual.md @@ -334,6 +334,12 @@ set_version("1.5.1") #define TB_CONFIG_VERSION_BUILD 201510220917 ``` +2.1.7版本支持buildversion的配置: + +```lua +set_version("1.5.1", {build = "%Y%m%d%H%M"}) +``` + ##### set_xmakever ###### 设置最小xmake版本 diff --git a/xmake/actions/config/configheader.lua b/xmake/actions/config/configheader.lua index c16f1b429..789f7982e 100644 --- a/xmake/actions/config/configheader.lua +++ b/xmake/actions/config/configheader.lua @@ -47,7 +47,7 @@ function _make_for_target(files, target) file:print("") -- make version - local version = project.version() + local version, version_build = project.version() if version then file:print("// version") file:print("#define %s_VERSION \"%s\"", configprefix, version) @@ -58,7 +58,9 @@ function _make_for_target(files, target) i = i + 1 if i > 3 then break end end - file:print("#define %s_VERSION_BUILD %s", configprefix, os.date("%Y%m%d%H%M", os.time())) + if version_build then + file:print("#define %s_VERSION_BUILD %s", configprefix, version_build) + end file:print("") end diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index bae02f7a0..715b3d83d 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -149,7 +149,23 @@ end -- get the project version function sandbox_core_project.version() - return project.get("version") + + -- get version and build version + local version = project.get("version") + local version_build = sandbox_core_project._version_build + if version then + local version_extra = project.get("__extra_version") + if version_extra then + version_build = table.wrap(version_extra[version]).build + if type(version_build) == "string" then + version_build = os.date(version_build, os.time()) + sandbox_core_project._version_build = version_build + end + end + end + + -- ok? + return version, version_build end -- get the project name |
