Commit Graph

9037 Commits

Author SHA1 Message Date
Mårten Kongstad
517ac4801b aconfig: dump --filter: implement predicates
The aconfig dump command can now limit which flags to print by passing
in one or more --filter=<query> commands.

If multiple --filter arguments are provided, flags that match any filter
will be included in the output.

The <query> syntax is <what>:<value>, where <what> is the name of a
ProtoParsedFlag field. Multiple queries can be AND-ed together by
joining them with a plus ('+') character.

Example queries:

  - --filter='is_exported:true' # only show exported flags
  - --filter='permission:READ_ONLY+state:ENABLED' # only show flags that are read-only and enabled
  - --filter='permission:READ_ONLY' --filter='state:ENABLED' # only show flags that are read-only or enabled (or both)

Current limitations that may be addressed in future CLs:

  - No support to invert a query, e.g. "flags *not* in the following
    namespace"

  - No support to quote strings; this makes description matching
    difficult

  - No support to glob strings, only exact matches are considered

  - No support to filter by description, trace or metadata fields

Bug: 315487153
Test: atest aconfig.test
Test: printflags --format="{fully_qualified_name}={state}" --filter=permission:READ_ONLY # manually verify output
Change-Id: Ie1e40fa444cec429e336048439da955f30e22979
2023-12-15 17:30:48 +01:00
Treehugger Robot
ca2175d3af Merge changes from topic "aconfig-codegen-ownership" into main
* changes:
  aconfig: pass ownership of ProtoParsedFlag items to Java codegen
  aconfig: pass ownership of ProtoParsedFlag items to C++ codegen
  aconfig: pass ownership of ProtoParsedFlag items to Rust codegen
2023-12-15 15:24:39 +00:00
Mårten Kongstad
49e4d6e73d aconfig: dump --filter: hook up command line args to dump.rs
This is the first step towards teaching dump to (optionally) filter
which flags to print.

A follow-up CL will implement dump::create_filter_predicate.

Bug: 315487153
Test: atest aconfig.test
Change-Id: Ibe0d4ce6563d3b5718fedd3ebfd45fbf5d935b92
2023-12-15 15:23:31 +01:00
Mårten Kongstad
ee58f98cc0 aconfig: support custom dump format specs
Teach `dump --format=<arg>` to format the output according to a
user-defined format string. The format string now accepts these
arguments:

  - "protobuf": output all data as binary protobuf (as before)
  - "textproto": output all data as text protobuf (as before)
  - any other string: format according to the format spec, see below

Custom format spec: placeholders, enclosed in { and } and named after
the fields of ProtoParsedFlag, will be replaced by the actual values.
All other text is output verbatim. As an example:

  - "{name}={state}" -> "enabled_ro=ENABLED"

Some fields support an alternative formatting via {<field>:<format>}. As
an example:

  - "{name}={state:bool}" -> "enabled_ro=true"

Note that the text replacement does not support escaping { and }. This
means there is no way to print the string "{name}" without expanding it
to the actual flag's name. If needed this feature can be introduced in a
later CL.

For backwards compatibility, the following format strings have special
meaning and will produce an output identically to what it was before
this change:

  - "text"
  - "verbose"
  - "bool"

A follow-up CL will add a new `dump --filter=` argument to limit which
parsed flags are included in the output.

Test: atest
Bug: b/315487153
Change-Id: If7c14b5fb3e7b41ea962425078bd04b4996318f4
2023-12-15 08:31:51 +01:00
Colin Cross
d7eac17f46 Raise go.mod version of build/make/tools/rbcrun
Raising the go.mod version to 1.17 or higher enables module graph
pruning (https://go.dev/ref/mod#graph-pruning), which prevents the
go tools like "go build ./..." from loading unused transitive
dependencies, including ones that are missing from our tree.

Bug: 314133304
Test: prebuilts/build-tools/build-prebuilts.sh
Change-Id: If1cc0fda1dc744e65fc3367b7f44b8c91230e5ce
2023-12-14 12:05:03 -08:00
Treehugger Robot
e4b265321a Merge "Update go.mod to 1.21" into main am: 9e4744383a am: 9e59d40c2c am: d7930f7cc0
Original change: https://android-review.googlesource.com/c/platform/build/+/2874720

Change-Id: Idd7d4f6d9263c5dc9fd82f55937815b0965b3cd7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-14 19:55:19 +00:00
Atneya Nair
a3a6bfb4a0 aconfig: Print flags with namespace, and sort them
For readability/convenience when looking at BRs/dev.

Test: adb shell printflags
Bug: 315402442
Change-Id: Ia8c447d99f6fe0a9ed6a33c4c68f2e97f5310dc0
2023-12-14 18:02:57 +00:00
Jeongik Cha
0be07c2279 Update go.mod to 1.21
because it requires android/soong which uses go 1.21
Bug: 3141333041
Test: go test ./...
Change-Id: I184e6165beafab337b09cd87fd02748e49c65650
2023-12-14 15:37:35 +00:00
Mårten Kongstad
0c6a2fac77 aconfig: pass ownership of ProtoParsedFlag items to Java codegen
Pass ownership of the ProtoParsedFlag iterator items to the Java
codegen: this removes the need for an explicit lifetime annotation.

Bug: N/A
Test: atest aconfig.test
Change-Id: I78705b65b4cf41c3e23b59afbd122a029ee45df4
2023-12-14 13:56:25 +01:00
Mårten Kongstad
49c49f365a aconfig: pass ownership of ProtoParsedFlag items to C++ codegen
Pass ownership of the ProtoParsedFlag iterator items to the C++ codegen:
this removes the need for an explicit lifetime annotation.

Bug: N/A
Test: atest aconfig.test
Change-Id: Ic6606a9ab01ddcb61aa668d7ac901469b1e25a1f
2023-12-14 13:53:52 +01:00
Mårten Kongstad
b7fc0d3e16 aconfig: pass ownership of ProtoParsedFlag items to Rust codegen
Pass ownership of the ProtoParsedFlag iterator items to the Rust
codegen: this removes the need for an explicit lifetime annotation.

Bug: N/A
Test: atest aconfig.test
Change-Id: Ia37ff9f1238684ea31cda6be70acde54fdb04881
2023-12-14 13:43:12 +01:00
Zhi Dou
ca421bacaf Merge "aconfig: CodegenMode::Exported: only generate code for exported flags" into main am: 3f2432967b am: 6fc359725a am: 035f2bcdf1
Original change: https://android-review.googlesource.com/c/platform/build/+/2873755

Change-Id: Ifcc6be47e5b4357dd62619404a7bbd17eddda5b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-13 22:50:41 +00:00
Zhi Dou
82df71123a aconfig: CodegenMode::Exported: only generate code for exported flags
If the codegen mode is CodegenMode::Exported, the codegen should not
generate code including any non-exported flags. This change add a
function to filter the parsed flags before feeding to codegen.

Test: atest aconfig.test aconfig.test.java AconfigJavaHostTest
aconfig.test.cpp aconfig.test.cpp.test_mode aconfig.prod_mode.test.rust
Bug: 311152500

Change-Id: Ia88795bbd13774d02c76d8ab7ef20868149599b5
2023-12-13 20:02:32 +00:00
Dennis Shen
3f8bba2bd0 Merge "aconfig: add create storage command" into main am: 728fe988d8 am: 0d4c6cafca am: d54e79e7ef
Original change: https://android-review.googlesource.com/c/platform/build/+/2855807

Change-Id: If7126d48c8602ec591bf64782c6f220e86fc02b0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-13 00:50:39 +00:00
Ted Bauer
8e0515f97b Merge "aconfig: fix template bug in exported mode." into main am: a27d46c590 am: cab7e07de4 am: fef8de03ab
Original change: https://android-review.googlesource.com/c/platform/build/+/2863216

Change-Id: Ic39434c24064a9677620e0e3117342cc44583dfd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-12 23:29:28 +00:00
Dennis Shen
728fe988d8 Merge "aconfig: add create storage command" into main 2023-12-12 23:15:59 +00:00
Dennis Shen
0d1c5629f7 aconfig: add create storage command
Add a new aconfig command called create-storage which takes a number
of aconfig cache files that belong to a specific container and produces
storage files.

Add a new module called storage (src/storage/mod.rs) as the entry point
of storage files generation. FlagPackage struct is defined as an
intermediate data structure that will be used to drive all storage files creation.

Add a unit test to lock down FlagPackage creation behaviors.

Bug: b/312243587
Test: atest aconfig.test

Change-Id: Ia7e9f68237ea903f295ac7891c923f6a39f3422d
2023-12-12 21:46:57 +00:00
Ted Bauer
a27d46c590 Merge "aconfig: fix template bug in exported mode." into main 2023-12-12 20:47:19 +00:00
Treehugger Robot
e438f967ff Merge "Support overriding cow version during OTA generation" into main am: 4f3ea9eeb8 am: fc926cd680 am: 8e1d4fb41b
Original change: https://android-review.googlesource.com/c/platform/build/+/2864988

Change-Id: I2e44164f0828d997e47c3ccb7acfdc79f873f45e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-12 20:10:36 +00:00
Ted Bauer
98562fded9 aconfig: fix template bug in exported mode.
FakeFeatureFlagsImpl still generated all flags in its mFlagMap field, but it should generate only exported flags in exported mode.

Test: atest aconfig.test.java
Bug: 311152507
Change-Id: I61843cd87b3bb5035772791a5869a91b07d574d8
2023-12-12 14:42:45 -05:00
Treehugger Robot
4f3ea9eeb8 Merge "Support overriding cow version during OTA generation" into main 2023-12-12 18:38:29 +00:00
Treehugger Robot
450c25c47e Merge "aconfig: include all tests in TEST_MAPPING" into main am: 83bc504d74 am: 3b122b17ee am: 033f38784c
Original change: https://android-review.googlesource.com/c/platform/build/+/2870454

Change-Id: I45b94db50a4c0e26af7779525fce204061b3ae7b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-12 15:42:27 +00:00
Treehugger Robot
e5c08a8c57 Merge "aconfig: fix broken test 'aconfig.test.cpp.test_mode:AconfigTest#ResetFlagValue'" into main am: d2a333f691 am: 773c57f5a4 am: ada37d1911
Original change: https://android-review.googlesource.com/c/platform/build/+/2868579

Change-Id: Ia2619ced848ba97f23ad529550eb1bf9262194d4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-12 14:19:49 +00:00
Mårten Kongstad
0ae74f86ba aconfig: include all tests in TEST_MAPPING
The aconfig tests used to be implicitly run by Treehugger, but something
has changed and Treehugger no longer verifies aconfig uploads. Fix this
by explicitly listing all aconfig tests in the TEST_MAPPING file.

Treehugger does not allow new tests in presubmit before they have proven
themselves (in terms of flakiness and execution speed) in postsubmit.
For this reason this CL adds the tests to postsubmit; a follow-up CL
will move them to presubmit.

This has the added benefit of allowing developers to easily run all
tests locally, either by

  $ atest

if current working directory is build/tools/aconfig or one of its
subdirectories, or

  $ atest --test-mapping $(gettop)/build/tools/aconfig

from anywhere in the Android tree.

Also add all tests to "general-tests" to enable Treehugger to run them.
Move aconfig.test from "device-tests" to "general-tests"; the former
group is intended for tests that depend on device-specific
functionality. See [1] for more info.

1. https://source.android.com/docs/core/tests/development/test-mapping

Bug: N/A
Test: atest --test-mapping $(gettop)/build/tools/aconfig
Change-Id: If857733834c8ad43a16e6162e50e6b1f713f979d
2023-12-12 14:05:15 +01:00
Mårten Kongstad
0bedc1507d aconfig: fix broken test 'aconfig.test.cpp.test_mode:AconfigTest#ResetFlagValue'
The aconfig.test.cpp.test_mode test cases modify the local flag
overrides, but was not resetting the values between tests. This meant
that

  $ atest 'aconfig.test.cpp.test_mode:AconfigTest#ResetFlagValue'

would succeed, but

  $ atest aconfig.test.cpp.test_mode

would fail. Fix this by calling reset_flags() as part of the per-test
setup.

Bug: N/A
Test: atest aconfig.test.cpp.test_mode
Change-Id: Ic8cffff0deb279b7ae103c05642c67230afc040f
2023-12-12 10:29:58 +01:00
Wei Li
84359f11f3 Merge "Fix the function invocation which missed the package name." into main am: 35baf405e0 am: f251d3ec11 am: c6105c42a3
Original change: https://android-review.googlesource.com/c/platform/build/+/2869634

Change-Id: I74df8096c8717524aca17e7c45e523fd99e91e0d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-11 23:36:18 +00:00
Oriol Prieto Gascó
59fce2e273 Merge "aconfig: Respect flag naming convention on test flags" into main am: 13af7616bf am: 97dba65914 am: 1d6738bebd
Original change: https://android-review.googlesource.com/c/platform/build/+/2868794

Change-Id: Ia205f0c845ec4899c7ea1cc23084d4f6de6675df
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-11 23:34:30 +00:00
Dennis Shen
c263e63ce4 Merge "aconfig: update aconfig cpp integration tests" into main am: 97ae9d35de am: 654831f852 am: e5018e4428
Original change: https://android-review.googlesource.com/c/platform/build/+/2862453

Change-Id: I196c678d27213057f319003b12acce603d58bf2c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-11 23:30:07 +00:00
Wei Li
b32ad827c7 Fix the function invocation which missed the package name.
The issue was introduced in the last refactoring, but the logic using the function is currently not used so nothing is broken.

Bug: 303904827
Test: CIs
Change-Id: I428e5b8d525ec49d0d5f62b7fbcc54caf482ac59
2023-12-11 12:19:30 -08:00
Oriol Prieto Gascó
13af7616bf Merge "aconfig: Respect flag naming convention on test flags" into main 2023-12-11 18:45:37 +00:00
Oriol Prieto Gasco
bbeda85949 aconfig: Respect flag naming convention on test flags
Test: atest aconfig.test
Bug: 311152507
Change-Id: I960867d32415007db5dacab57e97b813cbbee650
2023-12-11 18:45:06 +00:00
Dennis Shen
813267d1e7 aconfig: update aconfig cpp integration tests
Note a new cc_test target aconfig.test.cpp.test_mode is added instead of
reusing the old aconfig.test.cpp test target is becuase the test and
production version codegen flag lib has symbol conflict, one should only
link one at a a time.

Bug: b/291068147
Test: atest aconfig.test.cpp/aconfig.test.cpp.test_mode
Change-Id: Ifd52fd6eb7538fba90a13f0a6618a33a69b2358e
2023-12-11 13:20:12 +00:00
Dennis Shen
0d01239d02 Merge "aconfig: update aconfig owners" into main am: 60eeb8578b am: c64fa2e2c6 am: d32db765a4
Original change: https://android-review.googlesource.com/c/platform/build/+/2863158

Change-Id: I17b988f0bc9b45013a3fb961bf00792ffde73860
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-08 20:53:10 +00:00
Dennis Shen
60eeb8578b Merge "aconfig: update aconfig owners" into main 2023-12-08 19:16:00 +00:00
Dennis Shen
102bec338a aconfig: update aconfig owners
Change-Id: Ie97963c68c789e64495db4ed6e198f17eab412f6
2023-12-08 19:14:17 +00:00
Treehugger Robot
25fafb3cfe Merge "aconfig: move codegen into separate module" into main am: a18d7b17b7 am: 7c9c3c00ce am: d2b84e5049
Original change: https://android-review.googlesource.com/c/platform/build/+/2863041

Change-Id: Idef2c472d077c640b0979373f77f3a43087ff7e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-08 15:55:35 +00:00
Treehugger Robot
a18d7b17b7 Merge "aconfig: move codegen into separate module" into main 2023-12-08 14:15:51 +00:00
Treehugger Robot
ad76a70bbf Merge "aconfig: consolidate how fully qualified flag name is calculated" into main am: 5f24a2095d am: a57772e2b8 am: 73b007336b
Original change: https://android-review.googlesource.com/c/platform/build/+/2864525

Change-Id: I16fccfc59cc1932f1a9151e8c1c1d5228a29340a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-08 13:12:15 +00:00
Jihoon Kang
c063fdbe51 Merge "Add new dump format map in aconfig" into main am: 14a82dab15 am: 3d25718707 am: d449b41164
Original change: https://android-review.googlesource.com/c/platform/build/+/2860210

Change-Id: I7ce7f3f39e7aaea03c71a8b284c6e9ffa34acbba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-08 11:31:22 +00:00
Mårten Kongstad
12e593cd02 aconfig: move codegen into separate module
Consolidate the code generation sources into its own module. This is
done in preparation for when support for the new flag storage will be
added, which should also be placed in a separate module.

Bug: N/A
Test: atest aconfig.test aconfig.test.java
Change-Id: I8246729218ec60f2af4568c460e98329665a89fa
2023-12-08 11:24:54 +01:00
Mårten Kongstad
f3f20efd0c aconfig: consolidate how fully qualified flag name is calculated
Add an extension trait to consolidate how the fully qualified package
name (<package>.<name>) is calculated and use this where possible.

This CL is a semantic change only. The intention of this CL is to reduce
the risk of future bugs.

Bug: N/A
Test: atest aconfig.test
Change-Id: Ibab6641dda3843337fbea02631c31a1fdd8fb4ab
2023-12-08 11:02:32 +01:00
Jihoon Kang
a95f2b230c Add new dump format map in aconfig
The `aconfig dump --format map` lists aconfig keys mapped to its boolean
values that represents whether the flag is enabled or not, as seen below:
```
flag.name1=true
flag.name2=false
```

Test: aconfig dump --format map --cache out/soong/.intermediates/build/make/tools/aconfig/aconfig.test.flags/intermediate.pb && inspect output
Bug: 306024510
Change-Id: Ic4990c168f6fa9c87869113ba695c07394adbc67
2023-12-07 22:36:59 +00:00
Kelvin Zhang
8793a72bfd Support overriding cow version during OTA generation
Added a --vabc_cow_version flag to override cow version.
This enables testing on COW v3 without switching the android platform to
v3.

Test: th
Bug: 313962438
Change-Id: I9ff3ae6b6c7c8ef8c1423af6f25e420f94558d35
2023-12-07 13:20:43 -08:00
Micha Schwab
8d02a20932 Merge "Add metadata to aconfig" into main am: 56835092e4 am: 558eb199a5 am: bc2314b66a
Original change: https://android-review.googlesource.com/c/platform/build/+/2851033

Change-Id: If8ed530d99faaaf08dda2b758091728937108e14
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-07 17:48:40 +00:00
Micha Schwab
56835092e4 Merge "Add metadata to aconfig" into main 2023-12-07 15:55:18 +00:00
Treehugger Robot
c5eb14c90a Merge "Update create_brick_ota doc" into main am: ed339976c6 am: f41a3011f2 am: 6f8ae6f124
Original change: https://android-review.googlesource.com/c/platform/build/+/2863186

Change-Id: I0b450a72504ab2daf45cdef1eee200254d6f1ff0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06 23:45:46 +00:00
Kelvin Zhang
84e14c2102 Update create_brick_ota doc
Serial number need to be a | separated list per
bootable/recovery/install/install.cpp

Test: th
Change-Id: I09d8d615fde4206ebe6c07a7314ff8f7a394f10c
2023-12-06 13:01:54 -08:00
Aditya Choudhary
7cb1d0d4e4 Merge "Code metadata integration with Generator tool" into main am: 58b049f749 am: d605d59d5c am: a4cbd84242
Original change: https://android-review.googlesource.com/c/platform/build/+/2847033

Change-Id: I29679cbdd32c4742abcbc04cb25917c8f71325df
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06 09:29:53 +00:00
Aditya Choudhary
58b049f749 Merge "Code metadata integration with Generator tool" into main 2023-12-06 07:37:50 +00:00
Treehugger Robot
0f6ba0d36f Merge "Sign OTA packages inside target_files during signing" into main am: ca96bcb0c8 am: f77ae7ec12 am: b9f350054c
Original change: https://android-review.googlesource.com/c/platform/build/+/2818780

Change-Id: I1eb03f589dcecaa1893378aac75cbac99e82479d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-05 23:34:35 +00:00