[gtk/wip.win32.fixes: 20/20] gen-demo-header.py: Fix running without git
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip.win32.fixes: 20/20] gen-demo-header.py: Fix running without git
- Date: Tue, 18 May 2021 03:06:36 +0000 (UTC)
commit 4324f516d5355948f590520613b811fe454ec6a4
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue May 18 11:02:27 2021 +0800
gen-demo-header.py: Fix running without git
The script assumes that the git program is in the PATH which may not be always
the case, so if git was not found, fallback to the former behavior of making
VCS_TAG an empty string if the profile option was not set to 'devel'.
Also fix the call to the script so that we do indeed call GIT on the source GIT
repo so that we can get the right short SHA1 sum.
build-aux/meson/gen-demo-header.py | 17 ++++++++++++-----
demos/meson.build | 2 +-
2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/build-aux/meson/gen-demo-header.py b/build-aux/meson/gen-demo-header.py
index 700193a50b..43c543280e 100755
--- a/build-aux/meson/gen-demo-header.py
+++ b/build-aux/meson/gen-demo-header.py
@@ -4,7 +4,8 @@ import os
import subprocess
import sys
-profile = sys.argv[1]
+repodir = sys.argv[1]
+profile = sys.argv[2]
sys.stdout.write("/* This file is auto-generated. Do not edit. */\n")
sys.stdout.write("#pragma once\n")
@@ -15,7 +16,13 @@ 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")
+ cmd = ["git", "-C", repodir, "rev-parse", "--short", "HEAD"]
+ try:
+ 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")
+ except FileNotFoundError:
+ tag_string = ''
+ if profile != 'default':
+ tag_string = 'devel'
+ sys.stdout.write(f"#define VCS_TAG \"{tag_string}\"\n")
diff --git a/demos/meson.build b/demos/meson.build
index c66d19308b..5b68828eef 100644
--- a/demos/meson.build
+++ b/demos/meson.build
@@ -3,7 +3,7 @@ demo_profile = get_option('profile')
demo_conf_h = declare_dependency(
sources: custom_target('demo-header',
- command: [gen_demo_header, demo_profile],
+ command: [gen_demo_header, meson.source_root(), demo_profile],
capture: true,
output: 'demo_conf.h',
build_by_default: true,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]