Before java code will directly use the flag name as the method name.
This change adds funciton to try the best to convert flag name to
camelCase, and then use the camelCase string as the method name in the
generated code.
Bug: 279483816
Test: atest aconfig.test aconfig.test.java
Change-Id: I45fc6df46c9d535cd38a657a41313202f9b660af
Partition images are allowed to be in either IMAGES/ or RADIO/ dir of a
target_files zip, so when searching for .map files we should look in
both dirs.
Test: th
Bug: 227848550
Change-Id: I0a9d2c582d8f5d570237434902fac012513c9aad
This change includes
- refactor generated java code to generate
- Flags.java to support the static API
- FeatureFlagsImpl.java to support injection API
- FeatureFlags.java interface
Bug: 279483816
Test: atest aconfig.test aconfig.test.java
Change-Id: If0d4baf317b9174635cd0fff3832ab7091ee52ed
The Java codegen may translate flag names (snake_case) to Java
camelCase, dropping the underscores. The flags a_b and a__b will
translate to the same camelCase form, which is ambiguous.
Circumvent this problem by disallowing consecutive underscores in flag
names, flag namespaces, and packages.
Bug: 284252015
Test: atest aconfig.test
Change-Id: I2586a38160723c06265a140193da8178655553e4
So that we have a more restricted enviornment for this new configuration
axis that can also be imported into other tools more easily.
Test: Manually (this time also tested setting OUT_DIR outside of the tree)
Change-Id: I01d90e06e45cba756156af16f63e04f575877263
Supply generator with parameter --apex_info_file=META/apex_info.pb
if the file exists.
This ensures that apex_info is included in payload header.
This is identical to the behaviour of brillo_update_payload
which is not being used since:
Invoke delta_generator directly
fcd731e3d6
Issue: 286253576
Test: Manual, confirm that apex_info is included in payload header
Change-Id: Ic096c5f8966beec8686f918aba462c955290a6c5
Add integration tests for Java. This test setup verifies that
- the build system calls aconfig to generate a Java library
- the Java test compiles against the auto-generated library
- the auto-generated code returns expected values
Similar integration tests for C++ and Rust will be added in follow-up
CLs.
Note: the build does not currently support specifying that
tests/*.values should be applied, so the test flags will all be assigned
the defaults. A later CL will fix this.
Bug: b/283911467
Test: atest aconfig.test aconfig.test.java
Change-Id: Ia365e209261f4935a23e2dac9ef0ab5b60f76e52
* changes:
aconfig: include namespace in create-device-config-defaults
aconfig: improve code diffs in tests
aconfig: add namespace field to flag_declaration and parsed_flag
aconfig: allow dots in package fields
aconfig: rename namespace -> package
The following log message would always be shown:
WARNING : Cannot find care map file in target_file package
Break out of the care map copying loop as soon a file has been
copied. This ensures that else statement is only executed if no
care map file exists.
Test: Manual. Run ota_from_target_files with target-zip with and
without care map files.
Change-Id: Ia196aa182ed81f21424317a7005f5634866b4b99
Update the output format of create-device-config-defaults to include the
flag's namespace. Also change the delimiters. The new format is
<namespace>:<package>.<flag-name>=[enabled|disabled|
Bug: 285468565
Test: atest aconfig.test
Change-Id: I9b4ca1611cca8528dc341fc12812b614c86f6c08
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
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
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
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
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
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
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
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
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
Remove unnecessary use from the cache::test module: they already covered
by `use super:*;`.
Bug: 283910447
Test: atest aconfig.test
Change-Id: I9e03385629f38180c0f92080c7f097a8e0d9ef69
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
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
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
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
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