-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'lineage-21.0' of https://github.com/LineageOS/android_b…
…uild_soong into 14
- Loading branch information
Showing
570 changed files
with
28,493 additions
and
50,388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
# Bug component: 99142 | ||
# This file is included by several other projects as the list of people | ||
# approving build related projects. | ||
|
||
# AMER | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
|
||
# APAC | ||
[email protected] | ||
|
||
# EMEA | ||
[email protected] | ||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,6 @@ review request is enough. For more substantial changes, file a bug in our | |
[bug tracker](https://issuetracker.google.com/issues/new?component=381517) or | ||
or write us at [email protected] . | ||
|
||
For Googlers, see our [internal documentation](http://go/soong). | ||
|
||
## Android.bp file format | ||
|
||
By design, Android.bp files are very simple. There are no conditionals or | ||
|
@@ -565,6 +563,12 @@ modules (`cc_defaults`, `java_defaults`, etc.), which can then be referenced | |
by all of the vendor's other modules using the normal namespace and visibility | ||
rules. | ||
|
||
`soongConfigTraceMutator` enables modules affected by soong config variables to | ||
write outputs into a hashed directory path. It does this by recording accesses | ||
to soong config variables on each module, and then accumulating records of each | ||
module's all dependencies. `m soong_config_trace` builds information about | ||
hashes to `$OUT_DIR/soong/soong_config_trace.json`. | ||
|
||
## Build logic | ||
|
||
The build logic is written in Go using the | ||
|
@@ -644,8 +648,8 @@ invocations are run in the debugger, e.g., running | |
SOONG_DELVE=2345 SOONG_DELVE_STEPS='build,modulegraph' m | ||
``` | ||
results in only `build` (main build step) and `modulegraph` being run in the debugger. | ||
The allowed step names are `api_bp2build`, `bp2build_files`, `bp2build_workspace`, | ||
`build`, `modulegraph`, `queryview`, `soong_docs`. | ||
The allowed step names are `bp2build_files`, `bp2build_workspace`, `build`, | ||
`modulegraph`, `queryview`, `soong_docs`. | ||
|
||
Note setting or unsetting `SOONG_DELVE` causes a recompilation of `soong_build`. This | ||
is because in order to debug the binary, it needs to be built with debug | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package { | ||
default_applicable_licenses: ["Android-Apache-2.0"], | ||
} | ||
|
||
bootstrap_go_package { | ||
name: "soong-aconfig", | ||
pkgPath: "android/soong/aconfig", | ||
deps: [ | ||
"blueprint", | ||
"blueprint-pathtools", | ||
"sbox_proto", | ||
"soong", | ||
"soong-android", | ||
], | ||
srcs: [ | ||
"aconfig_declarations.go", | ||
"aconfig_values.go", | ||
"aconfig_value_set.go", | ||
"all_aconfig_declarations.go", | ||
"exported_java_aconfig_library.go", | ||
"init.go", | ||
"testing.go", | ||
], | ||
testSrcs: [ | ||
"aconfig_declarations_test.go", | ||
"aconfig_values_test.go", | ||
"aconfig_value_set_test.go", | ||
], | ||
pluginFor: ["soong_build"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
// Copyright 2023 Google Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package aconfig | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"android/soong/android" | ||
|
||
"github.com/google/blueprint" | ||
) | ||
|
||
type DeclarationsModule struct { | ||
android.ModuleBase | ||
android.DefaultableModuleBase | ||
|
||
// Properties for "aconfig_declarations" | ||
properties struct { | ||
// aconfig files, relative to this Android.bp file | ||
Srcs []string `android:"path"` | ||
|
||
// Release config flag package | ||
Package string | ||
|
||
// Values from TARGET_RELEASE / RELEASE_ACONFIG_VALUE_SETS | ||
Values []string `blueprint:"mutated"` | ||
|
||
// Container(system/vendor/apex) that this module belongs to | ||
Container string | ||
} | ||
|
||
intermediatePath android.WritablePath | ||
} | ||
|
||
func DeclarationsFactory() android.Module { | ||
module := &DeclarationsModule{} | ||
|
||
android.InitAndroidModule(module) | ||
android.InitDefaultableModule(module) | ||
module.AddProperties(&module.properties) | ||
|
||
return module | ||
} | ||
|
||
type implicitValuesTagType struct { | ||
blueprint.BaseDependencyTag | ||
} | ||
|
||
var implicitValuesTag = implicitValuesTagType{} | ||
|
||
func (module *DeclarationsModule) DepsMutator(ctx android.BottomUpMutatorContext) { | ||
// Validate Properties | ||
if len(module.properties.Srcs) == 0 { | ||
ctx.PropertyErrorf("srcs", "missing source files") | ||
return | ||
} | ||
if len(module.properties.Package) == 0 { | ||
ctx.PropertyErrorf("package", "missing package property") | ||
} | ||
// TODO(b/311155208): Add mandatory check for container after all pre-existing | ||
// ones are changed. | ||
|
||
// Add a dependency on the aconfig_value_sets defined in | ||
// RELEASE_ACONFIG_VALUE_SETS, and add any aconfig_values that | ||
// match our package. | ||
valuesFromConfig := ctx.Config().ReleaseAconfigValueSets() | ||
if len(valuesFromConfig) > 0 { | ||
ctx.AddDependency(ctx.Module(), implicitValuesTag, valuesFromConfig...) | ||
} | ||
} | ||
|
||
func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) { | ||
switch tag { | ||
case "": | ||
// The default output of this module is the intermediates format, which is | ||
// not installable and in a private format that no other rules can handle | ||
// correctly. | ||
return []android.Path{module.intermediatePath}, nil | ||
default: | ||
return nil, fmt.Errorf("unsupported aconfig_declarations module reference tag %q", tag) | ||
} | ||
} | ||
|
||
func joinAndPrefix(prefix string, values []string) string { | ||
var sb strings.Builder | ||
for _, v := range values { | ||
sb.WriteString(prefix) | ||
sb.WriteString(v) | ||
} | ||
return sb.String() | ||
} | ||
|
||
func optionalVariable(prefix string, value string) string { | ||
var sb strings.Builder | ||
if value != "" { | ||
sb.WriteString(prefix) | ||
sb.WriteString(value) | ||
} | ||
return sb.String() | ||
} | ||
|
||
// Provider published by aconfig_value_set | ||
type DeclarationsProviderData struct { | ||
Package string | ||
Container string | ||
IntermediateCacheOutputPath android.WritablePath | ||
IntermediateDumpOutputPath android.WritablePath | ||
} | ||
|
||
var DeclarationsProviderKey = blueprint.NewProvider(DeclarationsProviderData{}) | ||
|
||
// This is used to collect the aconfig declarations info on the transitive closure, | ||
// the data is keyed on the container. | ||
type TransitiveDeclarationsInfo struct { | ||
AconfigFiles map[string]android.Paths | ||
} | ||
|
||
var TransitiveDeclarationsInfoProvider = blueprint.NewProvider(TransitiveDeclarationsInfo{}) | ||
|
||
func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { | ||
// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag | ||
valuesFiles := make([]android.Path, 0) | ||
ctx.VisitDirectDeps(func(dep android.Module) { | ||
if !ctx.OtherModuleHasProvider(dep, valueSetProviderKey) { | ||
// Other modules get injected as dependencies too, for example the license modules | ||
return | ||
} | ||
depData := ctx.OtherModuleProvider(dep, valueSetProviderKey).(valueSetProviderData) | ||
paths, ok := depData.AvailablePackages[module.properties.Package] | ||
if ok { | ||
valuesFiles = append(valuesFiles, paths...) | ||
for _, path := range paths { | ||
module.properties.Values = append(module.properties.Values, path.String()) | ||
} | ||
} | ||
}) | ||
|
||
// Intermediate format | ||
declarationFiles := android.PathsForModuleSrc(ctx, module.properties.Srcs) | ||
intermediateCacheFilePath := android.PathForModuleOut(ctx, "intermediate.pb") | ||
defaultPermission := ctx.Config().ReleaseAconfigFlagDefaultPermission() | ||
inputFiles := make([]android.Path, len(declarationFiles)) | ||
copy(inputFiles, declarationFiles) | ||
inputFiles = append(inputFiles, valuesFiles...) | ||
ctx.Build(pctx, android.BuildParams{ | ||
Rule: aconfigRule, | ||
Output: intermediateCacheFilePath, | ||
Inputs: inputFiles, | ||
Description: "aconfig_declarations", | ||
Args: map[string]string{ | ||
"release_version": ctx.Config().ReleaseVersion(), | ||
"package": module.properties.Package, | ||
"declarations": android.JoinPathsWithPrefix(declarationFiles, "--declarations "), | ||
"values": joinAndPrefix(" --values ", module.properties.Values), | ||
"default-permission": optionalVariable(" --default-permission ", defaultPermission), | ||
}, | ||
}) | ||
|
||
intermediateDumpFilePath := android.PathForModuleOut(ctx, "intermediate.txt") | ||
ctx.Build(pctx, android.BuildParams{ | ||
Rule: aconfigTextRule, | ||
Output: intermediateDumpFilePath, | ||
Inputs: android.Paths{intermediateCacheFilePath}, | ||
Description: "aconfig_text", | ||
}) | ||
|
||
ctx.SetProvider(DeclarationsProviderKey, DeclarationsProviderData{ | ||
Package: module.properties.Package, | ||
Container: module.properties.Container, | ||
IntermediateCacheOutputPath: intermediateCacheFilePath, | ||
IntermediateDumpOutputPath: intermediateDumpFilePath, | ||
}) | ||
|
||
} | ||
func CollectDependencyAconfigFiles(ctx android.ModuleContext, mergedAconfigFiles *map[string]android.Paths) { | ||
if *mergedAconfigFiles == nil { | ||
*mergedAconfigFiles = make(map[string]android.Paths) | ||
} | ||
ctx.VisitDirectDeps(func(module android.Module) { | ||
if dep := ctx.OtherModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData); dep.IntermediateCacheOutputPath != nil { | ||
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath) | ||
return | ||
} | ||
if dep := ctx.OtherModuleProvider(module, TransitiveDeclarationsInfoProvider).(TransitiveDeclarationsInfo); len(dep.AconfigFiles) > 0 { | ||
for container, v := range dep.AconfigFiles { | ||
(*mergedAconfigFiles)[container] = append((*mergedAconfigFiles)[container], v...) | ||
} | ||
} | ||
}) | ||
|
||
for container, aconfigFiles := range *mergedAconfigFiles { | ||
(*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles) | ||
} | ||
|
||
ctx.SetProvider(TransitiveDeclarationsInfoProvider, TransitiveDeclarationsInfo{ | ||
AconfigFiles: *mergedAconfigFiles, | ||
}) | ||
} | ||
|
||
func mergeAconfigFiles(ctx android.ModuleContext, inputs android.Paths) android.Paths { | ||
inputs = android.LastUniquePaths(inputs) | ||
if len(inputs) == 1 { | ||
return android.Paths{inputs[0]} | ||
} | ||
|
||
output := android.PathForModuleOut(ctx, "aconfig_merged.pb") | ||
|
||
ctx.Build(pctx, android.BuildParams{ | ||
Rule: mergeAconfigFilesRule, | ||
Description: "merge aconfig files", | ||
Inputs: inputs, | ||
Output: output, | ||
Args: map[string]string{ | ||
"flags": android.JoinWithPrefix(inputs.Strings(), "--cache "), | ||
}, | ||
}) | ||
|
||
return android.Paths{output} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2018 Google Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package aconfig | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"android/soong/android" | ||
) | ||
|
||
func TestAconfigDeclarations(t *testing.T) { | ||
bp := ` | ||
aconfig_declarations { | ||
name: "module_name", | ||
package: "com.example.package", | ||
container: "com.android.foo", | ||
srcs: [ | ||
"foo.aconfig", | ||
"bar.aconfig", | ||
], | ||
} | ||
` | ||
result := runTest(t, android.FixtureExpectsNoErrors, bp) | ||
|
||
module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule) | ||
|
||
// Check that the provider has the right contents | ||
depData := result.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData) | ||
android.AssertStringEquals(t, "package", depData.Package, "com.example.package") | ||
android.AssertStringEquals(t, "container", depData.Container, "com.android.foo") | ||
if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") { | ||
t.Errorf("Missing intermediates proto path in provider: %s", depData.IntermediateCacheOutputPath.String()) | ||
} | ||
if !strings.HasSuffix(depData.IntermediateDumpOutputPath.String(), "/intermediate.txt") { | ||
t.Errorf("Missing intermediates text path in provider: %s", depData.IntermediateDumpOutputPath.String()) | ||
} | ||
} |
Oops, something went wrong.