The Meson Build System
http://mesonbuild.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.4 KiB
72 lines
2.4 KiB
11 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
# Copyright 2014 Jussi Pakkanen
|
||
|
|
||
|
# 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.
|
||
|
|
||
|
"""This is a helper script for IDE developers. It allows you to
|
||
|
extract information such as list of targets, files, compiler flags,
|
||
|
tests and so on. All output is in JSON for simple parsing.
|
||
|
|
||
|
Currently only works for the Ninja backend. Others use generated
|
||
|
project files and don't need this info."""
|
||
|
|
||
|
import json, pickle
|
||
|
import coredata, build
|
||
|
from optparse import OptionParser
|
||
|
import sys, os
|
||
|
|
||
|
parser = OptionParser()
|
||
|
parser.add_option('--list-targets', action='store_true', dest='list_targets', default=False)
|
||
|
|
||
|
def list_targets(coredata, builddata):
|
||
|
tlist = []
|
||
|
for target in builddata.get_targets().values():
|
||
|
t = {}
|
||
|
t['name'] = target.get_basename()
|
||
|
t['filename'] = os.path.join(target.subdir, target.get_filename())
|
||
|
if isinstance(target, build.Executable):
|
||
|
typename = 'executable'
|
||
|
elif isinstance(target, build.SharedLibrary):
|
||
|
typename = 'shared library'
|
||
|
elif isinstance(target, build.StaticLibrary):
|
||
|
typename = 'static library'
|
||
|
else:
|
||
|
typename = 'unknown'
|
||
|
t['type'] = typename
|
||
|
if target.should_install():
|
||
|
t['installed'] = True
|
||
|
else:
|
||
|
t['installed'] = False
|
||
|
tlist.append(t)
|
||
|
print(json.dumps(tlist))
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
(options, args) = parser.parse_args()
|
||
|
if len(args) > 1:
|
||
|
print('Too many arguments')
|
||
|
sys.exit(1)
|
||
|
elif len(args) == 1:
|
||
|
bdir = args[0]
|
||
|
else:
|
||
|
bdir == ''
|
||
|
corefile = os.path.join(bdir, 'meson-private/coredata.dat')
|
||
|
buildfile = os.path.join(bdir, 'meson-private/build.dat')
|
||
|
coredata = pickle.load(open(corefile, 'rb'))
|
||
|
builddata = pickle.load(open(buildfile, 'rb'))
|
||
|
if options.list_targets:
|
||
|
list_targets(coredata, builddata)
|
||
|
else:
|
||
|
print('No command specified')
|
||
|
sys.exit(1)
|