From 03bd3efaa7072021b702ab3f4ce8abcd1ac47d46 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 19 Jun 2020 10:32:46 +0430 Subject: [PATCH] [meson] Write git revision to .tarball-revision on dist tarball --- Makefile.am | 1 + meson.build | 2 ++ write-tarball-revision.py | 13 +++++++++++++ 3 files changed, 16 insertions(+) create mode 100755 write-tarball-revision.py diff --git a/Makefile.am b/Makefile.am index 766b2cca4..62ce69026 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ EXTRA_DIST = \ subprojects/zlib.wrap \ meson-cc-tests/intel-atomic-primitives-test.c \ meson-cc-tests/solaris-atomic-operations.c \ + write-tarball-revision.py \ $(NULL) MAINTAINERCLEANFILES = \ diff --git a/meson.build b/meson.build index 32758db83..bb8ab681d 100644 --- a/meson.build +++ b/meson.build @@ -356,6 +356,8 @@ if not get_option('gtk_doc').disabled() subdir('docs') endif +meson.add_dist_script('write-tarball-revision.py') + configure_file(output: 'config.h', configuration: conf) summary({'prefix': get_option('prefix'), diff --git a/write-tarball-revision.py b/write-tarball-revision.py new file mode 100755 index 000000000..0b3ffee6d --- /dev/null +++ b/write-tarball-revision.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os, subprocess +from pathlib import Path + +outfile = Path( + os.getenv('MESON_DIST_ROOT') + or os.getenv('MESON_SOURCE_ROOT') + or Path(__file__).parent +) / '.tarball-revision' + +with open(outfile, 'wb') as f: + f.write(subprocess.check_output(['git', 'log', '--no-color', '--no-decorate', 'HEAD~..HEAD']))