Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/meson
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2016-03-19 18:40:22 +0300
committerNirbheek Chauhan <nirbheek@centricular.com>2020-10-28 19:59:08 +0300
commitc2b542b6c02bafbe7a83b2eeec6cb5a0bfa3ed0d (patch)
treed788ad2c57bd1ccaae6aa73dced21c83c59df1b1 /meson
parent034c1b61a250457649d788bbf983b3f0fb63f02e (diff)
Add support for Meson build system
Tested on: - Linux/x86* with gcc - Android armv7 arm64 x86 x86_64 with clang - Windows x86 x86_64 with Visual Studio 2017 - Windows x86 x86_64 with MinGW - macOS x86_64 with clang - iOS arm64 x86_64 with clang Co-authored by: Nirbheek Chauhan <nirbheek@centricular.com> https://gitlab.xiph.org/xiph/opus/-/merge_requests/13
Diffstat (limited to 'meson')
-rwxr-xr-xmeson/get-version.py86
-rwxr-xr-xmeson/read-sources-list.py28
2 files changed, 114 insertions, 0 deletions
diff --git a/meson/get-version.py b/meson/get-version.py
new file mode 100755
index 00000000..0e8b8623
--- /dev/null
+++ b/meson/get-version.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+#
+# Opus get-version.py
+#
+# Extracts versions for build:
+# - Opus package version based on 'git describe' or $srcroot/package_version
+# - libtool version based on configure.ac
+# - macos lib version based on configure.ac
+#
+# Usage:
+# get-version.py [--package-version | --libtool-version | --darwin-version]
+import argparse
+import subprocess
+import os
+import sys
+import shutil
+
+if __name__ == '__main__':
+ arg_parser = argparse.ArgumentParser(description='Extract Opus package version or libtool version')
+ group = arg_parser.add_mutually_exclusive_group(required=True)
+ group.add_argument('--libtool-version', action='store_true')
+ group.add_argument('--package-version', action='store_true')
+ group.add_argument('--darwin-version', action='store_true')
+ args = arg_parser.parse_args()
+
+ srcroot = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
+
+ # package version
+ if args.package_version:
+ package_version = None
+
+ # check if git checkout
+ git_dir = os.path.join(srcroot, '.git')
+ is_git = os.path.isdir(git_dir)
+ have_git = shutil.which('git') is not None
+
+ if is_git and have_git:
+ git_cmd = subprocess.run(['git', '--git-dir=' + git_dir, 'describe', 'HEAD'], stdout=subprocess.PIPE)
+ if git_cmd.returncode:
+ print('ERROR: Could not extract package version via `git describe` in', srcroot, file=sys.stderr)
+ sys.exit(-1)
+ package_version = git_cmd.stdout.decode('ascii').strip().lstrip('v')
+ else:
+ with open(os.path.join(srcroot, 'package_version'), 'r') as f:
+ for line in f:
+ if line.startswith('PACKAGE_VERSION="'):
+ package_version = line[17:].strip().lstrip('v').rstrip('"')
+ if package_version:
+ break
+
+ if not package_version:
+ print('ERROR: Could not extract package version from package_version file in', srcroot, file=sys.stderr)
+ sys.exit(-1)
+
+ print(package_version)
+ sys.exit(0)
+
+ # libtool version + darwin version
+ elif args.libtool_version or args.darwin_version:
+ opus_lt_cur = None
+ opus_lt_rev = None
+ opus_lt_age = None
+
+ with open(os.path.join(srcroot, 'configure.ac'), 'r') as f:
+ for line in f:
+ if line.strip().startswith('OPUS_LT_CURRENT='):
+ opus_lt_cur = line[16:].strip()
+ elif line.strip().startswith('OPUS_LT_REVISION='):
+ opus_lt_rev = line[17:].strip()
+ elif line.strip().startswith('OPUS_LT_AGE='):
+ opus_lt_age = line[12:].strip()
+
+ if opus_lt_cur and opus_lt_rev and opus_lt_age:
+ opus_lt_cur = int(opus_lt_cur)
+ opus_lt_rev = int(opus_lt_rev)
+ opus_lt_age = int(opus_lt_age)
+ if args.libtool_version:
+ print('{}.{}.{}'.format(opus_lt_cur - opus_lt_age, opus_lt_age, opus_lt_rev))
+ elif args.darwin_version:
+ print('{}.{}.{}'.format(opus_lt_cur + 1, 0, 0))
+ sys.exit(0)
+ else:
+ print('ERROR: Could not extract libtool version from configure.ac file in', srcroot, file=sys.stderr)
+ sys.exit(-1)
+ else:
+ sys.exit(-1)
diff --git a/meson/read-sources-list.py b/meson/read-sources-list.py
new file mode 100755
index 00000000..fcbec501
--- /dev/null
+++ b/meson/read-sources-list.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+#
+# opus/read-sources-list.py
+#
+# Parses .mk files and extracts list of source files.
+# Prints one line per source file list, with filenames space-separated.
+
+import sys
+
+if len(sys.argv) < 2:
+ sys.exit('Usage: {} sources_foo.mk [sources_bar.mk...]'.format(sys.argv[0]))
+
+for input_fn in sys.argv[1:]:
+ with open(input_fn, 'r', encoding='utf8') as f:
+ text = f.read()
+ text = text.replace('\\\n', '')
+
+ # Remove empty lines
+ lines = [line for line in text.split('\n') if line.strip()]
+
+ # Print SOURCES_XYZ = file1.c file2.c
+ for line in lines:
+ values = line.strip().split('=', maxsplit=2)
+ if len(values) != 2:
+ raise RuntimeError('Unable to parse line "{}" from file "{}"'.format(line, input_fn))
+ var, files = values
+ sources_list = [f for f in files.split(' ') if f]
+ print(var.strip(), '=', ' '.join(sources_list))