Skip to content

Commit

Permalink
Handle files() in Vala arguments and set up deps correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Jul 3, 2015
1 parent 5cbcb14 commit cd40187
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import dependencies
import mlog
import copy, os
from mesonlib import File
from mesonlib import File, flatten

known_basic_kwargs = {'install' : True,
'c_pch' : True,
Expand Down Expand Up @@ -476,8 +476,9 @@ def add_include_dirs(self, args):
self.include_dirs += ids

def add_compiler_args(self, language, args):
args = flatten(args)
for a in args:
if not isinstance(a, str):
if not isinstance(a, (str, File)):
raise InvalidArguments('A non-string passed to compiler args.')
if language in self.extra_args:
self.extra_args[language] += args
Expand Down
11 changes: 11 additions & 0 deletions mesonlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ def __eq__(self, other):
def __hash__(self):
return hash((self.fname, self.subdir, self.is_built))

def flatten(item):
if not isinstance(item, list):
return item
result = []
for i in item:
if isinstance(i, list):
result += flatten(i)
else:
result.append(i)
return result

def is_osx():
return platform.system().lower() == 'darwin'

Expand Down
14 changes: 13 additions & 1 deletion ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ def generate_vala_compile(self, target, outfile):
generated_c = []
(src, vapi_src) = self.split_vala_sources(target.get_sources())
vapi_src = [x.rel_to_builddir(self.build_to_src) for x in vapi_src]
extra_dep_files = []
for s in src:
if not s.endswith('.vala'):
continue
Expand All @@ -714,11 +715,22 @@ def generate_vala_compile(self, target, outfile):
args += ['--target-glib', d.version_requirement[2:]]
args += ['--pkg', d.name]
args += vapi_src
args += target.extra_args.get('vala', [])
extra_args = []

for a in target.extra_args.get('vala', []):
if isinstance(a, File):
relname = a.rel_to_builddir(self.build_to_src)
extra_dep_files.append(relname)
extra_args.append(relname)
else:
extra_args.append(a)
print(extra_args)
args += extra_args
generated_c += [relsc]
element = NinjaBuildElement(relsc, valac.get_language() + '_COMPILER', rel_s)
element.add_item('ARGS', args)
element.add_orderdep(vapi_order_deps)
element.add_dep(extra_dep_files)
element.write(outfile)
return generated_c

Expand Down

0 comments on commit cd40187

Please sign in to comment.