aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-05-21 18:21:23 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2016-05-21 18:21:23 +0300
commitdc148e0702dc47197f36a843b499d3d513faf272 (patch)
tree4e5bf878799a9c9826896cb8723d4b3822fd4eee /mesonbuild/scripts
parent12a4e7d7e74e9d8b39a0509984910caa79a45e12 (diff)
downloadmeson-dc148e0702dc47197f36a843b499d3d513faf272.zip
meson-dc148e0702dc47197f36a843b499d3d513faf272.tar.gz
meson-dc148e0702dc47197f36a843b499d3d513faf272.tar.bz2
Remove all special casing for gettext and use elementary operations instead.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/gettext.py65
-rw-r--r--mesonbuild/scripts/meson_install.py14
2 files changed, 65 insertions, 14 deletions
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
new file mode 100644
index 0000000..adc4483
--- /dev/null
+++ b/mesonbuild/scripts/gettext.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+
+# Copyright 2016 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.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os, subprocess, shutil
+
+def run_potgen(src_sub, pkgname, langs):
+ listfile = os.path.join(src_sub, 'POTFILES')
+ ofile = os.path.join(src_sub, pkgname + '.pot')
+ return subprocess.call(['xgettext', '--package-name=' + pkgname, '-p', src_sub, listfile,
+ '-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile])
+
+def gen_gmo(src_sub, bld_sub, langs):
+ for l in langs:
+ subprocess.check_call(['msgfmt', os.path.join(src_sub, l + '.po'),
+ '-o', os.path.join(bld_sub, l + '.gmo')])
+ return 0
+
+def do_install(src_sub, bld_sub, dest, pkgname, langs):
+ for l in langs:
+ srcfile = os.path.join(bld_sub, l + '.gmo')
+ outfile = os.path.join(dest, l, 'LC_MESSAGES',
+ pkgname + '.mo')
+ os.makedirs(os.path.split(outfile)[0], exist_ok=True)
+ shutil.copyfile(srcfile, outfile)
+ shutil.copystat(srcfile, outfile)
+ print('Installing %s to %s.' % (srcfile, outfile))
+ return 0
+
+def run(args):
+ subcmd = args[0]
+ if subcmd == 'pot':
+ src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], os.environ['MESON_SUBDIR'])
+ bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], os.environ['MESON_SUBDIR'])
+ return run_potgen(src_sub, args[1], args[2:])
+ elif subcmd == 'gen_gmo':
+ src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], os.environ['MESON_SUBDIR'])
+ bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], os.environ['MESON_SUBDIR'])
+ return gen_gmo(src_sub, bld_sub, args[1:])
+ elif subcmd == 'install':
+ subdir = args[1]
+ pkgname = args[2]
+ instsubdir = args[3]
+ langs = args[4:]
+ src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], subdir)
+ bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], subdir)
+ dest = os.environ.get('DESTDIR') + os.path.join(os.environ['MESON_INSTALL_PREFIX'], instsubdir)
+ if gen_gmo(src_sub, bld_sub, langs) != 0:
+ return 1
+ do_install(src_sub, bld_sub, dest, pkgname, langs)
+ else:
+ print('Unknown subcommand.')
+ return 1
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py
index 8e3d0ca..765969d 100644
--- a/mesonbuild/scripts/meson_install.py
+++ b/mesonbuild/scripts/meson_install.py
@@ -32,7 +32,6 @@ def do_install(datafilename):
install_headers(d)
install_man(d)
install_data(d)
- install_po(d)
run_install_script(d)
def install_subdirs(d):
@@ -50,19 +49,6 @@ def install_subdirs(d):
shutil.copytree(src_dir, final_dst, symlinks=True)
print('Installing subdir %s to %s.' % (src_dir, dst_dir))
-def install_po(d):
- packagename = d.po_package_name
- for f in d.po:
- srcfile = f[0]
- localedir = f[1]
- languagename = f[2]
- outfile = os.path.join(d.fullprefix, localedir, languagename, 'LC_MESSAGES',
- packagename + '.mo')
- os.makedirs(os.path.split(outfile)[0], exist_ok=True)
- shutil.copyfile(srcfile, outfile)
- shutil.copystat(srcfile, outfile)
- print('Installing %s to %s.' % (srcfile, outfile))
-
def install_data(d):
for i in d.data:
fullfilename = i[0]