Add jsonmodify tool
This tool is used to modify apex_manifest.json when building apex
module.
Here's the usage:
usage: jsonmodify [-h] [-o output] [-v path value] [-s path value]
[-r path] [-a path [value ...]]
[input]
positional arguments:
input JSON file
optional arguments:
-h, --help show this help message and exit
-o output, --out output
write result to a file. If omitted, print to stdout
-v path value, --value path value
set value of the key specified by path. If path
doesn't exist, creates new one.
-s path value, --replace path value
replace value of the key specified by path. If path
doesn't exist, no op.
-r path, --remove path
remove the key specified by path. If path doesn't
exist, no op.
-a path [value ...], --append_list path [value ...]
append values to the list specified by path. If path
doesn't exist, creates new list for it.
Bug: 138695532
Test: m jsonmodify
Test: echo {} | jsonmodify -v name hello -a list.nested a b c
{
"name": "hello",
"list": {
"nested": [
"a",
"b",
"c"
]
}
}
Change-Id: I2cd043c614b3ad2306a0c27ccee302633c6d2525
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 31f5922..8c59cbc 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -69,3 +69,19 @@
},
test_suites: ["general-tests"],
}
+
+python_binary_host {
+ name: "jsonmodify",
+ main: "jsonmodify.py",
+ srcs: [
+ "jsonmodify.py",
+ ],
+ version: {
+ py2: {
+ enabled: true,
+ },
+ py3: {
+ enabled: false,
+ },
+ }
+}