def _get_name(module): # Always use the frame of the current module, though. if craftr.module() != module: raise RuntimeError('target name deduction only available when ' 'used from the currently executed module') return magic.get_assigned_name( magic.get_module_frame(module, allow_local=False))
def __init__(self, inputs, frameworks, kwargs, meta=None, module=None, name=None, stacklevel=1): if meta is None: meta = {} if not isinstance(meta, dict): raise TypeError('meta must be a dictionary') self.meta = meta self.caller = magic.get_caller(stacklevel + 1) frameworks = list(frameworks) self.inputs = expand_inputs(inputs, frameworks) self.frameworks = expand_frameworks(frameworks) self.kwargs = kwargs self.options = FrameworkJoin(Framework(self.caller, kwargs), *self.frameworks) self.module = module or craftr.module() self.name = name self.target_attrs = {} if not self.name: try: self.name = Target._get_name(self.module) except ValueError: index = 0 while True: name = '{0}_{1:0>4}'.format(self.caller, index) if self.module.project_name + '.' + name not in session.targets: break index += 1 self.name = name
def __init__(self, inputs, frameworks, kwargs, meta=None, module=None, name=None, stacklevel=1): if meta is None: meta = {} if not isinstance(meta, dict): raise TypeError('meta must be a dictionary') self.meta = meta self.caller = magic.get_caller(stacklevel + 1) frameworks = list(frameworks) self.inputs = expand_inputs(inputs, frameworks) self.frameworks = expand_frameworks(frameworks) self.kwargs = kwargs self.options = FrameworkJoin(Framework(self.caller, kwargs), *self.frameworks) self.module = module or craftr.module() self.name = name self.target_attrs = {} if not self.name: try: self.name = Target._get_name(self.module) except ValueError: index = 0 while True: name = '{0}_{1:0>4}'.format(self.caller, index) if self.module.project_name + '.' + name not in session.targets: break index += 1 self.name = name
def __init__(self, command, inputs=None, outputs=None, implicit_deps=None, order_only_deps=None, requires=None, foreach=False, description=None, pool=None, var=None, deps=None, depfile=None, msvc_deps_prefix=None, explicit=False, frameworks=None, meta=None, module=None, name=None): if callable(command): # This target will be a task, alias RTS target. if not name: name = command.__name__ if not description: description = command.__doc__ elif isinstance(command, str): command = shell.split(command) else: command = _check_list_of_str('command', command) if not command: raise ValueError('command can not be empty') if not module and craftr.module: module = craftr.module() if not name: name = Target._get_name(module) if requires is not None: if isinstance(requires, Target): requires = [requires] else: requires = list(requires) for obj in requires: if not isinstance(obj, Target): raise TypeError( 'requires must contain only Target objects') def _expand(x, name): if x is None: return None if isinstance(x, str): x = [x] x = expand_inputs(x) x = _check_list_of_str(name, x) return x inputs = _expand(inputs, 'inputs') outputs = _expand(outputs, 'outputs') implicit_deps = _expand(implicit_deps, 'implicit_deps') order_only_deps = _expand(order_only_deps, 'order_only_deps') if foreach and len(inputs) != len(outputs): raise ValueError( 'len(inputs) must match len(outputs) in foreach Target') if meta is None: meta = {} if not isinstance(meta, dict): raise TypeError('meta must be a dictionary') self.module = module self.name = name self.rts_func = None if callable(command): self.rts_func = command command = [RTS_COMMAND, self.fullname] self.command = command self.inputs = inputs self.outputs = outputs self.implicit_deps = implicit_deps or [] self.order_only_deps = order_only_deps or [] self.requires = requires or [] self.foreach = foreach self.pool = pool self.description = description self.deps = deps self.depfile = depfile self.msvc_deps_prefix = msvc_deps_prefix self.frameworks = expand_frameworks(frameworks or []) self.explicit = explicit self.meta = meta self.graph = None if module: module.__session__.register_target(self)
def __init__(self, module=None): self.module = module or craftr.module()
def __init__(self, module=None): self.module = module or craftr.module()
def _get_name(module): # Always use the frame of the current module, though. if craftr.module() != module: raise RuntimeError('target name deduction only available when ' 'used from the currently executed module') return magic.get_assigned_name(magic.get_module_frame(module, allow_local=False))
def __init__(self, command, inputs=None, outputs=None, implicit_deps=None, order_only_deps=None, foreach=False, description=None, pool=None, var=None, deps=None, depfile=None, msvc_deps_prefix=None, explicit=False, frameworks=None, meta=None, module=None, name=None): if not module and craftr.module: module = craftr.module() if not name: name = Target._get_name(module) if isinstance(command, str): command = shell.split(command) else: command = _check_list_of_str('command', command) if not command: raise ValueError('command can not be empty') if inputs is not None: if isinstance(inputs, str): inputs = [inputs] inputs = expand_inputs(inputs) inputs = _check_list_of_str('inputs', inputs) if outputs is not None: if isinstance(outputs, str): outputs = [outputs] elif callable(outputs): outputs = outputs(inputs) outputs = _check_list_of_str('outputs', outputs) if foreach and len(inputs) != len(outputs): raise ValueError('len(inputs) must match len(outputs) in foreach Target') if implicit_deps is not None: implicit_deps = _check_list_of_str('implicit_deps', implicit_deps) if order_only_deps is not None: order_only_deps = _check_list_of_str('order_only_deps', order_only_deps) if meta is None: meta = {} if not isinstance(meta, dict): raise TypeError('meta must be a dictionary') self.module = module self.name = name self.command = command self.inputs = inputs self.outputs = outputs self.implicit_deps = implicit_deps or [] self.order_only_deps = order_only_deps or [] self.foreach = foreach self.pool = pool self.description = description self.deps = deps self.depfile = depfile self.msvc_deps_prefix = msvc_deps_prefix self.frameworks = expand_frameworks(frameworks or []) self.explicit = explicit self.meta = meta if module: targets = module.__session__.targets if self.fullname in targets: raise ValueError('target {0!r} already exists'.format(self.fullname)) targets[self.fullname] = self
def __init__(self, command, inputs=None, outputs=None, implicit_deps=None, order_only_deps=None, foreach=False, description=None, pool=None, var=None, deps=None, depfile=None, msvc_deps_prefix=None, explicit=False, frameworks=None, meta=None, module=None, name=None): if not module and craftr.module: module = craftr.module() if not name: name = Target._get_name(module) if isinstance(command, str): command = shell.split(command) else: command = _check_list_of_str('command', command) if not command: raise ValueError('command can not be empty') if inputs is not None: if isinstance(inputs, str): inputs = [inputs] inputs = expand_inputs(inputs) inputs = _check_list_of_str('inputs', inputs) if outputs is not None: if isinstance(outputs, str): outputs = [outputs] elif callable(outputs): outputs = outputs(inputs) outputs = _check_list_of_str('outputs', outputs) if foreach and len(inputs) != len(outputs): raise ValueError( 'len(inputs) must match len(outputs) in foreach Target') if implicit_deps is not None: implicit_deps = _check_list_of_str('implicit_deps', implicit_deps) if order_only_deps is not None: order_only_deps = _check_list_of_str('order_only_deps', order_only_deps) if meta is None: meta = {} if not isinstance(meta, dict): raise TypeError('meta must be a dictionary') self.module = module self.name = name self.command = command self.inputs = inputs self.outputs = outputs self.implicit_deps = implicit_deps or [] self.order_only_deps = order_only_deps or [] self.foreach = foreach self.pool = pool self.description = description self.deps = deps self.depfile = depfile self.msvc_deps_prefix = msvc_deps_prefix self.frameworks = expand_frameworks(frameworks or []) self.explicit = explicit self.meta = meta if module: targets = module.__session__.targets if self.fullname in targets: raise ValueError('target {0!r} already exists'.format( self.fullname)) targets[self.fullname] = self
def __init__(self, command, inputs=None, outputs=None, implicit_deps=None, order_only_deps=None, requires=None, foreach=False, description=None, pool=None, var=None, deps=None, depfile=None, msvc_deps_prefix=None, explicit=False, frameworks=None, meta=None, module=None, name=None): if callable(command): # This target will be a task, alias RTS target. if not name: name = command.__name__ if not description: description = command.__doc__ elif isinstance(command, str): command = shell.split(command) else: command = _check_list_of_str('command', command) if not command: raise ValueError('command can not be empty') if not module and craftr.module: module = craftr.module() if not name: name = Target._get_name(module) if requires is not None: if isinstance(requires, Target): requires = [requires] else: requires = list(requires) for obj in requires: if not isinstance(obj, Target): raise TypeError('requires must contain only Target objects') def _expand(x, name): if x is None: return None if isinstance(x, str): x = [x] x = expand_inputs(x) x = _check_list_of_str(name, x) return x inputs = _expand(inputs, 'inputs') outputs = _expand(outputs, 'outputs') implicit_deps = _expand(implicit_deps, 'implicit_deps') order_only_deps = _expand(order_only_deps, 'order_only_deps') if foreach and len(inputs) != len(outputs): raise ValueError('len(inputs) must match len(outputs) in foreach Target') if meta is None: meta = {} if not isinstance(meta, dict): raise TypeError('meta must be a dictionary') self.module = module self.name = name self.rts_func = None if callable(command): self.rts_func = command command = [RTS_COMMAND, self.fullname] self.command = command self.inputs = inputs self.outputs = outputs self.implicit_deps = implicit_deps or [] self.order_only_deps = order_only_deps or [] self.requires = requires or [] self.foreach = foreach self.pool = pool self.description = description self.deps = deps self.depfile = depfile self.msvc_deps_prefix = msvc_deps_prefix self.frameworks = expand_frameworks(frameworks or []) self.explicit = explicit self.meta = meta self.graph = None if module: module.__session__.register_target(self)