Commit Graph

8487 Commits

Author SHA1 Message Date
Mårten Kongstad
b025507857 aconfig: improve code diffs in tests
Implement a helper function to make it easier for unit tests to diff
(and find the first difference) generated code and expected code.

Bug: 283910447
Test: atest aconfig.test
Change-Id: I460e8fbf05e8f33e8a62ecef67b2d9d77051e876
2023-06-08 11:27:59 +02:00
Mårten Kongstad
066575b95f aconfig: add namespace field to flag_declaration and parsed_flag
Add a new field to the proto messages flag_declaration and parsed_flag.

The new field will be used verbatim as a parameter when calling
DeviceConfig.getBoolean to read the value of a READ_WRITE flag. See the
DeviceConfig API for more info.

Note: not to be confused with the old namespace field, which has been
renamed to package.

Bug: 285211724
Test: atest aconfig.test
Change-Id: I2181be7b5e98fc334e5277fb5f7e386f1fe0b550
2023-06-08 11:27:57 +02:00
Mårten Kongstad
fbd71e2773 aconfig: allow dots in package fields
Allow package fields to include dots.

Update the generated code based on the package name: if the package name
is com.android.example:

  - java: package com.android.example; ...
  - C++: namespace com::android::example { ... }
  - Rust: mod com { mod android { mod example { ... } } }

Also, update examples to use dots in the package fields.

Also, remove unnecessary #include from the auto-generated C++ code: the
header should not include itself.

Bug: 285000854
Test: atest aconfig.test
Change-Id: I8a5352e25c64c34dee0725202a1b7c9957819de8
2023-06-08 11:25:43 +02:00
Devin Moore
d10e1e46b7 Merge "Add new script to analyze static/shared library usage" am: 9bf17fd9dd am: 0d3d349885 am: df53f92fd6
Original change: https://android-review.googlesource.com/c/platform/build/+/2590128

Change-Id: Ic48dc344b6c31db45bd3f72d1d2716c86bbe9921
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-07 22:20:47 +00:00
Devin Moore
0d3d349885 Merge "Add new script to analyze static/shared library usage" am: 9bf17fd9dd
Original change: https://android-review.googlesource.com/c/platform/build/+/2590128

Change-Id: I6fced63d717ea4b5cfff7fff0a4e00e0e3a6deba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-07 20:55:17 +00:00
Devin Moore
9bf17fd9dd Merge "Add new script to analyze static/shared library usage" 2023-06-07 20:18:09 +00:00
Treehugger Robot
39113c0584 Merge "Resolve test crash in build/make/tools/compliance." am: 69227ff9ae am: 295a2df7cd am: 9c1ac01d12
Original change: https://android-review.googlesource.com/c/platform/build/+/2619070

Change-Id: I391d522aad017d1d72b5274cd643062d00ef84b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-07 20:07:44 +00:00
Treehugger Robot
295a2df7cd Merge "Resolve test crash in build/make/tools/compliance." am: 69227ff9ae
Original change: https://android-review.googlesource.com/c/platform/build/+/2619070

Change-Id: I28a58137fe08032a88da937a8bb412eeb0766dc6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-07 18:19:52 +00:00
Jingwen Chen
376b6b6378 Resolve test crash in build/make/tools/compliance.
Test: m compliance_sbom
Test: go test ./...
Fixes: 285157766
BUG: 282746032
Change-Id: I5cc39f45f7ac3d9c574e2ebaa7fdfda864cb109d
2023-06-07 13:06:13 +00:00
Mårten Kongstad
9fb58965af aconfig: rename namespace -> package
What used to be referred to as a namespace is now called a package.

This CL is a semantic change only.

Bug: 285000854
Test: m nothing
Test: atest aconfig.test
Change-Id: If3fca67c415af75b44f316e16666b97089407069
2023-06-07 14:53:04 +02:00
Treehugger Robot
161b0fab75 Merge changes from topic "aconfig-gen-device-config-files" am: 2bb714ed2b am: 2960cffd7b am: 167b26de05
Original change: https://android-review.googlesource.com/c/platform/build/+/2613433

Change-Id: I22dd2fddc3f0e5ecdc8ac8c8ffb01289d2103f6b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-07 11:58:12 +00:00
Treehugger Robot
2960cffd7b Merge changes from topic "aconfig-gen-device-config-files" am: 2bb714ed2b
Original change: https://android-review.googlesource.com/c/platform/build/+/2613433

Change-Id: I06f9c490eea3026808db32a80b3f2f2e2909050f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-07 10:35:09 +00:00
Treehugger Robot
2bb714ed2b Merge changes from topic "aconfig-gen-device-config-files"
* changes:
  aconfig: add create-device-config-sysprops command
  aconfig: add create-device-config-defaults command
  aconfig: add test utilities
  aconfig: cache.rs: remove unnecessary use statements
  aconfig: give commands ownership of all arguments
2023-06-07 09:50:23 +00:00
Treehugger Robot
54eca11796 Merge "Use python based unzip function for portability" am: 3cda7834aa am: 976a36fb8e am: 60b74959a8
Original change: https://android-review.googlesource.com/c/platform/build/+/2615433

Change-Id: I73b5e85885ee22eaa5eb98623715abcaea17489e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-06 20:29:33 +00:00
Treehugger Robot
e7ae241f2e Merge "Always set a avb salt for hermetic build" am: fff48d788f am: 4c357806a3 am: f9fb104f9e
Original change: https://android-review.googlesource.com/c/platform/build/+/2613794

Change-Id: Ie529f3b071ba7def82cb963ea1a99eb4ead0f334
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-06 20:27:20 +00:00
Treehugger Robot
976a36fb8e Merge "Use python based unzip function for portability" am: 3cda7834aa
Original change: https://android-review.googlesource.com/c/platform/build/+/2615433

Change-Id: Id10787e68ac4a0a6ea0ada47a24f46dd7e128915
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-06 19:08:34 +00:00
Treehugger Robot
4c357806a3 Merge "Always set a avb salt for hermetic build" am: fff48d788f
Original change: https://android-review.googlesource.com/c/platform/build/+/2613794

Change-Id: I3feffd1c65f8e92e7c6a6c6e0481e206b28ec8dd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-06 19:07:16 +00:00
Kelvin Zhang
7c9205b008 Use python based unzip function for portability
Bug: 283033491
Test: th
Change-Id: Ief86b55c1d4a14220a0fb593c583a721d59cf86c
2023-06-05 15:54:12 -07:00
Devin Moore
bd13e63e99 Add new script to analyze static/shared library usage
Parses module-info.json, gathers stats on how many times each library is
included shared or statically.

Can print a list of libraries that would be a candidate for changing
from static to shared or visa versa.

Test: m
Bug: 280829178
Change-Id: I4bbffbd673ab2e08c69d0ab6e68402be77c9ffbc
2023-06-05 20:23:36 +00:00
Kelvin Zhang
c819b29f46 Always set a avb salt for hermetic build
When building images via `m` , build_image.py is invoked directly
without going through add_img_to_target_files. To ensure images built in
either way are identical, move uuid/salt computation to build_image.py,
so that the same uuid/salt will be used.

Bug: 281960439
Test: m installclean && m && m target-files-dir , maks sure images in
$OUT and $OUT/obj/PACKING/target_files_intermediates are identical

Change-Id: Icdab29df84f5a0ec7c080f99f9fdbdc3c9b10b90
2023-06-05 09:59:54 -07:00
Treehugger Robot
b2989fc109 Merge "Adding option to disable fastboot_info" am: ecf635f507 am: 8f26a9ca1d am: b083f09783
Original change: https://android-review.googlesource.com/c/platform/build/+/2612133

Change-Id: Ic02ad4911e965eb9d07e0882c804f56d945ad6e9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-03 04:13:22 +00:00
Treehugger Robot
8f26a9ca1d Merge "Adding option to disable fastboot_info" am: ecf635f507
Original change: https://android-review.googlesource.com/c/platform/build/+/2612133

Change-Id: I45872eab4df9b1044ff6a6fb1c582f5cd316a365
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-03 02:42:53 +00:00
Treehugger Robot
ecf635f507 Merge "Adding option to disable fastboot_info" 2023-06-03 01:56:41 +00:00
Dennis Shen
d0799b1a77 Merge "aconfig: update rust code gen to use libflags_rust" am: 3b0ca61d36 am: 8c1cce4e39 am: 1b0d706359
Original change: https://android-review.googlesource.com/c/platform/build/+/2607428

Change-Id: Id767e678c777b383a0143584c4bd9dd55e858abe
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-02 17:41:54 +00:00
Dennis Shen
8c1cce4e39 Merge "aconfig: update rust code gen to use libflags_rust" am: 3b0ca61d36
Original change: https://android-review.googlesource.com/c/platform/build/+/2607428

Change-Id: I5f100c044c906f06714ad1b4acbcbea83048a770
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-02 15:48:31 +00:00
Dennis Shen
3b0ca61d36 Merge "aconfig: update rust code gen to use libflags_rust" 2023-06-02 15:13:40 +00:00
Mårten Kongstad
c31a6ff653 aconfig: add create-device-config-sysprops command
Add a new "create-device-config-sysprops" command that works like
"create-device-config-defaults" but for system properties.

DeviceConfig is a Java service, and will mirror (some of) its values by
setting system properties in the persist.device_config namespace. Native
code will access DeviceConfig (actually, the system properties) via the
server_configurable_flags library.

The new command writes a file that can be appended to /system/build.prop
to pre-populate persist.device_config before DeviceConfig has started.

Like create-device-config-defaults, the new command skips READ_ONLY
flags.

Bug: 285468565
Test: atest aconfig.test
Change-Id: I311c7c5e0b03dc897b09204137d43cc182324717
2023-06-02 16:47:04 +02:00
Mårten Kongstad
f02734e915 aconfig: add create-device-config-defaults command
DeviceConfig is the backend for READ_WRITE flags.

Add a new command "create-device-config-defaults" to create a file that
DeviceConfig will read to pre-populate its data store on first init.

This will be used to quickly switch flag values during CI tests:
rebuilding and reflashing a device would have the same effect, but would
be costlier. This feature is not expected to be used outside CI tests.

Note: because DeviceConfig only works with READ_WRITE flags, the
generated file excludes READ_ONLY flags.

Bug: 285468565
Test: atest aconfig.test
Change-Id: I4caff1a10647b8da0ce4e3615678993a957a92dd
2023-06-02 16:46:28 +02:00
Mårten Kongstad
83a8760bbc aconfig: add test utilities
Create a test utility function to create a Cache from the files in
testdata/*. A follow-up CL will update the unit tests to use this
instead of creating their own caches.

Bug: 283910447
Test: atest aconfig.test
Change-Id: Ice5064eadb0babde5eb38d292330d213ab136d96
2023-06-02 12:54:22 +02:00
Mårten Kongstad
1cd166cd31 aconfig: cache.rs: remove unnecessary use statements
Remove unnecessary use from the cache::test module: they already covered
by `use super:*;`.

Bug: 283910447
Test: atest aconfig.test
Change-Id: I9e03385629f38180c0f92080c7f097a8e0d9ef69
2023-06-02 12:52:48 +02:00
Mårten Kongstad
b27f2ce436 aconfig: give commands ownership of all arguments
Pass the Cache argument to command::create_<lang>_lib functions by value
instead of by reference, to align with other commands.

The intended ownership flow is as follows:

  - main creates objects based on command line arguments
  - main hands commands ownership of the objects
  - command processes the objects
  - command gives main ownership of any generated output
  - main writes the output to file

Rationale: commands.rs is a unit testable version of main, and to the
rest of aconfig, acts as the top level entry point; main.rs exists only
to parse command line arguments and perform I/O.

Bug: 283910447
Test: atest aconfig.test
Change-Id: I1e1dea7da8ecc2bb6e2f7ee4a6df64562c148959
2023-06-02 12:49:26 +02:00
Treehugger Robot
eb6c9b7921 Merge "Open ab_partitions.txt with just read access" am: f9a6f5f06b am: b5535214ad am: 4cd34e5ce6
Original change: https://android-review.googlesource.com/c/platform/build/+/2611511

Change-Id: I263ecf630f7e62caaa6a70e4642f02122dfb64d0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-02 00:13:28 +00:00
Treehugger Robot
b5535214ad Merge "Open ab_partitions.txt with just read access" am: f9a6f5f06b
Original change: https://android-review.googlesource.com/c/platform/build/+/2611511

Change-Id: I075bf60c1586dd0af5d39cc23db97e9ae5c5532d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-01 22:42:53 +00:00
Daniel Zheng
ee10d07057 Adding option to disable fastboot_info
Fastboot_info can be disabled if use_fastboot_info is set to false.
Adding this flag as fastboot-info.txt is currently broken

Test: m updatepackage -> inspect contents
Bug: 284263071
Change-Id: I3e0ca13968ba9747cc39284ea6798981d22ad5e5
2023-06-01 14:21:58 -07:00
Kelvin Zhang
89b87f6aa9 Open ab_partitions.txt with just read access
We don't actually need write permission, so going with least privilege
principle. We have observed some mysterious permission denied errors on server environments. Without detailed logs or access to the server it's hard to pinpoint what the root cause is. This is an attempt/hypothesis to fix the permission denied error.

Test: th
Bug: 283033491
Change-Id: I52dc360d593aab57c749109994bf3e1e3625d0ce
2023-06-01 17:28:25 +00:00
Dennis Shen
6461673140 aconfig: update rust code gen to use libflags_rust
Bug: b/284096062, b/279483360
Test: atest aconfig.test
Change-Id: I4c96f35807de5cb2a745ba1c653513d9b22a5013
2023-05-31 14:35:59 +00:00
Treehugger Robot
1fe7af4274 Merge "aconfig: restrict valid namespace and flag names" am: cfc5f5e9fd am: 2d8615198c am: 6129693adb
Original change: https://android-review.googlesource.com/c/platform/build/+/2607087

Change-Id: Ic26969bbb8b273ceeabd4004e2b3ac07815fac03
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-30 22:11:32 +00:00
Treehugger Robot
2d8615198c Merge "aconfig: restrict valid namespace and flag names" am: cfc5f5e9fd
Original change: https://android-review.googlesource.com/c/platform/build/+/2607087

Change-Id: Ifb0c77ff4e3c51f8bd0dce787abb022946518c79
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-30 20:42:52 +00:00
Mårten Kongstad
00cf045c85 aconfig: restrict valid namespace and flag names
The namespace and flag names will be used as identifiers in the
auto-generated code. Place restrictions on what constitutes a valid
name.

Valid identifiers are those that match /[a-z][a-z0-9_]/. aconfig
explicitly does not implement any automatic translation to make names
valid identifiers: this sidesteps potential conflicts such as "foo.bar"
and "foo_bar" mapping to the same name if dots were translated to
underscores.

Bug: b/284252015
Test: atest aconfig.test
Change-Id: I38d005a74311e5829e540063404d1565071e6e96
2023-05-26 17:09:10 +02:00
Mårten Kongstad
e144b18ab9 Merge changes from topic "aconfig-create-rust-lib" am: aa977fb083 am: 5c2756c13a am: e6c068798d
Original change: https://android-review.googlesource.com/c/platform/build/+/2602726

Change-Id: I84c5ac6dc692612f1caa9c45fc99be8319287c3f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-26 09:01:35 +00:00
Mårten Kongstad
5c2756c13a Merge changes from topic "aconfig-create-rust-lib" am: aa977fb083
Original change: https://android-review.googlesource.com/c/platform/build/+/2602726

Change-Id: I2e708156312d2274c430a698b983b5cfe73c20ab
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-26 07:08:20 +00:00
Mårten Kongstad
aa977fb083 Merge changes from topic "aconfig-create-rust-lib"
* changes:
  aconfig: first iteration of Rust codegen
  aconfig: improve dump --format=debug output
2023-05-26 06:00:47 +00:00
Mårten Kongstad
f73b963283 aconfig: first iteration of Rust codegen
Add a new `create-rust-lib` command to generate Rust code. The output is
a src/lib.rs file; the build system is assumed to set the generated
crate's name.

For READ_ONLY flags, the generated code returns a hard-coded true or false.

For READ_WRITE flags, the generated code reaches out to DeviceConfig via
the cc_library server_configurable_flags via the
libprofcollect_libflags_rust Rust bindings. The build system is assumed
to add this to the generated crate's dependencies.

Note: libprofcollect_libflags_rust seems generic enough that it should
be moved to an official Rust wrapper for server_configurable_flags. This
is tracked in b/284096062.

Summary of module the built system is assumed to wrap the auto-generated
code in:

  rust_library {
      name: "lib<namespace>_rs",
      crate_name: "<namespace>_rs",
      edition: "2021",
      clippy_lints: "none",
      no_stdlibs: true,
      lints: "none",
      srcs: ["src/lib.rs"],
      rustlibs: [
          "libprofcollect_libflags_rust",
      ],
  }

Also add a set of test input to be used in the unit tests for a more
coherent test strategy. A follow-up CL will migrate the code in
commands.rs, codegen_java.rs and codegen_cpp.rs.

Bug: 279483360
Bug: 283907905
Test: atest aconfig.test
Test: manual: create cache from files in testdata, create rust lib, add to module template above, verify the module builds
Change-Id: I02606aa3686eda921116e33f7e2df8fd1156a7aa
2023-05-25 16:18:59 +02:00
Treehugger Robot
26fda7e335 Merge "Fix merge_target_files in GRF case" am: b3adc24301 am: 592ad2cb13 am: 7c629dbb53
Original change: https://android-review.googlesource.com/c/platform/build/+/2564310

Change-Id: I5a0f0236e07f50b7d8cfa05b476734ed3f98300a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-25 13:06:05 +00:00
Treehugger Robot
592ad2cb13 Merge "Fix merge_target_files in GRF case" am: b3adc24301
Original change: https://android-review.googlesource.com/c/platform/build/+/2564310

Change-Id: I564bb6d43bfa5b9cb79463f0ba50038d03ef6abb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-25 11:37:45 +00:00
Treehugger Robot
b3adc24301 Merge "Fix merge_target_files in GRF case" 2023-05-25 10:46:32 +00:00
Mårten Kongstad
993111f91c aconfig: improve dump --format=debug output
Use Rust's {:#?} formatter for more readable output.

Bug: 279485059
Test: atest aconfig.test
Change-Id: I127f413e3d7aebfba96cad1dd58d9e261dd613a4
2023-05-24 14:56:45 +02:00
Treehugger Robot
4f4da804bf Merge "Unsparse images before generating OTA" am: b4406d06f0 am: 74ad39125c am: 8b55fd52a0
Original change: https://android-review.googlesource.com/c/platform/build/+/2598008

Change-Id: Ib062901d1b91380b98da95f38666c66f1205f587
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-23 23:11:17 +00:00
Treehugger Robot
74ad39125c Merge "Unsparse images before generating OTA" am: b4406d06f0
Original change: https://android-review.googlesource.com/c/platform/build/+/2598008

Change-Id: I40ac20dd7b30d11e1eda77688718566af4c1c416
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-05-23 21:22:54 +00:00
Treehugger Robot
b4406d06f0 Merge "Unsparse images before generating OTA" 2023-05-23 20:51:10 +00:00