diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2021-05-17 21:12:09 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2021-05-17 21:34:13 +0100 |
commit | c1fbf654a05ac20b03906695ce340a863b05cec6 (patch) | |
tree | d5e1b0bf29756a7161664b15339dde65b1a525c3 /build-aux | |
parent | 1a426d6fffc39abd13e225db3ac76925df5e21b2 (diff) | |
download | gtk+-c1fbf654a05ac20b03906695ce340a863b05cec6.tar.gz |
build: Check CI envvars before rev-parse
The CI pipeline does not do a full clone, so we cannot use `git
rev-parse` to get the short SHA checksum for the current commit.
Of course, since nothing's ever easy, we cannot use vcs_tag() with a
custom command, so we need to generate our out `demo_conf.h` header
straight from a script.
Diffstat (limited to 'build-aux')
-rwxr-xr-x | build-aux/meson/gen-demo-header.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/build-aux/meson/gen-demo-header.py b/build-aux/meson/gen-demo-header.py new file mode 100755 index 0000000000..700193a50b --- /dev/null +++ b/build-aux/meson/gen-demo-header.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +profile = sys.argv[1] + +sys.stdout.write("/* This file is auto-generated. Do not edit. */\n") +sys.stdout.write("#pragma once\n") +sys.stdout.write("\n") +sys.stdout.write(f"#define PROFILE \"{profile}\"\n") + +short_sha = os.environ.get('CI_COMMIT_SHORT_SHA') +if short_sha is not None: + sys.stdout.write(f"#define VCS_TAG \"{short_sha}\"\n") +else: + cmd = ["git", "rev-parse", "--short", "HEAD"] + with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p: + short_sha = p.stdout.read().decode('utf-8').rstrip("\n") + sys.stdout.write(f"#define VCS_TAG \"{short_sha}\"\n") |