Commit 041372d9 authored by Parth Pratim Chatterjee's avatar Parth Pratim Chatterjee Committed by Tom Henderson
Browse files

Support for command_argument attribute for depends_on element


Signed-off-by: Parth Pratim Chatterjee's avatarParth Pratim Chatterjee <parth27official@gmail.com>
parent 4e78f0ca
......@@ -46,6 +46,7 @@ from optparse import OptionParser
from bake.Dependencies import Dependencies, DependencyUnmet
from bake.Exceptions import MetadataError
from bake.Utils import ColorTool
from bake.Utils import ModuleAttribute, ModuleAttribute
from bake.Exceptions import TaskError
from bake.ModuleSource import SystemDependency
from bake.ModuleBuild import NoneModuleBuild
......@@ -679,14 +680,14 @@ class Bake:
deps.add_dst(m, wrapper.function)
# Review the dependencies of all the configured modules
for m in configuration.modules():
for dependency in m.dependencies():
src = configuration.lookup (dependency.name())
for dependency in m.dependencies():
src = configuration.lookup (dependency._name)
# verifies if the dependency really exists in the configuration
# if not we could have a problem of a corrupt, or badly
# configured xml file, e.g. misspelled module name
if src is None:
self._error('Dependency "%s" not found' % dependency.name())
self._error('Dependency "%s" not found' % dependency._name)
if not src in configuration.disabled():
# if it is set to add even the optional modules, or the
......
......@@ -334,9 +334,9 @@ class Configuration:
# self._read_libpath(build_node, build)
dependencies = []
for dep_node in module_node.findall('depends_on'):
dependencies.append(ModuleDependency(dep_node.get('name'),
bool(dep_node.get('optional', '').upper()=='TRUE')))
for dep_node in module_node.findall('depends_on'):
dependencies.append(self._create_obj_from_node(dep_node,ModuleDependency,'depends_on',name))
module = Module(name, source, build, mtype, min_ver, max_ver, dependencies=dependencies,
built_once=bool(module_node.get('built_once', '').upper()=='TRUE'),
installed=installed)
......@@ -371,13 +371,8 @@ class Configuration:
# handles the dependencies for the module and register them
# into module node
for dependency in module.dependencies():
attrs = {'name' : dependency.name() }
if dependency.is_optional():
attrs['optional'] = 'True'
else:
attrs['optional'] = 'False'
dep_node = ET.Element('depends_on', attrs)
for dependency in module.dependencies():
dep_node = self._create_node_from_obj(dependency, 'depends_on')
module_node.append(dep_node)
modules_node.append(module_node)
......
......@@ -34,20 +34,78 @@ import shutil
from bake.FilesystemMonitor import FilesystemMonitor
from bake.Exceptions import TaskError
from bake.Utils import ColorTool
from bake.Exceptions import NotImplemented
from bake.ModuleSource import SystemDependency
from bake.Utils import ModuleAttributeBase
class ModuleDependency:
class ModuleDependency(ModuleAttributeBase):
""" Dependency information. """
def __init__(self, name, optional = False):
self._name = name
self._optional = optional
instances = []
def __init__(self):
ModuleAttributeBase.__init__(self)
self.add_attribute('name', '', 'Name of the Module', mandatory=True)
self.add_attribute('optional', 'False', 'Name of the Module', mandatory=True)
self.__class__.instances.append(self)
@classmethod
def subclasses(self):
return ModuleDependency.__subclasses__()
def name(self):
return self._name
@classmethod
def name(cls):
return 'default'
@property
def _name(self):
return self.attribute('name').value
@property
def _optional(self):
return self.is_optional()
@classmethod
def create(cls, build_type):
for subclass in ModuleDependency.subclasses():
if subclass.name() == build_type:
instance = subclass()
return instance
return ModuleDependency()
def is_optional(self):
return self._optional
return bool(self.attribute('optional').value.upper() == "TRUE")
def configure_arguments(self):
raise NotImplemented()
@classmethod
def lookup_obj(cl,name):
for instance in cl.instances:
if instance._name == name:
return instance
return None
class WafModuleDependency(ModuleDependency):
def __init__(self):
ModuleDependency.__init__(self)
self.add_attribute('configure_arguments', '', 'Arguments to pass to'
' "waf configure"')
@classmethod
def name(cls):
return 'waf'
def configure_arguments(self):
return self.attribute('configure_arguments').value
class Module:
followOptional = None
......
......@@ -41,6 +41,7 @@ import shlex
from bake.Utils import ModuleAttributeBase
from bake.Exceptions import NotImplemented
from bake.Exceptions import TaskError
from bake.Module import ModuleDependency
class ModuleBuild(ModuleAttributeBase):
""" Generic build, to be extended by the specialized classes,
......@@ -76,7 +77,7 @@ class ModuleBuild(ModuleAttributeBase):
' system variable on the format VARIABLE1=value1'
';VARIABLE2=value2', mandatory=False)
# self.add_attribute('condition_to_build', '', 'Condition that, if '
# 'existent, should be true for allowing the instalation')
# 'existent, should be true for allowing the instalation')
@classmethod
def subclasses(self):
......@@ -405,9 +406,27 @@ class WafModuleBuild(ModuleBuild):
"""
extra_configure_options = []
if self.attribute('configure_arguments').value != '':
"""
Check if default configure arguments have been already
defined while adding the current module as a dependency.
"""
configure_arguments = None
if self.attribute('configure_arguments').value != '' :
configure_arguments = self.attribute('configure_arguments').value
mod_dep = ModuleDependency.lookup_obj(env._module_name)
if mod_dep != None:
if mod_dep.__class__.name() == 'waf':
if mod_dep.configure_arguments() != "" :
configure_arguments = mod_dep.configure_arguments()
if configure_arguments != None:
extra_configure_options = [env.replace_variables(tmp) for tmp in
bake.Utils.split_args(env.replace_variables(self.attribute('configure_arguments').value))]
bake.Utils.split_args(env.replace_variables(configure_arguments))]
env.run(self._binary(env.srcdir) + extra_configure_options,
directory=env.srcdir,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment