Commit graph

3170 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
Android Build Coastguard Worker
0d3fa2663b Snap for 11504269 from 25e25de53e to 24Q3-release
Change-Id: I13a30deacd23a736116442e53ca86c3486e8a95e
2024-02-28 00:01:29 +00: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
Android Build Coastguard Worker
a85f446741 Snap for 11472972 from 6ec9fb89cb to 24Q3-release
Change-Id: Ife1c554fdbc398206043858c52859560cdef1b42
2024-02-21 00:01:41 +00: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
Android Build Coastguard Worker
c3bf86867d Snap for 11438798 from 236de5b7d1 to 24Q3-release
Change-Id: Id701a26049ebecb1000b52e2151dcdc12e0b254f
2024-02-13 00:01:55 +00: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
Android Build Coastguard Worker
1f99e2779c Snap for 11434705 from aa1aa64411 to 24Q3-release
Change-Id: I1a8f902f806d86fd6ee66e60bdea0099a25051c3
2024-02-10 22:00:58 +00:00
Joe Onorato
aa1aa64411 Add contents of properties and providers to soong-debug-info.json am: e66903065b am: b4058b4182
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2956892

Change-Id: I216d20153e2e4ee0e5fc9a19ac5ef2c646d332c7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-10 01:30:14 +00:00
Joe Onorato
b4058b4182 Add contents of properties and providers to soong-debug-info.json am: e66903065b
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2956892

Change-Id: I54953f828ebbedf9d8d65f54cc755a6489132bdd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-10 00:50:12 +00:00
Joe Onorato
c7ec117556 Add tag data to soong-debug-info.json.
It's not super useful because of Go's stupid restriction on not letting
you reflect private fields.

Test: m nothing
Change-Id: I1f73f06f5e64eaf4adce58a667b98b131aede53f
2024-02-09 16:26:16 -08:00
Joe Onorato
e66903065b Add contents of properties and providers to soong-debug-info.json
Test: whatever
Change-Id: I9e602c690ecbbf2150a65174d334ae2cbacc62b5
2024-02-08 23:06:19 -08:00
Colin Cross
6a4dcd0944 Merge "Optimize (Extend|Append|Prepend)[Matching]Properties" into main am: 51d8322241 am: d15eef65e1
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2947018

Change-Id: Ia78fd84e8a4b0141ff723a9fd8a0a7110c1f3c8b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-05 21:42:47 +00:00
Colin Cross
d15eef65e1 Merge "Optimize (Extend|Append|Prepend)[Matching]Properties" into main am: 51d8322241
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2947018

Change-Id: I49a3461e3008fd67afc978f62ccdc3aaac643365
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-05 21:23:33 +00:00
Colin Cross
984b7c81e1 Merge "Optimize blueprint.variationMap.equal" into main am: 4a918d4e91 am: 409c25a85a
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2947017

Change-Id: I008d8774df733de81858a6abb9be14fdb20dbacb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-05 21:22:09 +00:00
Colin Cross
714f321596 Merge changes I5894f739,I4d1292cb into main am: 9beaa476d6 am: 1daaad4500
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2947016

Change-Id: I19bf269d90f5d42a801905d549c076367ff807c2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-05 21:21:46 +00:00
Colin Cross
51d8322241 Merge "Optimize (Extend|Append|Prepend)[Matching]Properties" into main 2024-02-05 21:02:02 +00:00
Colin Cross
409c25a85a Merge "Optimize blueprint.variationMap.equal" into main am: 4a918d4e91
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2947017

Change-Id: I9adb50dd5f8d9549fa7b738b680a4610e2295670
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-05 20:41:37 +00:00
Colin Cross
1daaad4500 Merge changes I5894f739,I4d1292cb into main am: 9beaa476d6
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2947016

Change-Id: I2fdb25ebda8e2679fc9a1a0ad8acefbce5cab070
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-05 20:41:03 +00:00
Colin Cross
4a918d4e91 Merge "Optimize blueprint.variationMap.equal" into main 2024-02-05 20:29:19 +00:00
Colin Cross
9beaa476d6 Merge changes I5894f739,I4d1292cb into main
* changes:
  Use WriteString in hashProviderInternal
  Optimize deduplicateOrderOnlyDeps
2024-02-05 20:00:38 +00:00
Joe Onorato
d23d746eb5 Add new soong module debug info json. am: 8ad2b88c8d am: 2f019ce883
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2949327

Change-Id: I3d1bf3b2e91612a8bbd35376d871c0f01cf8e0b2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-04 01:35:00 +00:00
Joe Onorato
2f019ce883 Add new soong module debug info json. am: 8ad2b88c8d
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2949327

Change-Id: Id900142900cc5c6b302e69e4d88770cdb5654db5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-04 00:51:59 +00:00
Joe Onorato
8ad2b88c8d Add new soong module debug info json.
Enabled by setting GENERATE_SOONG_DEBUG=true

Test: GENERATE_SOONG_DEBUG=true m nothing ; soongdbg ...
Change-Id: If70c7d91cc59a5a7642e453c85278e8022693ac7
2024-02-03 14:37:02 -08:00
Colin Cross
c4fc4b447f Optimize (Extend|Append|Prepend)[Matching]Properties
The property squashing functions were performing 19% of all allocations
and allocating 3.43 GB, most of which was used to track the name of the
property, but the name of the property is only used to print errors.
Keep the elements of the name in a preallocated slice instead, and only
compute the name when an error occurs.

Calling reflect.Value.Interface() was also expensive, and only passed
to filter and order functions, none of which use the values.  Modify
the signature of the filter and order functions to remove the interfaces
and the property name.

Test: extend_test.go
Change-Id: I517f89daf251bb43f7cfefa6f1e83951c0e271b7
2024-02-02 15:57:26 -08:00
Colin Cross
1d82de2aab Optimize blueprint.variationMap.equal
blueprint.variationMap.Equal was responsible for 11.5% of allocations
and 2.2% of allocated memory.  reflect.DeepEquals is an expensive way
to compare a map.  variationMap.subsetOf is already iterating through
the elements of the map to compare them, replace equal with a check that
the maps are the same length and then reuse subsetOf to check that the
have the same keys and values.

Test: SOONG_PROFILE_MEM=/tmp/mem.pprof m nothing
Change-Id: Ifb7cdf612e5455fd2f412488b7f94416c4e70c54
2024-02-02 15:57:26 -08:00
Colin Cross
2ef2c35664 Use WriteString in hashProviderInternal
maphash.Hash implements WriteString, which avoids an allocation in
order to convert the string to a byte slice.  Using the concrete
type instead of the io.Writer interface also allows int64Array to
be allocated on the stack.

Test: SOONG_PROFILE_MEM=/tmp/mem.pprof m nothing
Change-Id: I5894f7399c2a232f5f67d7d0724a6115ba2c278f
2024-02-02 15:57:26 -08:00
Colin Cross
dbf18bec98 Optimize deduplicateOrderOnlyDeps
keyForPhonyCandidate was using sha256, which is a crypto hash and
unnecessarily expensive for this use case.  hash/maphash would be
much faster because it implements WriteString and so doesn't cause
an extra allocation to copy to a byte slice for every write, but it
insists on randomizing the seed, which makes it unsuitable for writing
to the build.ninja file.  Use hash/fnv instead, and use unsafe to
write strings to the hash to avoid the extra allocation.

Also replace the manually rolled parallelism with the existing
parallelVisit, which will reuse goroutines and limit the parallelism
to a useful value.

The hash could collide, and using a 64-bit hash makes that more
likely, so also check the full contents to make sure they are really
equal.

Cuts 1 second off Soong analysis time.

Test: SOONG_PROFILE_MEM=/tmp/mem.pprof m nothing
Change-Id: I4d1292cb158cfc5823a0f4d8b4aeac1d0b10230e
2024-02-02 15:57:26 -08:00
Cole Faust
2ea6b5a3e2 Enforce that providers are not changed am: 7add62142d am: 689b3e5ce4
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2928138

Change-Id: I9be0f9060b4bdb87cd1140bfe41b6e3dc15ff867
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-31 03:04:16 +00:00
Cole Faust
689b3e5ce4 Enforce that providers are not changed am: 7add62142d
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2928138

Change-Id: I9509cd10e21d24b9792f35a1a208b755adae08c2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-31 01:31:41 +00:00
Cole Faust
7add62142d Enforce that providers are not changed
When setProvider() is called, hash the provider and store the hash in
the module. Then after the build is done, hash all the providers again
and compare the hashes. It's an error if they don't match.

Also add a flag to control it in case this check gets slow as we convert
more things to providers. However right now it's fast (unnoticable
in terms of whole seconds) so just have the flag always enabled.

Bug: 322069292
Test: m nothing
Change-Id: Ie4e806a6a9f20542ffcc7439eef376d3fb6a98ca
2024-01-30 15:18:24 -08:00
Colin Cross
0aca478e0d Merge changes from topic "transition-mutator-config" into main am: 1b3fe6bd2c am: 1236187824
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2922240

Change-Id: Ie0d751e36fce33f95e8201d06c16201fcdccde71
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-24 21:16:11 +00:00
Colin Cross
c6e88cec73 Fix OutgoingTransitionContext to match the description of TransitionMutators am: 33bec91aec am: 8530c625b9
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2923530

Change-Id: Ia38f817be92234d11d6a09d5da7f635085741f1b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-24 21:16:05 +00:00
Colin Cross
1236187824 Merge changes from topic "transition-mutator-config" into main am: 1b3fe6bd2c
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2922240

Change-Id: I881619ef13ed58d5fd65fe03d6923b76f8d7d7c7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-24 20:36:28 +00:00
Colin Cross
8530c625b9 Fix OutgoingTransitionContext to match the description of TransitionMutators am: 33bec91aec
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2923530

Change-Id: I8f76a7cdc0694e0f8ea34fb1b17ade729a6cf412
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-24 20:36:25 +00:00
Colin Cross
1b3fe6bd2c Merge changes from topic "transition-mutator-config" into main
* changes:
  Add Config() to TransitionMutator contexts
  Fix OutgoingTransitionContext to match the description of TransitionMutators
2024-01-24 20:03:46 +00:00
Colin Cross
9c2f78f6c4 Add Config() to TransitionMutator contexts
Test: builds
Change-Id: Iadcea3081d8537220d54b4eeb1ba3691105e1d82
2024-01-22 17:18:45 -08:00
Colin Cross
33bec91aec Fix OutgoingTransitionContext to match the description of TransitionMutators
The description of TransitionMutators says that "the outgoing transition
should not take the properties of the dependency into account, only those
of the module that depends on it. For this reason, the dependency is not
even passed into it as an argument."  However, OutgoingTransitionContext
was returing the dependency from ctx.Module(), not the parent.  This
didn't matter for the only existing TransitionMutator, as it only used
the module to get a constant value.

Test: sanitize_test.go
Change-Id: I1ce5b3144787f57be4d50e95f0c923da9b2b079f
2024-01-22 17:18:40 -08:00
Cole Faust
6549a0dd63 Merge "Remove SymlinkOutputs" into main am: 079c92fb04 am: 01b4981fe2
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2917003

Change-Id: I8f2a8d7108435c8d665c043314d0fed40049da96
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 20:40:43 +00:00
Cole Faust
01b4981fe2 Merge "Remove SymlinkOutputs" into main am: 079c92fb04
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2917003

Change-Id: Icc339be8a89a9ad1bb186f6706c5e6402c7ed755
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 19:59:24 +00:00
Cole Faust
079c92fb04 Merge "Remove SymlinkOutputs" into main 2024-01-19 19:38:55 +00:00
Colin Cross
50b84b744b Fix data race in a parallel singletons calling VisitAllModules am: e70495ba9a am: 21ed16ee0b
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2917002

Change-Id: Iae60288427abfe7719f7cf1b2e2dcfdd5a7a0d15
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 01:09:25 +00:00
Colin Cross
76ea0d18ba Move name memoization out of variables am: 6bc984abca am: c0b0a19454
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2917001

Change-Id: Idd457cc6d067422653136c272915eb3dc2e302d5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 01:09:17 +00:00
Colin Cross
21ed16ee0b Fix data race in a parallel singletons calling VisitAllModules am: e70495ba9a
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2917002

Change-Id: I1ed3c25b4e82337337f311a0eb1b9624d7454daf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 00:48:43 +00:00
Colin Cross
c0b0a19454 Move name memoization out of variables am: 6bc984abca
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2917001

Change-Id: I240b9a3db493a0114c53195e99721644586184da
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 00:48:29 +00:00