def callback( *, name: Optional[str] = None, deps: Sequence[str] = (), impl: Callable = lambda _: None, out: Union[str, Sequence[str]] = (), do_not_symlink: bool = False, do_not_cache: bool = False, ): build_root = make_callback.build_root if build_root is None: raise BuildException( "Rules files can only define functions, not invoke callback()" ) if isinstance(out, str): out = [out] def wrapped_impl(ctx): ctx.add_deps(deps) return impl(ctx) rule = Rule( name=name, location=build_root, impl=wrapped_impl, outputs=[normalize_path(build_root, output) for output in out], do_not_symlink=do_not_symlink, do_not_cache=do_not_cache, ) for output in rule.outputs: add_target_rule(output, rule) if name is not None: add_target_rule(":" + name, rule) return f":{name}"
def callback( *, name: Optional[str] = None, deps: Sequence[str] = (), impl: Callable, out: Union[str, Sequence[str]] = (), do_not_symlink: bool = False, ): build_root = make_callback.build_root if build_root is None: raise BuildException( "Rules files can only define functions, not invoke callback()") if isinstance(out, str): out = [out] rule = Rule( name=name, location=build_root, deps=[ dep if dep.startswith(":") else normalize_path( repo_root, build_root, dep) for dep in deps ], impl=impl, outputs=[ normalize_path(repo_root, build_root, output) for output in out ], do_not_symlink=do_not_symlink, ) for output in rule.outputs: add_target_rule(output, rule) if name is not None: add_target_rule(":" + name, rule) return f":{name}"