mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 03:00:11 +01:00
Revert "meson: use vcs_tag() instead of custom script"
This reverts commit e4edf9203b.
Meson is unfortunately not quite ready yet, and prints stderr noise when
_not_ building from a git clone.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37717>
This commit is contained in:
parent
e5353fd917
commit
d31f468ad8
5 changed files with 57 additions and 5 deletions
|
|
@ -290,6 +290,7 @@ include:
|
|||
- if: *is-merge-attempt
|
||||
changes: &all_paths
|
||||
- VERSION
|
||||
- bin/git_sha1_gen.py
|
||||
- bin/install_megadrivers.py
|
||||
- bin/symbols-check.py
|
||||
- bin/ci/**/*
|
||||
|
|
|
|||
50
bin/git_sha1_gen.py
Normal file
50
bin/git_sha1_gen.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
"""
|
||||
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 ""')
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# 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,
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
#define MESA_GIT_SHA1 @VCS_TAG@
|
||||
|
|
@ -33,11 +33,12 @@ glsl_util_files = files(
|
|||
'mesa/program/dummy_errors.c',
|
||||
)
|
||||
|
||||
sha1_h = vcs_tag(
|
||||
input : 'git_sha1.h.in',
|
||||
sha1_h = custom_target(
|
||||
'git_sha1.h',
|
||||
output : 'git_sha1.h',
|
||||
command : ['git', 'show', '--no-patch', '--abbrev=10', '--format=" (git-%h)"'],
|
||||
fallback : '""',
|
||||
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
|
||||
)
|
||||
|
||||
if cc.get_argument_syntax() == 'msvc'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue