Commit graph

12 commits

Author SHA1 Message Date
Cole Faust
6437d4e737 Select statements
Select statements are a new blueprint feature inspired by bazel's select
statements. They are essentially alternative syntax for soong config
variables that require less boilerplate. In addition, they support
making decisions based on a module's variant, which will eliminate
the need for manual property struct manipulation, such as the arch
mutator's arch: and target: properties.

In order to support decisions based on the variant, select statements
cannot be evaluated as soon as they're parsed. Instead, they must be
stored in the property struct unevaluated. This means that individual
properties need to change their type from say, string, to
Configurable[string]. Currently, only configurable strings, bools, and
string slices are supported, but more types can be added later.
The module implementation must call my_property.Evaluate(ctx) in order
to get the final, resolved value of the select statement.

Bug: 323382414
Test: go tests
Change-Id: I62f8721d7f0ac3d1df4a06d7eaa260a5aa7fcba3
2024-03-06 15:00:39 -08:00
Zi Wang
e5913c17e9 Remove unnecessary used names before reporting
When property a.b.c is not used, (also there is no a.* or a.b.* used)
"a", "a.b" and "a.b.c" are all in unusedNames.
removeUnnecessaryUnusedNames only keeps the last "a.b.c" as the
real unused name.

Test: TestNonExistentPropertyInSoongConfigModule, unpack_test.go and CI

Bug: 171232169
Change-Id: I861fa6933e558b07694ee5ff40ef549117d115ff
2024-01-04 12:24:39 -08:00
Sam Delmerico
26e44b7b78 apply gofmt
Change-Id: I2416e246b3d8485a6b7810b998cff2f45f6a0494
2023-02-21 15:11:20 -05:00
Usta Shrestha
290e675625 Revert "Add support for maps in blueprint files."
This reverts commit 42cb28f66e.

Reason for revert: Dead code - map type properties in Module

Change-Id: Ie944a311963cc54258cbc4ba3fc974882e5539ce
2022-08-02 10:55:21 -04:00
Liz Kammer
42cb28f66e Add support for maps in blueprint files.
This limits support to allow-listed property names to prevent
proliferation of map types requiring additional support to migrate.

Test: go test blueprint tests
Test: m nothing && diff build.ninja & Android-aosp_arm.mk -- no changes
Change-Id: Id12637462f19ac5de1b562f63507de989a51600d
2022-01-26 12:18:31 -05:00
Colin Cross
3adb240964 Fix silently ignoring values assigned to map properties
Values assigned to map properties were silently ignored instead of
reported as an error.  Add a check when recursing into structs that
the value is a map.

Fixes: 177706602
Test: m nothing
Test: TestUnpackErrors
Change-Id: Ic56aeb1b9da6d5c86b6d98adae7bddb60c450404
2021-01-15 22:21:28 -08:00
Colin Cross
f6ef155884 Use UnpackError for incorrect property type errors
Returning a fmt.Errorf error causes Blueprint to identify the error
as an "internal error", return an UnpackError instead.

Bug: 177706602
Test: TestUnpackErrors
Change-Id: I19fba134ad778d08d5a4d90a0335bdf8cbea6a20
2021-01-15 22:21:28 -08:00
Sasha Smundak
de4d9f94ac Fix bug in buildPropertyMap in previous commit.
Property value should be evaluated before proeprty map is populated with
it. Added the test for this case.
2020-03-03 17:42:38 -08:00
Sasha Smundak
29fdcad56c Implement list of maps
Allow property value to be a list of maps, e.g.
my_module {
  my_list: [
    { name: "foo", value: 42, something: true, },
    { name: "bar", value: 34, something: false, },
  ],
}

Test: internal
Change-Id: I2fc37d692aac39f23c9aa7bda2859ab49f3bc672
2020-03-02 17:26:20 -08:00
Colin Cross
6898d26054 Add isStruct and isStructPtr helpers
Test: proptools tests
Change-Id: I7814b2138cd19b538a3a33036a15119e118d7644
2020-01-28 09:51:19 -08:00
Colin Cross
571f77a60d Remove blueprint:"filter(*)" tag support
The filter tag is unused, replaced with FilterPropertyStruct to
generate a new type at runtime that only contains the filtered
fields.

Test: unpack_test.go
Change-Id: Id91cf99290832094d05426f3263279836f0fea73
2020-01-21 11:49:27 -08:00
Colin Cross
f27c5e470b Move unpackProperties to proptools and export it
Test: unpack_test.go
Change-Id: I145369323bd7d5003a261c13dfb8ed31d0be51b5
2020-01-02 20:32:51 -08:00
Renamed from unpack.go (Browse further)