Before this cl, blueprint expressions were evaluated as they were
parsed. We want to add a feature to select statements where we can
bind the value of soome value from soong into a blueprint variable,
that then can be used like a regular variable in the .bp file. This
means that select statements need to hold whole unevalated expression
trees, and have the ability to evaluate them later on when the value
of the bound variable is known.
This cl doesn't implement the new select syntax, but it does split
blueprint's parsing and evaluating into two separate stages. We also
store expressions in selects and evaluate them when the select is
resolved.
I didn't do extensive performance evaluation, but a simple comparison
of the time of `touch Android.bp && m nothing` before/after this cl
showed a 1 second speedup. (That was probably just noise)
Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I12f373719991afeb4aec76517153f32229d97ff2
This is treated similar to other set commands, but add a single boolean
value to the property.
Test: bpmodify_test.go
Test: bpmodify -d -m android.hardware.drm -property frozen -set-bool
false Android.bp
Test: Same command above with "true" "misspelled" "1" for -set-bool
Bug: 231903487
Change-Id: I598da41a38409877af410f9715838d86b0873173
Test: go run bpmodify.go -w -m=libcore-memory-metrics-tests -property=something,static_libs,deps,required,test_suites -replace-property=ahat:ahat_lib,general-tests:something -s ~/aosp-master-with-phones/libcore/metrictests/memory/host/Android.bp
go test -v
Change-Id: I005b6dd675beb205f544e89c729fe9191e6470c2
bpmodify can know move the contents of a property into another
property using moveProperty. After moving the contents, the original
property is deleted.
Bug: 226636335
Change-Id: Id68d11d59f00909b4c93aa78666d14f433f236fb
Test: manually ran on several Android.bp files in bug 226636335
Multiple bpmodify process on the same Android.bp can run in parallel in
the case of aidl-freeze-api.
So, add a file lock for in-place editing case(-w)
Bug: 229413853
Test: run bpmodify in parallel and check result
Change-Id: I5368b0304b59f34fff60025120b38cc5f615ac40
`r` option removes only item(s) in a list, so add `remove-property`
option to remove a property itself.
Bug: 146436251
Test: unittest
Change-Id: I0c838d31e72358f094cfb5fa9468dce07018e061
-a works with only string values. When we need to add numbers, booleans,
or even structs, -add-literal can be used now.
bpmodify -m foo -property list-of-ints -add-literal 123
bpmodify -m foo -property list-of-structs \
-add-literal "{key: \"value\"}"
Bug: 146436251
Test: go test ./bpmodify
Change-Id: I91d23d7bf89491643aa595f5ebccd9410a9cbb09
Make TestProcessModule use subtests, give the tests names, and
use named fields in the testcase struct.
Test: bpmodify_test.go
Change-Id: I85345bd419e4c3ccf0050b7efae0479dd03d8bea
bpmodify sorts touched list respecting numbers embedded in strings. For
example, "foo-2" comes before "foo-10".
Test: bpmodify_test.go
Change-Id: If2fe9bc871a463a47dd3c0b52982b34c9fde05f0
Co-authored-by: Jooyung Han <jooyung@google.com>
Add an option "-property", which is an alias to the option "-parameter".
For example if Android.bp contains:
cc_foo {
name: "foo",
}
Then `bpmodify -m foo -a bar -property baz.buz Android.bp` outputs:
cc_foo {
name: "foo",
baz: {
buz: ["bar"],
},
}
Bug: 149715904
Test: go test -v
Change-Id: I9660cff1b5239ccf5aa9ef1a41835b8ac6cd4b9f
The `defer func() { os.Exit() }()` in main() method shadows panic().
Make the exit handler recover() from panic(), log the panic(), and then
gracefully exit.
Test: m bpmodify
Change-Id: Icc89f8fce0b6096489baa0ba0f08c21d1ef623bc
golang `flag` package's default FlagSet `flag.CommandLine` calls
`flag.Usage` and `os.Exit(2)` on error to print the usage string.
Set `flag.Usage` to our custom usage function.
Test: m bpmodify; bpmodify -h; bpmodify --help
Change-Id: Ida107b0dbb07c291c3d7ea90eda9147d04a7cd51
before, adding to a list which had no entries would do nothing (and not
throw any errors). Now it will create the list and add a single element
as expected.
Change-Id: I8c48a42303f7d9b3741868ad86097e2071ec434a
It wasn't adding anything useful, and it resulted in Name.Name to get to
the identifier. Replace Name Ident with Name string; NamePos
scanner.Position.
Change-Id: Idf9b18b31dd563a18f27c602c2d14298955af371
Refactor the blueprint parser Value object, which contained a Type enum
and members to hold every possible type, into an interface (now called
Expression). Rename the existing Expression object that represented a binary
operator Operator.
Also adds and fixes some new printer test cases with mulitline expressions.
Change-Id: Icf4a20f92c8c2a27f18df8ca515a9d7f282ff133
Make integrating with go tools easier by putting the blueprint package
files in the top level directory of the git project instead of in a
subdirectory called blueprint.
Change-Id: I35c144c5fe7ddf34e478d0c47c50b2f6c92c2a03