Work on adding GTest support.

pull/15/head
Jussi Pakkanen 12 years ago
parent 70f6b769a6
commit 1b11431079
  1. 27
      dependencies.py
  2. 8
      environment.py
  3. 4
      interpreter.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,
}

@ -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):

@ -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):

Loading…
Cancel
Save