diff --git a/dependencies.py b/dependencies.py index 10d59104d..70680fb9c 100644 --- a/dependencies.py +++ b/dependencies.py @@ -97,4 +97,29 @@ class BoostDependency(): flags.append(linkcmd) return flags -packages = {'boost': BoostDependency} + def get_sources(self): + return [] + +class GTestDependency(): + def __init__(self, kwargs): + self.include_dir = '/usr/include' + self.src_include_dir = '/usr/src/gtest' + self.src_dir = '/usr/src/gtest/src' + self.all_src = os.path.join(self.src_dir, 'gtest-all.cc') + self.main_src = os.path.join(self.src_dir, 'gtest_main.cc') + + def found(self): + return os.path.exists(self.all_src) + def get_compile_flags(self): + return ['-I' + self.include_dir, '-I' + self.src_include_dir] + def get_link_flags(self): + return [] + def get_version(self): + return '1.something_maybe' + + def get_sources(self): + return [self.all_src, self.main_src] + +packages = {'boost': BoostDependency, + 'gtest': GTestDependency, + } diff --git a/environment.py b/environment.py index a6af07afe..8b98132ca 100755 --- a/environment.py +++ b/environment.py @@ -462,6 +462,11 @@ class Dependency(): def found(self): return False + def get_sources(self): + """Source files that need to be added to the target. + As an example, gtest-all.cc when using GTest.""" + return [] + class PackageDependency(Dependency): # Custom detector, not pkg-config. def __init__(self, dep): Dependency.__init__(self) @@ -476,6 +481,9 @@ class PackageDependency(Dependency): # Custom detector, not pkg-config. def found(self): return self.dep.found() + def get_sources(self): + return self.dep.get_sources() + # This should be an InterpreterObject. Fix it. class PkgConfigDependency(Dependency): diff --git a/interpreter.py b/interpreter.py index 87b4e0bf5..58e07be7d 100755 --- a/interpreter.py +++ b/interpreter.py @@ -381,6 +381,8 @@ class BuildTarget(InterpreterObject): not isinstance(dep, ExternalLibraryHolder): raise InvalidArguments('Argument is not an external dependency') self.external_deps.append(dep) + if isinstance(dep, environment.Dependency): + self.process_sourcelist(dep.get_sources()) def get_external_deps(self): return self.external_deps @@ -605,6 +607,8 @@ class Interpreter(): actual = args[i] if wanted != None: if not isinstance(actual, wanted): + print(actual) + print(wanted) raise InvalidArguments('Incorrect argument type.') def func_project(self, node, args, kwargs):