diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a33c642a839..7e0e7983329 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -296,7 +296,6 @@ include: - if: *is-merge-attempt changes: &all_paths - VERSION - - bin/git_sha1_gen.py - bin/install_megadrivers.py - bin/symbols-check.py - bin/ci/**/* diff --git a/bin/git_sha1_gen.py b/bin/git_sha1_gen.py deleted file mode 100644 index a457b310d48..00000000000 --- a/bin/git_sha1_gen.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -Generate the contents of the git_sha1.h file. -""" - -import argparse -import os -import os.path -import subprocess -import sys - - -def get_git_sha1(): - """Try to get the git SHA1 with git rev-parse.""" - git_dir = os.path.join(os.path.dirname(sys.argv[0]), '..', '.git') - try: - git_sha1 = subprocess.check_output([ - 'git', - '--git-dir=' + git_dir, - 'rev-parse', - 'HEAD', - ], stderr=open(os.devnull, 'w')).decode("ascii") - except Exception: - # don't print anything if it fails - git_sha1 = '' - return git_sha1 - - -def write_if_different(contents): - """ - Avoid touching the output file if it doesn't need modifications - Useful to avoid triggering rebuilds when nothing has changed. - """ - if os.path.isfile(args.output): - with open(args.output, 'r') as file: - if file.read() == contents: - return - with open(args.output, 'w') as file: - file.write(contents) - - -parser = argparse.ArgumentParser() -parser.add_argument('--output', help='File to write the #define in', - required=True) -args = parser.parse_args() - -git_sha1 = os.environ.get('MESA_GIT_SHA1_OVERRIDE', get_git_sha1())[:10] -if git_sha1: - write_if_different('#define MESA_GIT_SHA1 " (git-' + git_sha1 + ')"') -else: - write_if_different('#define MESA_GIT_SHA1 ""') diff --git a/bin/meson.build b/bin/meson.build index e6664d7fe74..8749a69c349 100644 --- a/bin/meson.build +++ b/bin/meson.build @@ -1,7 +1,6 @@ # Copyright © 2017 Eric Engestrom # SPDX-License-Identifier: MIT -git_sha1_gen_py = files('git_sha1_gen.py') gen_vs_module_defs_py = files('gen_vs_module_defs.py') gen_vs_module_defs_normal_command = [ prog_python, gen_vs_module_defs_py, diff --git a/src/git_sha1.h.in b/src/git_sha1.h.in new file mode 100644 index 00000000000..1cc80cccb63 --- /dev/null +++ b/src/git_sha1.h.in @@ -0,0 +1 @@ +#define MESA_GIT_SHA1 @VCS_TAG@ diff --git a/src/meson.build b/src/meson.build index fdfb2dc246f..ae9dcffad6d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -33,12 +33,11 @@ glsl_util_files = files( 'mesa/program/dummy_errors.c', ) -sha1_h = custom_target( - 'git_sha1.h', +sha1_h = vcs_tag( + input : 'git_sha1.h.in', output : 'git_sha1.h', - command : [prog_python, git_sha1_gen_py, '--output', '@OUTPUT@'], - build_by_default : true, - build_always_stale : true, # commit sha1 can change without having touched these files + command : ['git', 'show', '--no-patch', '--abbrev=10', '--format=" (git-%h)"'], + fallback : '""', ) if cc.get_argument_syntax() == 'msvc'