Sometimes you just need to:
template("patch_file") {
assert(defined(invoker.patch_path),
"patch_path must be defined for $target_name")
assert(defined(invoker.source_file),
"source_file must be defined for $target_name")
action(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
script = "patch.py"
sources = [
invoker.patch_path,
invoker.source_file,
]
outputs = [ "$target_gen_dir/" + invoker.source_file ]
args = rebase_path(sources, root_build_dir) +
rebase_path(outputs, root_build_dir)
}
}
patch_file("patch_SomeFile_m") {
patch_path = "patches/path_to_SomeFile.m.diff"
source_file = "src/path/to/SomeFile.m"
}
And then you need to:
sources -= [ "src/path/to/SomeFile.m" ]
sources += get_target_outputs(":patch_SomeFile_m")
deps += [ ":patch_SomeFile_m" ]
For fun and profit.