diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-03-04 15:47:26 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-03-04 20:07:46 +0100 |
commit | c89bfcbb2b991a57d0f829e49d91f0f7c00531b7 (patch) | |
tree | 4a891177caffea5e839eae295a7af567128d3f27 /rules/patch | |
parent | 7ed8ff309907dd336cdca8a3e38eecfbe1f3b00f (diff) | |
download | justbuild-c89bfcbb2b991a57d0f829e49d91f0f7c00531b7.tar.gz |
Add rule ["patch", "file"]
... to patch a single file, logically in place.
Diffstat (limited to 'rules/patch')
-rw-r--r-- | rules/patch/RULES | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/rules/patch/RULES b/rules/patch/RULES new file mode 100644 index 00000000..87bf5750 --- /dev/null +++ b/rules/patch/RULES @@ -0,0 +1,68 @@ +{ "file": + { "doc": ["Replace a file, logically in pace, by a patched version"] + , "target_fields": ["src", "patch"] + , "config_vars": ["PATCH"] + , "field_doc": + { "src": + ["The single source file to patch, typically an explict file reference."] + , "patch": ["The patch to apply."] + } + , "imports": + { "stage_field": ["./", "..", "stage_singleton_field"] + , "stage_artifact": ["./", "..", "stage_artifact_to_singleton_field"] + } + , "expression": + { "type": "let*" + , "bindings": + [ [ "orig" + , { "type": "let*" + , "bindings": [["fieldname", "src"], ["location", "orig"]] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} + } + ] + , [ "patch" + , { "type": "let*" + , "bindings": [["fieldname", "patch"], ["location", "patch"]] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} + } + ] + , [ "inputs" + , { "type": "map_union" + , "$1": + [{"type": "var", "name": "orig"}, {"type": "var", "name": "patch"}] + } + ] + , [ "patched" + , { "type": "ACTION" + , "inputs": {"type": "var", "name": "inputs"} + , "outs": ["patched"] + , "cmd": + [ {"type": "var", "name": "PATCH", "default": "patch"} + , "-s" + , "--read-only=ignore" + , "--follow-symlinks" + , "-o" + , "patched" + , "orig" + , "patch" + ] + } + ] + , [ "result" + , { "type": "let*" + , "bindings": + [ ["artifact", {"type": "var", "name": "patched"}] + , ["fieldname", "src"] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_artifact"} + } + ] + ] + , "body": + { "type": "RESULT" + , "artifacts": {"type": "var", "name": "result"} + , "runfiles": {"type": "var", "name": "result"} + } + } + } +} |