Exemplo n.º 1
0
def process_rule(self):
    """
    Process the attribute ``rule``. When present, :py:meth:`waflib.TaskGen.process_source` is disabled::

        def build(bld):
            bld(rule='cp ${SRC} ${TGT}', source='wscript', target='bar.txt')
    """
    if not getattr(self, 'rule', None):
        return

    # create the task class
    name = str(getattr(self, 'name', None) or self.target or self.rule)
    cls = Task.task_factory(name,
                            self.rule,
                            getattr(self, 'vars', []),
                            shell=getattr(self, 'shell', True),
                            color=getattr(self, 'color', 'BLUE'))

    # now create one instance
    tsk = self.create_task(name)

    if getattr(self, 'target', None):
        if isinstance(self.target, str):
            self.target = self.target.split()
        if not isinstance(self.target, list):
            self.target = [self.target]
        for x in self.target:
            if isinstance(x, str):
                tsk.outputs.append(self.path.find_or_declare(x))
            else:
                x.parent.mkdir(
                )  # if a node was given, create the required folders
                tsk.outputs.append(x)
        if getattr(self, 'install_path', None):
            # from waf 1.5
            # although convenient, it does not 1. allow to name the target file and 2. symlinks
            # TODO remove in waf 1.7
            self.bld.install_files(self.install_path, tsk.outputs)

    if getattr(self, 'source', None):
        tsk.inputs = self.to_nodes(self.source)
        # bypass the execution of process_source by setting the source to an empty list
        self.source = []

    if getattr(self, 'scan', None):
        cls.scan = self.scan

    if getattr(self, 'cwd', None):
        tsk.cwd = self.cwd

    # TODO remove on_results in waf 1.7
    if getattr(self, 'update_outputs', None) or getattr(
            self, 'on_results', None):
        Task.update_outputs(cls)

    if getattr(self, 'always', None):
        Task.always_run(cls)

    for x in ['after', 'before', 'ext_in', 'ext_out']:
        setattr(cls, x, getattr(self, x, []))
Exemplo n.º 2
0
def process_rule(self):
	if not getattr(self,'rule',None):
		return
	name=str(getattr(self,'name',None)or self.target or self.rule)
	cls=Task.task_factory(name,self.rule,getattr(self,'vars',[]),shell=getattr(self,'shell',True),color=getattr(self,'color','BLUE'))
	tsk=self.create_task(name)
	if getattr(self,'target',None):
		if isinstance(self.target,str):
			self.target=self.target.split()
		if not isinstance(self.target,list):
			self.target=[self.target]
		for x in self.target:
			if isinstance(x,str):
				tsk.outputs.append(self.path.find_or_declare(x))
			else:
				x.parent.mkdir()
				tsk.outputs.append(x)
		if getattr(self,'install_path',None):
			self.bld.install_files(self.install_path,tsk.outputs)
	if getattr(self,'source',None):
		tsk.inputs=self.to_nodes(self.source)
		self.source=[]
	if getattr(self,'scan',None):
		cls.scan=self.scan
	if getattr(self,'cwd',None):
		tsk.cwd=self.cwd
	if getattr(self,'update_outputs',None)or getattr(self,'on_results',None):
		Task.update_outputs(cls)
	if getattr(self,'always',None):
		Task.always_run(cls)
	for x in['after','before','ext_in','ext_out']:
		setattr(cls,x,getattr(self,x,[]))
Exemplo n.º 3
0
def process_rule(self):
	if not getattr(self,'rule',None):
		return
	name=str(getattr(self,'name',None)or self.target or getattr(self.rule,'__name__',self.rule))
	try:
		cache=self.bld.cache_rule_attr
	except AttributeError:
		cache=self.bld.cache_rule_attr={}
	cls=None
	if getattr(self,'cache_rule','True'):
		try:
			cls=cache[(name,self.rule)]
		except KeyError:
			pass
	if not cls:
		cls=Task.task_factory(name,self.rule,getattr(self,'vars',[]),shell=getattr(self,'shell',True),color=getattr(self,'color','BLUE'),scan=getattr(self,'scan',None))
		if getattr(self,'scan',None):
			cls.scan=self.scan
		elif getattr(self,'deps',None):
			def scan(self):
				nodes=[]
				for x in self.generator.to_list(getattr(self.generator,'deps',None)):
					node=self.generator.path.find_resource(x)
					if not node:
						self.generator.bld.fatal('Could not find %r (was it declared?)'%x)
					nodes.append(node)
				return[nodes,[]]
			cls.scan=scan
		if getattr(self,'update_outputs',None):
			Task.update_outputs(cls)
		if getattr(self,'always',None):
			Task.always_run(cls)
		for x in('after','before','ext_in','ext_out'):
			setattr(cls,x,getattr(self,x,[]))
		if getattr(self,'cache_rule','True'):
			cache[(name,self.rule)]=cls
		if getattr(self,'cls_str',None):
			setattr(cls,'__str__',self.cls_str)
		if getattr(self,'cls_keyword',None):
			setattr(cls,'keyword',self.cls_keyword)
	tsk=self.create_task(name)
	if getattr(self,'target',None):
		if isinstance(self.target,str):
			self.target=self.target.split()
		if not isinstance(self.target,list):
			self.target=[self.target]
		for x in self.target:
			if isinstance(x,str):
				tsk.outputs.append(self.path.find_or_declare(x))
			else:
				x.parent.mkdir()
				tsk.outputs.append(x)
		if getattr(self,'install_path',None):
			self.bld.install_files(self.install_path,tsk.outputs)
	if getattr(self,'source',None):
		tsk.inputs=self.to_nodes(self.source)
		self.source=[]
	if getattr(self,'cwd',None):
		tsk.cwd=self.cwd
Exemplo n.º 4
0
def process_rule(self):
    """
    Process the attribute ``rule``. When present, :py:meth:`waflib.TaskGen.process_source` is disabled::

        def build(bld):
            bld(rule='cp ${SRC} ${TGT}', source='wscript', target='bar.txt')
    """
    if not getattr(self, 'rule', None):
        return

    # create the task class
    name = str(getattr(self, 'name', None) or self.target or self.rule)
    cls = Task.task_factory(name, self.rule,
        getattr(self, 'vars', []),
        shell=getattr(self, 'shell', True), color=getattr(self, 'color', 'BLUE'))

    # now create one instance
    tsk = self.create_task(name)

    if getattr(self, 'target', None):
        if isinstance(self.target, str):
            self.target = self.target.split()
        if not isinstance(self.target, list):
            self.target = [self.target]
        for x in self.target:
            if isinstance(x, str):
                tsk.outputs.append(self.path.find_or_declare(x))
            else:
                x.parent.mkdir() # if a node was given, create the required folders
                tsk.outputs.append(x)
        if getattr(self, 'install_path', None):
            # from waf 1.5
            # although convenient, it does not 1. allow to name the target file and 2. symlinks
            # TODO remove in waf 1.7
            self.bld.install_files(self.install_path, tsk.outputs)

    if getattr(self, 'source', None):
        tsk.inputs = self.to_nodes(self.source)
        # bypass the execution of process_source by setting the source to an empty list
        self.source = []

    if getattr(self, 'scan', None):
        cls.scan = self.scan

    if getattr(self, 'cwd', None):
        tsk.cwd = self.cwd

    # TODO remove on_results in waf 1.7
    if getattr(self, 'update_outputs', None) or getattr(self, 'on_results', None):
        Task.update_outputs(cls)

    if getattr(self, 'always', None):
        Task.always_run(cls)

    for x in ['after', 'before', 'ext_in', 'ext_out']:
        setattr(cls, x, getattr(self, x, []))
def process_rule(self):
	if not getattr(self,'rule',None):
		return
	name=str(getattr(self,'name',None)or self.target or getattr(self.rule,'__name__',self.rule))
	try:
		cache=self.bld.cache_rule_attr
	except AttributeError:
		cache=self.bld.cache_rule_attr={}
	cls=None
	if getattr(self,'cache_rule','True'):
		try:
			cls=cache[(name,self.rule)]
		except KeyError:
			pass
	if not cls:
		cls=Task.task_factory(name,self.rule,getattr(self,'vars',[]),shell=getattr(self,'shell',True),color=getattr(self,'color','BLUE'),scan=getattr(self,'scan',None))
		if getattr(self,'scan',None):
			cls.scan=self.scan
		elif getattr(self,'deps',None):
			def scan(self):
				nodes=[]
				for x in self.generator.to_list(getattr(self.generator,'deps',None)):
					node=self.generator.path.find_resource(x)
					if not node:
						self.generator.bld.fatal('Could not find %r (was it declared?)'%x)
					nodes.append(node)
				return[nodes,[]]
			cls.scan=scan
		if getattr(self,'update_outputs',None):
			Task.update_outputs(cls)
		if getattr(self,'always',None):
			Task.always_run(cls)
		for x in('after','before','ext_in','ext_out'):
			setattr(cls,x,getattr(self,x,[]))
		if getattr(self,'cache_rule','True'):
			cache[(name,self.rule)]=cls
	tsk=self.create_task(name)
	if getattr(self,'target',None):
		if isinstance(self.target,str):
			self.target=self.target.split()
		if not isinstance(self.target,list):
			self.target=[self.target]
		for x in self.target:
			if isinstance(x,str):
				tsk.outputs.append(self.path.find_or_declare(x))
			else:
				x.parent.mkdir()
				tsk.outputs.append(x)
		if getattr(self,'install_path',None):
			self.bld.install_files(self.install_path,tsk.outputs)
	if getattr(self,'source',None):
		tsk.inputs=self.to_nodes(self.source)
		self.source=[]
	if getattr(self,'cwd',None):
		tsk.cwd=self.cwd
Exemplo n.º 6
0
def process_execrule(self):

    if not getattr(self, 'execrule', None):
        return
    self.meths.remove('process_source')
    name = str(getattr(self, 'name', None) or self.target or self.execrule)
    cls = Task.task_factory(name,
                            self.execrule,
                            getattr(self, 'vars', []),
                            shell=getattr(self, 'shell', True),
                            color=getattr(self, 'color', 'BLUE'))
    tsk = self.create_task(name)
    if getattr(self, 'target', None):
        if isinstance(self.target, str):
            self.target = self.target.split()
        if not isinstance(self.target, list):
            self.target = [self.target]
        for x in self.target:
            if isinstance(x, str):
                tsk.outputs.append(self.path.find_or_declare(x))
            else:
                x.parent.mkdir()
                tsk.outputs.append(x)
        if getattr(self, 'install_path', None):
            self.bld.install_files(self.install_path,
                                   tsk.outputs,
                                   chmod=Utils.O755)
    if getattr(self, 'source', None):
        tsk.inputs = self.to_nodes(self.source)
        self.source = []
    if getattr(self, 'scan', None):
        cls.scan = self.scan
    if getattr(self, 'cwd', None):
        tsk.cwd = self.cwd
    if getattr(self, 'update_outputs', None) or getattr(
            self, 'on_results', None):
        Task.update_outputs(cls)
    if getattr(self, 'always', None):
        Task.always_run(cls)
    for x in ['after', 'before', 'ext_in', 'ext_out']:
        setattr(cls, x, getattr(self, x, []))
Exemplo n.º 7
0
def process_rule(self):
    if not getattr(self, "rule", None):
        return
    name = str(getattr(self, "name", None) or self.target or self.rule)
    cls = Task.task_factory(
        name,
        self.rule,
        getattr(self, "vars", []),
        shell=getattr(self, "shell", True),
        color=getattr(self, "color", "BLUE"),
    )
    tsk = self.create_task(name)
    if getattr(self, "target", None):
        if isinstance(self.target, str):
            self.target = self.target.split()
        if not isinstance(self.target, list):
            self.target = [self.target]
        for x in self.target:
            if isinstance(x, str):
                tsk.outputs.append(self.path.find_or_declare(x))
            else:
                x.parent.mkdir()
                tsk.outputs.append(x)
        if getattr(self, "install_path", None):
            self.bld.install_files(self.install_path, tsk.outputs)
    if getattr(self, "source", None):
        tsk.inputs = self.to_nodes(self.source)
        self.source = []
    if getattr(self, "scan", None):
        cls.scan = self.scan
    if getattr(self, "cwd", None):
        tsk.cwd = self.cwd
    if getattr(self, "update_outputs", None) or getattr(self, "on_results", None):
        Task.update_outputs(cls)
    if getattr(self, "always", None):
        Task.always_run(cls)
    for x in ["after", "before", "ext_in", "ext_out"]:
        setattr(cls, x, getattr(self, x, []))
Exemplo n.º 8
0
def process_rule(self):
	"""
	Process the attribute ``rule``. When present, :py:meth:`waflib.TaskGen.process_source` is disabled::

		def build(bld):
			bld(rule='cp ${SRC} ${TGT}', source='wscript', target='bar.txt')
	"""
	if not getattr(self, 'rule', None):
		return

	# create the task class
	name = str(getattr(self, 'name', None) or self.target or self.rule)

	# or we can put the class in a cache for performance reasons
	try:
		cache = self.bld.cache_rule_attr
	except AttributeError:
		cache = self.bld.cache_rule_attr = {}

	cls = None
	if getattr(self, 'cache_rule', 'True'):
		try:
			cls = cache[(name, self.rule)]
		except KeyError:
			pass
	if not cls:
		cls = Task.task_factory(name, self.rule,
			getattr(self, 'vars', []),
			shell=getattr(self, 'shell', True), color=getattr(self, 'color', 'BLUE'),
			scan = getattr(self, 'scan', None))
		if getattr(self, 'scan', None):
			cls.scan = self.scan
		elif getattr(self, 'deps', None):
			def scan(self):
				nodes = []
				for x in self.generator.to_list(getattr(self.generator, 'deps', None)):
					node = self.generator.path.find_resource(x)
					if not node:
						self.generator.bld.fatal('Could not find %r (was it declared?)' % x)
					nodes.append(node)
				return [nodes, []]
			cls.scan = scan

		if getattr(self, 'update_outputs', None):
			Task.update_outputs(cls)

		if getattr(self, 'always', None):
			Task.always_run(cls)

		for x in ['after', 'before', 'ext_in', 'ext_out']:
			setattr(cls, x, getattr(self, x, []))

		if getattr(self, 'cache_rule', 'True'):
			cache[(name, self.rule)] = cls

	# now create one instance
	tsk = self.create_task(name)

	if getattr(self, 'target', None):
		if isinstance(self.target, str):
			self.target = self.target.split()
		if not isinstance(self.target, list):
			self.target = [self.target]
		for x in self.target:
			if isinstance(x, str):
				tsk.outputs.append(self.path.find_or_declare(x))
			else:
				x.parent.mkdir() # if a node was given, create the required folders
				tsk.outputs.append(x)
		if getattr(self, 'install_path', None):
			# from waf 1.5
			# although convenient, it does not 1. allow to name the target file and 2. symlinks
			# TODO remove in waf 1.7
			self.bld.install_files(self.install_path, tsk.outputs)

	if getattr(self, 'source', None):
		tsk.inputs = self.to_nodes(self.source)
		# bypass the execution of process_source by setting the source to an empty list
		self.source = []

	if getattr(self, 'cwd', None):
		tsk.cwd = self.cwd
Exemplo n.º 9
0
                    cmd,
                    cwd=self.env.GBENCHMARK_BUILD,
                    quiet=Context.BOTH,
                )
            return 0
        except WafError as e:
            print(e)
            if hasattr(e, 'stderr'):
                print('')
                print(e.stderr)
            return 1

    def __str__(self):
        return 'Google Benchmark'

gbenchmark_build = Task.always_run(Task.update_outputs(gbenchmark_build))

build_task = None

@feature('gbenchmark')
@before_method('process_use')
def append_gbenchmark_use(self):
    self.use = self.to_list(getattr(self, 'use', []))
    if 'GBENCHMARK' not in self.use:
        self.use.append('GBENCHMARK')

@feature('gbenchmark')
@after_method('process_source')
def wait_for_gbenchmark_build(self):
    global build_task
Exemplo n.º 10
0
                    cwd=self.env.GBENCHMARK_BUILD,
                    quiet=Context.BOTH,
                )
            return 0
        except WafError as e:
            print(e)
            if hasattr(e, 'stderr'):
                print('')
                print(e.stderr)
            return 1

    def __str__(self):
        return 'Google Benchmark'


gbenchmark_build = Task.always_run(Task.update_outputs(gbenchmark_build))

build_task = None


@feature('gbenchmark')
@before_method('process_use')
def append_gbenchmark_use(self):
    self.use = self.to_list(getattr(self, 'use', []))
    if 'GBENCHMARK' not in self.use:
        self.use.append('GBENCHMARK')


@feature('gbenchmark')
@after_method('process_source')
def wait_for_gbenchmark_build(self):
Exemplo n.º 11
0
    def __str__(self):
        config_name = self.generator.config_taskgen.name
        target = self.generator.cmake_target
        return '%s %s' % (config_name, target)

    def keyword(self):
        return 'CMake Build'

# allow tasks to depend on possible headers or other resources if the user
# declares outputs for the cmake build
cmake_build_task = Task.update_outputs(cmake_build_task)

# the cmake-generated build system is responsible of managing its own
# dependencies
cmake_build_task = Task.always_run(cmake_build_task)

@feature('cmake_configure')
def process_cmake_configure(self):
    if not hasattr(self, 'name'):
        self.bld.fatal('cmake_configure: taskgen is missing name')
    if not hasattr(self, 'cmake_src'):
        self.bld.fatal('cmake_configure: taskgen is missing cmake_src')

    if not isinstance(self.cmake_src, Node.Node):
        self.cmake_src = self.bld.path.find_dir(self.cmake_src)

    if not hasattr(self, 'cmake_bld'):
        self.cmake_bld = self.cmake_src.get_bld()
    elif not isinstance(self.cmake_bld, Node.Node):
        self.cmake_bld = self.bld.bldnode.make_node(self.cmake_bld)
Exemplo n.º 12
0
cmake_build_task = Task.update_outputs(cmake_build_task)

cmake_build_task.original_post_run = cmake_build_task.post_run
def _cmake_build_task_post_run(self):
    self.output_patterns = Utils.to_list(self.output_patterns)
    if not self.output_patterns:
        return self.original_post_run()
    bldnode = self.cmake.bldnode
    for node in bldnode.ant_glob(self.output_patterns, remove=False):
        self.set_outputs(node)
    return self.original_post_run()
cmake_build_task.post_run = _cmake_build_task_post_run

# the cmake-generated build system is responsible of managing its own
# dependencies
cmake_build_task = Task.always_run(cmake_build_task)

class CMakeConfig(object):
    '''
    CMake configuration. This object shouldn't be instantiated directly. Use
    bld.cmake().
    '''
    def __init__(self, bld, name, srcnode, bldnode, cmake_vars):
        self.bld = bld
        self.name = name
        self.srcnode = srcnode
        self.bldnode = bldnode
        self.vars = cmake_vars

        self._config_task = None
        self.last_build_task = None
Exemplo n.º 13
0
def process_rule(self):
    """
	Process the attribute ``rule``. When present, :py:meth:`waflib.TaskGen.process_source` is disabled::

		def build(bld):
			bld(rule='cp ${SRC} ${TGT}', source='wscript', target='bar.txt')
	"""
    if not getattr(self, "rule", None):
        return

        # create the task class
    name = str(getattr(self, "name", None) or self.target or getattr(self.rule, "__name__", self.rule))

    # or we can put the class in a cache for performance reasons
    try:
        cache = self.bld.cache_rule_attr
    except AttributeError:
        cache = self.bld.cache_rule_attr = {}

    cls = None
    if getattr(self, "cache_rule", "True"):
        try:
            cls = cache[(name, self.rule)]
        except KeyError:
            pass
    if not cls:
        cls = Task.task_factory(
            name,
            self.rule,
            getattr(self, "vars", []),
            shell=getattr(self, "shell", True),
            color=getattr(self, "color", "BLUE"),
            scan=getattr(self, "scan", None),
        )
        if getattr(self, "scan", None):
            cls.scan = self.scan
        elif getattr(self, "deps", None):

            def scan(self):
                nodes = []
                for x in self.generator.to_list(getattr(self.generator, "deps", None)):
                    node = self.generator.path.find_resource(x)
                    if not node:
                        self.generator.bld.fatal("Could not find %r (was it declared?)" % x)
                    nodes.append(node)
                return [nodes, []]

            cls.scan = scan

        if getattr(self, "update_outputs", None):
            Task.update_outputs(cls)

        if getattr(self, "always", None):
            Task.always_run(cls)

        for x in ("after", "before", "ext_in", "ext_out"):
            setattr(cls, x, getattr(self, x, []))

        if getattr(self, "cache_rule", "True"):
            cache[(name, self.rule)] = cls

            # now create one instance
    tsk = self.create_task(name)

    if getattr(self, "target", None):
        if isinstance(self.target, str):
            self.target = self.target.split()
        if not isinstance(self.target, list):
            self.target = [self.target]
        for x in self.target:
            if isinstance(x, str):
                tsk.outputs.append(self.path.find_or_declare(x))
            else:
                x.parent.mkdir()  # if a node was given, create the required folders
                tsk.outputs.append(x)
        if getattr(self, "install_path", None):
            self.bld.install_files(self.install_path, tsk.outputs)

    if getattr(self, "source", None):
        tsk.inputs = self.to_nodes(self.source)
        # bypass the execution of process_source by setting the source to an empty list
        self.source = []

    if getattr(self, "cwd", None):
        tsk.cwd = self.cwd
Exemplo n.º 14
0
def process_rule(self):
    if not getattr(self, "rule", None):
        return
    name = str(getattr(self, "name", None) or self.target or getattr(self.rule, "__name__", self.rule))
    try:
        cache = self.bld.cache_rule_attr
    except AttributeError:
        cache = self.bld.cache_rule_attr = {}
    cls = None
    if getattr(self, "cache_rule", "True"):
        try:
            cls = cache[(name, self.rule)]
        except KeyError:
            pass
    if not cls:
        cls = Task.task_factory(
            name,
            self.rule,
            getattr(self, "vars", []),
            shell=getattr(self, "shell", True),
            color=getattr(self, "color", "BLUE"),
            scan=getattr(self, "scan", None),
        )
        if getattr(self, "scan", None):
            cls.scan = self.scan
        elif getattr(self, "deps", None):

            def scan(self):
                nodes = []
                for x in self.generator.to_list(getattr(self.generator, "deps", None)):
                    node = self.generator.path.find_resource(x)
                    if not node:
                        self.generator.bld.fatal("Could not find %r (was it declared?)" % x)
                    nodes.append(node)
                return [nodes, []]

            cls.scan = scan
        if getattr(self, "update_outputs", None):
            Task.update_outputs(cls)
        if getattr(self, "always", None):
            Task.always_run(cls)
        for x in ("after", "before", "ext_in", "ext_out"):
            setattr(cls, x, getattr(self, x, []))
        if getattr(self, "cache_rule", "True"):
            cache[(name, self.rule)] = cls
    tsk = self.create_task(name)
    if getattr(self, "target", None):
        if isinstance(self.target, str):
            self.target = self.target.split()
        if not isinstance(self.target, list):
            self.target = [self.target]
        for x in self.target:
            if isinstance(x, str):
                tsk.outputs.append(self.path.find_or_declare(x))
            else:
                x.parent.mkdir()
                tsk.outputs.append(x)
        if getattr(self, "install_path", None):
            self.bld.install_files(self.install_path, tsk.outputs)
    if getattr(self, "source", None):
        tsk.inputs = self.to_nodes(self.source)
        self.source = []
    if getattr(self, "cwd", None):
        tsk.cwd = self.cwd