mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
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.
This commit is contained in:
parent
1a426d6fff
commit
c1fbf654a0
21
build-aux/meson/gen-demo-header.py
Executable file
21
build-aux/meson/gen-demo-header.py
Executable file
@ -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")
|
@ -1,16 +1,13 @@
|
|||||||
demo_conf = configuration_data()
|
gen_demo_header = find_program('../build-aux/meson/gen-demo-header.py')
|
||||||
demo_conf.set_quoted('PROFILE', get_option('profile'))
|
demo_profile = get_option('profile')
|
||||||
demo_conf.set_quoted('VCS_TAG', '@VCS_TAG@')
|
|
||||||
|
|
||||||
demo_conf_h = declare_dependency(
|
demo_conf_h = declare_dependency(
|
||||||
sources: vcs_tag(
|
sources: custom_target('demo-header',
|
||||||
command: [ 'git', 'rev-parse', '--short', 'HEAD' ],
|
command: [gen_demo_header, demo_profile],
|
||||||
fallback: get_option('profile') != 'default' ? 'devel' : '',
|
capture: true,
|
||||||
input: configure_file(
|
output: 'demo_conf.h',
|
||||||
output: 'demo_conf.h.in',
|
build_by_default: true,
|
||||||
configuration: demo_conf
|
build_always_stale: true,
|
||||||
),
|
|
||||||
output: 'demo_conf.h'
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user