mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-31 22:25:29 -04:00
opt: optimize version message when build in release package
This commit is contained in:
parent
1d4138412a
commit
7a5f40112e
1 changed files with 20 additions and 9 deletions
27
meson.build
27
meson.build
|
|
@ -41,18 +41,29 @@ pcre2_dep = dependency('libpcre2-8')
|
||||||
libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1')
|
libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1')
|
||||||
|
|
||||||
|
|
||||||
# 获取 Git Commit Hash 和最新的 tag
|
# 获取版本信息
|
||||||
git = find_program('git', required : false)
|
git = find_program('git', required : false)
|
||||||
|
is_git_repo = false
|
||||||
|
|
||||||
|
# 检查当前目录是否是 Git 仓库
|
||||||
if git.found()
|
if git.found()
|
||||||
commit_hash = run_command(git, 'rev-parse', '--short', 'HEAD', check : false).stdout().strip()
|
git_status = run_command(git, 'rev-parse', '--is-inside-work-tree', check : false)
|
||||||
latest_tag = run_command(git, 'describe', '--tags', '--abbrev=0', check : false).stdout().strip()
|
if git_status.returncode() == 0 and git_status.stdout().strip() == 'true'
|
||||||
else
|
is_git_repo = true
|
||||||
commit_hash = 'unknown'
|
endif
|
||||||
latest_tag = meson.project_version() # 如果 Git 不可用,使用默认版本号
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# 将 Commit Hash 和最新的 tag 添加到版本信息中
|
if is_git_repo
|
||||||
version_with_hash = '@0@(@1@)'.format(latest_tag, commit_hash)
|
# 如果是 Git 目录,获取 Commit Hash 和最新的 tag
|
||||||
|
commit_hash = run_command(git, 'rev-parse', '--short', 'HEAD', check : false).stdout().strip()
|
||||||
|
latest_tag = run_command(git, 'describe', '--tags', '--abbrev=0', check : false).stdout().strip()
|
||||||
|
version_with_hash = '@0@(@1@)'.format(latest_tag, commit_hash)
|
||||||
|
else
|
||||||
|
# 如果不是 Git 目录,使用项目版本号和 "release" 字符串
|
||||||
|
commit_hash = 'release'
|
||||||
|
latest_tag = meson.project_version()
|
||||||
|
version_with_hash = '@0@(@1@)'.format(latest_tag, commit_hash)
|
||||||
|
endif
|
||||||
|
|
||||||
# 定义编译参数
|
# 定义编译参数
|
||||||
c_args = [
|
c_args = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue