|
|
@ -40,11 +40,11 @@ class InterpreterObject(): |
|
|
|
raise InvalidCode('Unknown method "%s" in object.' % method_name) |
|
|
|
raise InvalidCode('Unknown method "%s" in object.' % method_name) |
|
|
|
|
|
|
|
|
|
|
|
class ExternalProgram(InterpreterObject): |
|
|
|
class ExternalProgram(InterpreterObject): |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, name, fullpath=None): |
|
|
|
def __init__(self, name, fullpath=None): |
|
|
|
InterpreterObject.__init__(self) |
|
|
|
InterpreterObject.__init__(self) |
|
|
|
self.name = name |
|
|
|
self.name = name |
|
|
|
self.fullpath = fullpath |
|
|
|
self.fullpath = fullpath |
|
|
|
|
|
|
|
#self.methods.update({'found': self.found_method}) |
|
|
|
|
|
|
|
|
|
|
|
def found(self): |
|
|
|
def found(self): |
|
|
|
return self.fullpath is not None |
|
|
|
return self.fullpath is not None |
|
|
@ -58,6 +58,25 @@ class ExternalProgram(InterpreterObject): |
|
|
|
def get_name(self): |
|
|
|
def get_name(self): |
|
|
|
return self.name |
|
|
|
return self.name |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExternalLibrary(InterpreterObject): |
|
|
|
|
|
|
|
def __init__(self, name, fullpath=None): |
|
|
|
|
|
|
|
InterpreterObject.__init__(self) |
|
|
|
|
|
|
|
self.name = name |
|
|
|
|
|
|
|
self.fullpath = fullpath |
|
|
|
|
|
|
|
#self.methods.update({'found': self.found_method}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def found(self): |
|
|
|
|
|
|
|
return self.fullpath is not None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def found_method(self, args, kwargs): |
|
|
|
|
|
|
|
return self.found() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_filename(self): |
|
|
|
|
|
|
|
return self.fullpath |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_name(self): |
|
|
|
|
|
|
|
return self.name |
|
|
|
|
|
|
|
|
|
|
|
class Generator(InterpreterObject): |
|
|
|
class Generator(InterpreterObject): |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, args, kwargs): |
|
|
|
def __init__(self, args, kwargs): |
|
|
@ -349,7 +368,8 @@ class BuildTarget(InterpreterObject): |
|
|
|
|
|
|
|
|
|
|
|
def add_external_deps(self, deps): |
|
|
|
def add_external_deps(self, deps): |
|
|
|
for dep in deps: |
|
|
|
for dep in deps: |
|
|
|
if not isinstance(dep, environment.Dependency): |
|
|
|
if not isinstance(dep, environment.Dependency) and\ |
|
|
|
|
|
|
|
not isinstance(dep, ExternalLibrary): |
|
|
|
raise InvalidArguments('Argument is not an external dependency') |
|
|
|
raise InvalidArguments('Argument is not an external dependency') |
|
|
|
self.external_deps.append(dep) |
|
|
|
self.external_deps.append(dep) |
|
|
|
|
|
|
|
|
|
|
@ -496,6 +516,7 @@ class Interpreter(): |
|
|
|
'include_directories' : self.func_include_directories, |
|
|
|
'include_directories' : self.func_include_directories, |
|
|
|
'add_global_arguments' : self.func_add_global_arguments, |
|
|
|
'add_global_arguments' : self.func_add_global_arguments, |
|
|
|
'find_program' : self.func_find_program, |
|
|
|
'find_program' : self.func_find_program, |
|
|
|
|
|
|
|
'find_library' : self.func_find_library, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def get_build_def_files(self): |
|
|
|
def get_build_def_files(self): |
|
|
@ -625,6 +646,22 @@ class Interpreter(): |
|
|
|
raise InvalidArguments('Line %d: program "%s" not found.' % (node.lineno(), exename)) |
|
|
|
raise InvalidArguments('Line %d: program "%s" not found.' % (node.lineno(), exename)) |
|
|
|
return progobj |
|
|
|
return progobj |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def func_find_library(self, node, args, kwargs): |
|
|
|
|
|
|
|
self.validate_arguments(args, 1, [str]) |
|
|
|
|
|
|
|
required = kwargs.get('required', False) |
|
|
|
|
|
|
|
if not isinstance(required, bool): |
|
|
|
|
|
|
|
raise InvalidArguments('Line %d: "required" argument must be a boolean.' % node.lineno()) |
|
|
|
|
|
|
|
libname = args[0] |
|
|
|
|
|
|
|
if libname in self.coredata.ext_libs and\ |
|
|
|
|
|
|
|
self.coredata.ext_libs[libname].found(): |
|
|
|
|
|
|
|
return self.coredata.ext_progs[libname] |
|
|
|
|
|
|
|
result = self.environment.find_library(libname) |
|
|
|
|
|
|
|
libobj = ExternalLibrary(libname, result) |
|
|
|
|
|
|
|
self.coredata.ext_libs[libname] = libobj |
|
|
|
|
|
|
|
if required and not libobj.found(): |
|
|
|
|
|
|
|
raise InvalidArguments('Line %d: external library "%s" not found.' % (node.lineno(), libname)) |
|
|
|
|
|
|
|
return libobj |
|
|
|
|
|
|
|
|
|
|
|
def func_find_dep(self, node, args, kwargs): |
|
|
|
def func_find_dep(self, node, args, kwargs): |
|
|
|
self.validate_arguments(args, 1, [str]) |
|
|
|
self.validate_arguments(args, 1, [str]) |
|
|
|
name = args[0] |
|
|
|
name = args[0] |
|
|
|