Commit graph

12 commits

Author SHA1 Message Date
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