Use File objects for all sources. Fix all basic tests.

pull/102/head
Jussi Pakkanen 10 years ago
parent bf9b5d7b72
commit 6237695e96
  1. 2
      backends.py
  2. 1
      build.py
  3. 14
      interpreter.py
  4. 6
      mesonlib.py

@ -167,6 +167,8 @@ class Backend():
for osrc in extobj.srclist:
if not self.source_suffix_in_objs:
osrc = '.'.join(osrc.split('.')[:-1])
if hasattr(osrc, 'fname'): # FIXME allow only strings.
osrc = osrc.fname
objname = os.path.join(proj_dir_to_build_root,
targetdir, os.path.basename(osrc) + suffix)
result.append(objname)

@ -259,6 +259,7 @@ class BuildTarget():
for src in srclist:
if not isinstance(src, str):
raise coredata.MesonException('Extraction arguments must be strings.')
src = File(False, self.subdir, src)
if src not in self.sources:
raise coredata.MesonException('Tried to extract unknown source %s.' % src)
obj_src.append(src)

@ -1494,6 +1494,19 @@ class Interpreter():
result.append(a)
return result
def source_strings_to_files(self, sources):
results = []
for s in sources:
if isinstance(s, File) or isinstance(s, GeneratedListHolder) or \
isinstance(s, CustomTargetHolder):
pass
elif isinstance(s, str): # FIXME do not allow plain strings.
s = File.from_source_file(self.environment.source_dir, self.subdir, s)
else:
raise RuntimeError("Unreachable code")
results.append(s)
return results
def build_target(self, node, args, kwargs, targetholder):
args = self.flatten(args)
name = args[0]
@ -1515,6 +1528,7 @@ class Interpreter():
except KeyError:
kw_src = []
sources += kw_src
sources = self.source_strings_to_files(sources)
objs = self.flatten(kwargs.get('objects', []))
if not isinstance(objs, list):
objs = [objs]

@ -48,6 +48,12 @@ class File:
def split(self, s):
return self.fname.split(s)
def __eq__(self, other):
return (self.fname, self.subdir, self.is_built) == (other.fname, other.subdir, other.is_built)
def __hash__(self):
return hash((self.fname, self.subdir, self.is_built))
def is_osx():
return platform.system().lower() == 'darwin'

Loading…
Cancel
Save