aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interpreter.py13
-rw-r--r--test cases/common/73 vcstag/meson.build8
-rw-r--r--test cases/common/73 vcstag/tagprog.c9
-rw-r--r--test cases/common/73 vcstag/vcstag.c.in2
4 files changed, 31 insertions, 1 deletions
diff --git a/interpreter.py b/interpreter.py
index e682387..5431585 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2014 The Meson development team
+# Copyright 2012-2015 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -726,6 +726,7 @@ class Interpreter():
'get_option' : self.func_get_option,
'subproject' : self.func_subproject,
'pkgconfig_gen' : self.func_pkgconfig_gen,
+ 'vcs_tag' : self.func_vcs_tag,
}
def get_build_def_files(self):
@@ -1105,6 +1106,16 @@ class Interpreter():
def func_jar(self, node, args, kwargs):
return self.build_target(node, args, kwargs, JarHolder)
+ def func_vcs_tag(self, node, args, kwargs):
+ fallback = kwargs.get('fallback', None)
+ if not isinstance(fallback, str):
+ raise InterpreterException('Keyword argument must exist and be a string.')
+ del kwargs['fallback']
+ scriptfile = os.path.join(os.path.split(__file__)[0], 'vcstagger.py')
+ kwargs['command'] = [sys.executable, scriptfile, '@INPUT@', '@OUTPUT@', fallback]
+ kwargs['build_always'] = True
+ return self.func_custom_target(node, ['vcstag'], kwargs)
+
def func_custom_target(self, node, args, kwargs):
if len(args) != 1:
raise InterpreterException('Incorrect number of arguments')
diff --git a/test cases/common/73 vcstag/meson.build b/test cases/common/73 vcstag/meson.build
new file mode 100644
index 0000000..23ff487
--- /dev/null
+++ b/test cases/common/73 vcstag/meson.build
@@ -0,0 +1,8 @@
+project('vcstag', 'c')
+
+version_src = vcs_tag(input : 'vcstag.c.in',
+output : 'vcstag.c',
+fallback : '1.0.0')
+
+executable('tagprog', 'tagprog.c', version_src)
+
diff --git a/test cases/common/73 vcstag/tagprog.c b/test cases/common/73 vcstag/tagprog.c
new file mode 100644
index 0000000..34146b4
--- /dev/null
+++ b/test cases/common/73 vcstag/tagprog.c
@@ -0,0 +1,9 @@
+#include<stdio.h>
+
+const char *vcstag;
+
+int main(int argc, char **argv) {
+ printf("Version is %s\n", vcstag);
+ return 0;
+}
+
diff --git a/test cases/common/73 vcstag/vcstag.c.in b/test cases/common/73 vcstag/vcstag.c.in
new file mode 100644
index 0000000..09192d9
--- /dev/null
+++ b/test cases/common/73 vcstag/vcstag.c.in
@@ -0,0 +1,2 @@
+const char *vcstag = "@VCS_TAG@";
+