Merge "Overridden APEX doesn't contribute to the file contexts"
diff --git a/Android.bp b/Android.bp
index 6910d75..f72d624 100644
--- a/Android.bp
+++ b/Android.bp
@@ -508,7 +508,10 @@
"sdk/update.go",
],
testSrcs: [
+ "sdk/cc_sdk_test.go",
+ "sdk/java_sdk_test.go",
"sdk/sdk_test.go",
+ "sdk/testing.go",
],
pluginFor: ["soong_build"],
}
diff --git a/android/defaults.go b/android/defaults.go
index f489c02..7597446 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -151,7 +151,8 @@
module.AddProperties(
&hostAndDeviceProperties{},
commonProperties,
- &variableProperties{})
+ &variableProperties{},
+ &ApexProperties{})
InitArchModule(module)
InitDefaultableModule(module)
diff --git a/android/sdk.go b/android/sdk.go
index 01e18ed..b9220ca 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -17,6 +17,7 @@
import (
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -31,9 +32,6 @@
MemberName() string
BuildWithSdks(sdks SdkRefs)
RequiredSdks() SdkRefs
-
- // Build a snapshot of the module.
- BuildSnapshot(sdkModuleContext ModuleContext, builder SnapshotBuilder)
}
// SdkRef refers to a version of an SDK
@@ -203,3 +201,56 @@
type BpModule interface {
BpPropertySet
}
+
+// An individual member of the SDK, includes all of the variants that the SDK
+// requires.
+type SdkMember interface {
+ // The name of the member.
+ Name() string
+
+ // All the variants required by the SDK.
+ Variants() []SdkAware
+}
+
+// Interface that must be implemented for every type that can be a member of an
+// sdk.
+//
+// The basic implementation should look something like this, where ModuleType is
+// the name of the module type being supported.
+//
+// var ModuleTypeSdkMemberType = newModuleTypeSdkMemberType()
+//
+// func newModuleTypeSdkMemberType() android.SdkMemberType {
+// return &moduleTypeSdkMemberType{}
+// }
+//
+// type moduleTypeSdkMemberType struct {
+// }
+//
+// ...methods...
+//
+type SdkMemberType interface {
+ // Add dependencies from the SDK module to all the variants the member
+ // contributes to the SDK. The exact set of variants required is determined
+ // by the SDK and its properties. The dependencies must be added with the
+ // supplied tag.
+ //
+ // The BottomUpMutatorContext provided is for the SDK module.
+ AddDependencies(mctx BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string)
+
+ // Return true if the supplied module is an instance of this member type.
+ //
+ // This is used to check the type of each variant before added to the
+ // SdkMember. Returning false will cause an error to be logged expaining that
+ // the module is not allowed in whichever sdk property it was added.
+ IsInstance(module Module) bool
+
+ // Build the snapshot for the SDK member
+ //
+ // The ModuleContext provided is for the SDK module, so information for
+ // variants in the supplied member can be accessed using the Other... methods.
+ //
+ // The SdkMember is guaranteed to contain variants for which the
+ // IsInstance(Module) method returned true.
+ BuildSnapshot(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember)
+}
diff --git a/apex/apex.go b/apex/apex.go
index 289175b..3dde149 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1157,12 +1157,12 @@
})
// check apex_available requirements
- if !ctx.Host() {
+ if !ctx.Host() && !a.testApex {
for _, fi := range filesInfo {
if am, ok := fi.module.(android.ApexModule); ok {
if !am.AvailableFor(ctx.ModuleName()) {
ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
- return
+ // don't stop so that we can report other violations in the same run
}
}
}
diff --git a/cc/cc.go b/cc/cc.go
index f306a00..733bda6 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2459,7 +2459,6 @@
&PgoProperties{},
&XomProperties{},
&android.ProtoProperties{},
- &android.ApexProperties{},
)
android.InitDefaultsModule(module)
diff --git a/cc/compiler.go b/cc/compiler.go
index 671861b..2bc6ae2 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -27,6 +27,10 @@
"android/soong/cc/config"
)
+var (
+ allowedManualInterfacePaths = []string{"vendor/", "hardware/"}
+)
+
// This file contains the basic C/C++/assembly to .o compliation steps
type BaseCompilerProperties struct {
@@ -509,6 +513,12 @@
flags.Local.CFlags = append(flags.Local.CFlags, "-fopenmp")
}
+ // Exclude directories from manual binder interface whitelisting.
+ //TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths.
+ if android.PrefixInList(ctx.ModuleDir(), allowedManualInterfacePaths) {
+ flags.Local.CFlags = append(flags.Local.CFlags, "-DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES")
+ }
+
return flags
}
diff --git a/cc/config/clang.go b/cc/config/clang.go
index eddc341..8618d09 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -132,6 +132,10 @@
// Disable -Winconsistent-missing-override until we can clean up the existing
// codebase for it.
"-Wno-inconsistent-missing-override",
+
+ // Warnings from clang-10
+ // Nested and array designated initialization is nice to have.
+ "-Wno-c99-designator",
}, " "))
pctx.StaticVariable("ClangExtraCppflags", strings.Join([]string{
@@ -161,6 +165,10 @@
// new warnings are fixed.
"-Wno-tautological-constant-compare",
"-Wno-tautological-type-limit-compare",
+ // http://b/145210666
+ "-Wno-reorder-init-list",
+ // http://b/145211066
+ "-Wno-implicit-int-float-conversion",
}, " "))
// Extra cflags for external third-party projects to disable warnings that
@@ -176,6 +184,13 @@
// Bug: http://b/29823425 Disable -Wnull-dereference until the
// new instances detected by this warning are fixed.
"-Wno-null-dereference",
+
+ // http://b/145211477
+ "-Wno-pointer-compare",
+ // http://b/145211022
+ "-Wno-xor-used-as-pow",
+ // http://b/145211022
+ "-Wno-final-dtor-non-final-class",
}, " "))
}
diff --git a/cc/config/global.go b/cc/config/global.go
index 0943126..bae5555 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -48,6 +48,8 @@
"-fno-strict-aliasing",
"-Werror=date-time",
+ "-Werror=pragma-pack",
+ "-Werror=pragma-pack-suspicious-include",
}
commonGlobalConlyflags = []string{}
@@ -124,8 +126,8 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r365631b"
- ClangDefaultShortVersion = "9.0.7"
+ ClangDefaultVersion = "clang-r370808"
+ ClangDefaultShortVersion = "10.0.1"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
diff --git a/cc/fuzz.go b/cc/fuzz.go
index bb89bb4..c2b0ff4 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -345,6 +345,11 @@
return
}
+ // Discard modules that are in an unavailable namespace.
+ if !ccModule.ExportedToMake() {
+ return
+ }
+
s.fuzzTargets[module.Name()] = true
hostOrTargetString := "target"
diff --git a/cc/library.go b/cc/library.go
index 98cae3d..60b00b1 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -24,6 +24,7 @@
"strings"
"sync"
+ "github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"android/soong/android"
@@ -1403,3 +1404,230 @@
return outputFile
}
+
+var LibrarySdkMemberType = &librarySdkMemberType{}
+
+type librarySdkMemberType struct {
+}
+
+func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
+ targets := mctx.MultiTargets()
+ for _, lib := range names {
+ for _, target := range targets {
+ name, version := StubsLibNameAndVersion(lib)
+ if version == "" {
+ version = LatestStubsVersionFor(mctx.Config(), name)
+ }
+ mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
+ {Mutator: "image", Variation: android.CoreVariation},
+ {Mutator: "link", Variation: "shared"},
+ {Mutator: "version", Variation: version},
+ }...), dependencyTag, name)
+ }
+ }
+}
+
+func (mt *librarySdkMemberType) IsInstance(module android.Module) bool {
+ _, ok := module.(*Module)
+ return ok
+}
+
+// copy exported header files and stub *.so files
+func (mt *librarySdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
+ info := organizeVariants(member)
+ buildSharedNativeLibSnapshot(sdkModuleContext, info, builder)
+}
+
+func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder) {
+ // a function for emitting include dirs
+ printExportedDirCopyCommandsForNativeLibs := func(lib archSpecificNativeLibInfo) {
+ includeDirs := lib.exportedIncludeDirs
+ includeDirs = append(includeDirs, lib.exportedSystemIncludeDirs...)
+ if len(includeDirs) == 0 {
+ return
+ }
+ for _, dir := range includeDirs {
+ if _, gen := dir.(android.WritablePath); gen {
+ // generated headers are copied via exportedDeps. See below.
+ continue
+ }
+ targetDir := nativeIncludeDir
+ if info.hasArchSpecificFlags {
+ targetDir = filepath.Join(lib.archType, targetDir)
+ }
+
+ // TODO(jiyong) copy headers having other suffixes
+ headers, _ := sdkModuleContext.GlobWithDeps(dir.String()+"/**/*.h", nil)
+ for _, file := range headers {
+ src := android.PathForSource(sdkModuleContext, file)
+ dest := filepath.Join(targetDir, file)
+ builder.CopyToSnapshot(src, dest)
+ }
+ }
+
+ genHeaders := lib.exportedDeps
+ for _, file := range genHeaders {
+ targetDir := nativeGeneratedIncludeDir
+ if info.hasArchSpecificFlags {
+ targetDir = filepath.Join(lib.archType, targetDir)
+ }
+ dest := filepath.Join(targetDir, lib.name, file.Rel())
+ builder.CopyToSnapshot(file, dest)
+ }
+ }
+
+ if !info.hasArchSpecificFlags {
+ printExportedDirCopyCommandsForNativeLibs(info.archVariants[0])
+ }
+
+ // for each architecture
+ for _, av := range info.archVariants {
+ builder.CopyToSnapshot(av.outputFile, nativeStubFilePathFor(av))
+
+ if info.hasArchSpecificFlags {
+ printExportedDirCopyCommandsForNativeLibs(av)
+ }
+ }
+
+ info.generatePrebuiltLibrary(sdkModuleContext, builder)
+}
+
+func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder) {
+
+ // a function for emitting include dirs
+ addExportedDirsForNativeLibs := func(lib archSpecificNativeLibInfo, properties android.BpPropertySet, systemInclude bool) {
+ includeDirs := nativeIncludeDirPathsFor(lib, systemInclude, info.hasArchSpecificFlags)
+ if len(includeDirs) == 0 {
+ return
+ }
+ var propertyName string
+ if !systemInclude {
+ propertyName = "export_include_dirs"
+ } else {
+ propertyName = "export_system_include_dirs"
+ }
+ properties.AddProperty(propertyName, includeDirs)
+ }
+
+ pbm := builder.AddPrebuiltModule(info.name, "cc_prebuilt_library_shared")
+
+ if !info.hasArchSpecificFlags {
+ addExportedDirsForNativeLibs(info.archVariants[0], pbm, false /*systemInclude*/)
+ addExportedDirsForNativeLibs(info.archVariants[0], pbm, true /*systemInclude*/)
+ }
+
+ archProperties := pbm.AddPropertySet("arch")
+ for _, av := range info.archVariants {
+ archTypeProperties := archProperties.AddPropertySet(av.archType)
+ archTypeProperties.AddProperty("srcs", []string{nativeStubFilePathFor(av)})
+ if info.hasArchSpecificFlags {
+ // export_* properties are added inside the arch: {<arch>: {...}} block
+ addExportedDirsForNativeLibs(av, archTypeProperties, false /*systemInclude*/)
+ addExportedDirsForNativeLibs(av, archTypeProperties, true /*systemInclude*/)
+ }
+ }
+ pbm.AddProperty("stl", "none")
+ pbm.AddProperty("system_shared_libs", []string{})
+}
+
+const (
+ nativeIncludeDir = "include"
+ nativeGeneratedIncludeDir = "include_gen"
+ nativeStubDir = "lib"
+ nativeStubFileSuffix = ".so"
+)
+
+// path to the stub file of a native shared library. Relative to <sdk_root>/<api_dir>
+func nativeStubFilePathFor(lib archSpecificNativeLibInfo) string {
+ return filepath.Join(lib.archType,
+ nativeStubDir, lib.name+nativeStubFileSuffix)
+}
+
+// paths to the include dirs of a native shared library. Relative to <sdk_root>/<api_dir>
+func nativeIncludeDirPathsFor(lib archSpecificNativeLibInfo, systemInclude bool, archSpecific bool) []string {
+ var result []string
+ var includeDirs []android.Path
+ if !systemInclude {
+ includeDirs = lib.exportedIncludeDirs
+ } else {
+ includeDirs = lib.exportedSystemIncludeDirs
+ }
+ for _, dir := range includeDirs {
+ var path string
+ if _, gen := dir.(android.WritablePath); gen {
+ path = filepath.Join(nativeGeneratedIncludeDir, lib.name)
+ } else {
+ path = filepath.Join(nativeIncludeDir, dir.String())
+ }
+ if archSpecific {
+ path = filepath.Join(lib.archType, path)
+ }
+ result = append(result, path)
+ }
+ return result
+}
+
+// archSpecificNativeLibInfo represents an arch-specific variant of a native lib
+type archSpecificNativeLibInfo struct {
+ name string
+ archType string
+ exportedIncludeDirs android.Paths
+ exportedSystemIncludeDirs android.Paths
+ exportedFlags []string
+ exportedDeps android.Paths
+ outputFile android.Path
+}
+
+func (lib *archSpecificNativeLibInfo) signature() string {
+ return fmt.Sprintf("%v %v %v %v",
+ lib.name,
+ lib.exportedIncludeDirs.Strings(),
+ lib.exportedSystemIncludeDirs.Strings(),
+ lib.exportedFlags)
+}
+
+// nativeLibInfo represents a collection of arch-specific modules having the same name
+type nativeLibInfo struct {
+ name string
+ archVariants []archSpecificNativeLibInfo
+ // hasArchSpecificFlags is set to true if modules for each architecture all have the same
+ // include dirs, flags, etc, in which case only those of the first arch is selected.
+ hasArchSpecificFlags bool
+}
+
+// Organize the variants by architecture.
+func organizeVariants(member android.SdkMember) *nativeLibInfo {
+ info := &nativeLibInfo{name: member.Name()}
+
+ for _, variant := range member.Variants() {
+ ccModule := variant.(*Module)
+
+ info.archVariants = append(info.archVariants, archSpecificNativeLibInfo{
+ name: ccModule.BaseModuleName(),
+ archType: ccModule.Target().Arch.ArchType.String(),
+ exportedIncludeDirs: ccModule.ExportedIncludeDirs(),
+ exportedSystemIncludeDirs: ccModule.ExportedSystemIncludeDirs(),
+ exportedFlags: ccModule.ExportedFlags(),
+ exportedDeps: ccModule.ExportedDeps(),
+ outputFile: ccModule.OutputFile().Path(),
+ })
+ }
+
+ // Determine if include dirs and flags for each variant are different across arch-specific
+ // variants or not. And set hasArchSpecificFlags accordingly
+ // by default, include paths and flags are assumed to be the same across arches
+ info.hasArchSpecificFlags = false
+ oldSignature := ""
+ for _, av := range info.archVariants {
+ newSignature := av.signature()
+ if oldSignature == "" {
+ oldSignature = newSignature
+ }
+ if oldSignature != newSignature {
+ info.hasArchSpecificFlags = true
+ break
+ }
+ }
+
+ return info
+}
diff --git a/cc/makevars.go b/cc/makevars.go
index e8cedf0..0f9f4c1 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -147,6 +147,7 @@
ctx.Strict("WITH_TIDY_FLAGS", "${config.TidyWithTidyFlags}")
ctx.Strict("AIDL_CPP", "${aidlCmd}")
+ ctx.Strict("ALLOWED_MANUAL_INTERFACE_PATHS", strings.Join(allowedManualInterfacePaths, " "))
ctx.Strict("M4", "${m4Cmd}")
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index c47cbf0..da94d33 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -261,6 +261,7 @@
// We're knowingly doing some otherwise unsightly things with builtin
// functions here. We're just generating stub libraries, so ignore it.
"-Wno-incompatible-library-redeclaration",
+ "-Wno-incomplete-setjmp-declaration",
"-Wno-builtin-requires-header",
"-Wno-invalid-noreturn",
"-Wall",
diff --git a/cmd/multiproduct_kati/Android.bp b/cmd/multiproduct_kati/Android.bp
index 13b3679..d34f8c3 100644
--- a/cmd/multiproduct_kati/Android.bp
+++ b/cmd/multiproduct_kati/Android.bp
@@ -24,4 +24,7 @@
srcs: [
"main.go",
],
+ testSrcs: [
+ "main_test.go",
+ ],
}
diff --git a/cmd/multiproduct_kati/main.go b/cmd/multiproduct_kati/main.go
index 2800ade..4771206 100644
--- a/cmd/multiproduct_kati/main.go
+++ b/cmd/multiproduct_kati/main.go
@@ -64,6 +64,9 @@
var skipProducts = flag.String("skip-products", "", "comma-separated list of products to skip (known failures, etc)")
var includeProducts = flag.String("products", "", "comma-separated list of products to build")
+var shardCount = flag.Int("shard-count", 1, "split the products into multiple shards (to spread the build onto multiple machines, etc)")
+var shard = flag.Int("shard", 1, "1-indexed shard to execute")
+
const errorLeadingLines = 20
const errorTrailingLines = 20
@@ -278,6 +281,17 @@
}
}
+ if *shard < 1 {
+ log.Fatalf("--shard value must be >= 1, not %d\n", *shard)
+ } else if *shardCount < 1 {
+ log.Fatalf("--shard-count value must be >= 1, not %d\n", *shardCount)
+ } else if *shard > *shardCount {
+ log.Fatalf("--shard (%d) must not be greater than --shard-count (%d)\n", *shard,
+ *shardCount)
+ } else if *shardCount > 1 {
+ finalProductsList = splitList(finalProductsList, *shardCount)[*shard-1]
+ }
+
log.Verbose("Got product list: ", finalProductsList)
s := buildCtx.Status.StartTool()
@@ -472,3 +486,18 @@
// discard writes
return len(p), nil
}
+
+func splitList(list []string, shardCount int) (ret [][]string) {
+ each := len(list) / shardCount
+ extra := len(list) % shardCount
+ for i := 0; i < shardCount; i++ {
+ count := each
+ if extra > 0 {
+ count += 1
+ extra -= 1
+ }
+ ret = append(ret, list[:count])
+ list = list[count:]
+ }
+ return
+}
diff --git a/cmd/multiproduct_kati/main_test.go b/cmd/multiproduct_kati/main_test.go
new file mode 100644
index 0000000..263a124
--- /dev/null
+++ b/cmd/multiproduct_kati/main_test.go
@@ -0,0 +1,93 @@
+// Copyright 2019 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 main
+
+import (
+ "fmt"
+ "reflect"
+ "testing"
+)
+
+func TestSplitList(t *testing.T) {
+ testcases := []struct {
+ inputCount int
+ shardCount int
+ want [][]string
+ }{
+ {
+ inputCount: 1,
+ shardCount: 1,
+ want: [][]string{{"1"}},
+ },
+ {
+ inputCount: 1,
+ shardCount: 2,
+ want: [][]string{{"1"}, {}},
+ },
+ {
+ inputCount: 4,
+ shardCount: 2,
+ want: [][]string{{"1", "2"}, {"3", "4"}},
+ },
+ {
+ inputCount: 19,
+ shardCount: 10,
+ want: [][]string{
+ {"1", "2"},
+ {"3", "4"},
+ {"5", "6"},
+ {"7", "8"},
+ {"9", "10"},
+ {"11", "12"},
+ {"13", "14"},
+ {"15", "16"},
+ {"17", "18"},
+ {"19"},
+ },
+ },
+ {
+ inputCount: 15,
+ shardCount: 10,
+ want: [][]string{
+ {"1", "2"},
+ {"3", "4"},
+ {"5", "6"},
+ {"7", "8"},
+ {"9", "10"},
+ {"11"},
+ {"12"},
+ {"13"},
+ {"14"},
+ {"15"},
+ },
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(fmt.Sprintf("%d/%d", tc.inputCount, tc.shardCount), func(t *testing.T) {
+ input := []string{}
+ for i := 1; i <= tc.inputCount; i++ {
+ input = append(input, fmt.Sprintf("%d", i))
+ }
+
+ got := splitList(input, tc.shardCount)
+
+ if !reflect.DeepEqual(got, tc.want) {
+ t.Errorf("unexpected result for splitList([]string{...%d...}, %d):\nwant: %v\n got: %v\n",
+ tc.inputCount, tc.shardCount, tc.want, got)
+ }
+ })
+ }
+}
diff --git a/cuj/Android.bp b/cuj/Android.bp
new file mode 100644
index 0000000..21d667f
--- /dev/null
+++ b/cuj/Android.bp
@@ -0,0 +1,12 @@
+blueprint_go_binary {
+ name: "cuj_tests",
+ deps: [
+ "soong-ui-build",
+ "soong-ui-logger",
+ "soong-ui-terminal",
+ "soong-ui-tracer",
+ ],
+ srcs: [
+ "cuj.go",
+ ],
+}
diff --git a/cuj/cuj.go b/cuj/cuj.go
new file mode 100644
index 0000000..c7ff8ff
--- /dev/null
+++ b/cuj/cuj.go
@@ -0,0 +1,190 @@
+// Copyright 2019 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.
+
+// This executable runs a series of build commands to test and benchmark some critical user journeys.
+package main
+
+import (
+ "context"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "time"
+
+ "android/soong/ui/build"
+ "android/soong/ui/logger"
+ "android/soong/ui/metrics"
+ "android/soong/ui/status"
+ "android/soong/ui/terminal"
+ "android/soong/ui/tracer"
+)
+
+type Test struct {
+ name string
+ args []string
+
+ results TestResults
+}
+
+type TestResults struct {
+ metrics *metrics.Metrics
+ err error
+}
+
+// Run runs a single build command. It emulates the "m" command line by calling into Soong UI directly.
+func (t *Test) Run(logsDir string) {
+ output := terminal.NewStatusOutput(os.Stdout, "", false, false)
+
+ log := logger.New(output)
+ defer log.Cleanup()
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ trace := tracer.New(log)
+ defer trace.Close()
+
+ met := metrics.New()
+
+ stat := &status.Status{}
+ defer stat.Finish()
+ stat.AddOutput(output)
+ stat.AddOutput(trace.StatusTracer())
+
+ build.SetupSignals(log, cancel, func() {
+ trace.Close()
+ log.Cleanup()
+ stat.Finish()
+ })
+
+ buildCtx := build.Context{ContextImpl: &build.ContextImpl{
+ Context: ctx,
+ Logger: log,
+ Metrics: met,
+ Tracer: trace,
+ Writer: output,
+ Status: stat,
+ }}
+
+ defer logger.Recover(func(err error) {
+ t.results.err = err
+ })
+
+ config := build.NewConfig(buildCtx, t.args...)
+ build.SetupOutDir(buildCtx, config)
+
+ os.MkdirAll(logsDir, 0777)
+ log.SetOutput(filepath.Join(logsDir, "soong.log"))
+ trace.SetOutput(filepath.Join(logsDir, "build.trace"))
+ stat.AddOutput(status.NewVerboseLog(log, filepath.Join(logsDir, "verbose.log")))
+ stat.AddOutput(status.NewErrorLog(log, filepath.Join(logsDir, "error.log")))
+ stat.AddOutput(status.NewProtoErrorLog(log, filepath.Join(logsDir, "build_error")))
+ stat.AddOutput(status.NewCriticalPath(log))
+
+ defer met.Dump(filepath.Join(logsDir, "soong_metrics"))
+
+ if start, ok := os.LookupEnv("TRACE_BEGIN_SOONG"); ok {
+ if !strings.HasSuffix(start, "N") {
+ if start_time, err := strconv.ParseUint(start, 10, 64); err == nil {
+ log.Verbosef("Took %dms to start up.",
+ time.Since(time.Unix(0, int64(start_time))).Nanoseconds()/time.Millisecond.Nanoseconds())
+ buildCtx.CompleteTrace(metrics.RunSetupTool, "startup", start_time, uint64(time.Now().UnixNano()))
+ }
+ }
+
+ if executable, err := os.Executable(); err == nil {
+ trace.ImportMicrofactoryLog(filepath.Join(filepath.Dir(executable), "."+filepath.Base(executable)+".trace"))
+ }
+ }
+
+ f := build.NewSourceFinder(buildCtx, config)
+ defer f.Shutdown()
+ build.FindSources(buildCtx, config, f)
+
+ build.Build(buildCtx, config, build.BuildAll)
+
+ t.results.metrics = met
+}
+
+func main() {
+ outDir := os.Getenv("OUT_DIR")
+ if outDir == "" {
+ outDir = "out"
+ }
+
+ cujDir := filepath.Join(outDir, "cuj_tests")
+
+ // Use a subdirectory for the out directory for the tests to keep them isolated.
+ os.Setenv("OUT_DIR", filepath.Join(cujDir, "out"))
+
+ // Each of these tests is run in sequence without resetting the output tree. The state of the output tree will
+ // affect each successive test. To maintain the validity of the benchmarks across changes, care must be taken
+ // to avoid changing the state of the tree when a test is run. This is most easily accomplished by adding tests
+ // at the end.
+ tests := []Test{
+ {
+ // Reset the out directory to get reproducible results.
+ name: "clean",
+ args: []string{"clean"},
+ },
+ {
+ // Parse the build files.
+ name: "nothing",
+ args: []string{"nothing"},
+ },
+ {
+ // Parse the build files again to monitor issues like globs rerunning.
+ name: "nothing_rebuild",
+ args: []string{"nothing"},
+ },
+ {
+ // Parse the build files again, this should always be very short.
+ name: "nothing_rebuild_twice",
+ args: []string{"nothing"},
+ },
+ {
+ // Build the framework as a common developer task and one that keeps getting longer.
+ name: "framework",
+ args: []string{"framework"},
+ },
+ {
+ // Build the framework again to make sure it doesn't rebuild anything.
+ name: "framework_rebuild",
+ args: []string{"framework"},
+ },
+ {
+ // Build the framework again to make sure it doesn't rebuild anything even if it did the second time.
+ name: "framework_rebuild_twice",
+ args: []string{"framework"},
+ },
+ }
+
+ cujMetrics := metrics.NewCriticalUserJourneysMetrics()
+ defer cujMetrics.Dump(filepath.Join(cujDir, "logs", "cuj_metrics.pb"))
+
+ for i, t := range tests {
+ logsSubDir := fmt.Sprintf("%02d_%s", i, t.name)
+ logsDir := filepath.Join(cujDir, "logs", logsSubDir)
+ t.Run(logsDir)
+ if t.results.err != nil {
+ fmt.Printf("error running test %q: %s\n", t.name, t.results.err)
+ break
+ }
+ if t.results.metrics != nil {
+ cujMetrics.Add(t.name, t.results.metrics)
+ }
+ }
+}
diff --git a/cuj/run_cuj_tests.sh b/cuj/run_cuj_tests.sh
new file mode 100755
index 0000000..b4f9f88
--- /dev/null
+++ b/cuj/run_cuj_tests.sh
@@ -0,0 +1,29 @@
+#!/bin/bash -e
+
+readonly UNAME="$(uname)"
+case "$UNAME" in
+Linux)
+ readonly OS='linux'
+ ;;
+Darwin)
+ readonly OS='darwin'
+ ;;
+*)
+ echo "Unsupported OS '$UNAME'"
+ exit 1
+ ;;
+esac
+
+readonly ANDROID_TOP="$(cd $(dirname $0)/../../..; pwd)"
+cd "$ANDROID_TOP"
+
+export OUT_DIR="${OUT_DIR:-out}"
+readonly SOONG_OUT="${OUT_DIR}/soong"
+
+build/soong/soong_ui.bash --make-mode "${SOONG_OUT}/host/${OS}-x86/bin/cuj_tests"
+
+"${SOONG_OUT}/host/${OS}-x86/bin/cuj_tests" || true
+
+if [ -n "${DIST_DIR}" ]; then
+ cp -r "${OUT_DIR}/cuj_tests/logs" "${DIST_DIR}"
+fi
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 40986c3..ee04dfd 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -495,8 +495,7 @@
}
for _, f := range global.PatternsOnSystemOther {
- // See comment of SYSTEM_OTHER_ODEX_FILTER for details on the matching.
- if makefileMatch("/"+f, dexLocation) || makefileMatch(filepath.Join(SystemPartition, f), dexLocation) {
+ if makefileMatch(filepath.Join(SystemPartition, f), dexLocation) {
return true
}
}
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index 254be0a..3264d6a 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -104,12 +104,13 @@
{module: productModule, expectedPartition: "product"},
},
},
+ // product/app/% only applies to product apps inside the system partition
{
patterns: []string{"app/%", "product/app/%"},
moduleTests: []moduleTest{
{module: systemModule, expectedPartition: "system_other/system"},
{module: systemProductModule, expectedPartition: "system_other/system/product"},
- {module: productModule, expectedPartition: "system_other/product"},
+ {module: productModule, expectedPartition: "product"},
},
},
}
@@ -129,7 +130,7 @@
}
if rule.Installs().String() != wantInstalls.String() {
- t.Errorf("\npatterns: %v\nwant installs:\n %v\ngot:\n %v", test.patterns, wantInstalls, rule.Installs())
+ t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
}
}
}
diff --git a/java/app_test.go b/java/app_test.go
index fc8cf8e..c7ed49b 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -175,6 +175,95 @@
`)
}
+func TestAndroidAppLinkType(t *testing.T) {
+ testJava(t, `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ static_libs: ["baz"],
+ platform_apis: true,
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ android_library {
+ name: "baz",
+ sdk_version: "system_current",
+ srcs: ["c.java"],
+ }
+ `)
+
+ testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ sdk_version: "current",
+ static_libs: ["baz"],
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ android_library {
+ name: "baz",
+ sdk_version: "system_current",
+ srcs: ["c.java"],
+ }
+ `)
+
+ testJava(t, `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ sdk_version: "system_current",
+ static_libs: ["baz"],
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ android_library {
+ name: "baz",
+ sdk_version: "system_current",
+ srcs: ["c.java"],
+ }
+ `)
+
+ testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ sdk_version: "system_current",
+ static_libs: ["baz"],
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ android_library {
+ name: "baz",
+ srcs: ["c.java"],
+ }
+ `)
+}
+
func TestResourceDirs(t *testing.T) {
testCases := []struct {
name string
diff --git a/java/dex.go b/java/dex.go
index 5b25b21..cd6d90d 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -115,7 +115,6 @@
r8Flags = append(r8Flags, proguardRaiseDeps.FormJavaClassPath("-libraryjars"))
r8Flags = append(r8Flags, flags.bootClasspath.FormJavaClassPath("-libraryjars"))
r8Flags = append(r8Flags, flags.classpath.FormJavaClassPath("-libraryjars"))
- r8Flags = append(r8Flags, "-forceprocessing")
r8Deps = append(r8Deps, proguardRaiseDeps...)
r8Deps = append(r8Deps, flags.bootClasspath...)
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 5e72cee..88e3bc2 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -217,7 +217,7 @@
// Always create the default boot image first, to get a unique profile rule for all images.
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
// Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
- buildBootImage(ctx, artBootImageConfig(ctx))
+ d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
if global.GenerateApexImage {
// Create boot images for the JIT-zygote experiment.
d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
@@ -547,7 +547,7 @@
BuiltTool(ctx, "oatdumpd").
FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocationsDeps, ":").
- FlagWithArg("--image=", dexpreopt.PathToLocation(image.images[arch], arch)).Implicit(image.images[arch]).
+ FlagWithArg("--image=", strings.Join(image.imageLocations, ":")).Implicits(image.imagesDeps[arch].Paths()).
FlagWithOutput("--output=", output).
FlagWithArg("--instruction-set=", arch.String())
rule.Build(pctx, ctx, "dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String())
@@ -598,7 +598,6 @@
ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPathsDeps.Strings(), " "))
ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.dexLocationsDeps, " "))
ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS", strings.Join(image.imageLocations, ":"))
- ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+image.name, image.zip.String())
var imageNames []string
for _, current := range append(d.otherImages, image) {
@@ -619,6 +618,8 @@
if current.zip != nil {
}
}
+
+ ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String())
}
ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " "))
}
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 57a770e..fd1cfd4 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -226,12 +226,13 @@
c.images[arch] = imageDir.Join(ctx, imageName)
c.imagesDeps[arch] = c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex")
}
+
+ c.zip = c.dir.Join(ctx, c.name+".zip")
}
// specific to the framework config
frameworkCfg.dexPathsDeps = append(artCfg.dexPathsDeps, frameworkCfg.dexPathsDeps...)
frameworkCfg.imageLocations = append(artCfg.imageLocations, frameworkCfg.imageLocations...)
- frameworkCfg.zip = frameworkCfg.dir.Join(ctx, frameworkCfg.stem+".zip")
return configs
}).(map[string]*bootImageConfig)
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 16e6921..45a72e1 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -19,6 +19,7 @@
"path/filepath"
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -1973,7 +1974,27 @@
return module
}
-func (d *Droidstubs) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder) {
+var DroidStubsSdkMemberType = &droidStubsSdkMemberType{}
+
+type droidStubsSdkMemberType struct {
+}
+
+func (mt *droidStubsSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
+ mctx.AddVariationDependencies(nil, dependencyTag, names...)
+}
+
+func (mt *droidStubsSdkMemberType) IsInstance(module android.Module) bool {
+ _, ok := module.(*Droidstubs)
+ return ok
+}
+
+func (mt *droidStubsSdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
+ variants := member.Variants()
+ if len(variants) != 1 {
+ sdkModuleContext.ModuleErrorf("sdk contains %d variants of member %q but only one is allowed", len(variants), member.Name())
+ }
+ variant := variants[0]
+ d, _ := variant.(*Droidstubs)
stubsSrcJar := d.stubsSrcJar
snapshotRelativeDir := filepath.Join("java", d.Name()+"_stubs_sources")
diff --git a/java/java.go b/java/java.go
index 9c0fcba..71b95df 100644
--- a/java/java.go
+++ b/java/java.go
@@ -792,8 +792,7 @@
return
}
switch module.(type) {
- case *Library:
- case *AndroidLibrary:
+ case *Library, *AndroidLibrary:
if to, ok := module.(linkTypeContext); ok {
switch tag {
case bootClasspathTag, libTag, staticLibTag:
@@ -1721,7 +1720,31 @@
return filepath.Join(javaStubDir, j.Name()+javaStubFileSuffix)
}
-func (j *Library) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder) {
+var LibrarySdkMemberType = &librarySdkMemberType{}
+
+type librarySdkMemberType struct {
+}
+
+func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
+ mctx.AddVariationDependencies(nil, dependencyTag, names...)
+}
+
+func (mt *librarySdkMemberType) IsInstance(module android.Module) bool {
+ _, ok := module.(*Library)
+ return ok
+}
+
+func (mt *librarySdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
+ variants := member.Variants()
+ if len(variants) != 1 {
+ sdkModuleContext.ModuleErrorf("sdk contains %d variants of member %q but only one is allowed", len(variants), member.Name())
+ for _, variant := range variants {
+ sdkModuleContext.ModuleErrorf(" %q", variant)
+ }
+ }
+ variant := variants[0]
+ j := variant.(*Library)
+
headerJars := j.HeaderJars()
if len(headerJars) != 1 {
panic(fmt.Errorf("there must be only one header jar from %q", j.Name()))
diff --git a/java/java_test.go b/java/java_test.go
index dc498a4..b8fae8e 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -288,6 +288,94 @@
}
}
+func TestJavaLinkType(t *testing.T) {
+ testJava(t, `
+ java_library {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ static_libs: ["baz"],
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ java_library {
+ name: "baz",
+ sdk_version: "system_current",
+ srcs: ["c.java"],
+ }
+ `)
+
+ testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
+ java_library {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ sdk_version: "current",
+ static_libs: ["baz"],
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ java_library {
+ name: "baz",
+ sdk_version: "system_current",
+ srcs: ["c.java"],
+ }
+ `)
+
+ testJava(t, `
+ java_library {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ sdk_version: "system_current",
+ static_libs: ["baz"],
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ java_library {
+ name: "baz",
+ sdk_version: "system_current",
+ srcs: ["c.java"],
+ }
+ `)
+
+ testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
+ java_library {
+ name: "foo",
+ srcs: ["a.java"],
+ libs: ["bar"],
+ sdk_version: "system_current",
+ static_libs: ["baz"],
+ }
+
+ java_library {
+ name: "bar",
+ sdk_version: "current",
+ srcs: ["b.java"],
+ }
+
+ java_library {
+ name: "baz",
+ srcs: ["c.java"],
+ }
+ `)
+}
+
func TestSimple(t *testing.T) {
ctx, _ := testJava(t, `
java_library {
diff --git a/python/tests/par_test.py b/python/tests/par_test.py
index 1fafe0f..56a5063 100644
--- a/python/tests/par_test.py
+++ b/python/tests/par_test.py
@@ -44,6 +44,13 @@
assert_equal("sys.path[1]", sys.path[1], os.path.join(archive, "internal"))
assert_equal("sys.path[2]", sys.path[2], os.path.join(archive, "internal", "stdlib"))
+if os.getenv('ARGTEST', False):
+ assert_equal("len(sys.argv)", len(sys.argv), 3)
+ assert_equal("sys.argv[1]", sys.argv[1], "--arg1")
+ assert_equal("sys.argv[2]", sys.argv[2], "arg2")
+else:
+ assert_equal("len(sys.argv)", len(sys.argv), 1)
+
if failed:
sys.exit(1)
diff --git a/python/tests/runtest.sh b/python/tests/runtest.sh
index 1ecdebc..21187ed 100755
--- a/python/tests/runtest.sh
+++ b/python/tests/runtest.sh
@@ -36,8 +36,12 @@
PYTHONHOME=/usr $ANDROID_HOST_OUT/nativetest64/par_test/par_test
PYTHONPATH=/usr $ANDROID_HOST_OUT/nativetest64/par_test/par_test
+ARGTEST=true $ANDROID_HOST_OUT/nativetest64/par_test/par_test --arg1 arg2
+
PYTHONHOME= PYTHONPATH= $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3
PYTHONHOME=/usr $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3
PYTHONPATH=/usr $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3
+ARGTEST=true $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3 --arg1 arg2
+
echo "Passed!"
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
new file mode 100644
index 0000000..315669a
--- /dev/null
+++ b/sdk/cc_sdk_test.go
@@ -0,0 +1,340 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// 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 sdk
+
+import (
+ "testing"
+
+ "android/soong/cc"
+)
+
+func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
+ t.Helper()
+
+ fs := map[string][]byte{
+ "Test.cpp": nil,
+ "include/Test.h": nil,
+ "libfoo.so": nil,
+ "aidl/foo/bar/Test.aidl": nil,
+ }
+ return testSdkWithFs(t, bp, fs)
+}
+
+// Contains tests for SDK members provided by the cc package.
+
+func TestSdkIsCompileMultilibBoth(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["sdkmember"],
+ }
+
+ cc_library_shared {
+ name: "sdkmember",
+ srcs: ["Test.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_core_shared").(*cc.Module).OutputFile()
+ arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_core_shared").(*cc.Module).OutputFile()
+
+ var inputs []string
+ buildParams := result.Module("mysdk", "android_common").BuildParamsForTests()
+ for _, bp := range buildParams {
+ if bp.Input != nil {
+ inputs = append(inputs, bp.Input.String())
+ }
+ }
+
+ // ensure that both 32/64 outputs are inputs of the sdk snapshot
+ ensureListContains(t, inputs, armOutput.String())
+ ensureListContains(t, inputs, arm64Output.String())
+}
+
+func TestBasicSdkWithCc(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["sdkmember"],
+ }
+
+ sdk_snapshot {
+ name: "mysdk@1",
+ native_shared_libs: ["sdkmember_mysdk_1"],
+ }
+
+ sdk_snapshot {
+ name: "mysdk@2",
+ native_shared_libs: ["sdkmember_mysdk_2"],
+ }
+
+ cc_prebuilt_library_shared {
+ name: "sdkmember",
+ srcs: ["libfoo.so"],
+ prefer: false,
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_prebuilt_library_shared {
+ name: "sdkmember_mysdk_1",
+ sdk_member_name: "sdkmember",
+ srcs: ["libfoo.so"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_prebuilt_library_shared {
+ name: "sdkmember_mysdk_2",
+ sdk_member_name: "sdkmember",
+ srcs: ["libfoo.so"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library_shared {
+ name: "mycpplib",
+ srcs: ["Test.cpp"],
+ shared_libs: ["sdkmember"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ apex {
+ name: "myapex",
+ native_shared_libs: ["mycpplib"],
+ uses_sdks: ["mysdk@1"],
+ key: "myapex.key",
+ certificate: ":myapex.cert",
+ }
+
+ apex {
+ name: "myapex2",
+ native_shared_libs: ["mycpplib"],
+ uses_sdks: ["mysdk@2"],
+ key: "myapex.key",
+ certificate: ":myapex.cert",
+ }
+ `)
+
+ sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_core_shared_myapex").Rule("toc").Output
+ sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_core_shared_myapex2").Rule("toc").Output
+
+ cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_core_shared_myapex")
+ cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_core_shared_myapex2")
+
+ // Depending on the uses_sdks value, different libs are linked
+ ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
+ ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
+}
+
+func TestSnapshotWithCcShared(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["mynativelib"],
+ }
+
+ cc_library_shared {
+ name: "mynativelib",
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["include"],
+ aidl: {
+ export_aidl_headers: true,
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.so"],
+ export_include_dirs: [
+ "arm64/include/include",
+ "arm64/include_gen/mynativelib",
+ ],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.so"],
+ export_include_dirs: [
+ "arm/include/include",
+ "arm/include_gen/mynativelib",
+ ],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+cc_prebuilt_library_shared {
+ name: "mynativelib",
+ prefer: false,
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.so"],
+ export_include_dirs: [
+ "arm64/include/include",
+ "arm64/include_gen/mynativelib",
+ ],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.so"],
+ export_include_dirs: [
+ "arm/include/include",
+ "arm/include_gen/mynativelib",
+ ],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ native_shared_libs: ["mysdk_mynativelib@current"],
+}
+`),
+ checkAllCopyRules(`
+.intermediates/mynativelib/android_arm64_armv8-a_core_shared/mynativelib.so -> arm64/lib/mynativelib.so
+include/Test.h -> arm64/include/include/Test.h
+.intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/mynativelib.so -> arm/lib/mynativelib.so
+include/Test.h -> arm/include/include/Test.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+`),
+ )
+}
+
+func TestHostSnapshotWithCcShared(t *testing.T) {
+ // b/145598135 - Generating host snapshots for anything other than linux is not supported.
+ SkipIfNotLinux(t)
+
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ device_supported: false,
+ host_supported: true,
+ native_shared_libs: ["mynativelib"],
+ }
+
+ cc_library_shared {
+ name: "mynativelib",
+ device_supported: false,
+ host_supported: true,
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["include"],
+ aidl: {
+ export_aidl_headers: true,
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "linux_glibc_common",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ device_supported: false,
+ host_supported: true,
+ arch: {
+ x86_64: {
+ srcs: ["x86_64/lib/mynativelib.so"],
+ export_include_dirs: [
+ "x86_64/include/include",
+ "x86_64/include_gen/mynativelib",
+ ],
+ },
+ x86: {
+ srcs: ["x86/lib/mynativelib.so"],
+ export_include_dirs: [
+ "x86/include/include",
+ "x86/include_gen/mynativelib",
+ ],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+cc_prebuilt_library_shared {
+ name: "mynativelib",
+ prefer: false,
+ device_supported: false,
+ host_supported: true,
+ arch: {
+ x86_64: {
+ srcs: ["x86_64/lib/mynativelib.so"],
+ export_include_dirs: [
+ "x86_64/include/include",
+ "x86_64/include_gen/mynativelib",
+ ],
+ },
+ x86: {
+ srcs: ["x86/lib/mynativelib.so"],
+ export_include_dirs: [
+ "x86/include/include",
+ "x86/include_gen/mynativelib",
+ ],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ device_supported: false,
+ host_supported: true,
+ native_shared_libs: ["mysdk_mynativelib@current"],
+}
+`),
+ checkAllCopyRules(`
+.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
+include/Test.h -> x86_64/include/include/Test.h
+.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
+include/Test.h -> x86/include/include/Test.h
+.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+`),
+ )
+}
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
new file mode 100644
index 0000000..e87a82c
--- /dev/null
+++ b/sdk/java_sdk_test.go
@@ -0,0 +1,352 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// 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 sdk
+
+import (
+ "testing"
+)
+
+func testSdkWithJava(t *testing.T, bp string) *testSdkResult {
+ t.Helper()
+
+ fs := map[string][]byte{
+ "Test.java": nil,
+ "aidl/foo/bar/Test.aidl": nil,
+ }
+ return testSdkWithFs(t, bp, fs)
+}
+
+// Contains tests for SDK members provided by the java package.
+
+func TestBasicSdkWithJavaLibrary(t *testing.T) {
+ result := testSdkWithJava(t, `
+ sdk {
+ name: "mysdk",
+ java_libs: ["myjavalib"],
+ }
+
+ sdk_snapshot {
+ name: "mysdk@1",
+ java_libs: ["sdkmember_mysdk_1"],
+ }
+
+ sdk_snapshot {
+ name: "mysdk@2",
+ java_libs: ["sdkmember_mysdk_2"],
+ }
+
+ java_import {
+ name: "sdkmember",
+ prefer: false,
+ host_supported: true,
+ }
+
+ java_import {
+ name: "sdkmember_mysdk_1",
+ sdk_member_name: "sdkmember",
+ host_supported: true,
+ }
+
+ java_import {
+ name: "sdkmember_mysdk_2",
+ sdk_member_name: "sdkmember",
+ host_supported: true,
+ }
+
+ java_library {
+ name: "myjavalib",
+ srcs: ["Test.java"],
+ libs: ["sdkmember"],
+ system_modules: "none",
+ sdk_version: "none",
+ compile_dex: true,
+ host_supported: true,
+ }
+
+ apex {
+ name: "myapex",
+ java_libs: ["myjavalib"],
+ uses_sdks: ["mysdk@1"],
+ key: "myapex.key",
+ certificate: ":myapex.cert",
+ }
+
+ apex {
+ name: "myapex2",
+ java_libs: ["myjavalib"],
+ uses_sdks: ["mysdk@2"],
+ key: "myapex.key",
+ certificate: ":myapex.cert",
+ }
+ `)
+
+ sdkMemberV1 := result.ctx.ModuleForTests("sdkmember_mysdk_1", "android_common_myapex").Rule("combineJar").Output
+ sdkMemberV2 := result.ctx.ModuleForTests("sdkmember_mysdk_2", "android_common_myapex2").Rule("combineJar").Output
+
+ javalibForMyApex := result.ctx.ModuleForTests("myjavalib", "android_common_myapex")
+ javalibForMyApex2 := result.ctx.ModuleForTests("myjavalib", "android_common_myapex2")
+
+ // Depending on the uses_sdks value, different libs are linked
+ ensureListContains(t, pathsToStrings(javalibForMyApex.Rule("javac").Implicits), sdkMemberV1.String())
+ ensureListContains(t, pathsToStrings(javalibForMyApex2.Rule("javac").Implicits), sdkMemberV2.String())
+}
+
+func TestSnapshotWithJavaLibrary(t *testing.T) {
+ result := testSdkWithJava(t, `
+ sdk {
+ name: "mysdk",
+ java_libs: ["myjavalib"],
+ }
+
+ java_library {
+ name: "myjavalib",
+ srcs: ["Test.java"],
+ aidl: {
+ export_include_dirs: ["aidl"],
+ },
+ system_modules: "none",
+ sdk_version: "none",
+ compile_dex: true,
+ host_supported: true,
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+java_import {
+ name: "mysdk_myjavalib@current",
+ sdk_member_name: "myjavalib",
+ jars: ["java/myjavalib.jar"],
+}
+
+java_import {
+ name: "myjavalib",
+ prefer: false,
+ jars: ["java/myjavalib.jar"],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ java_libs: ["mysdk_myjavalib@current"],
+}
+
+`),
+ checkAllCopyRules(`
+.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar
+aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
+`),
+ )
+}
+
+func TestHostSnapshotWithJavaLibrary(t *testing.T) {
+ // b/145598135 - Generating host snapshots for anything other than linux is not supported.
+ SkipIfNotLinux(t)
+
+ result := testSdkWithJava(t, `
+ sdk {
+ name: "mysdk",
+ device_supported: false,
+ host_supported: true,
+ java_libs: ["myjavalib"],
+ }
+
+ java_library {
+ name: "myjavalib",
+ device_supported: false,
+ host_supported: true,
+ srcs: ["Test.java"],
+ aidl: {
+ export_include_dirs: ["aidl"],
+ },
+ system_modules: "none",
+ sdk_version: "none",
+ compile_dex: true,
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "linux_glibc_common",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+java_import {
+ name: "mysdk_myjavalib@current",
+ sdk_member_name: "myjavalib",
+ device_supported: false,
+ host_supported: true,
+ jars: ["java/myjavalib.jar"],
+}
+
+java_import {
+ name: "myjavalib",
+ prefer: false,
+ device_supported: false,
+ host_supported: true,
+ jars: ["java/myjavalib.jar"],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ device_supported: false,
+ host_supported: true,
+ java_libs: ["mysdk_myjavalib@current"],
+}
+`),
+ checkAllCopyRules(`
+.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/myjavalib.jar
+aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
+`),
+ )
+}
+
+func testSdkWithDroidstubs(t *testing.T, bp string) *testSdkResult {
+ t.Helper()
+
+ fs := map[string][]byte{
+ "foo/bar/Foo.java": nil,
+ "stubs-sources/foo/bar/Foo.java": nil,
+ }
+ return testSdkWithFs(t, bp, fs)
+}
+
+// Note: This test does not verify that a droidstubs can be referenced, either
+// directly or indirectly from an APEX as droidstubs can never be a part of an
+// apex.
+func TestBasicSdkWithDroidstubs(t *testing.T) {
+ testSdkWithDroidstubs(t, `
+ sdk {
+ name: "mysdk",
+ stubs_sources: ["mystub"],
+ }
+ sdk_snapshot {
+ name: "mysdk@10",
+ stubs_sources: ["mystub_mysdk@10"],
+ }
+ prebuilt_stubs_sources {
+ name: "mystub_mysdk@10",
+ sdk_member_name: "mystub",
+ srcs: ["stubs-sources/foo/bar/Foo.java"],
+ }
+ droidstubs {
+ name: "mystub",
+ srcs: ["foo/bar/Foo.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ java_library {
+ name: "myjavalib",
+ srcs: [":mystub"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ `)
+}
+
+func TestSnapshotWithDroidstubs(t *testing.T) {
+ result := testSdkWithDroidstubs(t, `
+ sdk {
+ name: "mysdk",
+ stubs_sources: ["myjavaapistubs"],
+ }
+
+ droidstubs {
+ name: "myjavaapistubs",
+ srcs: ["foo/bar/Foo.java"],
+ system_modules: "none",
+ sdk_version: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+prebuilt_stubs_sources {
+ name: "mysdk_myjavaapistubs@current",
+ sdk_member_name: "myjavaapistubs",
+ srcs: ["java/myjavaapistubs_stubs_sources"],
+}
+
+prebuilt_stubs_sources {
+ name: "myjavaapistubs",
+ prefer: false,
+ srcs: ["java/myjavaapistubs_stubs_sources"],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ stubs_sources: ["mysdk_myjavaapistubs@current"],
+}
+
+`),
+ checkAllCopyRules(""),
+ checkMergeZip(".intermediates/mysdk/android_common/tmp/java/myjavaapistubs_stubs_sources.zip"),
+ )
+}
+
+func TestHostSnapshotWithDroidstubs(t *testing.T) {
+ // b/145598135 - Generating host snapshots for anything other than linux is not supported.
+ SkipIfNotLinux(t)
+
+ result := testSdkWithDroidstubs(t, `
+ sdk {
+ name: "mysdk",
+ device_supported: false,
+ host_supported: true,
+ stubs_sources: ["myjavaapistubs"],
+ }
+
+ droidstubs {
+ name: "myjavaapistubs",
+ device_supported: false,
+ host_supported: true,
+ srcs: ["foo/bar/Foo.java"],
+ system_modules: "none",
+ sdk_version: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "linux_glibc_common",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+prebuilt_stubs_sources {
+ name: "mysdk_myjavaapistubs@current",
+ sdk_member_name: "myjavaapistubs",
+ device_supported: false,
+ host_supported: true,
+ srcs: ["java/myjavaapistubs_stubs_sources"],
+}
+
+prebuilt_stubs_sources {
+ name: "myjavaapistubs",
+ prefer: false,
+ device_supported: false,
+ host_supported: true,
+ srcs: ["java/myjavaapistubs_stubs_sources"],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ device_supported: false,
+ host_supported: true,
+ stubs_sources: ["mysdk_myjavaapistubs@current"],
+}
+`),
+ checkAllCopyRules(""),
+ checkMergeZip(".intermediates/mysdk/linux_glibc_common/tmp/java/myjavaapistubs_stubs_sources.zip"),
+ )
+}
diff --git a/sdk/sdk.go b/sdk/sdk.go
index 431ace9..75c8585 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -27,14 +27,25 @@
// registered before mutators in this package. See RegisterPostDepsMutators for more details.
_ "android/soong/apex"
"android/soong/cc"
+ "android/soong/java"
)
func init() {
pctx.Import("android/soong/android")
+ pctx.Import("android/soong/java/config")
+
android.RegisterModuleType("sdk", ModuleFactory)
android.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory)
android.PreDepsMutators(RegisterPreDepsMutators)
android.PostDepsMutators(RegisterPostDepsMutators)
+
+ // Populate the dependency tags for each member list property. This needs to
+ // be done here to break an initialization cycle.
+ for _, memberListProperty := range sdkMemberListProperties {
+ memberListProperty.dependencyTag = &sdkMemberDependencyTag{
+ memberListProperty: memberListProperty,
+ }
+ }
}
type sdk struct {
@@ -60,6 +71,52 @@
Snapshot bool `blueprint:"mutated"`
}
+type sdkMemberDependencyTag struct {
+ blueprint.BaseDependencyTag
+ memberListProperty *sdkMemberListProperty
+}
+
+// Contains information about the sdk properties that list sdk members, e.g.
+// Java_libs.
+type sdkMemberListProperty struct {
+ // the name of the property as used in a .bp file
+ name string
+
+ // getter for the list of member names
+ getter func(properties *sdkProperties) []string
+
+ // the type of member referenced in the list
+ memberType android.SdkMemberType
+
+ // the dependency tag used for items in this list.
+ dependencyTag *sdkMemberDependencyTag
+}
+
+// Information about how to handle each member list property.
+//
+// It is organized first by package and then by name within the package.
+// Packages are in alphabetical order and properties are in alphabetical order
+// within each package.
+var sdkMemberListProperties = []*sdkMemberListProperty{
+ // Members from cc package.
+ {
+ name: "native_shared_libs",
+ getter: func(properties *sdkProperties) []string { return properties.Native_shared_libs },
+ memberType: cc.LibrarySdkMemberType,
+ },
+ // Members from java package.
+ {
+ name: "java_libs",
+ getter: func(properties *sdkProperties) []string { return properties.Java_libs },
+ memberType: java.LibrarySdkMemberType,
+ },
+ {
+ name: "stubs_sources",
+ getter: func(properties *sdkProperties) []string { return properties.Stubs_sources },
+ memberType: java.DroidStubsSdkMemberType,
+ },
+}
+
// sdk defines an SDK which is a logical group of modules (e.g. native libs, headers, java libs, etc.)
// which Mainline modules like APEX can choose to build with.
func ModuleFactory() android.Module {
@@ -143,10 +200,6 @@
blueprint.BaseDependencyTag
}
-// For dependencies from an SDK module to its members
-// e.g. mysdk -> libfoo and libbar
-var sdkMemberDepTag dependencyTag
-
// For dependencies from an in-development version of an SDK member to frozen versions of the same member
// e.g. libfoo -> libfoo.mysdk.11 and libfoo.mysdk.12
type sdkMemberVesionedDepTag struct {
@@ -158,22 +211,10 @@
// Step 1: create dependencies from an SDK module to its members.
func memberMutator(mctx android.BottomUpMutatorContext) {
if m, ok := mctx.Module().(*sdk); ok {
- mctx.AddVariationDependencies(nil, sdkMemberDepTag, m.properties.Java_libs...)
- mctx.AddVariationDependencies(nil, sdkMemberDepTag, m.properties.Stubs_sources...)
-
- targets := mctx.MultiTargets()
- for _, target := range targets {
- for _, lib := range m.properties.Native_shared_libs {
- name, version := cc.StubsLibNameAndVersion(lib)
- if version == "" {
- version = cc.LatestStubsVersionFor(mctx.Config(), name)
- }
- mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: android.CoreVariation},
- {Mutator: "link", Variation: "shared"},
- {Mutator: "version", Variation: version},
- }...), sdkMemberDepTag, name)
- }
+ for _, memberListProperty := range sdkMemberListProperties {
+ names := memberListProperty.getter(&m.properties)
+ tag := memberListProperty.dependencyTag
+ memberListProperty.memberType.AddDependencies(mctx, tag, names)
}
}
}
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 5435ef6..0a9dfb1 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -15,326 +15,12 @@
package sdk
import (
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
"testing"
-
- "android/soong/android"
- "android/soong/apex"
- "android/soong/cc"
- "android/soong/java"
)
-func testSdkContext(t *testing.T, bp string) (*android.TestContext, android.Config) {
- config := android.TestArchConfig(buildDir, nil)
- ctx := android.NewTestArchContext()
-
- // from android package
- ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
- ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
- })
- ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.TopDown("prebuilt_select", android.PrebuiltSelectModuleMutator).Parallel()
- ctx.BottomUp("prebuilt_postdeps", android.PrebuiltPostDepsMutator).Parallel()
- })
-
- // from java package
- ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
- ctx.RegisterModuleType("java_library", java.LibraryFactory)
- ctx.RegisterModuleType("java_import", java.ImportFactory)
- ctx.RegisterModuleType("droidstubs", java.DroidstubsFactory)
- ctx.RegisterModuleType("prebuilt_stubs_sources", java.PrebuiltStubsSourcesFactory)
-
- // from cc package
- ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
- ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
- ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
- ctx.RegisterModuleType("cc_prebuilt_library_shared", cc.PrebuiltSharedLibraryFactory)
- ctx.RegisterModuleType("cc_prebuilt_library_static", cc.PrebuiltStaticLibraryFactory)
- ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
- ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
- ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("image", android.ImageMutator).Parallel()
- ctx.BottomUp("link", cc.LinkageMutator).Parallel()
- ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
- ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
- ctx.BottomUp("version", cc.VersionMutator).Parallel()
- ctx.BottomUp("begin", cc.BeginMutator).Parallel()
- })
-
- // from apex package
- ctx.RegisterModuleType("apex", apex.BundleFactory)
- ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
- ctx.PostDepsMutators(apex.RegisterPostDepsMutators)
-
- // from this package
- ctx.RegisterModuleType("sdk", ModuleFactory)
- ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory)
- ctx.PreDepsMutators(RegisterPreDepsMutators)
- ctx.PostDepsMutators(RegisterPostDepsMutators)
-
- ctx.Register()
-
- bp = bp + `
- apex_key {
- name: "myapex.key",
- public_key: "myapex.avbpubkey",
- private_key: "myapex.pem",
- }
-
- android_app_certificate {
- name: "myapex.cert",
- certificate: "myapex",
- }
- ` + cc.GatherRequiredDepsForTest(android.Android)
-
- ctx.MockFileSystem(map[string][]byte{
- "Android.bp": []byte(bp),
- "build/make/target/product/security": nil,
- "apex_manifest.json": nil,
- "system/sepolicy/apex/myapex-file_contexts": nil,
- "system/sepolicy/apex/myapex2-file_contexts": nil,
- "myapex.avbpubkey": nil,
- "myapex.pem": nil,
- "myapex.x509.pem": nil,
- "myapex.pk8": nil,
- "Test.java": nil,
- "Test.cpp": nil,
- "include/Test.h": nil,
- "aidl/foo/bar/Test.aidl": nil,
- "libfoo.so": nil,
- "stubs-sources/foo/bar/Foo.java": nil,
- "foo/bar/Foo.java": nil,
- })
-
- return ctx, config
-}
-
-func testSdk(t *testing.T, bp string) (*android.TestContext, android.Config) {
- ctx, config := testSdkContext(t, bp)
- _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
- android.FailIfErrored(t, errs)
- _, errs = ctx.PrepareBuildActions(config)
- android.FailIfErrored(t, errs)
- return ctx, config
-}
-
-func testSdkError(t *testing.T, pattern, bp string) {
- t.Helper()
- ctx, config := testSdkContext(t, bp)
- _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
- if len(errs) > 0 {
- android.FailIfNoMatchingErrors(t, pattern, errs)
- return
- }
- _, errs = ctx.PrepareBuildActions(config)
- if len(errs) > 0 {
- android.FailIfNoMatchingErrors(t, pattern, errs)
- return
- }
-
- t.Fatalf("missing expected error %q (0 errors are returned)", pattern)
-}
-
-func ensureListContains(t *testing.T, result []string, expected string) {
- t.Helper()
- if !android.InList(expected, result) {
- t.Errorf("%q is not found in %v", expected, result)
- }
-}
-
-func pathsToStrings(paths android.Paths) []string {
- ret := []string{}
- for _, p := range paths {
- ret = append(ret, p.String())
- }
- return ret
-}
-
-func TestBasicSdkWithJava(t *testing.T) {
- ctx, _ := testSdk(t, `
- sdk {
- name: "mysdk",
- java_libs: ["sdkmember"],
- }
-
- sdk_snapshot {
- name: "mysdk@1",
- java_libs: ["sdkmember_mysdk_1"],
- }
-
- sdk_snapshot {
- name: "mysdk@2",
- java_libs: ["sdkmember_mysdk_2"],
- }
-
- java_import {
- name: "sdkmember",
- prefer: false,
- host_supported: true,
- }
-
- java_import {
- name: "sdkmember_mysdk_1",
- sdk_member_name: "sdkmember",
- host_supported: true,
- }
-
- java_import {
- name: "sdkmember_mysdk_2",
- sdk_member_name: "sdkmember",
- host_supported: true,
- }
-
- java_library {
- name: "myjavalib",
- srcs: ["Test.java"],
- libs: ["sdkmember"],
- system_modules: "none",
- sdk_version: "none",
- compile_dex: true,
- host_supported: true,
- }
-
- apex {
- name: "myapex",
- java_libs: ["myjavalib"],
- uses_sdks: ["mysdk@1"],
- key: "myapex.key",
- certificate: ":myapex.cert",
- }
-
- apex {
- name: "myapex2",
- java_libs: ["myjavalib"],
- uses_sdks: ["mysdk@2"],
- key: "myapex.key",
- certificate: ":myapex.cert",
- }
- `)
-
- sdkMemberV1 := ctx.ModuleForTests("sdkmember_mysdk_1", "android_common_myapex").Rule("combineJar").Output
- sdkMemberV2 := ctx.ModuleForTests("sdkmember_mysdk_2", "android_common_myapex2").Rule("combineJar").Output
-
- javalibForMyApex := ctx.ModuleForTests("myjavalib", "android_common_myapex")
- javalibForMyApex2 := ctx.ModuleForTests("myjavalib", "android_common_myapex2")
-
- // Depending on the uses_sdks value, different libs are linked
- ensureListContains(t, pathsToStrings(javalibForMyApex.Rule("javac").Implicits), sdkMemberV1.String())
- ensureListContains(t, pathsToStrings(javalibForMyApex2.Rule("javac").Implicits), sdkMemberV2.String())
-}
-
-func TestBasicSdkWithCc(t *testing.T) {
- ctx, _ := testSdk(t, `
- sdk {
- name: "mysdk",
- native_shared_libs: ["sdkmember"],
- }
-
- sdk_snapshot {
- name: "mysdk@1",
- native_shared_libs: ["sdkmember_mysdk_1"],
- }
-
- sdk_snapshot {
- name: "mysdk@2",
- native_shared_libs: ["sdkmember_mysdk_2"],
- }
-
- cc_prebuilt_library_shared {
- name: "sdkmember",
- srcs: ["libfoo.so"],
- prefer: false,
- system_shared_libs: [],
- stl: "none",
- }
-
- cc_prebuilt_library_shared {
- name: "sdkmember_mysdk_1",
- sdk_member_name: "sdkmember",
- srcs: ["libfoo.so"],
- system_shared_libs: [],
- stl: "none",
- }
-
- cc_prebuilt_library_shared {
- name: "sdkmember_mysdk_2",
- sdk_member_name: "sdkmember",
- srcs: ["libfoo.so"],
- system_shared_libs: [],
- stl: "none",
- }
-
- cc_library_shared {
- name: "mycpplib",
- srcs: ["Test.cpp"],
- shared_libs: ["sdkmember"],
- system_shared_libs: [],
- stl: "none",
- }
-
- apex {
- name: "myapex",
- native_shared_libs: ["mycpplib"],
- uses_sdks: ["mysdk@1"],
- key: "myapex.key",
- certificate: ":myapex.cert",
- }
-
- apex {
- name: "myapex2",
- native_shared_libs: ["mycpplib"],
- uses_sdks: ["mysdk@2"],
- key: "myapex.key",
- certificate: ":myapex.cert",
- }
- `)
-
- sdkMemberV1 := ctx.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_core_shared_myapex").Rule("toc").Output
- sdkMemberV2 := ctx.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_core_shared_myapex2").Rule("toc").Output
-
- cpplibForMyApex := ctx.ModuleForTests("mycpplib", "android_arm64_armv8-a_core_shared_myapex")
- cpplibForMyApex2 := ctx.ModuleForTests("mycpplib", "android_arm64_armv8-a_core_shared_myapex2")
-
- // Depending on the uses_sdks value, different libs are linked
- ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
- ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
-}
-
-// Note: This test does not verify that a droidstubs can be referenced, either
-// directly or indirectly from an APEX as droidstubs can never be a part of an
-// apex.
-func TestBasicSdkWithDroidstubs(t *testing.T) {
- testSdk(t, `
- sdk {
- name: "mysdk",
- stubs_sources: ["mystub"],
- }
- sdk_snapshot {
- name: "mysdk@10",
- stubs_sources: ["mystub_mysdk@10"],
- }
- prebuilt_stubs_sources {
- name: "mystub_mysdk@10",
- sdk_member_name: "mystub",
- srcs: ["stubs-sources/foo/bar/Foo.java"],
- }
- droidstubs {
- name: "mystub",
- srcs: ["foo/bar/Foo.java"],
- sdk_version: "none",
- system_modules: "none",
- }
- java_library {
- name: "myjavalib",
- srcs: [":mystub"],
- sdk_version: "none",
- system_modules: "none",
- }
- `)
+// Needed in an _test.go file in this package to ensure tests run correctly, particularly in IDE.
+func TestMain(m *testing.M) {
+ runTestWithBuildDir(m)
}
func TestDepNotInRequiredSdks(t *testing.T) {
@@ -393,440 +79,3 @@
}
`)
}
-
-func TestSdkIsCompileMultilibBoth(t *testing.T) {
- ctx, _ := testSdk(t, `
- sdk {
- name: "mysdk",
- native_shared_libs: ["sdkmember"],
- }
-
- cc_library_shared {
- name: "sdkmember",
- srcs: ["Test.cpp"],
- system_shared_libs: [],
- stl: "none",
- }
- `)
-
- armOutput := ctx.ModuleForTests("sdkmember", "android_arm_armv7-a-neon_core_shared").Module().(*cc.Module).OutputFile()
- arm64Output := ctx.ModuleForTests("sdkmember", "android_arm64_armv8-a_core_shared").Module().(*cc.Module).OutputFile()
-
- var inputs []string
- buildParams := ctx.ModuleForTests("mysdk", "android_common").Module().BuildParamsForTests()
- for _, bp := range buildParams {
- if bp.Input != nil {
- inputs = append(inputs, bp.Input.String())
- }
- }
-
- // ensure that both 32/64 outputs are inputs of the sdk snapshot
- ensureListContains(t, inputs, armOutput.String())
- ensureListContains(t, inputs, arm64Output.String())
-}
-
-func TestSnapshot(t *testing.T) {
- ctx, config := testSdk(t, `
- sdk {
- name: "mysdk",
- java_libs: ["myjavalib"],
- native_shared_libs: ["mynativelib"],
- stubs_sources: ["myjavaapistubs"],
- }
-
- java_library {
- name: "myjavalib",
- srcs: ["Test.java"],
- aidl: {
- export_include_dirs: ["aidl"],
- },
- system_modules: "none",
- sdk_version: "none",
- compile_dex: true,
- host_supported: true,
- }
-
- cc_library_shared {
- name: "mynativelib",
- srcs: [
- "Test.cpp",
- "aidl/foo/bar/Test.aidl",
- ],
- export_include_dirs: ["include"],
- aidl: {
- export_aidl_headers: true,
- },
- system_shared_libs: [],
- stl: "none",
- }
-
- droidstubs {
- name: "myjavaapistubs",
- srcs: ["foo/bar/Foo.java"],
- system_modules: "none",
- sdk_version: "none",
- }
- `)
-
- sdk := ctx.ModuleForTests("mysdk", "android_common").Module().(*sdk)
-
- checkSnapshotAndroidBpContents(t, sdk, `// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- jars: ["java/myjavalib.jar"],
-}
-
-java_import {
- name: "myjavalib",
- prefer: false,
- jars: ["java/myjavalib.jar"],
-}
-
-prebuilt_stubs_sources {
- name: "mysdk_myjavaapistubs@current",
- sdk_member_name: "myjavaapistubs",
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-prebuilt_stubs_sources {
- name: "myjavaapistubs",
- prefer: false,
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
- arch: {
- arm64: {
- srcs: ["arm64/lib/mynativelib.so"],
- export_include_dirs: [
- "arm64/include/include",
- "arm64/include_gen/mynativelib",
- ],
- },
- arm: {
- srcs: ["arm/lib/mynativelib.so"],
- export_include_dirs: [
- "arm/include/include",
- "arm/include_gen/mynativelib",
- ],
- },
- },
- stl: "none",
- system_shared_libs: [],
-}
-
-cc_prebuilt_library_shared {
- name: "mynativelib",
- prefer: false,
- arch: {
- arm64: {
- srcs: ["arm64/lib/mynativelib.so"],
- export_include_dirs: [
- "arm64/include/include",
- "arm64/include_gen/mynativelib",
- ],
- },
- arm: {
- srcs: ["arm/lib/mynativelib.so"],
- export_include_dirs: [
- "arm/include/include",
- "arm/include_gen/mynativelib",
- ],
- },
- },
- stl: "none",
- system_shared_libs: [],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- java_libs: ["mysdk_myjavalib@current"],
- stubs_sources: ["mysdk_myjavaapistubs@current"],
- native_shared_libs: ["mysdk_mynativelib@current"],
-}
-
-`)
-
- var copySrcs []string
- var copyDests []string
- buildParams := sdk.BuildParamsForTests()
- var zipBp android.BuildParams
- for _, bp := range buildParams {
- ruleString := bp.Rule.String()
- if ruleString == "android/soong/android.Cp" {
- copySrcs = append(copySrcs, bp.Input.String())
- copyDests = append(copyDests, bp.Output.Rel()) // rooted at the snapshot root
- } else if ruleString == "<local rule>:m.mysdk_android_common.snapshot" {
- zipBp = bp
- }
- }
-
- buildDir := config.BuildDir()
- ensureListContains(t, copySrcs, "aidl/foo/bar/Test.aidl")
- ensureListContains(t, copySrcs, "include/Test.h")
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BnTest.h"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BpTest.h"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/Test.h"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/mynativelib.so"))
-
- ensureListContains(t, copyDests, "aidl/aidl/foo/bar/Test.aidl")
- ensureListContains(t, copyDests, "arm64/include/include/Test.h")
- ensureListContains(t, copyDests, "arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h")
- ensureListContains(t, copyDests, "arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h")
- ensureListContains(t, copyDests, "arm64/include_gen/mynativelib/aidl/foo/bar/Test.h")
- ensureListContains(t, copyDests, "java/myjavalib.jar")
- ensureListContains(t, copyDests, "arm64/lib/mynativelib.so")
-
- // Ensure that the droidstubs .srcjar as repackaged into a temporary zip file
- // and then merged together with the intermediate snapshot zip.
- snapshotCreationInputs := zipBp.Implicits.Strings()
- ensureListContains(t, snapshotCreationInputs,
- filepath.Join(buildDir, ".intermediates/mysdk/android_common/tmp/java/myjavaapistubs_stubs_sources.zip"))
- ensureListContains(t, snapshotCreationInputs,
- filepath.Join(buildDir, ".intermediates/mysdk/android_common/mysdk-current.unmerged.zip"))
- actual := zipBp.Output.String()
- expected := filepath.Join(buildDir, ".intermediates/mysdk/android_common/mysdk-current.zip")
- if actual != expected {
- t.Errorf("Expected snapshot output to be %q but was %q", expected, actual)
- }
-}
-
-func TestHostSnapshot(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
- ctx, config := testSdk(t, `
- sdk {
- name: "mysdk",
- device_supported: false,
- host_supported: true,
- java_libs: ["myjavalib"],
- native_shared_libs: ["mynativelib"],
- stubs_sources: ["myjavaapistubs"],
- }
-
- java_library {
- name: "myjavalib",
- device_supported: false,
- host_supported: true,
- srcs: ["Test.java"],
- aidl: {
- export_include_dirs: ["aidl"],
- },
- system_modules: "none",
- sdk_version: "none",
- compile_dex: true,
- }
-
- cc_library_shared {
- name: "mynativelib",
- device_supported: false,
- host_supported: true,
- srcs: [
- "Test.cpp",
- "aidl/foo/bar/Test.aidl",
- ],
- export_include_dirs: ["include"],
- aidl: {
- export_aidl_headers: true,
- },
- system_shared_libs: [],
- stl: "none",
- }
-
- droidstubs {
- name: "myjavaapistubs",
- device_supported: false,
- host_supported: true,
- srcs: ["foo/bar/Foo.java"],
- system_modules: "none",
- sdk_version: "none",
- }
- `)
-
- sdk := ctx.ModuleForTests("mysdk", "linux_glibc_common").Module().(*sdk)
-
- checkSnapshotAndroidBpContents(t, sdk, `// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- device_supported: false,
- host_supported: true,
- jars: ["java/myjavalib.jar"],
-}
-
-java_import {
- name: "myjavalib",
- prefer: false,
- device_supported: false,
- host_supported: true,
- jars: ["java/myjavalib.jar"],
-}
-
-prebuilt_stubs_sources {
- name: "mysdk_myjavaapistubs@current",
- sdk_member_name: "myjavaapistubs",
- device_supported: false,
- host_supported: true,
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-prebuilt_stubs_sources {
- name: "myjavaapistubs",
- prefer: false,
- device_supported: false,
- host_supported: true,
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
- device_supported: false,
- host_supported: true,
- arch: {
- x86_64: {
- srcs: ["x86_64/lib/mynativelib.so"],
- export_include_dirs: [
- "x86_64/include/include",
- "x86_64/include_gen/mynativelib",
- ],
- },
- x86: {
- srcs: ["x86/lib/mynativelib.so"],
- export_include_dirs: [
- "x86/include/include",
- "x86/include_gen/mynativelib",
- ],
- },
- },
- stl: "none",
- system_shared_libs: [],
-}
-
-cc_prebuilt_library_shared {
- name: "mynativelib",
- prefer: false,
- device_supported: false,
- host_supported: true,
- arch: {
- x86_64: {
- srcs: ["x86_64/lib/mynativelib.so"],
- export_include_dirs: [
- "x86_64/include/include",
- "x86_64/include_gen/mynativelib",
- ],
- },
- x86: {
- srcs: ["x86/lib/mynativelib.so"],
- export_include_dirs: [
- "x86/include/include",
- "x86/include_gen/mynativelib",
- ],
- },
- },
- stl: "none",
- system_shared_libs: [],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- device_supported: false,
- host_supported: true,
- java_libs: ["mysdk_myjavalib@current"],
- stubs_sources: ["mysdk_myjavaapistubs@current"],
- native_shared_libs: ["mysdk_mynativelib@current"],
-}
-
-`)
-
- var copySrcs []string
- var copyDests []string
- buildParams := sdk.BuildParamsForTests()
- var zipBp android.BuildParams
- for _, bp := range buildParams {
- ruleString := bp.Rule.String()
- if ruleString == "android/soong/android.Cp" {
- copySrcs = append(copySrcs, bp.Input.String())
- copyDests = append(copyDests, bp.Output.Rel()) // rooted at the snapshot root
- } else if ruleString == "<local rule>:m.mysdk_linux_glibc_common.snapshot" {
- zipBp = bp
- }
- }
-
- buildDir := config.BuildDir()
- ensureListContains(t, copySrcs, "aidl/foo/bar/Test.aidl")
- ensureListContains(t, copySrcs, "include/Test.h")
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar"))
- ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so"))
-
- ensureListContains(t, copyDests, "aidl/aidl/foo/bar/Test.aidl")
- ensureListContains(t, copyDests, "x86_64/include/include/Test.h")
- ensureListContains(t, copyDests, "x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h")
- ensureListContains(t, copyDests, "x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h")
- ensureListContains(t, copyDests, "x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h")
- ensureListContains(t, copyDests, "java/myjavalib.jar")
- ensureListContains(t, copyDests, "x86_64/lib/mynativelib.so")
-
- // Ensure that the droidstubs .srcjar as repackaged into a temporary zip file
- // and then merged together with the intermediate snapshot zip.
- snapshotCreationInputs := zipBp.Implicits.Strings()
- ensureListContains(t, snapshotCreationInputs,
- filepath.Join(buildDir, ".intermediates/mysdk/linux_glibc_common/tmp/java/myjavaapistubs_stubs_sources.zip"))
- ensureListContains(t, snapshotCreationInputs,
- filepath.Join(buildDir, ".intermediates/mysdk/linux_glibc_common/mysdk-current.unmerged.zip"))
- actual := zipBp.Output.String()
- expected := filepath.Join(buildDir, ".intermediates/mysdk/linux_glibc_common/mysdk-current.zip")
- if actual != expected {
- t.Errorf("Expected snapshot output to be %q but was %q", expected, actual)
- }
-}
-
-func checkSnapshotAndroidBpContents(t *testing.T, s *sdk, expectedContents string) {
- t.Helper()
- androidBpContents := strings.NewReplacer("\\n", "\n").Replace(s.GetAndroidBpContentsForTests())
- if androidBpContents != expectedContents {
- t.Errorf("Android.bp contents do not match, expected %s, actual %s", expectedContents, androidBpContents)
- }
-}
-
-var buildDir string
-
-func setUp() {
- var err error
- buildDir, err = ioutil.TempDir("", "soong_sdk_test")
- if err != nil {
- panic(err)
- }
-}
-
-func tearDown() {
- os.RemoveAll(buildDir)
-}
-
-func TestMain(m *testing.M) {
- run := func() int {
- setUp()
- defer tearDown()
-
- return m.Run()
- }
-
- os.Exit(run())
-}
-
-func SkipIfNotLinux(t *testing.T) {
- t.Helper()
- if android.BuildOs != android.Linux {
- t.Skipf("Skipping as sdk snapshot generation is only supported on %s not %s", android.Linux, android.BuildOs)
- }
-}
diff --git a/sdk/testing.go b/sdk/testing.go
new file mode 100644
index 0000000..47a58b1
--- /dev/null
+++ b/sdk/testing.go
@@ -0,0 +1,397 @@
+// Copyright 2019 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 sdk
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "android/soong/android"
+ "android/soong/apex"
+ "android/soong/cc"
+ "android/soong/java"
+)
+
+func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, android.Config) {
+ config := android.TestArchConfig(buildDir, nil)
+ ctx := android.NewTestArchContext()
+
+ // from android package
+ ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
+ ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
+ })
+ ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.TopDown("prebuilt_select", android.PrebuiltSelectModuleMutator).Parallel()
+ ctx.BottomUp("prebuilt_postdeps", android.PrebuiltPostDepsMutator).Parallel()
+ })
+
+ // from java package
+ ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
+ ctx.RegisterModuleType("java_library", java.LibraryFactory)
+ ctx.RegisterModuleType("java_import", java.ImportFactory)
+ ctx.RegisterModuleType("droidstubs", java.DroidstubsFactory)
+ ctx.RegisterModuleType("prebuilt_stubs_sources", java.PrebuiltStubsSourcesFactory)
+
+ // from cc package
+ ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
+ ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
+ ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
+ ctx.RegisterModuleType("cc_prebuilt_library_shared", cc.PrebuiltSharedLibraryFactory)
+ ctx.RegisterModuleType("cc_prebuilt_library_static", cc.PrebuiltStaticLibraryFactory)
+ ctx.RegisterModuleType("llndk_library", cc.LlndkLibraryFactory)
+ ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
+ ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("image", android.ImageMutator).Parallel()
+ ctx.BottomUp("link", cc.LinkageMutator).Parallel()
+ ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
+ ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
+ ctx.BottomUp("version", cc.VersionMutator).Parallel()
+ ctx.BottomUp("begin", cc.BeginMutator).Parallel()
+ })
+
+ // from apex package
+ ctx.RegisterModuleType("apex", apex.BundleFactory)
+ ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
+ ctx.PostDepsMutators(apex.RegisterPostDepsMutators)
+
+ // from this package
+ ctx.RegisterModuleType("sdk", ModuleFactory)
+ ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory)
+ ctx.PreDepsMutators(RegisterPreDepsMutators)
+ ctx.PostDepsMutators(RegisterPostDepsMutators)
+
+ ctx.Register()
+
+ bp = bp + `
+ apex_key {
+ name: "myapex.key",
+ public_key: "myapex.avbpubkey",
+ private_key: "myapex.pem",
+ }
+
+ android_app_certificate {
+ name: "myapex.cert",
+ certificate: "myapex",
+ }
+ ` + cc.GatherRequiredDepsForTest(android.Android)
+
+ mockFS := map[string][]byte{
+ "Android.bp": []byte(bp),
+ "build/make/target/product/security": nil,
+ "apex_manifest.json": nil,
+ "system/sepolicy/apex/myapex-file_contexts": nil,
+ "system/sepolicy/apex/myapex2-file_contexts": nil,
+ "myapex.avbpubkey": nil,
+ "myapex.pem": nil,
+ "myapex.x509.pem": nil,
+ "myapex.pk8": nil,
+ }
+
+ for k, v := range fs {
+ mockFS[k] = v
+ }
+
+ ctx.MockFileSystem(mockFS)
+
+ return ctx, config
+}
+
+func testSdkWithFs(t *testing.T, bp string, fs map[string][]byte) *testSdkResult {
+ t.Helper()
+ ctx, config := testSdkContext(bp, fs)
+ _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
+ android.FailIfErrored(t, errs)
+ _, errs = ctx.PrepareBuildActions(config)
+ android.FailIfErrored(t, errs)
+ return &testSdkResult{
+ TestHelper: TestHelper{t: t},
+ ctx: ctx,
+ config: config,
+ }
+}
+
+func testSdkError(t *testing.T, pattern, bp string) {
+ t.Helper()
+ ctx, config := testSdkContext(bp, nil)
+ _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
+ if len(errs) > 0 {
+ android.FailIfNoMatchingErrors(t, pattern, errs)
+ return
+ }
+ _, errs = ctx.PrepareBuildActions(config)
+ if len(errs) > 0 {
+ android.FailIfNoMatchingErrors(t, pattern, errs)
+ return
+ }
+
+ t.Fatalf("missing expected error %q (0 errors are returned)", pattern)
+}
+
+func ensureListContains(t *testing.T, result []string, expected string) {
+ t.Helper()
+ if !android.InList(expected, result) {
+ t.Errorf("%q is not found in %v", expected, result)
+ }
+}
+
+func pathsToStrings(paths android.Paths) []string {
+ var ret []string
+ for _, p := range paths {
+ ret = append(ret, p.String())
+ }
+ return ret
+}
+
+// Provides general test support.
+type TestHelper struct {
+ t *testing.T
+}
+
+func (h *TestHelper) AssertStringEquals(message string, expected string, actual string) {
+ h.t.Helper()
+ if actual != expected {
+ h.t.Errorf("%s: expected %s, actual %s", message, expected, actual)
+ }
+}
+
+func (h *TestHelper) AssertTrimmedStringEquals(message string, expected string, actual string) {
+ h.t.Helper()
+ h.AssertStringEquals(message, strings.TrimSpace(expected), strings.TrimSpace(actual))
+}
+
+// Encapsulates result of processing an SDK definition. Provides support for
+// checking the state of the build structures.
+type testSdkResult struct {
+ TestHelper
+ ctx *android.TestContext
+ config android.Config
+}
+
+// Analyse the sdk build rules to extract information about what it is doing.
+
+// e.g. find the src/dest pairs from each cp command, the various zip files
+// generated, etc.
+func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo {
+ androidBpContents := strings.NewReplacer("\\n", "\n").Replace(sdk.GetAndroidBpContentsForTests())
+
+ info := &snapshotBuildInfo{
+ r: r,
+ androidBpContents: androidBpContents,
+ }
+
+ buildParams := sdk.BuildParamsForTests()
+ copyRules := &strings.Builder{}
+ for _, bp := range buildParams {
+ switch bp.Rule.String() {
+ case android.Cp.String():
+ // Get source relative to build directory.
+ src := r.pathRelativeToBuildDir(bp.Input)
+ // Get destination relative to the snapshot root
+ dest := bp.Output.Rel()
+ _, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest)
+ info.snapshotContents = append(info.snapshotContents, dest)
+
+ case repackageZip.String():
+ // Add the destdir to the snapshot contents as that is effectively where
+ // the content of the repackaged zip is copied.
+ dest := bp.Args["destdir"]
+ info.snapshotContents = append(info.snapshotContents, dest)
+
+ case zipFiles.String():
+ // This could be an intermediate zip file and not the actual output zip.
+ // In that case this will be overridden when the rule to merge the zips
+ // is processed.
+ info.outputZip = r.pathRelativeToBuildDir(bp.Output)
+
+ case mergeZips.String():
+ // Copy the current outputZip to the intermediateZip.
+ info.intermediateZip = info.outputZip
+ mergeInput := r.pathRelativeToBuildDir(bp.Input)
+ if info.intermediateZip != mergeInput {
+ r.t.Errorf("Expected intermediate zip %s to be an input to merge zips but found %s instead",
+ info.intermediateZip, mergeInput)
+ }
+
+ // Override output zip (which was actually the intermediate zip file) with the actual
+ // output zip.
+ info.outputZip = r.pathRelativeToBuildDir(bp.Output)
+
+ // Save the zips to be merged into the intermediate zip.
+ info.mergeZips = r.pathsRelativeToBuildDir(bp.Inputs)
+ }
+ }
+
+ info.copyRules = copyRules.String()
+
+ return info
+}
+
+func (r *testSdkResult) Module(name string, variant string) android.Module {
+ return r.ctx.ModuleForTests(name, variant).Module()
+}
+
+func (r *testSdkResult) ModuleForTests(name string, variant string) android.TestingModule {
+ return r.ctx.ModuleForTests(name, variant)
+}
+
+func (r *testSdkResult) pathRelativeToBuildDir(path android.Path) string {
+ buildDir := filepath.Clean(r.config.BuildDir()) + "/"
+ return strings.TrimPrefix(filepath.Clean(path.String()), buildDir)
+}
+
+func (r *testSdkResult) pathsRelativeToBuildDir(paths android.Paths) []string {
+ var result []string
+ for _, path := range paths {
+ result = append(result, r.pathRelativeToBuildDir(path))
+ }
+ return result
+}
+
+// Check the snapshot build rules.
+//
+// Takes a list of functions which check different facets of the snapshot build rules.
+// Allows each test to customize what is checked without duplicating lots of code
+// or proliferating check methods of different flavors.
+func (r *testSdkResult) CheckSnapshot(name string, variant string, checkers ...snapshotBuildInfoChecker) {
+ r.t.Helper()
+
+ sdk := r.Module(name, variant).(*sdk)
+
+ snapshotBuildInfo := r.getSdkSnapshotBuildInfo(sdk)
+
+ // Check state of the snapshot build.
+ for _, checker := range checkers {
+ checker(snapshotBuildInfo)
+ }
+
+ // Make sure that the generated zip file is in the correct place.
+ actual := snapshotBuildInfo.outputZip
+ r.AssertStringEquals("Snapshot zip file in wrong place",
+ fmt.Sprintf(".intermediates/%s/%s/%s-current.zip", name, variant, name), actual)
+
+ // Populate a mock filesystem with the files that would have been copied by
+ // the rules.
+ fs := make(map[string][]byte)
+ for _, dest := range snapshotBuildInfo.snapshotContents {
+ fs[dest] = nil
+ }
+
+ // Process the generated bp file to make sure it is valid.
+ testSdkWithFs(r.t, snapshotBuildInfo.androidBpContents, fs)
+}
+
+type snapshotBuildInfoChecker func(info *snapshotBuildInfo)
+
+// Check that the snapshot's generated Android.bp is correct.
+//
+// Both the expected and actual string are both trimmed before comparing.
+func checkAndroidBpContents(expected string) snapshotBuildInfoChecker {
+ return func(info *snapshotBuildInfo) {
+ info.r.t.Helper()
+ info.r.AssertTrimmedStringEquals("Android.bp contents do not match", expected, info.androidBpContents)
+ }
+}
+
+// Check that the snapshot's copy rules are correct.
+//
+// The copy rules are formatted as <src> -> <dest>, one per line and then compared
+// to the supplied expected string. Both the expected and actual string are trimmed
+// before comparing.
+func checkAllCopyRules(expected string) snapshotBuildInfoChecker {
+ return func(info *snapshotBuildInfo) {
+ info.r.t.Helper()
+ info.r.AssertTrimmedStringEquals("Incorrect copy rules", expected, info.copyRules)
+ }
+}
+
+// Check that the specified path is in the list of zips to merge with the intermediate zip.
+func checkMergeZip(expected string) snapshotBuildInfoChecker {
+ return func(info *snapshotBuildInfo) {
+ info.r.t.Helper()
+ if info.intermediateZip == "" {
+ info.r.t.Errorf("No intermediate zip file was created")
+ }
+ ensureListContains(info.r.t, info.mergeZips, expected)
+ }
+}
+
+// Encapsulates information about the snapshot build structure in order to insulate tests from
+// knowing too much about internal structures.
+//
+// All source/input paths are relative either the build directory. All dest/output paths are
+// relative to the snapshot root directory.
+type snapshotBuildInfo struct {
+ r *testSdkResult
+
+ // The contents of the generated Android.bp file
+ androidBpContents string
+
+ // The paths, relative to the snapshot root, of all files and directories copied into the
+ // snapshot.
+ snapshotContents []string
+
+ // A formatted representation of the src/dest pairs, one pair per line, of the format
+ // src -> dest
+ copyRules string
+
+ // The path to the intermediate zip, which is a zip created from the source files copied
+ // into the snapshot directory and which will be merged with other zips to form the final output.
+ // Is am empty string if there is no intermediate zip because there are no zips to merge in.
+ intermediateZip string
+
+ // The paths to the zips to merge into the output zip, does not include the intermediate
+ // zip.
+ mergeZips []string
+
+ // The final output zip.
+ outputZip string
+}
+
+var buildDir string
+
+func setUp() {
+ var err error
+ buildDir, err = ioutil.TempDir("", "soong_sdk_test")
+ if err != nil {
+ panic(err)
+ }
+}
+
+func tearDown() {
+ _ = os.RemoveAll(buildDir)
+}
+
+func runTestWithBuildDir(m *testing.M) {
+ run := func() int {
+ setUp()
+ defer tearDown()
+
+ return m.Run()
+ }
+
+ os.Exit(run())
+}
+
+func SkipIfNotLinux(t *testing.T) {
+ t.Helper()
+ if android.BuildOs != android.Linux {
+ t.Skipf("Skipping as sdk snapshot generation is only supported on %s not %s", android.Linux, android.BuildOs)
+ }
+}
diff --git a/sdk/update.go b/sdk/update.go
index 8159d3b..7731fbb 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -16,19 +16,47 @@
import (
"fmt"
- "path/filepath"
"reflect"
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
- "android/soong/cc"
- "android/soong/java"
)
var pctx = android.NewPackageContext("android/soong/sdk")
+var (
+ repackageZip = pctx.AndroidStaticRule("SnapshotRepackageZip",
+ blueprint.RuleParams{
+ Command: `${config.Zip2ZipCmd} -i $in -o $out "**/*:$destdir"`,
+ CommandDeps: []string{
+ "${config.Zip2ZipCmd}",
+ },
+ },
+ "destdir")
+
+ zipFiles = pctx.AndroidStaticRule("SnapshotZipFiles",
+ blueprint.RuleParams{
+ Command: `${config.SoongZipCmd} -C $basedir -l $out.rsp -o $out`,
+ CommandDeps: []string{
+ "${config.SoongZipCmd}",
+ },
+ Rspfile: "$out.rsp",
+ RspfileContent: "$in",
+ },
+ "basedir")
+
+ mergeZips = pctx.AndroidStaticRule("SnapshotMergeZips",
+ blueprint.RuleParams{
+ Command: `${config.MergeZipsCmd} $out $in`,
+ CommandDeps: []string{
+ "${config.MergeZipsCmd}",
+ },
+ })
+)
+
type generatedContents struct {
content strings.Builder
indentLevel int
@@ -74,105 +102,46 @@
rb.Build(pctx, ctx, gf.path.Base(), "Build "+gf.path.Base())
}
-func (s *sdk) javaLibs(ctx android.ModuleContext) []android.SdkAware {
- result := []android.SdkAware{}
+// Collect all the members.
+//
+// The members are first grouped by type and then grouped by name. The order of
+// the types is the order they are referenced in sdkMemberListProperties. The
+// names are in order in which the dependencies were added.
+func collectMembers(ctx android.ModuleContext) []*sdkMember {
+ byType := make(map[android.SdkMemberType][]*sdkMember)
+ byName := make(map[string]*sdkMember)
+
ctx.VisitDirectDeps(func(m android.Module) {
- if j, ok := m.(*java.Library); ok {
- result = append(result, j)
- }
- })
- return result
-}
+ tag := ctx.OtherModuleDependencyTag(m)
+ if memberTag, ok := tag.(*sdkMemberDependencyTag); ok {
+ memberListProperty := memberTag.memberListProperty
+ memberType := memberListProperty.memberType
-func (s *sdk) stubsSources(ctx android.ModuleContext) []android.SdkAware {
- result := []android.SdkAware{}
- ctx.VisitDirectDeps(func(m android.Module) {
- if j, ok := m.(*java.Droidstubs); ok {
- result = append(result, j)
- }
- })
- return result
-}
-
-// archSpecificNativeLibInfo represents an arch-specific variant of a native lib
-type archSpecificNativeLibInfo struct {
- name string
- archType string
- exportedIncludeDirs android.Paths
- exportedSystemIncludeDirs android.Paths
- exportedFlags []string
- exportedDeps android.Paths
- outputFile android.Path
-}
-
-func (lib *archSpecificNativeLibInfo) signature() string {
- return fmt.Sprintf("%v %v %v %v",
- lib.name,
- lib.exportedIncludeDirs.Strings(),
- lib.exportedSystemIncludeDirs.Strings(),
- lib.exportedFlags)
-}
-
-// nativeLibInfo represents a collection of arch-specific modules having the same name
-type nativeLibInfo struct {
- name string
- archVariants []archSpecificNativeLibInfo
- // hasArchSpecificFlags is set to true if modules for each architecture all have the same
- // include dirs, flags, etc, in which case only those of the first arch is selected.
- hasArchSpecificFlags bool
-}
-
-// nativeMemberInfos collects all cc.Modules that are member of an SDK.
-func (s *sdk) nativeMemberInfos(ctx android.ModuleContext) []*nativeLibInfo {
- infoMap := make(map[string]*nativeLibInfo)
-
- // Collect cc.Modules
- ctx.VisitDirectDeps(func(m android.Module) {
- ccModule, ok := m.(*cc.Module)
- if !ok {
- return
- }
- depName := ctx.OtherModuleName(m)
-
- if _, ok := infoMap[depName]; !ok {
- infoMap[depName] = &nativeLibInfo{name: depName}
- }
-
- info := infoMap[depName]
- info.archVariants = append(info.archVariants, archSpecificNativeLibInfo{
- name: ccModule.BaseModuleName(),
- archType: ccModule.Target().Arch.ArchType.String(),
- exportedIncludeDirs: ccModule.ExportedIncludeDirs(),
- exportedSystemIncludeDirs: ccModule.ExportedSystemIncludeDirs(),
- exportedFlags: ccModule.ExportedFlags(),
- exportedDeps: ccModule.ExportedDeps(),
- outputFile: ccModule.OutputFile().Path(),
- })
- })
-
- // Determine if include dirs and flags for each module are different across arch-specific
- // modules or not. And set hasArchSpecificFlags accordingly
- for _, info := range infoMap {
- // by default, include paths and flags are assumed to be the same across arches
- info.hasArchSpecificFlags = false
- oldSignature := ""
- for _, av := range info.archVariants {
- newSignature := av.signature()
- if oldSignature == "" {
- oldSignature = newSignature
+ // Make sure that the resolved module is allowed in the member list property.
+ if !memberType.IsInstance(m) {
+ ctx.ModuleErrorf("module %q is not valid in property %s", ctx.OtherModuleName(m), memberListProperty.name)
}
- if oldSignature != newSignature {
- info.hasArchSpecificFlags = true
- break
+
+ name := ctx.OtherModuleName(m)
+
+ member := byName[name]
+ if member == nil {
+ member = &sdkMember{memberType: memberType, name: name}
+ byName[name] = member
+ byType[memberType] = append(byType[memberType], member)
}
+
+ member.variants = append(member.variants, m.(android.SdkAware))
}
+ })
+
+ var members []*sdkMember
+ for _, memberListProperty := range sdkMemberListProperties {
+ membersOfType := byType[memberListProperty.memberType]
+ members = append(members, membersOfType...)
}
- var list []*nativeLibInfo
- for _, v := range infoMap {
- list = append(list, v)
- }
- return list
+ return members
}
// SDK directory structure
@@ -193,44 +162,6 @@
// <arch>/lib/
// libFoo.so : a stub library
-const (
- nativeIncludeDir = "include"
- nativeGeneratedIncludeDir = "include_gen"
- nativeStubDir = "lib"
- nativeStubFileSuffix = ".so"
-)
-
-// path to the stub file of a native shared library. Relative to <sdk_root>/<api_dir>
-func nativeStubFilePathFor(lib archSpecificNativeLibInfo) string {
- return filepath.Join(lib.archType,
- nativeStubDir, lib.name+nativeStubFileSuffix)
-}
-
-// paths to the include dirs of a native shared library. Relative to <sdk_root>/<api_dir>
-func nativeIncludeDirPathsFor(ctx android.ModuleContext, lib archSpecificNativeLibInfo,
- systemInclude bool, archSpecific bool) []string {
- var result []string
- var includeDirs []android.Path
- if !systemInclude {
- includeDirs = lib.exportedIncludeDirs
- } else {
- includeDirs = lib.exportedSystemIncludeDirs
- }
- for _, dir := range includeDirs {
- var path string
- if _, gen := dir.(android.WritablePath); gen {
- path = filepath.Join(nativeGeneratedIncludeDir, lib.name)
- } else {
- path = filepath.Join(nativeIncludeDir, dir.String())
- }
- if archSpecific {
- path = filepath.Join(lib.archType, path)
- }
- result = append(result, path)
- }
- return result
-}
-
// A name that uniquely identifies a prebuilt SDK member for a version of SDK snapshot
// This isn't visible to users, so could be changed in future.
func versionedSdkMemberName(ctx android.ModuleContext, memberName string, version string) string {
@@ -259,22 +190,8 @@
}
s.builderForTests = builder
- // copy exported AIDL files and stub jar files
- javaLibs := s.javaLibs(ctx)
- for _, m := range javaLibs {
- m.BuildSnapshot(ctx, builder)
- }
-
- // copy stubs sources
- stubsSources := s.stubsSources(ctx)
- for _, m := range stubsSources {
- m.BuildSnapshot(ctx, builder)
- }
-
- // copy exported header files and stub *.so files
- nativeLibInfos := s.nativeMemberInfos(ctx)
- for _, info := range nativeLibInfos {
- buildSharedNativeLibSnapshot(ctx, info, builder)
+ for _, member := range collectMembers(ctx) {
+ member.memberType.BuildSnapshot(ctx, builder, member)
}
for _, unversioned := range builder.prebuiltOrder {
@@ -295,14 +212,11 @@
snapshotModule := bpFile.newModule("sdk_snapshot")
snapshotModule.AddProperty("name", snapshotName)
addHostDeviceSupportedProperties(&s.ModuleBase, snapshotModule)
- if len(s.properties.Java_libs) > 0 {
- snapshotModule.AddProperty("java_libs", builder.versionedSdkMemberNames(s.properties.Java_libs))
- }
- if len(s.properties.Stubs_sources) > 0 {
- snapshotModule.AddProperty("stubs_sources", builder.versionedSdkMemberNames(s.properties.Stubs_sources))
- }
- if len(s.properties.Native_shared_libs) > 0 {
- snapshotModule.AddProperty("native_shared_libs", builder.versionedSdkMemberNames(s.properties.Native_shared_libs))
+ for _, memberListProperty := range sdkMemberListProperties {
+ names := memberListProperty.getter(&s.properties)
+ if len(names) > 0 {
+ snapshotModule.AddProperty(memberListProperty.name, builder.versionedSdkMemberNames(names))
+ }
}
bpFile.AddModule(snapshotModule)
@@ -316,41 +230,39 @@
// zip them all
outputZipFile := android.PathForModuleOut(ctx, ctx.ModuleName()+"-current.zip").OutputPath
- outputRuleName := "snapshot"
outputDesc := "Building snapshot for " + ctx.ModuleName()
// If there are no zips to merge then generate the output zip directly.
// Otherwise, generate an intermediate zip file into which other zips can be
// merged.
var zipFile android.OutputPath
- var ruleName string
var desc string
if len(builder.zipsToMerge) == 0 {
zipFile = outputZipFile
- ruleName = outputRuleName
desc = outputDesc
} else {
zipFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"-current.unmerged.zip").OutputPath
- ruleName = "intermediate snapshot"
desc = "Building intermediate snapshot for " + ctx.ModuleName()
}
- rb := android.NewRuleBuilder()
- rb.Command().
- BuiltTool(ctx, "soong_zip").
- FlagWithArg("-C ", builder.snapshotDir.String()).
- FlagWithRspFileInputList("-l ", filesToZip).
- FlagWithOutput("-o ", zipFile)
- rb.Build(pctx, ctx, ruleName, desc)
+ ctx.Build(pctx, android.BuildParams{
+ Description: desc,
+ Rule: zipFiles,
+ Inputs: filesToZip,
+ Output: zipFile,
+ Args: map[string]string{
+ "basedir": builder.snapshotDir.String(),
+ },
+ })
if len(builder.zipsToMerge) != 0 {
- rb := android.NewRuleBuilder()
- rb.Command().
- BuiltTool(ctx, "merge_zips").
- Output(outputZipFile).
- Input(zipFile).
- Inputs(builder.zipsToMerge)
- rb.Build(pctx, ctx, outputRuleName, outputDesc)
+ ctx.Build(pctx, android.BuildParams{
+ Description: outputDesc,
+ Rule: mergeZips,
+ Input: zipFile,
+ Inputs: builder.zipsToMerge,
+ Output: outputZipFile,
+ })
}
return outputZipFile
@@ -364,7 +276,6 @@
outputPropertySet(contents, &bpModule.bpPropertySet)
contents.Printfln("}")
}
- contents.Printfln("")
}
func outputPropertySet(contents *generatedContents, set *bpPropertySet) {
@@ -413,98 +324,6 @@
return contents.content.String()
}
-func buildSharedNativeLibSnapshot(ctx android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder) {
- // a function for emitting include dirs
- printExportedDirCopyCommandsForNativeLibs := func(lib archSpecificNativeLibInfo) {
- includeDirs := lib.exportedIncludeDirs
- includeDirs = append(includeDirs, lib.exportedSystemIncludeDirs...)
- if len(includeDirs) == 0 {
- return
- }
- for _, dir := range includeDirs {
- if _, gen := dir.(android.WritablePath); gen {
- // generated headers are copied via exportedDeps. See below.
- continue
- }
- targetDir := nativeIncludeDir
- if info.hasArchSpecificFlags {
- targetDir = filepath.Join(lib.archType, targetDir)
- }
-
- // TODO(jiyong) copy headers having other suffixes
- headers, _ := ctx.GlobWithDeps(dir.String()+"/**/*.h", nil)
- for _, file := range headers {
- src := android.PathForSource(ctx, file)
- dest := filepath.Join(targetDir, file)
- builder.CopyToSnapshot(src, dest)
- }
- }
-
- genHeaders := lib.exportedDeps
- for _, file := range genHeaders {
- targetDir := nativeGeneratedIncludeDir
- if info.hasArchSpecificFlags {
- targetDir = filepath.Join(lib.archType, targetDir)
- }
- dest := filepath.Join(targetDir, lib.name, file.Rel())
- builder.CopyToSnapshot(file, dest)
- }
- }
-
- if !info.hasArchSpecificFlags {
- printExportedDirCopyCommandsForNativeLibs(info.archVariants[0])
- }
-
- // for each architecture
- for _, av := range info.archVariants {
- builder.CopyToSnapshot(av.outputFile, nativeStubFilePathFor(av))
-
- if info.hasArchSpecificFlags {
- printExportedDirCopyCommandsForNativeLibs(av)
- }
- }
-
- info.generatePrebuiltLibrary(ctx, builder)
-}
-
-func (info *nativeLibInfo) generatePrebuiltLibrary(ctx android.ModuleContext, builder android.SnapshotBuilder) {
-
- // a function for emitting include dirs
- addExportedDirsForNativeLibs := func(lib archSpecificNativeLibInfo, properties android.BpPropertySet, systemInclude bool) {
- includeDirs := nativeIncludeDirPathsFor(ctx, lib, systemInclude, info.hasArchSpecificFlags)
- if len(includeDirs) == 0 {
- return
- }
- var propertyName string
- if !systemInclude {
- propertyName = "export_include_dirs"
- } else {
- propertyName = "export_system_include_dirs"
- }
- properties.AddProperty(propertyName, includeDirs)
- }
-
- pbm := builder.AddPrebuiltModule(info.name, "cc_prebuilt_library_shared")
-
- if !info.hasArchSpecificFlags {
- addExportedDirsForNativeLibs(info.archVariants[0], pbm, false /*systemInclude*/)
- addExportedDirsForNativeLibs(info.archVariants[0], pbm, true /*systemInclude*/)
- }
-
- archProperties := pbm.AddPropertySet("arch")
- for _, av := range info.archVariants {
- archTypeProperties := archProperties.AddPropertySet(av.archType)
- archTypeProperties.AddProperty("srcs", []string{nativeStubFilePathFor(av)})
- if info.hasArchSpecificFlags {
- // export_* properties are added inside the arch: {<arch>: {...}} block
- addExportedDirsForNativeLibs(av, archTypeProperties, false /*systemInclude*/)
- addExportedDirsForNativeLibs(av, archTypeProperties, true /*systemInclude*/)
- }
- }
- pbm.AddProperty("stl", "none")
- pbm.AddProperty("system_shared_libs", []string{})
-}
-
type snapshotBuilder struct {
ctx android.ModuleContext
sdk *sdk
@@ -534,14 +353,16 @@
// Repackage the zip file so that the entries are in the destDir directory.
// This will allow the zip file to be merged into the snapshot.
tmpZipPath := android.PathForModuleOut(ctx, "tmp", destDir+".zip").OutputPath
- rb := android.NewRuleBuilder()
- rb.Command().
- BuiltTool(ctx, "zip2zip").
- FlagWithInput("-i ", zipPath).
- FlagWithOutput("-o ", tmpZipPath).
- Flag("**/*:" + destDir)
- rb.Build(pctx, ctx, "repackaging "+destDir,
- "Repackaging zip file "+destDir+" for snapshot "+ctx.ModuleName())
+
+ ctx.Build(pctx, android.BuildParams{
+ Description: "Repackaging zip file " + destDir + " for snapshot " + ctx.ModuleName(),
+ Rule: repackageZip,
+ Input: zipPath,
+ Output: tmpZipPath,
+ Args: map[string]string{
+ "destdir": destDir,
+ },
+ })
// Add the repackaged zip file to the files to merge.
s.zipsToMerge = append(s.zipsToMerge, tmpZipPath)
@@ -582,3 +403,19 @@
}
return references
}
+
+var _ android.SdkMember = (*sdkMember)(nil)
+
+type sdkMember struct {
+ memberType android.SdkMemberType
+ name string
+ variants []android.SdkAware
+}
+
+func (m *sdkMember) Name() string {
+ return m.name
+}
+
+func (m *sdkMember) Variants() []android.SdkAware {
+ return m.variants
+}
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index a876341..1fc94db 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -375,8 +375,8 @@
if isProduct {
// product can't own any sysprop_library now, so product must use public scope
scope = "public"
- } else if isVendor && !isOwnerPlatform {
- // vendor and odm can't use system's internal property.
+ } else if isVendor && isOwnerPlatform {
+ // vendor and odm can only use the public properties from the platform
scope = "public"
}
diff --git a/ui/build/build.go b/ui/build/build.go
index 6a19314..7dfb900 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -33,6 +33,15 @@
// can be parsed as ninja output.
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), "ninja_build"))
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), ".out-dir"))
+
+ if buildDateTimeFile, ok := config.environ.Get("BUILD_DATETIME_FILE"); ok {
+ err := ioutil.WriteFile(buildDateTimeFile, []byte(config.buildDateTime), 0777)
+ if err != nil {
+ ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
+ }
+ } else {
+ ctx.Fatalln("Missing BUILD_DATETIME_FILE")
+ }
}
var combinedBuildNinjaTemplate = template.Must(template.New("combined").Parse(`
diff --git a/ui/build/config.go b/ui/build/config.go
index 876bfe0..565f033 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -15,7 +15,6 @@
package build
import (
- "io/ioutil"
"os"
"path/filepath"
"runtime"
@@ -30,10 +29,11 @@
type configImpl struct {
// From the environment
- arguments []string
- goma bool
- environ *Environment
- distDir string
+ arguments []string
+ goma bool
+ environ *Environment
+ distDir string
+ buildDateTime string
// From the arguments
parallel int
@@ -244,18 +244,14 @@
outDir := ret.OutDir()
buildDateTimeFile := filepath.Join(outDir, "build_date.txt")
- var content string
if buildDateTime, ok := ret.environ.Get("BUILD_DATETIME"); ok && buildDateTime != "" {
- content = buildDateTime
+ ret.buildDateTime = buildDateTime
} else {
- content = strconv.FormatInt(time.Now().Unix(), 10)
+ ret.buildDateTime = strconv.FormatInt(time.Now().Unix(), 10)
}
+
if ctx.Metrics != nil {
- ctx.Metrics.SetBuildDateTime(content)
- }
- err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777)
- if err != nil {
- ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err)
+ ctx.Metrics.SetBuildDateTime(ret.buildDateTime)
}
ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
diff --git a/ui/metrics/metrics.go b/ui/metrics/metrics.go
index bc86f0a..64bbbf3 100644
--- a/ui/metrics/metrics.go
+++ b/ui/metrics/metrics.go
@@ -19,9 +19,9 @@
"os"
"strconv"
- "android/soong/ui/metrics/metrics_proto"
-
"github.com/golang/protobuf/proto"
+
+ soong_metrics_proto "android/soong/ui/metrics/metrics_proto"
)
const (
@@ -137,13 +137,32 @@
}
}
-func (m *Metrics) Serialize() (data []byte, err error) {
- return proto.Marshal(&m.metrics)
-}
-
// exports the output to the file at outputPath
func (m *Metrics) Dump(outputPath string) (err error) {
- data, err := m.Serialize()
+ return writeMessageToFile(&m.metrics, outputPath)
+}
+
+type CriticalUserJourneysMetrics struct {
+ cujs soong_metrics_proto.CriticalUserJourneysMetrics
+}
+
+func NewCriticalUserJourneysMetrics() *CriticalUserJourneysMetrics {
+ return &CriticalUserJourneysMetrics{}
+}
+
+func (c *CriticalUserJourneysMetrics) Add(name string, metrics *Metrics) {
+ c.cujs.Cujs = append(c.cujs.Cujs, &soong_metrics_proto.CriticalUserJourneyMetrics{
+ Name: proto.String(name),
+ Metrics: &metrics.metrics,
+ })
+}
+
+func (c *CriticalUserJourneysMetrics) Dump(outputPath string) (err error) {
+ return writeMessageToFile(&c.cujs, outputPath)
+}
+
+func writeMessageToFile(pb proto.Message, outputPath string) (err error) {
+ data, err := proto.Marshal(pb)
if err != nil {
return err
}
diff --git a/ui/metrics/metrics_proto/metrics.pb.go b/ui/metrics/metrics_proto/metrics.pb.go
index 5486ec1..0fe5a0d 100644
--- a/ui/metrics/metrics_proto/metrics.pb.go
+++ b/ui/metrics/metrics_proto/metrics.pb.go
@@ -509,6 +509,95 @@
return 0
}
+type CriticalUserJourneyMetrics struct {
+ // The name of a critical user journey test.
+ Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
+ // The metrics produced when running the critical user journey test.
+ Metrics *MetricsBase `protobuf:"bytes,2,opt,name=metrics" json:"metrics,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *CriticalUserJourneyMetrics) Reset() { *m = CriticalUserJourneyMetrics{} }
+func (m *CriticalUserJourneyMetrics) String() string { return proto.CompactTextString(m) }
+func (*CriticalUserJourneyMetrics) ProtoMessage() {}
+func (*CriticalUserJourneyMetrics) Descriptor() ([]byte, []int) {
+ return fileDescriptor_6039342a2ba47b72, []int{3}
+}
+
+func (m *CriticalUserJourneyMetrics) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_CriticalUserJourneyMetrics.Unmarshal(m, b)
+}
+func (m *CriticalUserJourneyMetrics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_CriticalUserJourneyMetrics.Marshal(b, m, deterministic)
+}
+func (m *CriticalUserJourneyMetrics) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_CriticalUserJourneyMetrics.Merge(m, src)
+}
+func (m *CriticalUserJourneyMetrics) XXX_Size() int {
+ return xxx_messageInfo_CriticalUserJourneyMetrics.Size(m)
+}
+func (m *CriticalUserJourneyMetrics) XXX_DiscardUnknown() {
+ xxx_messageInfo_CriticalUserJourneyMetrics.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_CriticalUserJourneyMetrics proto.InternalMessageInfo
+
+func (m *CriticalUserJourneyMetrics) GetName() string {
+ if m != nil && m.Name != nil {
+ return *m.Name
+ }
+ return ""
+}
+
+func (m *CriticalUserJourneyMetrics) GetMetrics() *MetricsBase {
+ if m != nil {
+ return m.Metrics
+ }
+ return nil
+}
+
+type CriticalUserJourneysMetrics struct {
+ // A set of metrics from a run of the critical user journey tests.
+ Cujs []*CriticalUserJourneyMetrics `protobuf:"bytes,1,rep,name=cujs" json:"cujs,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *CriticalUserJourneysMetrics) Reset() { *m = CriticalUserJourneysMetrics{} }
+func (m *CriticalUserJourneysMetrics) String() string { return proto.CompactTextString(m) }
+func (*CriticalUserJourneysMetrics) ProtoMessage() {}
+func (*CriticalUserJourneysMetrics) Descriptor() ([]byte, []int) {
+ return fileDescriptor_6039342a2ba47b72, []int{4}
+}
+
+func (m *CriticalUserJourneysMetrics) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_CriticalUserJourneysMetrics.Unmarshal(m, b)
+}
+func (m *CriticalUserJourneysMetrics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_CriticalUserJourneysMetrics.Marshal(b, m, deterministic)
+}
+func (m *CriticalUserJourneysMetrics) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_CriticalUserJourneysMetrics.Merge(m, src)
+}
+func (m *CriticalUserJourneysMetrics) XXX_Size() int {
+ return xxx_messageInfo_CriticalUserJourneysMetrics.Size(m)
+}
+func (m *CriticalUserJourneysMetrics) XXX_DiscardUnknown() {
+ xxx_messageInfo_CriticalUserJourneysMetrics.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_CriticalUserJourneysMetrics proto.InternalMessageInfo
+
+func (m *CriticalUserJourneysMetrics) GetCujs() []*CriticalUserJourneyMetrics {
+ if m != nil {
+ return m.Cujs
+ }
+ return nil
+}
+
func init() {
proto.RegisterEnum("soong_build_metrics.MetricsBase_BuildVariant", MetricsBase_BuildVariant_name, MetricsBase_BuildVariant_value)
proto.RegisterEnum("soong_build_metrics.MetricsBase_Arch", MetricsBase_Arch_name, MetricsBase_Arch_value)
@@ -516,59 +605,65 @@
proto.RegisterType((*MetricsBase)(nil), "soong_build_metrics.MetricsBase")
proto.RegisterType((*PerfInfo)(nil), "soong_build_metrics.PerfInfo")
proto.RegisterType((*ModuleTypeInfo)(nil), "soong_build_metrics.ModuleTypeInfo")
+ proto.RegisterType((*CriticalUserJourneyMetrics)(nil), "soong_build_metrics.CriticalUserJourneyMetrics")
+ proto.RegisterType((*CriticalUserJourneysMetrics)(nil), "soong_build_metrics.CriticalUserJourneysMetrics")
}
func init() { proto.RegisterFile("metrics.proto", fileDescriptor_6039342a2ba47b72) }
var fileDescriptor_6039342a2ba47b72 = []byte{
- // 769 bytes of a gzipped FileDescriptorProto
+ // 834 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x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, 0x92,
+ 0x1f, 0xc0, 0xcd, 0x50, 0x43, 0xd5, 0xba, 0xa8, 0xbb, 0x84, 0x6c, 0x63, 0x43, 0x7e, 0x84, 0x5e,
+ 0x5e, 0x66, 0x94, 0x2f, 0xa9, 0x29, 0x4a, 0xec, 0xb7, 0x1b, 0xee, 0xe7, 0x65, 0x36, 0x5f, 0x9a,
+ 0xfd, 0x64, 0xf0, 0x02, 0xdc, 0xc6, 0x5e, 0x77, 0xdf, 0x85, 0x03, 0xbb, 0x97, 0xf3, 0xf9, 0x4c,
+ 0xbf, 0xb4, 0x0e, 0xd8, 0xd3, 0xd3, 0x8b, 0x89, 0xb7, 0x13, 0xac, 0xe0, 0xfb, 0xb1, 0x48, 0x55,
+ 0x1a, 0x47, 0xab, 0x85, 0x64, 0xe2, 0x57, 0x5e, 0x8a, 0x9c, 0xad, 0xab, 0xdb, 0xbe, 0x39, 0x74,
+ 0xab, 0x71, 0xe8, 0x23, 0x68, 0x57, 0x5d, 0x62, 0x4a, 0x77, 0xd8, 0xff, 0xda, 0xc0, 0x08, 0x6b,
+ 0x41, 0x70, 0x0d, 0x4f, 0xb7, 0xec, 0x26, 0xeb, 0xed, 0xc6, 0x60, 0xc7, 0xe5, 0x67, 0xe9, 0x5b,
+ 0xf8, 0xb1, 0x6e, 0x3f, 0xd9, 0xff, 0x4f, 0x1b, 0xa2, 0xf8, 0xec, 0xbb, 0xdf, 0xab, 0xff, 0x61,
+ 0xa5, 0xa0, 0xf8, 0x93, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x20, 0x07, 0xbc, 0xf0, 0x34, 0x07,
+ 0x00, 0x00,
}
diff --git a/ui/metrics/metrics_proto/metrics.proto b/ui/metrics/metrics_proto/metrics.proto
index 93034eb..1ea24bf 100644
--- a/ui/metrics/metrics_proto/metrics.proto
+++ b/ui/metrics/metrics_proto/metrics.proto
@@ -125,3 +125,16 @@
// The number of logical modules.
optional uint32 num_of_modules = 3;
}
+
+message CriticalUserJourneyMetrics {
+ // The name of a critical user journey test.
+ optional string name = 1;
+
+ // The metrics produced when running the critical user journey test.
+ optional MetricsBase metrics = 2;
+}
+
+message CriticalUserJourneysMetrics {
+ // A set of metrics from a run of the critical user journey tests.
+ repeated CriticalUserJourneyMetrics cujs = 1;
+}
\ No newline at end of file
diff --git a/ui/status/log.go b/ui/status/log.go
index 9090f49..d407248 100644
--- a/ui/status/log.go
+++ b/ui/status/log.go
@@ -180,12 +180,12 @@
func (e *errorProtoLog) Flush() {
data, err := proto.Marshal(&e.errorProto)
if err != nil {
- e.log.Println("Failed to marshal build status proto: %v", err)
+ e.log.Printf("Failed to marshal build status proto: %v\n", err)
return
}
err = ioutil.WriteFile(e.filename, []byte(data), 0644)
if err != nil {
- e.log.Println("Failed to write file %s: %v", e.errorProto, err)
+ e.log.Printf("Failed to write file %s: %v\n", e.filename, err)
}
}