Skip to content

Commit

Permalink
Update Bridge tag/versioning scheme to match DXVK
Browse files Browse the repository at this point in the history
- Use same versioning scheme as dxvk
- REMIX-1890
  • Loading branch information
nv-nfreybler committed Jul 21, 2023
1 parent a06bdc0 commit a71bf64
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 8 deletions.
65 changes: 63 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@

project(
'bridge', ['c', 'cpp'],
version : 'remix-0.2.0',
meson_version : '>= 0.58',
default_options : ['werror=true', 'b_vscrt=static_from_buildtype', 'cpp_std=vc++17']
)

python_interpreter = find_program('python3', 'python')

global_src_root_norm = meson.global_source_root().replace('\\', '/')
output_dir = meson.global_source_root() + '/_output/'

cpu_family = target_machine.cpu_family()
build_os = build_machine.system()


# Get script paths
if build_os == 'windows'
Expand Down Expand Up @@ -164,9 +166,68 @@ else
output : [ '@BASENAME@' + res_ext ],
arguments : [ '-i', '@INPUT@', '-o', '@OUTPUT@' ])
endif

message('##############')
message('# Versioning #')
message('##############')

full_version = meson.project_version()

git_rev_parse_out = run_command('git',['rev-parse','--verify','--short=8', 'HEAD'])
git_hash = ''
if git_rev_parse_out.returncode() != 0
error('Failed to get current git hash')
else
git_hash = git_rev_parse_out.stdout().replace('\n','')
message('Current git hash: ' + git_hash)
endif

found_tag = ''
ci_commit_tag = ''
get_env_out = run_command(python_interpreter.full_path(),[global_src_root_norm + './scripts-common/get_env.py', 'CI_COMMIT_TAG'])
if get_env_out.returncode() != 0
error('get_env.py failed, which is unexpected')
else
ci_commit_tag = get_env_out.stdout().replace('\n','')
endif
b_found_ci_commit_tag = (ci_commit_tag != '')

if b_found_ci_commit_tag
message('Found tag in CI_COMMIT_TAG envvar: ' + ci_commit_tag)
found_tag = ci_commit_tag
else
git_describe_tag = ''
git_describe_out = run_command('git',['describe','--always','--exact-match', git_hash])
if git_describe_out.returncode() == 0
git_describe_tag = git_describe_out.stdout().replace('\n','')
message('Found tag via git describe: ' + git_describe_tag)
endif
found_tag = git_describe_tag
endif

b_found_tag = found_tag != ''
b_found_tag_matches = false
if b_found_tag
b_found_tag_matches = found_tag == meson.project_version()
endif

if b_found_tag
if not b_found_tag_matches
warning('Tag does not match current version: ' + meson.project_version() + '. Please reconcile tag with version in meson.build.')
else
message('Found tag matches current version: ' + meson.project_version())
message('This is a release version.')
endif
else
message('No tag found at current commit.')
message('This is NOT a release version')
full_version += '+' + git_hash
endif

message('Full version: ' + full_version)

bridge_version = vcs_tag(
command: ['git', 'describe', '--dirty=+'],
command: [python_interpreter.full_path(), global_src_root_norm + './scripts-common/echo.py', full_version],
input: 'version.h.in',
output: 'version.h')

Expand Down
7 changes: 7 additions & 0 deletions scripts-common/echo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sys

if len(sys.argv) != 2:
print("ERROR: Must provide one and only one positional arg to echo.py", sys.stderr)
exit(1)
print(sys.argv[1])
exit(0)
11 changes: 11 additions & 0 deletions scripts-common/get_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys
import os

if len(sys.argv) != 2:
print("ERROR: Must provide one and only one envvar name to get_env.py", sys.stderr)
exit(1)
envvar = sys.argv[1]
if envvar in os.environ.keys():
val = os.environ[envvar]
print(val)
exit(0)
6 changes: 3 additions & 3 deletions src/client/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#############################################################################

d3d9_version = vcs_tag(
command: ['git', 'describe', '--dirty=+'],
input: 'version.rc.in',
output: 'version.rc')
command: [python_interpreter.full_path(), global_src_root_norm + './scripts-common/echo.py', full_version],
input: 'version.rc.in',
output: 'version.rc')

d3d9_res = wrc_generator.process(d3d9_version)

Expand Down
6 changes: 3 additions & 3 deletions src/server/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ server_header = files([
thread_dep = dependency('threads')

server_tag = vcs_tag(
command: ['git', 'describe', '--dirty=+'],
input: 'version.rc.in',
output: 'version.rc')
command: [python_interpreter.full_path(), global_src_root_norm + './scripts-common/echo.py', full_version],
input: 'version.rc.in',
output: 'version.rc')

server_version = wrc_generator.process(server_tag)

Expand Down

0 comments on commit a71bf64

Please sign in to comment.