Commit graph

26 commits

Author SHA1 Message Date
Cole Faust
1e62c68bfe
Separate blueprint parsing and evaluating
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
2024-10-24 19:18:21 +02:00
Devin Moore
753a555fdd bpmodify: Add a set-bool flag to set single boolean values
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
2022-10-28 18:46:51 +00:00
MarkDacek
c3eb9199b2 Add LSC tool meant for remediating module/file collisions.
See b/198619163
Test: ./rename_module_and_deps.py art/tools/ahat/ahat

Change-Id: Ie2274701128befb6dd574ad674d1b494d77edd8c
2022-08-29 16:07:29 +00:00
MarkDacek
2b70006b32 Edit bpmodify to check Android. files and use '=' as the separator for
replacements.
Test: go test -v and running bpmodify with the LSC tool

Change-Id: I63741cce66179962e454f9a002bf358bf054c267
2022-08-17 18:54:16 +00:00
Alix
30751b313c added tests for move-property in bpmodify
Test: m nothing
Signed-off-by: Alix <agespino@google.com>
Change-Id: Ib8f1e88f7587476845e64a9d9ff96afb2b8d2df8
2022-08-11 02:44:02 +00:00
MarkDacek
c93385a75a Add functionality for replacing string values.
Test: go test -v

Change-Id: I8e59bd1dc319d06c5645c6f288df46702901573b
2022-08-09 23:33:22 +00:00
MarkDacek
856507f4d2 Add multiple property and replace functionality to bpmodify.
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
2022-08-08 17:58:11 +00:00
Alix
ab1bac0e12 changed newLocation option to be new-location in bpmodify
This is more consitant with other options in bpmodify

Test: ran manually
Change-Id: Ia0d267bdd3c67c53e72ef6556ff253eab0ae9a68
2022-08-05 14:27:54 +00:00
Alix
145d5a8c83 added moveProperty contents functionality to bpmodify
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
2022-07-25 19:38:40 +00:00
Jeongik Cha
28c7996f2c Add a filelock for in-place case
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
2022-05-10 01:30:08 +00:00
Jeongik Cha
5860caea33 bpmodify: remove-property
`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
2022-02-11 05:54:33 +00:00
Jooyung Han
451dd63611 bpmodify: -add-literal to add a value to the list
-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
2022-02-09 11:16:02 +09:00
Colin Cross
b1abbada6a Add support for setting string property in bpmodify
Add a -str argument to set a property to a string value.

Bug: 186723288
Test: bpmodify_test.go
Change-Id: I490e3be182693c8720020814da579e6e788b3d9f
2021-05-04 08:02:13 -07:00
Colin Cross
5ef7b6608c Improve bpmodify_test.go
Make TestProcessModule use subtests, give the tests names, and
use named fields in the testcase struct.

Test: bpmodify_test.go
Change-Id: I85345bd419e4c3ccf0050b7efae0479dd03d8bea
2021-04-29 19:11:39 -07:00
Jooyung Han
53e92a0de6
bpmodify: support numerical sort (#332)
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>
2020-12-14 11:30:48 -08:00
Yo Chiang
b138d49adf bpmodify: handle nested properties
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
2020-04-03 02:16:55 +08:00
Yo Chiang
9342b43c95 bpmodify: fix os.Exit() shouldn't shadow panic()
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
2020-03-05 19:45:49 +08:00
Dan Willemsen
aa919ddcbb
Merge pull request #290 from silverneko/bpmodify-exitcode
bpmodify: respect exitCode
2020-03-04 20:59:31 -08:00
Yo Chiang
e5a91f55e4 bpmodify: respect exitCode
main() method calls os.Exit(exitCode) upon return, respecting any
exitCode set by the report() method.

Test: bpmodify -w; echo "$?"
Test: bpmodify Android.bp; echo "$?"
Test: # echo command should output "2"
Change-Id: Iaf056301eaba3f249b256ecf0f0d87f8a4df1c58
2020-03-05 11:24:01 +08:00
Yo Chiang
3edfbc214a Set bpmodify usage function
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
2020-03-04 09:46:17 +08:00
Steven Moreland
b40aaadbca bpmodify: add argument if it is missing
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
2018-12-17 18:16:16 -08:00
Colin Cross
c1d878159c Fix format issues found by go vet
Test: m checkbuild
Change-Id: I5135e0daecd20abce9a66631f5f55230168613de
2018-02-23 14:05:03 -08:00
Colin Cross
c32c47938f Remove blueprint/parser.Ident
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
2016-06-14 15:26:49 -07:00
Colin Cross
e32cc80f20 Refactor blueprint parser nodes to an interface
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
2016-06-08 14:48:53 -07:00
Jamie Gennis
6cafc2cddc Update import paths to include github 2015-03-21 01:03:36 -04:00
Colin Cross
3e8e74f276 Move blueprint/* up a directory
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
2015-01-23 14:23:27 -08:00