summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-01-15 23:37:22 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-01-15 23:37:22 +0200
commit66c01401deb186e6daa20cf4bf6a098076dda236 (patch)
tree3ca6ab02d9d48612471af6f21eb51914908b9da7
parentd2a14075b3bcee9235ba21e881f0910f8bf9167a (diff)
downloadmeson-66c01401deb186e6daa20cf4bf6a098076dda236.tar.gz
Moved scripts in the module and started work to run them via the main meson command.
-rwxr-xr-xmeson.py22
-rw-r--r--meson/environment.py2
-rw-r--r--meson/mesonmain.py60
-rw-r--r--meson/modules/gnome.py2
-rw-r--r--meson/ninjabackend.py11
-rw-r--r--[-rwxr-xr-x]meson/scripts/commandrunner.py (renamed from scripts/commandrunner.py)12
-rw-r--r--[-rwxr-xr-x]meson/scripts/delwithsuffix.py (renamed from scripts/delwithsuffix.py)33
-rw-r--r--[-rwxr-xr-x]meson/scripts/depfixer.py (renamed from scripts/depfixer.py)15
-rw-r--r--[-rwxr-xr-x]meson/scripts/dirchanger.py (renamed from scripts/dirchanger.py)12
-rw-r--r--[-rwxr-xr-x]meson/scripts/gtkdochelper.py (renamed from scripts/gtkdochelper.py)10
-rw-r--r--[-rwxr-xr-x]meson/scripts/meson_benchmark.py (renamed from scripts/meson_benchmark.py)0
-rw-r--r--[-rwxr-xr-x]meson/scripts/meson_install.py (renamed from scripts/meson_install.py)11
-rw-r--r--[-rwxr-xr-x]meson/scripts/meson_test.py (renamed from scripts/meson_test.py)2
-rw-r--r--[-rwxr-xr-x]meson/scripts/regen_checker.py (renamed from scripts/regen_checker.py)9
-rw-r--r--[-rwxr-xr-x]meson/scripts/symbolextractor.py (renamed from scripts/symbolextractor.py)12
-rw-r--r--[-rwxr-xr-x]meson/scripts/vcstagger.py (renamed from scripts/vcstagger.py)11
-rw-r--r--[-rwxr-xr-x]mesonconf.py (renamed from scripts/mesonconf.py)0
-rw-r--r--[-rwxr-xr-x]mesongui.py (renamed from scripts/mesongui.py)0
-rw-r--r--[-rwxr-xr-x]mesonintrospect.py (renamed from scripts/mesonintrospect.py)0
-rwxr-xr-xwraptool.py (renamed from scripts/wraptool.py)0
20 files changed, 156 insertions, 68 deletions
diff --git a/meson.py b/meson.py
index 94d6e2201..ab8db7250 100755
--- a/meson.py
+++ b/meson.py
@@ -1,6 +1,24 @@
#!/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.
+
from meson import mesonmain
-import sys
+import sys, os
+
+thisfile = __file__
+if not os.path.isabs(thisfile):
+ thisfile = os.path.join(os.getcwd(), thisfile)
-sys.exit(mesonmain.run(sys.argv[:]))
+sys.exit(mesonmain.run(thisfile, sys.argv[1:]))
diff --git a/meson/environment.py b/meson/environment.py
index a99cb305f..8df856ca7 100644
--- a/meson/environment.py
+++ b/meson/environment.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2014 The Meson development team
+# Copyright 2012-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.
diff --git a/meson/mesonmain.py b/meson/mesonmain.py
index 0bf123caa..58ba06b2f 100644
--- a/meson/mesonmain.py
+++ b/meson/mesonmain.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2012-2015 The Meson development team
+# Copyright 2012-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.
@@ -18,7 +18,7 @@ import sys, stat, traceback, pickle, argparse
import datetime
import os.path
from . import environment, interpreter, mesonlib
-from .import build
+from . import build
import platform
from . import mlog, coredata
@@ -163,21 +163,58 @@ itself as required.'''
dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat')
pickle.dump(b, open(dumpfile, 'wb'))
-def run(args):
+def run_script_command(args):
+ cmdname = args[0]
+ cmdargs = args[1:]
+ if cmdname == 'test':
+ import meson.scripts.meson_test as abc
+ cmdfunc = abc.run
+ elif cmdname == 'benchmark':
+ import meson.scripts.meson_benchmark as abc
+ cmdfunc = abc.run
+ elif cmdname == 'commandrunner':
+ import meson.scripts.commandrunner as abc
+ cmdfunc = abc.run
+ elif cmdname == 'delsuffix':
+ import meson.scripts.delwithsuffix as abc
+ cmdfunc = abc.run
+ elif cmdname == 'dirchanger':
+ import meson.scripts.dirchanger as abc
+ cmdfunc = abc.run
+ elif cmdname == 'gtkdoc':
+ import meson.scripts.gtkdochelper as abc
+ cmdfunc = abc.run
+ elif cmdname == 'regencheck':
+ import meson.scripts.regen_checker as abc
+ cmdfunc = abc.run
+ elif cmdname == 'symbolextractor':
+ import meson.scripts.symbolextractor as abc
+ cmdfunc = abc.run
+ elif cmdname == 'vcstagger':
+ import meson.scripts.vcstagger as abc
+ cmdfunc = abc.run
+ else:
+ raise MesonException('Unknown internal command {}.'.format(cmdname))
+ return cmdfunc(cmdargs)
+
+def run(mainfile, args):
if sys.version_info < (3, 3):
print('Meson works correctly only with python 3.3+.')
print('You have python %s.' % sys.version)
print('Please update your environment')
return 1
- if args[-1] == 'secret-handshake':
- args = args[:-1]
+ if args[0] == '--internal':
+ if args[1] != 'regenerate':
+ sys.exit(run_script_command(args[1:]))
+ args = args[2:]
handshake = True
else:
handshake = False
+ print(args)
args = mesonlib.expand_arguments(args)
if not args:
return 1
- options = parser.parse_args(args[1:])
+ options = parser.parse_args(args)
if options.print_version:
print(coredata.version)
return 0
@@ -191,16 +228,15 @@ def run(args):
dir2 = args[1]
else:
dir2 = '.'
- this_file = os.path.abspath(__file__)
- while os.path.islink(this_file):
- resolved = os.readlink(this_file)
+ while os.path.islink(mainfile):
+ resolved = os.readlink(mainfile)
if resolved[0] != '/':
- this_file = os.path.join(os.path.dirname(this_file), resolved)
+ mainfile = os.path.join(os.path.dirname(mainfile), resolved)
else:
- this_file = resolved
+ mainfile = resolved
try:
- app = MesonApp(dir1, dir2, this_file, handshake, options)
+ app = MesonApp(dir1, dir2, mainfile, handshake, options)
except Exception as e:
# Log directory does not exist, so just print
# to stdout.
diff --git a/meson/modules/gnome.py b/meson/modules/gnome.py
index 70ac81b34..e552b8488 100644
--- a/meson/modules/gnome.py
+++ b/meson/modules/gnome.py
@@ -1,4 +1,4 @@
-# Copyright 2015 The Meson development team
+# Copyright 2015-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.
diff --git a/meson/ninjabackend.py b/meson/ninjabackend.py
index d21cea011..80c94f9e9 100644
--- a/meson/ninjabackend.py
+++ b/meson/ninjabackend.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2014 The Meson development team
+# Copyright 2012-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.
@@ -582,9 +582,8 @@ int dummy;
self.serialise_tests()
valgrind = environment.find_valgrind()
script_root = self.environment.get_script_dir()
- test_script = os.path.join(script_root, 'meson_test.py')
test_data = os.path.join(self.environment.get_scratch_dir(), 'meson_test_setup.dat')
- cmd = [sys.executable, test_script, test_data]
+ cmd = [sys.executable, self.environment.get_build_command(), '--internal', 'test', test_data]
elem = NinjaBuildElement('test', 'CUSTOM_COMMAND', ['all', 'PHONY'])
elem.add_item('COMMAND', cmd)
elem.add_item('DESC', 'Running all tests.')
@@ -604,7 +603,7 @@ int dummy;
# And then benchmarks.
benchmark_script = os.path.join(script_root, 'meson_benchmark.py')
benchmark_data = os.path.join(self.environment.get_scratch_dir(), 'meson_benchmark_setup.dat')
- cmd = [sys.executable, benchmark_script, benchmark_data]
+ cmd = [sys.executable, self.environment.get_build_command(), '--internal', 'benchmark', benchmark_data]
elem = NinjaBuildElement('benchmark', 'CUSTOM_COMMAND', ['all', 'PHONY'])
elem.add_item('COMMAND', cmd)
elem.add_item('DESC', 'Running benchmark suite.')
@@ -628,9 +627,11 @@ int dummy;
outfile.write('rule REGENERATE_BUILD\n')
c = (quote_char + ninja_quote(sys.executable) + quote_char,
quote_char + ninja_quote(self.environment.get_build_command()) + quote_char,
+ '--internal',
+ 'regenerate',
quote_char + ninja_quote(self.environment.get_source_dir()) + quote_char,
quote_char + ninja_quote(self.environment.get_build_dir()) + quote_char)
- outfile.write(" command = %s %s %s %s --backend ninja secret-handshake\n" % c)
+ outfile.write(" command = %s %s %s %s %s %s --backend ninja\n" % c)
outfile.write(' description = Regenerating build files\n')
outfile.write(' generator = 1\n\n')
if len(self.build.pot) > 0:
diff --git a/scripts/commandrunner.py b/meson/scripts/commandrunner.py
index 0dad58516..f5a2fffdf 100755..100644
--- a/scripts/commandrunner.py
+++ b/meson/scripts/commandrunner.py
@@ -42,9 +42,10 @@ def run_command(source_dir, build_dir, subdir, command, arguments):
print('Could not execute command "%s".' % command)
sys.exit(1)
-if __name__ == '__main__':
- if len(sys.argv) < 5:
- print(sys.argv[0], '<source dir> <build dir> <subdir> <command> [arguments]')
+def run(args):
+ if len(sys.argv) < 4:
+ print('commandrunner.py <source dir> <build dir> <subdir> <command> [arguments]')
+ sys.exit(1)
src_dir = sys.argv[1]
build_dir = sys.argv[2]
subdir = sys.argv[3]
@@ -52,4 +53,7 @@ if __name__ == '__main__':
arguments = sys.argv[5:]
pc = run_command(src_dir, build_dir, subdir, command, arguments)
pc.wait()
- sys.exit(pc.returncode)
+ return pc.returncode
+
+if __name__ == '__main__':
+ sys.exit(run(sys.argv[1:]))
diff --git a/scripts/delwithsuffix.py b/meson/scripts/delwithsuffix.py
index 4b8a60de8..38ab406fc 100755..100644
--- a/scripts/delwithsuffix.py
+++ b/meson/scripts/delwithsuffix.py
@@ -16,17 +16,22 @@
import os, sys
-if len(sys.argv) != 3:
- print('%s <root of subdir to process> <suffix to delete>' % sys.argv[0])
- sys.exit(1)
-
-topdir = sys.argv[1]
-suffix = sys.argv[2]
-if suffix[0] != '.':
- suffix = '.' + suffix
-
-for (root, dirs, files) in os.walk(topdir):
- for f in files:
- if f.endswith(suffix):
- fullname = os.path.join(root, f)
- os.unlink(fullname)
+def run(args):
+ if len(sys.argv) != 2:
+ print('delwithsuffix.py <root of subdir to process> <suffix to delete>')
+ sys.exit(1)
+
+ topdir = sys.argv[1]
+ suffix = sys.argv[2]
+ if suffix[0] != '.':
+ suffix = '.' + suffix
+
+ for (root, _, files) in os.walk(topdir):
+ for f in files:
+ if f.endswith(suffix):
+ fullname = os.path.join(root, f)
+ os.unlink(fullname)
+ return 0
+
+if __name__ == '__main__':
+ run(sys.argv[1:])
diff --git a/scripts/depfixer.py b/meson/scripts/depfixer.py
index 4f7ce3d87..1ab83b6d4 100755..100644
--- a/scripts/depfixer.py
+++ b/meson/scripts/depfixer.py
@@ -284,16 +284,19 @@ class Elf(DataSizes):
entry.write(self.bf)
return None
-if __name__ == '__main__':
- if len(sys.argv) < 2 or len(sys.argv) > 3:
+def run(args):
+ if len(args) < 1 or len(args) > 2:
print('This application resets target rpath.')
print('Don\'t run this unless you know what you are doing.')
print('%s: <binary file> <prefix>' % sys.argv[0])
exit(1)
- e = Elf(sys.argv[1])
- if len(sys.argv) == 2:
+ e = Elf(args[0])
+ if len(args) == 1:
e.print_rpath()
else:
- new_rpath = sys.argv[2]
+ new_rpath = args[1]
e.fix_rpath(new_rpath.encode('utf8'))
- #e.fix_deps(prefix.encode())
+ return 0
+
+if __name__ == '__main__':
+ run(sys.argv[1:])
diff --git a/scripts/dirchanger.py b/meson/scripts/dirchanger.py
index fd3dc2350..93a901d54 100755..100644
--- a/scripts/dirchanger.py
+++ b/meson/scripts/dirchanger.py
@@ -19,8 +19,12 @@ the command given in the rest of the arguments.'''
import os, subprocess, sys
-dirname = sys.argv[1]
-command = sys.argv[2:]
+def run(args):
+ dirname = args[0]
+ command = args[1:]
-os.chdir(dirname)
-sys.exit(subprocess.call(command))
+ os.chdir(dirname)
+ return subprocess.call(command)
+
+if __name__ == '__main__':
+ sys.exit(run(sys.argv[1:]))
diff --git a/scripts/gtkdochelper.py b/meson/scripts/gtkdochelper.py
index 7e476b8de..68be8f2af 100755..100644
--- a/scripts/gtkdochelper.py
+++ b/meson/scripts/gtkdochelper.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# Copyright 2015 The Meson development team
+# Copyright 2015-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.
@@ -87,8 +87,8 @@ def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module):
shutil.rmtree(final_destination, ignore_errors=True)
shutil.copytree(source, final_destination)
-if __name__ == '__main__':
- options = parser.parse_args(sys.argv[1:])
+def run(args):
+ options = parser.parse_args(args)
if len(options.htmlargs) > 0:
htmlargs = options.htmlargs.split('@@')
else:
@@ -116,3 +116,7 @@ if __name__ == '__main__':
installdir,
'share/gtk-doc/html',
options.modulename)
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(run(sys.argv[1:]))
diff --git a/scripts/meson_benchmark.py b/meson/scripts/meson_benchmark.py
index 26f1f95a1..26f1f95a1 100755..100644
--- a/scripts/meson_benchmark.py
+++ b/meson/scripts/meson_benchmark.py
diff --git a/scripts/meson_install.py b/meson/scripts/meson_install.py
index e0a5eb24b..a2868643e 100755..100644
--- a/scripts/meson_install.py
+++ b/meson/scripts/meson_install.py
@@ -203,10 +203,13 @@ def install_targets(d):
print('Stderr:\n%s\n' % stde.decode())
sys.exit(1)
-if __name__ == '__main__':
- if len(sys.argv) != 2:
+def run(args):
+ if len(args) != 1:
print('Installer script for Meson. Do not run on your own, mmm\'kay?')
- print('%s [install info file]' % sys.argv[0])
- datafilename = sys.argv[1]
+ print('meson_install.py [install info file]')
+ datafilename = args[0]
do_install(datafilename)
+ return 0
+if __name__ == '__main__':
+ sys.exit(run(sys.argv[1:]))
diff --git a/scripts/meson_test.py b/meson/scripts/meson_test.py
index 43b1cdb30..c5814ef32 100755..100644
--- a/scripts/meson_test.py
+++ b/meson/scripts/meson_test.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2013-2015 The Meson development team
+# Copyright 2013-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.
diff --git a/scripts/regen_checker.py b/meson/scripts/regen_checker.py
index a0fe028cb..f360a7ce3 100755..100644
--- a/scripts/regen_checker.py
+++ b/meson/scripts/regen_checker.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2015 The Meson development team
+# Copyright 2015-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.
@@ -35,8 +35,11 @@ def regen(regeninfo):
'--backend=vs2010', 'secret-handshake']
subprocess.check_call(cmd)
-if __name__ == '__main__':
- regeninfo = pickle.load(open(os.path.join(sys.argv[1], 'regeninfo.dump'), 'rb'))
+def run(args):
+ regeninfo = pickle.load(open(os.path.join(args[0], 'regeninfo.dump'), 'rb'))
if need_regen(regeninfo):
regen(regeninfo)
sys.exit(0)
+
+if __name__ == '__main__':
+ run(sys.argv[1:])
diff --git a/scripts/symbolextractor.py b/meson/scripts/symbolextractor.py
index fe86d355a..9607466d0 100755..100644
--- a/scripts/symbolextractor.py
+++ b/meson/scripts/symbolextractor.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2013-2015 The Meson development team
+# Copyright 2013-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.
@@ -92,11 +92,15 @@ def gen_symbols(libfilename, outfilename, cross_host):
else:
dummy_syms(outfilename)
-if __name__ == '__main__':
- options = parser.parse_args()
+def run(args):
+ options = parser.parse_args(args)
if len(options.args) != 2:
- print(sys.argv[0], '<shared library file> <output file>')
+ print('symbolextractor.py <shared library file> <output file>')
sys.exit(1)
libfile = options.args[0]
outfile = options.args[1]
gen_symbols(libfile, outfile, options.cross_host)
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(run(sys.argv[1:]))
diff --git a/scripts/vcstagger.py b/meson/scripts/vcstagger.py
index ccc584e92..390e37a8d 100755..100644
--- a/scripts/vcstagger.py
+++ b/meson/scripts/vcstagger.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2015 The Meson development team
+# Copyright 2015-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.
@@ -27,7 +27,10 @@ def config_vcs_tag(infile, outfile, fallback, source_dir, replace_string, regex_
if (not os.path.exists(outfile)) or (open(outfile).read() != new_data):
open(outfile, 'w').write(new_data)
-if __name__ == '__main__':
- infile, outfile, fallback, source_dir, replace_string, regex_selector = sys.argv[1:7]
- command = sys.argv[7:]
+def run(args):
+ infile, outfile, fallback, source_dir, replace_string, regex_selector = args[0:6]
+ command = args[6:]
config_vcs_tag(infile, outfile, fallback, source_dir, replace_string, regex_selector, command)
+
+if __name__ == '__main__':
+ sys.exit(run(sys.argv[1:]))
diff --git a/scripts/mesonconf.py b/mesonconf.py
index e53875f13..e53875f13 100755..100644
--- a/scripts/mesonconf.py
+++ b/mesonconf.py
diff --git a/scripts/mesongui.py b/mesongui.py
index bdd44bbce..bdd44bbce 100755..100644
--- a/scripts/mesongui.py
+++ b/mesongui.py
diff --git a/scripts/mesonintrospect.py b/mesonintrospect.py
index 9fcd4dbd8..9fcd4dbd8 100755..100644
--- a/scripts/mesonintrospect.py
+++ b/mesonintrospect.py
diff --git a/scripts/wraptool.py b/wraptool.py
index 46860aacf..46860aacf 100755
--- a/scripts/wraptool.py
+++ b/wraptool.py