Commit graph

3007 commits

Author SHA1 Message Date
Cole Faust
40acd0417b Rename Evaluate() to Get() and add GetDefault() am: 09fe90e407 am: 70c30f6ec8
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3028284

Change-Id: I226a299cc5c9af60ed8ef5d415541c739619cfe4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-08 21:33:48 +00:00
Cole Faust
97080d8421 Add android:replace_instead_of_append am: 2437d5edb9 am: e8602b8b22
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3025378

Change-Id: I271a96c3622853a364a11a10911d1ce50a1d7459
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-08 21:33:46 +00:00
Cole Faust
70c30f6ec8 Rename Evaluate() to Get() and add GetDefault() am: 09fe90e407
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3028284

Change-Id: Id10c8a2773f17f7a1d97d39c6f99f5b39d608728
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-08 21:16:18 +00:00
Cole Faust
e8602b8b22 Add android:replace_instead_of_append am: 2437d5edb9
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3025378

Change-Id: I0af8eab5aa136b05c0a97acdbe40380eccfd7f2d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-08 21:16:13 +00:00
Cole Faust
760d00076c Rename default select branch to 'default' keyword am: 0173a2268b am: 05b4504d80
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3024123

Change-Id: Icc4fde6bbf2a306ae71fc518a1ca664460161ea3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-04 22:23:48 +00:00
Cole Faust
05b4504d80 Rename default select branch to 'default' keyword am: 0173a2268b
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3024123

Change-Id: I985f397d1a954c711170bc2a757439950b7271ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-04 22:04:48 +00:00
Cole Faust
09fe90e407 Rename Evaluate() to Get() and add GetDefault()
Part of the design of property structs is that they were easy to access.
In keeping with that spirit, use a shorter and easier to spell name
for the getter, and add GetDefault() so that you don't need to pass
the result of Get() to one of the
proptools.StringDefault/BoolDefault/etc functions.

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: Ib9a69dcf2ab56a758935a461f37fe46bc0e17e27
2024-04-04 14:46:15 -07:00
Cole Faust
2437d5edb9 Add android:replace_instead_of_append
If a property is a pointer to a bool/string, that property would be
replaced instead of appended to when calling ExtendProperties().

This is confusing behavior, and I don't want to give anyone any reason
to use a pointer to a configurable property, so add this relflection
tag to recreate the functionality.

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I6b9e4dfee1d2685e0c9dc6a646cf45724cc04756
2024-04-04 14:35:18 -07:00
Cole Faust
0173a2268b Rename default select branch to 'default' keyword
Previously I was using an underscore to denote the default branch
because I was thinking that I would allow variable bindings in the
select branches, and 'default' could be mistaken for the name of a
variable. But I think it's better to just introduce alternate syntax,
like `default @ my_var: "foo" + my_var,` to do the variable bindings,
so that we can have a clearer name for the default case.

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: Ied762694e453855c03dd471898ebb52e97a5a671
2024-04-04 12:02:46 -07:00
Cole Faust
3cb9d78c74 Add support for unset select branches am: 021cc8f5b8 am: 1f6a30a4a8
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3019592

Change-Id: Ia9e14b0d641fbfea4d28127ab23411be77c5ffbc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-04 18:26:06 +00:00
Cole Faust
1f6a30a4a8 Add support for unset select branches am: 021cc8f5b8
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3019592

Change-Id: I08b0bc242778076690eb9d6e4805d9ac98969064
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-04 18:25:18 +00:00
Cole Faust
021cc8f5b8 Add support for unset select branches
Currently, with the arch/os mutator, you can override a property
using the default value for just a few arch types, for example:

cc_defaults {
    name: "my_defaults",
    target: {
        windows: {
            enabled: true,
        }
    }
}

cc_binary {
    name: "foo",
    enabled: false,
    defaults: ["my_defaults"],
}

You could make a select statment that acts like the above if it were
all in one module, but currently with select statements you can't make
a defaults module that can be generically applied to any other module
and have the same behavior as the above.

After this cl, the defaults module could look like:

cc_defaults {
    name: "my_defaults",
    enabled: select(variant("arch"), {
        "windows": true,
        _: unset,
    }),
}

Which would have the same behavior. Unset may also be useful for
setting the property under some configurations, but wanting to leave
the implementation-specific default value in others.

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I3ea3277ea8b9a0ac5e613b4378945388b9df036a
2024-04-02 16:35:33 -07:00
Colin Cross
d8759309aa Merge changes I4bb1a17f,I05ffdf6d,I5dc201f4,If16ee798,I2e42c0d6, ... into main am: a6074ea049 am: a295d7b965
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3017628

Change-Id: Ibb333c1b37fcb554b3f984248fd21c34a11bc58d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-02 18:04:52 +00:00
Colin Cross
a295d7b965 Merge changes I4bb1a17f,I05ffdf6d,I5dc201f4,If16ee798,I2e42c0d6, ... into main am: a6074ea049
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3017628

Change-Id: I75011814dcdd38e9a0253a139e14c662419d82c2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-02 17:45:32 +00:00
Colin Cross
a6074ea049 Merge changes I4bb1a17f,I05ffdf6d,I5dc201f4,If16ee798,I2e42c0d6, ... into main
* changes:
  Store mutator in mutatorContext instead of name
  Explicitly delete old logicModule entries from Context.moduleInfo
  Keep logicModule for obsolete variants
  Add Provider to transition contexts
  Cache outgoing transitions
  Use maps and slices packages
2024-04-02 17:24:37 +00:00
Colin Cross
d5d55e5b26 Store mutator in mutatorContext instead of name
TransitionMutators will need access to the original *mutatorInfo,
store it in mutatorContext instead of the name, and update all
accesses to the name to go through the *mutatorInfo.

Bug: 319288033
Test: go test ./...
Change-Id: I4bb1a17f44e55b23dd70708c9a5fde2ae80ce154
2024-04-01 15:55:16 -07:00
Colin Cross
1d5e1a56fe Explicitly delete old logicModule entries from Context.moduleInfo
Creating variants has an optimization to reuse the logicModule of the
original variant as the logicModule of the first new variant.  Using
the same logicModule meant that updating the Context.moduleInfo map
from logicModules to *moduleInfo would overwrite the old entry for
the original variant with the new entry for the first variant.

TransitionMutators will need to keep the original logicModule for
later use, which will require disabling the optimization that reuses
it.  When the first variant is added to the map it no longer overwrites
the original variant.  Excplicitly track the original logicModule and
remove it from the map if necessary.

Bug: 319288033
Test: go test ./...
Change-Id: I05ffdf6d7ce60508f6d9e9657c21032f2c4f5d9c
2024-04-01 15:55:16 -07:00
Colin Cross
7b5888a4f6 Keep logicModule for obsolete variants
When splitting a module into variants the original *moduleInfo was
left in place but with logicModule set to nil as a marker that the
variant was obsolete and any incoming dependencies needed to be resolved
onto one of the newly split variants.  A change to allow TransitionMutator
IncomingTransition calls when adding dependencies later will require
keeping the obsolete *moduleInfo and logicModule around so that
IncomingTransition can be called on it. so use an explicit boolean
to mark the module as obsolete instead of clearing logicModule.

Bug: 319288033
Test: go test ./...
Change-Id: I5dc201f43442aa07ac1b858240c675bab3782b55
2024-04-01 15:55:15 -07:00
Colin Cross
fab4866a68 Add Provider to transition contexts
Allow TransitionMutator OutgoingTransition and IncomingTransition
methods to access Providers from the current and dependency module
respectively.

Bug: 319288033
Test: none
Change-Id: If16ee7980ee0b8f4abaf3c112738fca3f13ab61c
2024-04-01 15:55:13 -07:00
Colin Cross
fca423d9e6 Cache outgoing transitions
TransitionMutators were calling OutgoingTransition and IncomingTransition
twice, once to determine all the necessary variations for each module,
and then again when creating the variations to resolve dependencies.
Store the final variation needed for each dependency during the first
computation, and use it to resolve the dependency variation in the second
pass.

Bug: 319288033
Test: all soong tests
Change-Id: I2e42c0d69efbfcff915267c484c18554b857e0b6
2024-04-01 15:54:42 -07:00
Colin Cross
4cc5290aac Use maps and slices packages
Use slices.Clone, slices.Contains, maps.Clone and maps.Equal.

Test: go test ./...
Change-Id: I96596f157dec2558007da4917c998a64d0cc4d79
2024-04-01 15:54:22 -07:00
Cole Faust
f607e5ccf4 OR booleans together when appending configurables am: 46cf6764fd am: 2201be78bc
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3019591

Change-Id: I6a35d45eb8058ca2f392d30bf3020b25e70c6fba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-01 18:24:05 +00:00
Cole Faust
2201be78bc OR booleans together when appending configurables am: 46cf6764fd
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3019591

Change-Id: I047172c4592e4101c682255ac2d5b0bba5fa50a4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-01 18:04:33 +00:00
Cole Faust
dd924e8d65 Don't recurse into configurable properties in filterPropertyStructFields am: 02790f32c9 am: fa1f3ea737
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3014981

Change-Id: Id38e8b08f9552082a311b9d4d3dd857b79f41b45
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-27 23:54:48 +00:00
Cole Faust
46cf6764fd OR booleans together when appending configurables
This is to match how (non-pointer) booleans work in AppendProperties().

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I16791fc5ac684eedf8064a65953b8b68f18c37c1
2024-03-27 16:39:07 -07:00
Cole Faust
fa1f3ea737 Don't recurse into configurable properties in filterPropertyStructFields am: 02790f32c9
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3014981

Change-Id: I524b528957fd1f5d5e0123aaa73615b447031139
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-27 23:37:32 +00:00
Cole Faust
02790f32c9 Don't recurse into configurable properties in filterPropertyStructFields
filterPropertyStructFields should treat configurable properties as
leaf nodes and not recurse into them. Configurable properties can be
made arch_variant, at least while we transition to full use of
Configurable.

Bug: 323382414
Test: soong tests when changing enabled to be configurable
Change-Id: Ib22dd3797f69e912dab0e0c3c1030d6c1f04db7e
2024-03-26 16:46:48 -07:00
Cole Faust
77421ea952 Add OtherModulePropertyErrorf am: 4f968700d1 am: f4551ed37f
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3010376

Change-Id: Ib5a38c0bd727897a2650a78369891802d98a99ba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-26 21:26:52 +00:00
Cole Faust
f4551ed37f Add OtherModulePropertyErrorf am: 4f968700d1
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3010376

Change-Id: I2c196005d97516e273d56b8637f54d5e151db202
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-26 21:11:15 +00:00
Cole Faust
4f968700d1 Add OtherModulePropertyErrorf
...and pass property name to ConfigurableEvaluator.

When trying to convert Enabled to a configurable property, I enountered
a bunch of different context types that all had different error methods.
OtherModulePropertyErrorf is an error method that can be implemented
by all contexts.

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I38b2a545c0ee8d23281cd88bc397f79f39835bc4
2024-03-22 13:02:51 -07:00
Cole Faust
0232d227b8 Fix error reporting in MatchesIncludeTags am: 894b318528 am: aa076d4e77
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3008164

Change-Id: I4f6e05adc1614edce18b0ca9e43eb7855d81d3dd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-22 18:44:53 +00:00
Cole Faust
aa076d4e77 Fix error reporting in MatchesIncludeTags am: 894b318528
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3008164

Change-Id: Ia6651b41dafc23e346c339f6b732731d993a4a4c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-22 18:21:14 +00:00
Cole Faust
894b318528 Fix error reporting in MatchesIncludeTags
ctx.ModuleErrorf for the main blueprint config object doesn't
report an error, it just returns it.

If go had something like C++'s `[[nodiscard]]` or rust's `#[must_use]`
that would be useful here, but the issue has been open since 2017:
https://github.com/golang/go/issues/20803

Test: Presubmits
Change-Id: I72709e6c5466d55f5c0f3fe51a25c29df0826271
2024-03-21 16:16:49 -07:00
Cole Faust
c26c8e86ee Get rid of some extra newlines in bpfmt am: d2f1141871 am: 6f7c2d8049
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3007878

Change-Id: I1090756b0a5095d59e4ac4817638406dfbf63ab4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-20 18:06:23 +00:00
Cole Faust
6f7c2d8049 Get rid of some extra newlines in bpfmt am: d2f1141871
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3007878

Change-Id: I958bf48af64ff4d70b7754dbbaf90345283e849b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-20 17:35:28 +00:00
Cole Faust
d2f1141871 Get rid of some extra newlines in bpfmt
Bug: 323382414
Test: go tests, and I also ran both the old/new bpfmts on the whole aosp source tree, and the only difference between the results was one extra removed line in external/uwb
Change-Id: I4942c9247a66f1de5028de39caa5cd34b66093c3
2024-03-19 17:07:00 -07:00
Cole Faust
64629eef9a Add proptools.Slice am: a962edf763 am: ab9b28700a
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3003509

Change-Id: Ic98ca868c66fd80a8810b800313c0bccc2c9e365
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-15 00:31:03 +00:00
Cole Faust
ab9b28700a Add proptools.Slice am: a962edf763
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3003509

Change-Id: Ic74a65ea7cf8a49900120682fa94460815acd278
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-15 00:11:05 +00:00
Cole Faust
a962edf763 Add proptools.Slice
To make it easier to handle the result of
Configurable[[]string].Evaluate()

Bug: 329711542
Test: go tests
Change-Id: I7364170564b1049a33873424c6da4fc26aff305b
2024-03-14 14:28:52 -07:00
Cole Faust
7121ab98ad Select statements am: 6437d4e737 am: f58da196f3
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2962528

Change-Id: I2802b767be43ccdb479874fd8c51f08b11f16b22
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-07 19:15:55 +00:00
Cole Faust
f58da196f3 Select statements am: 6437d4e737
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2962528

Change-Id: I01ed29c4af5b558e416ad74fab674e0ef1534a1f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-07 18:30:31 +00:00
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
LaMont Jones
25e25de53e debugValue: handle Interfaces better. am: 89e90b4c60 am: 34847c828d
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2975295

Change-Id: I0656d3ea8a02e73f164bd89fa507fbaa8d7a6ead
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-26 21:15:51 +00:00
LaMont Jones
34847c828d debugValue: handle Interfaces better. am: 89e90b4c60
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2975295

Change-Id: Iba23845605d8cdeb400f65cc3da34e4e2239b1d6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-26 20:35:19 +00:00
LaMont Jones
89e90b4c60 debugValue: handle Interfaces better.
Bug: none
Test: manual
Change-Id: Ic8ee668abf4387fc2f00e1f520efea360eebd66c
2024-02-23 15:04:04 -08:00
Joe Onorato
6ec9fb89cb Add maps to soong-debug-info.json am: 5920e5507e am: 2e39a573ce
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2968297

Change-Id: Iaca3aab6d1dab6e349f0fa49b21dd5cf1026c2a8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-20 19:28:52 +00:00
Joe Onorato
2e39a573ce Add maps to soong-debug-info.json am: 5920e5507e
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2968297

Change-Id: I3506b8e2ab0928381d11d0ff14e07f207ac28a43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-20 18:49:14 +00:00
Joe Onorato
5920e5507e Add maps to soong-debug-info.json
Test: m nothing
Change-Id: Iffa308e1b93a5f7e1cea7587bef3540d1eb37de5
2024-02-18 14:47:44 -08:00
Joe Onorato
236de5b7d1 Add tag data to soong-debug-info.json. am: c7ec117556 am: 6dacd69f65
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2956143

Change-Id: I182bdd2efd9c7ba80d819910998de2f7bfcd4c63
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-12 20:35:00 +00:00
Joe Onorato
6dacd69f65 Add tag data to soong-debug-info.json. am: c7ec117556
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2956143

Change-Id: Id701b9172a56db6780c1e1e899569e6bec689cc2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-12 19:55:21 +00:00