Merge "respect "apex_name:" for "apex" module"
diff --git a/android/androidmk.go b/android/androidmk.go
index 124523f..9071347 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -80,12 +80,14 @@
footer bytes.Buffer
ExtraEntries []AndroidMkExtraEntriesFunc
+ ExtraFooters []AndroidMkExtraFootersFunc
EntryMap map[string][]string
entryOrder []string
}
type AndroidMkExtraEntriesFunc func(entries *AndroidMkEntries)
+type AndroidMkExtraFootersFunc func(w io.Writer, name, prefix, moduleDir string, entries *AndroidMkEntries)
func (a *AndroidMkEntries) SetString(name, value string) {
if _, ok := a.EntryMap[name]; !ok {
@@ -94,6 +96,13 @@
a.EntryMap[name] = []string{value}
}
+func (a *AndroidMkEntries) SetPath(name string, path Path) {
+ if _, ok := a.EntryMap[name]; !ok {
+ a.entryOrder = append(a.entryOrder, name)
+ }
+ a.EntryMap[name] = []string{path.String()}
+}
+
func (a *AndroidMkEntries) SetBoolIfTrue(name string, flag bool) {
if flag {
if _, ok := a.EntryMap[name]; !ok {
@@ -103,6 +112,17 @@
}
}
+func (a *AndroidMkEntries) SetBool(name string, flag bool) {
+ if _, ok := a.EntryMap[name]; !ok {
+ a.entryOrder = append(a.entryOrder, name)
+ }
+ if flag {
+ a.EntryMap[name] = []string{"true"}
+ } else {
+ a.EntryMap[name] = []string{"false"}
+ }
+}
+
func (a *AndroidMkEntries) AddStrings(name string, value ...string) {
if len(value) == 0 {
return
@@ -254,9 +274,21 @@
// Write to footer.
fmt.Fprintln(&a.footer, "include "+a.Include)
+ blueprintDir := filepath.Dir(bpPath)
+ for _, footerFunc := range a.ExtraFooters {
+ footerFunc(&a.footer, name, prefix, blueprintDir, a)
+ }
}
func (a *AndroidMkEntries) write(w io.Writer) {
+ if a.Disabled {
+ return
+ }
+
+ if !a.OutputFile.Valid() {
+ return
+ }
+
w.Write(a.header.Bytes())
for _, name := range a.entryOrder {
fmt.Fprintln(w, name+" := "+strings.Join(a.EntryMap[name], " "))
@@ -264,6 +296,10 @@
w.Write(a.footer.Bytes())
}
+func (a *AndroidMkEntries) FooterLinesForTests() []string {
+ return strings.Split(string(a.footer.Bytes()), "\n")
+}
+
func AndroidMkSingleton() Singleton {
return &androidMkSingleton{}
}
diff --git a/android/hooks.go b/android/hooks.go
index 5810996..64ffd52 100644
--- a/android/hooks.go
+++ b/android/hooks.go
@@ -30,7 +30,7 @@
BaseModuleContext
AppendProperties(...interface{})
PrependProperties(...interface{})
- CreateModule(blueprint.ModuleFactory, ...interface{})
+ CreateModule(ModuleFactory, ...interface{})
}
// Arch hooks are run after the module has been split into architecture variants, and can be used
diff --git a/android/mutator.go b/android/mutator.go
index e76f847..7b7859c 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -121,7 +121,7 @@
Rename(name string)
- CreateModule(blueprint.ModuleFactory, ...interface{})
+ CreateModule(ModuleFactory, ...interface{})
}
type topDownMutatorContext struct {
@@ -243,9 +243,9 @@
t.Module().base().commonProperties.DebugName = name
}
-func (t *topDownMutatorContext) CreateModule(factory blueprint.ModuleFactory, props ...interface{}) {
+func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) {
inherited := []interface{}{&t.Module().base().commonProperties, &t.Module().base().variableProperties}
- t.bp.CreateModule(factory, append(inherited, props...)...)
+ t.bp.CreateModule(ModuleFactoryAdaptor(factory), append(inherited, props...)...)
}
func (b *bottomUpMutatorContext) MutatorName() string {
diff --git a/build_kzip.bash b/build_kzip.bash
index c1d09f7..1e0d48f 100755
--- a/build_kzip.bash
+++ b/build_kzip.bash
@@ -1,32 +1,27 @@
-# /bin/bash -uv
+#! /bin/bash -uv
#
# Build kzip files (source files for the indexing pipeline) for the given configuration,
# merge them and place the resulting all.kzip into $DIST_DIR.
# It is assumed that the current directory is the top of the source tree.
# The following environment variables affect the result:
-# TARGET_PRODUCT target device name, e.g., 'aosp_blueline'
-# TARGET_BUILD_VARIANT variant, e.g., `userdebug`
-# OUT_DIR absolute path where the build is happening ($PWD/out if not specified})
-# DIST_DIR where the resulting all.kzip will be placed
-# XREF_CORPUS source code repository URI, e.g., 'android.googlesource.com/platform/superproject'
# BUILD_NUMBER build number, used to generate unique ID (will use UUID if not set)
+# DIST_DIR where the resulting all.kzip will be placed
+# OUT_DIR output directory (out if not specified})
+# TARGET_BUILD_VARIANT variant, e.g., `userdebug`
+# TARGET_PRODUCT target device name, e.g., 'aosp_blueline'
+# XREF_CORPUS source code repository URI, e.g., 'android.googlesource.com/platform/superproject'
-# If OUT_DIR is not set, the build will use out/ as output directory, which is
-# a relative path. Make it absolute, otherwise the indexer will not know that it
-# contains only generated files.
-: ${OUT_DIR:=$PWD/out}
-[[ "$OUT_DIR" =~ ^/ ]] || { echo "$OUT_DIR is not an absolute path"; exit 1; }
+: ${BUILD_NUMBER:=$(uuidgen)}
-# The extraction might fail for some source files, so run with -k
-OUT_DIR=$OUT_DIR build/soong/soong_ui.bash --build-mode --all-modules --dir=$PWD -k merge_zips xref_cxx xref_java
-
-# We build with -k, so check that we have generated at least 100K files
-# (the actual number is 180K+)
-declare -r kzip_count=$(find $OUT_DIR -name '*.kzip' | wc -l)
+# The extraction might fail for some source files, so run with -k and then check that
+# sufficiently many files were generated.
+build/soong/soong_ui.bash --build-mode --all-modules --dir=$PWD -k merge_zips xref_cxx xref_java
+declare -r out="${OUT_DIR:-out}"
+declare -r kzip_count=$(find "$out" -name '*.kzip' | wc -l)
(($kzip_count>100000)) || { printf "Too few kzip files were generated: %d\n" $kzip_count; exit 1; }
# Pack
# TODO(asmundak): this should be done by soong.
-declare -r allkzip=all.kzip
-"$OUT_DIR/soong/host/linux-x86/bin/merge_zips" "$DIST_DIR/$allkzip" @<(find $OUT_DIR -name '*.kzip')
-echo "${BUILD_NUMBER:-$(uuidgen)}" >"$DIST_DIR/revision.txt"
+declare -r allkzip="$BUILD_NUMBER.kzip"
+"$out/soong/host/linux-x86/bin/merge_zips" "$DIST_DIR/$allkzip" @<(find "$out" -name '*.kzip')
+
diff --git a/cc/builder.go b/cc/builder.go
index b353814..c4f65da 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -224,12 +224,13 @@
_ = pctx.SourcePathVariable("cxxExtractor",
"prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/cxx_extractor")
+ _ = pctx.SourcePathVariable("kytheVnames", "build/soong/vnames.json")
_ = pctx.VariableFunc("kytheCorpus",
func(ctx android.PackageVarContext) string { return ctx.Config().XrefCorpusName() })
kytheExtract = pctx.StaticRule("kythe",
blueprint.RuleParams{
- Command: "rm -f $out && KYTHE_CORPUS=${kytheCorpus} KYTHE_OUTPUT_FILE=$out $cxxExtractor $cFlags $in ",
- CommandDeps: []string{"$cxxExtractor"},
+ Command: "rm -f $out && KYTHE_CORPUS=${kytheCorpus} KYTHE_OUTPUT_FILE=$out KYTHE_VNAMES=$kytheVnames $cxxExtractor $cFlags $in ",
+ CommandDeps: []string{"$cxxExtractor", "$kytheVnames"},
},
"cFlags")
)
diff --git a/cc/object.go b/cc/object.go
index f619c79..1f1ac8e 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -52,8 +52,9 @@
// input to a cc_genrule module.
func ObjectFactory() android.Module {
module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
+ module.sanitize = &sanitize{}
module.linker = &objectLinker{
- baseLinker: NewBaseLinker(nil),
+ baseLinker: NewBaseLinker(module.sanitize),
}
module.compiler = NewBaseCompiler()
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 415518c..c0a7c63 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -674,7 +674,7 @@
func isSanitizableDependencyTag(tag blueprint.DependencyTag) bool {
t, ok := tag.(dependencyTag)
- return ok && t.library || t == reuseObjTag
+ return ok && t.library || t == reuseObjTag || t == objDepTag
}
// Propagate sanitizer requirements down from binaries
diff --git a/cc/test.go b/cc/test.go
index ba0b7e4..0e66e28 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -80,6 +80,11 @@
// Add MinApiLevelModuleController to auto generated test config. If the device property of
// "ro.build.version.sdk" < Test_min_sdk_version, then skip this module.
Test_min_sdk_version *int64
+
+ // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
+ // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
+ // explicitly.
+ Auto_gen_config *bool
}
func init() {
@@ -362,7 +367,7 @@
}
test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
- test.Properties.Test_config_template, test.Properties.Test_suites, configs)
+ test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config)
test.binaryDecorator.baseInstaller.dir = "nativetest"
test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
@@ -453,6 +458,11 @@
// Add RootTargetPreparer to auto generated test config. This guarantees the test to run
// with root permission.
Require_root *bool
+
+ // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
+ // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
+ // explicitly.
+ Auto_gen_config *bool
}
type benchmarkDecorator struct {
@@ -490,7 +500,7 @@
configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
}
benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config,
- benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites, configs)
+ benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites, configs, benchmark.Properties.Auto_gen_config)
benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName())
benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName())
diff --git a/cmd/multiproduct_kati/main.go b/cmd/multiproduct_kati/main.go
index 1171a65..2800ade 100644
--- a/cmd/multiproduct_kati/main.go
+++ b/cmd/multiproduct_kati/main.go
@@ -158,7 +158,7 @@
func main() {
stdio := terminal.StdioImpl{}
- output := terminal.NewStatusOutput(stdio.Stdout(), "",
+ output := terminal.NewStatusOutput(stdio.Stdout(), "", false,
build.OsEnvironment().IsEnvTrue("ANDROID_QUIET_BUILD"))
log := logger.New(output)
@@ -391,7 +391,7 @@
Thread: mpctx.Tracer.NewThread(product),
Status: &status.Status{},
}}
- ctx.Status.AddOutput(terminal.NewStatusOutput(ctx.Writer, "",
+ ctx.Status.AddOutput(terminal.NewStatusOutput(ctx.Writer, "", false,
build.OsEnvironment().IsEnvTrue("ANDROID_QUIET_BUILD")))
config := build.NewConfig(ctx, flag.Args()...)
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index ec4f90e..974c644 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -41,6 +41,12 @@
// description for the flag (to display when running help)
description string
+ // Forces the status output into dumb terminal mode.
+ forceDumbOutput bool
+
+ // Sets a prefix string to use for filenames of log files.
+ logsPrefix string
+
// Creates the build configuration based on the args and build context.
config func(ctx build.Context, args ...string) build.Config
@@ -64,17 +70,21 @@
stdio: stdio,
run: make,
}, {
- flag: "--dumpvar-mode",
- description: "print the value of the legacy make variable VAR to stdout",
- config: dumpVarConfig,
- stdio: customStdio,
- run: dumpVar,
+ flag: "--dumpvar-mode",
+ description: "print the value of the legacy make variable VAR to stdout",
+ forceDumbOutput: true,
+ logsPrefix: "dumpvars-",
+ config: dumpVarConfig,
+ stdio: customStdio,
+ run: dumpVar,
}, {
- flag: "--dumpvars-mode",
- description: "dump the values of one or more legacy make variables, in shell syntax",
- config: dumpVarConfig,
- stdio: customStdio,
- run: dumpVars,
+ flag: "--dumpvars-mode",
+ description: "dump the values of one or more legacy make variables, in shell syntax",
+ forceDumbOutput: true,
+ logsPrefix: "dumpvars-",
+ config: dumpVarConfig,
+ stdio: customStdio,
+ run: dumpVars,
}, {
flag: "--build-mode",
description: "build modules based on the specified build action",
@@ -113,7 +123,7 @@
os.Exit(1)
}
- output := terminal.NewStatusOutput(c.stdio().Stdout(), os.Getenv("NINJA_STATUS"),
+ output := terminal.NewStatusOutput(c.stdio().Stdout(), os.Getenv("NINJA_STATUS"), c.forceDumbOutput,
build.OsEnvironment().IsEnvTrue("ANDROID_QUIET_BUILD"))
log := logger.New(output)
@@ -157,14 +167,14 @@
}
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")))
+ log.SetOutput(filepath.Join(logsDir, c.logsPrefix+"soong.log"))
+ trace.SetOutput(filepath.Join(logsDir, c.logsPrefix+"build.trace"))
+ stat.AddOutput(status.NewVerboseLog(log, filepath.Join(logsDir, c.logsPrefix+"verbose.log")))
+ stat.AddOutput(status.NewErrorLog(log, filepath.Join(logsDir, c.logsPrefix+"error.log")))
+ stat.AddOutput(status.NewProtoErrorLog(log, filepath.Join(logsDir, c.logsPrefix+"build_error")))
stat.AddOutput(status.NewCriticalPath(log))
- defer met.Dump(filepath.Join(logsDir, "soong_metrics"))
+ defer met.Dump(filepath.Join(logsDir, c.logsPrefix+"soong_metrics"))
if start, ok := os.LookupEnv("TRACE_BEGIN_SOONG"); ok {
if !strings.HasSuffix(start, "N") {
diff --git a/java/androidmk.go b/java/androidmk.go
index f006705..032dc6a 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -22,7 +22,9 @@
"android/soong/android"
)
-func (library *Library) AndroidMkHostDex(w io.Writer, name string, data android.AndroidMkData) {
+// TODO(jungjw): We'll probably want AndroidMkEntriesProvider.AndroidMkEntries to return multiple
+// entries so that this can be more error-proof.
+func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *android.AndroidMkEntries) {
if Bool(library.deviceProperties.Hostdex) && !library.Host() {
fmt.Fprintln(w, "include $(CLEAR_VARS)")
fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
@@ -38,14 +40,14 @@
}
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
- if len(data.Required) > 0 {
- fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(data.Required, " "))
+ if len(entries.Required) > 0 {
+ fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(entries.Required, " "))
}
- if len(data.Host_required) > 0 {
- fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(data.Host_required, " "))
+ if len(entries.Host_required) > 0 {
+ fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(entries.Host_required, " "))
}
- if len(data.Target_required) > 0 {
- fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(data.Target_required, " "))
+ if len(entries.Target_required) > 0 {
+ fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(entries.Target_required, " "))
}
if r := library.deviceProperties.Target.Hostdex.Required; len(r) > 0 {
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(r, " "))
@@ -54,75 +56,64 @@
}
}
-func (library *Library) AndroidMk() android.AndroidMkData {
+func (library *Library) AndroidMkEntries() android.AndroidMkEntries {
if !library.IsForPlatform() {
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Disabled: true,
}
}
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(library.outputFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
if len(library.logtagsSrcs) > 0 {
var logtags []string
for _, l := range library.logtagsSrcs {
logtags = append(logtags, l.Rel())
}
- fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
+ entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
}
if library.installFile == nil {
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+ entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
}
if library.dexJarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
+ entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
}
if len(library.dexpreopter.builtInstalled) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", library.dexpreopter.builtInstalled)
+ entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
}
- fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
+ entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion())
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
if library.jacocoReportClassesFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
+ entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
}
- if len(library.exportedSdkLibs) != 0 {
- fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
- }
+ entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
if len(library.additionalCheckedModules) != 0 {
- fmt.Fprintln(w, "LOCAL_ADDITIONAL_CHECKED_MODULE +=", strings.Join(library.additionalCheckedModules.Strings(), " "))
+ entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
}
if library.proguardDictionary != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", library.proguardDictionary.String())
+ entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
}
},
},
- Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- android.WriteAndroidMkData(w, data)
- library.AndroidMkHostDex(w, name, data)
+ ExtraFooters: []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ library.AndroidMkHostDex(w, name, entries)
+ },
},
}
}
// Called for modules that are a component of a test suite.
-func testSuiteComponent(w io.Writer, test_suites []string) {
- fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
- if len(test_suites) > 0 {
- fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
- strings.Join(test_suites, " "))
- } else {
- fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
- }
-}
-
-func testSuiteComponentEntries(entries *android.AndroidMkEntries, test_suites []string) {
+func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
entries.SetString("LOCAL_MODULE_TAGS", "tests")
if len(test_suites) > 0 {
entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
@@ -131,179 +122,175 @@
}
}
-func (j *Test) AndroidMk() android.AndroidMkData {
- data := j.Library.AndroidMk()
- data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
- testSuiteComponent(w, j.testProperties.Test_suites)
+func (j *Test) AndroidMkEntries() android.AndroidMkEntries {
+ entries := j.Library.AndroidMkEntries()
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
+ testSuiteComponent(entries, j.testProperties.Test_suites)
if j.testConfig != nil {
- fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
+ entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
}
+ androidMkWriteTestData(j.data, entries)
})
- androidMkWriteTestData(j.data, &data)
-
- return data
+ return entries
}
-func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData {
- data := j.Library.AndroidMk()
- data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
- testSuiteComponent(w, j.testHelperLibraryProperties.Test_suites)
+func (j *TestHelperLibrary) AndroidMkEntries() android.AndroidMkEntries {
+ entries := j.Library.AndroidMkEntries()
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
+ testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
})
- return data
+ return entries
}
-func (prebuilt *Import) AndroidMk() android.AndroidMkData {
+func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries {
if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().IsCurrentVersion() {
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Disabled: true,
}
}
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
- fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
+ entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
+ entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
},
},
}
}
-func (prebuilt *DexImport) AndroidMk() android.AndroidMkData {
+func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries {
if !prebuilt.IsForPlatform() {
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Disabled: true,
}
}
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
if prebuilt.dexJarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", prebuilt.dexJarFile.String())
+ entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
// TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
// boot_jars_package_check.mk can check dex jars.
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.dexJarFile.String())
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.dexJarFile.String())
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.dexJarFile)
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.dexJarFile)
}
if len(prebuilt.dexpreopter.builtInstalled) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", prebuilt.dexpreopter.builtInstalled)
+ entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
}
},
},
}
}
-func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (prebuilt *AARImport) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
- fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
- fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
- fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
- fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
- fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
+ entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
+ entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
+ entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
+ entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
+ entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
+ entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
},
},
}
}
-func (binary *Binary) AndroidMk() android.AndroidMkData {
+func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries {
if !binary.isWrapperVariant {
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(binary.outputFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
if binary.dexJarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
+ entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
}
if len(binary.dexpreopter.builtInstalled) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", binary.dexpreopter.builtInstalled)
+ entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
}
},
},
- Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- android.WriteAndroidMkData(w, data)
-
- fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
+ ExtraFooters: []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
+ },
},
}
} else {
- return android.AndroidMkData{
+ return android.AndroidMkEntries{
Class: "EXECUTABLES",
OutputFile: android.OptionalPathForPath(binary.wrapperFile),
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
+ entries.SetBool("LOCAL_STRIP_MODULE", false)
},
},
- Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- android.WriteAndroidMkData(w, data)
-
- // Ensure that the wrapper script timestamp is always updated when the jar is updated
- fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
- fmt.Fprintln(w, "jar_installed_module :=")
+ ExtraFooters: []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ // Ensure that the wrapper script timestamp is always updated when the jar is updated
+ fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
+ fmt.Fprintln(w, "jar_installed_module :=")
+ },
},
}
}
}
-func (app *AndroidApp) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "APPS",
OutputFile: android.OptionalPathForPath(app.outputFile),
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- // TODO(jungjw): This, outputting two LOCAL_MODULE lines, works, but is not ideal. Find a better solution.
- if app.Name() != app.installApkName {
- fmt.Fprintln(w, "# Overridden by PRODUCT_PACKAGE_NAME_OVERRIDES")
- fmt.Fprintln(w, "LOCAL_MODULE :=", app.installApkName)
- }
- fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
+ // App module names can be overridden.
+ entries.SetString("LOCAL_MODULE", app.installApkName)
+ entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
if app.dexJarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
+ entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
}
if app.implementationAndResourcesJar != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
}
if app.headerJarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
}
if app.bundleFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
+ entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
}
if app.jacocoReportClassesFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
+ entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
}
if app.proguardDictionary != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
+ entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary)
}
if app.Name() == "framework-res" {
- fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
+ entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
// Make base_rules.mk not put framework-res in a subdirectory called
// framework_res.
- fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
+ entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
}
filterRRO := func(filter overlayType) android.Paths {
@@ -319,38 +306,36 @@
}
deviceRRODirs := filterRRO(device)
if len(deviceRRODirs) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_DEVICE_RRO_DIRS :=", strings.Join(deviceRRODirs.Strings(), " "))
+ entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
}
productRRODirs := filterRRO(product)
if len(productRRODirs) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_PRODUCT_RRO_DIRS :=", strings.Join(productRRODirs.Strings(), " "))
+ entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
}
- if Bool(app.appProperties.Export_package_resources) {
- fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
- }
+ entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
- fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
+ entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
- if Bool(app.appProperties.Privileged) {
- fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
- }
+ entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(app.appProperties.Privileged))
- fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
- if overriddenPkgs := app.getOverriddenPackages(); len(overriddenPkgs) > 0 {
- fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES :=", strings.Join(overriddenPkgs, " "))
- }
+ entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem)
+ entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
for _, jniLib := range app.installJniLibs {
- fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
+ entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
}
if len(app.dexpreopter.builtInstalled) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", app.dexpreopter.builtInstalled)
+ entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
}
for _, split := range app.aapt.splits {
install := "$(LOCAL_MODULE_PATH)/" + strings.TrimSuffix(app.installApkName, ".apk") + split.suffix + ".apk"
- fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED +=", split.path.String()+":"+install)
+ entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", split.path.String()+":"+install)
}
+ },
+ },
+ ExtraFooters: []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
if app.noticeOutputs.Merged.Valid() {
fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
@@ -379,85 +364,116 @@
return overridden
}
-func (a *AndroidTest) AndroidMk() android.AndroidMkData {
- data := a.AndroidApp.AndroidMk()
- data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
- testSuiteComponent(w, a.testProperties.Test_suites)
+func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
+ entries := a.AndroidApp.AndroidMkEntries()
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
+ testSuiteComponent(entries, a.testProperties.Test_suites)
if a.testConfig != nil {
- fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
+ entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
}
- })
- androidMkWriteTestData(a.data, &data)
-
- return data
-}
-
-func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
- data := a.AndroidApp.AndroidMk()
- data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
- testSuiteComponent(w, a.appTestHelperAppProperties.Test_suites)
+ androidMkWriteTestData(a.data, entries)
})
- return data
+ return entries
}
-func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
- data := a.Library.AndroidMk()
+func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries {
+ entries := a.AndroidApp.AndroidMkEntries()
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
+ testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
+ })
- data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
+ return entries
+}
+
+func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
+ entries := a.Library.AndroidMkEntries()
+
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
if a.aarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
+ entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
}
if a.Name() == "framework-res" {
- fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
+ entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
// Make base_rules.mk not put framework-res in a subdirectory called
// framework_res.
- fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
+ entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
}
- fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
- fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
- fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.mergedManifestFile.String())
- fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
- strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+ entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
+ entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
+ entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
+ entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
+ entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
})
- return data
+ return entries
}
-func (jd *Javadoc) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
if BoolDefault(jd.properties.Installable, true) {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
+ entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
}
if jd.stubsSrcJar != nil {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
+ entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
}
},
},
}
}
-func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
+ entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
}
if ddoc.Javadoc.stubsSrcJar != nil {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
+ entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
}
+ apiFilePrefix := "INTERNAL_PLATFORM_"
+ if String(ddoc.properties.Api_tag_name) != "" {
+ apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
+ }
+ if ddoc.apiFile != nil {
+ entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile)
+ }
+ if ddoc.dexApiFile != nil {
+ entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile)
+ }
+ if ddoc.privateApiFile != nil {
+ entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile)
+ }
+ if ddoc.privateDexApiFile != nil {
+ entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile)
+ }
+ if ddoc.removedApiFile != nil {
+ entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile)
+ }
+ if ddoc.removedDexApiFile != nil {
+ entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile)
+ }
+ if ddoc.exactApiFile != nil {
+ entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile)
+ }
+ if ddoc.proguardFile != nil {
+ entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile)
+ }
+ },
+ },
+ ExtraFooters: []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
if ddoc.checkCurrentApiTimestamp != nil {
fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
@@ -493,58 +509,59 @@
fmt.Fprintln(w, "droidcore: checkapi")
}
}
- apiFilePrefix := "INTERNAL_PLATFORM_"
- if String(ddoc.properties.Api_tag_name) != "" {
- apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
- }
- if ddoc.apiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
- }
- if ddoc.dexApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
- }
- if ddoc.privateApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
- }
- if ddoc.privateDexApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
- }
- if ddoc.removedApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
- }
- if ddoc.removedDexApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
- }
- if ddoc.exactApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
- }
- if ddoc.proguardFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
- }
},
},
}
}
-func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
if dstubs.Javadoc.stubsSrcJar != nil {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
+ entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
}
if dstubs.apiVersionsXml != nil {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
+ entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
}
if dstubs.annotationsZip != nil {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
+ entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
}
if dstubs.jdiffDocZip != nil {
- fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
+ entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
}
+ apiFilePrefix := "INTERNAL_PLATFORM_"
+ if String(dstubs.properties.Api_tag_name) != "" {
+ apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
+ }
+ if dstubs.apiFile != nil {
+ entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile)
+ }
+ if dstubs.dexApiFile != nil {
+ entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile)
+ }
+ if dstubs.privateApiFile != nil {
+ entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile)
+ }
+ if dstubs.privateDexApiFile != nil {
+ entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile)
+ }
+ if dstubs.removedApiFile != nil {
+ entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile)
+ }
+ if dstubs.removedDexApiFile != nil {
+ entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile)
+ }
+ if dstubs.exactApiFile != nil {
+ entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile)
+ }
+ },
+ },
+ ExtraFooters: []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
if dstubs.checkCurrentApiTimestamp != nil {
fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
@@ -588,31 +605,6 @@
fmt.Fprintln(w, ".PHONY:", "droidcore")
fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
}
- apiFilePrefix := "INTERNAL_PLATFORM_"
- if String(dstubs.properties.Api_tag_name) != "" {
- apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
- }
- if dstubs.apiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
- }
- if dstubs.dexApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
- }
- if dstubs.privateApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
- }
- if dstubs.privateDexApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
- }
- if dstubs.removedApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
- }
- if dstubs.removedDexApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
- }
- if dstubs.exactApiFile != nil {
- fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
- }
},
},
}
@@ -627,7 +619,7 @@
func(entries *android.AndroidMkEntries) {
entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(a.properties.Privileged))
if a.certificate != nil {
- entries.SetString("LOCAL_CERTIFICATE", a.certificate.Pem.String())
+ entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
} else {
entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED")
}
@@ -644,25 +636,13 @@
func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
entries := a.AndroidAppImport.AndroidMkEntries()
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
- testSuiteComponentEntries(entries, a.testProperties.Test_suites)
- androidMkEntriesWriteTestData(a.data, entries)
+ testSuiteComponent(entries, a.testProperties.Test_suites)
+ androidMkWriteTestData(a.data, entries)
})
return entries
}
-func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
- var testFiles []string
- for _, d := range data {
- testFiles = append(testFiles, d.String()+":"+d.Rel())
- }
- if len(testFiles) > 0 {
- ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
- })
- }
-}
-
-func androidMkEntriesWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
+func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
var testFiles []string
for _, d := range data {
testFiles = append(testFiles, d.String()+":"+d.Rel())
diff --git a/java/androidmk_test.go b/java/androidmk_test.go
index fbf2baa..438b66a 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -15,107 +15,12 @@
package java
import (
- "bytes"
- "io"
- "io/ioutil"
- "strings"
+ "reflect"
"testing"
"android/soong/android"
)
-type testAndroidMk struct {
- *testing.T
- body []byte
-}
-
-type testAndroidMkModule struct {
- *testing.T
- props map[string]string
-}
-
-func newTestAndroidMk(t *testing.T, r io.Reader) *testAndroidMk {
- t.Helper()
- buf, err := ioutil.ReadAll(r)
- if err != nil {
- t.Fatal("failed to open read Android.mk.", err)
- }
- return &testAndroidMk{
- T: t,
- body: buf,
- }
-}
-
-func parseAndroidMkProps(lines []string) map[string]string {
- props := make(map[string]string)
- for _, line := range lines {
- line = strings.TrimLeft(line, " ")
- if line == "" || strings.HasPrefix(line, "#") {
- continue
- }
- tokens := strings.Split(line, " ")
- if tokens[1] == "+=" {
- props[tokens[0]] += " " + strings.Join(tokens[2:], " ")
- } else {
- props[tokens[0]] = strings.Join(tokens[2:], " ")
- }
- }
- return props
-}
-
-func (t *testAndroidMk) moduleFor(moduleName string) *testAndroidMkModule {
- t.Helper()
- lines := strings.Split(string(t.body), "\n")
- index := android.IndexList("LOCAL_MODULE := "+moduleName, lines)
- if index == -1 {
- t.Fatalf("%q is not found.", moduleName)
- }
- lines = lines[index:]
- includeIndex := android.IndexListPred(func(line string) bool {
- return strings.HasPrefix(line, "include")
- }, lines)
- if includeIndex == -1 {
- t.Fatalf("%q is not properly defined. (\"include\" not found).", moduleName)
- }
- props := parseAndroidMkProps(lines[:includeIndex])
- return &testAndroidMkModule{
- T: t.T,
- props: props,
- }
-}
-
-func (t *testAndroidMkModule) hasRequired(dep string) {
- t.Helper()
- required, ok := t.props["LOCAL_REQUIRED_MODULES"]
- if !ok {
- t.Error("LOCAL_REQUIRED_MODULES is not found.")
- return
- }
- if !android.InList(dep, strings.Split(required, " ")) {
- t.Errorf("%q is expected in LOCAL_REQUIRED_MODULES, but not found in %q.", dep, required)
- }
-}
-
-func (t *testAndroidMkModule) hasNoRequired(dep string) {
- t.Helper()
- required, ok := t.props["LOCAL_REQUIRED_MODULES"]
- if !ok {
- return
- }
- if android.InList(dep, strings.Split(required, " ")) {
- t.Errorf("%q is not expected in LOCAL_REQUIRED_MODULES, but found.", dep)
- }
-}
-
-func getAndroidMk(t *testing.T, ctx *android.TestContext, config android.Config, name string) *testAndroidMk {
- t.Helper()
- lib, _ := ctx.ModuleForTests(name, "android_common").Module().(*Library)
- data := android.AndroidMkDataForTest(t, config, "", lib)
- w := &bytes.Buffer{}
- data.Custom(w, name, "", "", data)
- return newTestAndroidMk(t, w)
-}
-
func TestRequired(t *testing.T) {
ctx, config := testJava(t, `
java_library {
@@ -125,8 +30,14 @@
}
`)
- mk := getAndroidMk(t, ctx, config, "foo")
- mk.moduleFor("foo").hasRequired("libfoo")
+ mod := ctx.ModuleForTests("foo", "android_common").Module()
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+
+ expected := []string{"libfoo"}
+ actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
+ }
}
func TestHostdex(t *testing.T) {
@@ -138,9 +49,19 @@
}
`)
- mk := getAndroidMk(t, ctx, config, "foo")
- mk.moduleFor("foo")
- mk.moduleFor("foo-hostdex")
+ mod := ctx.ModuleForTests("foo", "android_common").Module()
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+
+ expected := []string{"foo"}
+ actual := entries.EntryMap["LOCAL_MODULE"]
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Unexpected module name - expected: %q, actual: %q", expected, actual)
+ }
+
+ footerLines := entries.FooterLinesForTests()
+ if !android.InList("LOCAL_MODULE := foo-hostdex", footerLines) {
+ t.Errorf("foo-hostdex is not found in the footers: %q", footerLines)
+ }
}
func TestHostdexRequired(t *testing.T) {
@@ -153,9 +74,19 @@
}
`)
- mk := getAndroidMk(t, ctx, config, "foo")
- mk.moduleFor("foo").hasRequired("libfoo")
- mk.moduleFor("foo-hostdex").hasRequired("libfoo")
+ mod := ctx.ModuleForTests("foo", "android_common").Module()
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+
+ expected := []string{"libfoo"}
+ actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
+ }
+
+ footerLines := entries.FooterLinesForTests()
+ if !android.InList("LOCAL_REQUIRED_MODULES := libfoo", footerLines) {
+ t.Errorf("Wrong or missing required line for foo-hostdex in the footers: %q", footerLines)
+ }
}
func TestHostdexSpecificRequired(t *testing.T) {
@@ -172,7 +103,15 @@
}
`)
- mk := getAndroidMk(t, ctx, config, "foo")
- mk.moduleFor("foo").hasNoRequired("libfoo")
- mk.moduleFor("foo-hostdex").hasRequired("libfoo")
+ mod := ctx.ModuleForTests("foo", "android_common").Module()
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+
+ if r, ok := entries.EntryMap["LOCAL_REQUIRED_MODULES"]; ok {
+ t.Errorf("Unexpected required modules: %q", r)
+ }
+
+ footerLines := entries.FooterLinesForTests()
+ if !android.InList("LOCAL_REQUIRED_MODULES += libfoo", footerLines) {
+ t.Errorf("Wrong or missing required line for foo-hostdex in the footers: %q", footerLines)
+ }
}
diff --git a/java/app.go b/java/app.go
index d00c4c0..afddb6a 100644
--- a/java/app.go
+++ b/java/app.go
@@ -608,7 +608,8 @@
}
a.generateAndroidBuildActions(ctx)
- a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites)
+ a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config,
+ a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites, a.testProperties.Auto_gen_config)
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
}
@@ -656,6 +657,11 @@
// list of compatibility suites (for example "cts", "vts") that the module should be
// installed into.
Test_suites []string `android:"arch_variant"`
+
+ // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
+ // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
+ // explicitly.
+ Auto_gen_config *bool
}
type AndroidTestHelperApp struct {
diff --git a/java/builder.go b/java/builder.go
index 9e068fa..0a5c79b 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -64,6 +64,7 @@
_ = pctx.VariableFunc("kytheCorpus",
func(ctx android.PackageVarContext) string { return ctx.Config().XrefCorpusName() })
+ _ = pctx.SourcePathVariable("kytheVnames", "build/soong/vnames.json")
// Run it with -add-opens=java.base/java.nio=ALL-UNNAMED to avoid JDK9's warning about
// "Illegal reflective access by com.google.protobuf.Utf8$UnsafeProcessor ...
// to field java.nio.Buffer.address"
@@ -74,6 +75,7 @@
`( [ ! -s $srcJarDir/list -a ! -s $out.rsp ] || ` +
`KYTHE_ROOT_DIRECTORY=. KYTHE_OUTPUT_FILE=$out ` +
`KYTHE_CORPUS=${kytheCorpus} ` +
+ `KYTHE_VNAMES=${kytheVnames} ` +
`${config.SoongJavacWrapper} ${config.JavaCmd} ` +
`--add-opens=java.base/java.nio=ALL-UNNAMED ` +
`-jar ${config.JavaKytheExtractorJar} ` +
@@ -84,6 +86,7 @@
CommandDeps: []string{
"${config.JavaCmd}",
"${config.JavaKytheExtractorJar}",
+ "${kytheVnames}",
"${config.ZipSyncCmd}",
},
CommandOrderOnly: []string{"${config.SoongJavacWrapper}"},
diff --git a/java/java.go b/java/java.go
index 4dd6a49..ce72c27 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1685,6 +1685,11 @@
// list of files or filegroup modules that provide data that should be installed alongside
// the test
Data []string `android:"path"`
+
+ // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
+ // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
+ // explicitly.
+ Auto_gen_config *bool
}
type testHelperLibraryProperties struct {
@@ -1709,7 +1714,8 @@
}
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, j.testProperties.Test_suites)
+ j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template,
+ j.testProperties.Test_suites, j.testProperties.Auto_gen_config)
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
j.Library.GenerateAndroidBuildActions(ctx)
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index c370811..0d5e31f 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -82,7 +82,7 @@
props.Sdk_version = proptools.StringPtr("current")
props.Installable = proptools.BoolPtr(false)
- mctx.CreateModule(android.ModuleFactoryAdaptor(ImportFactory), &props)
+ mctx.CreateModule(ImportFactory, &props)
}
func createFilegroup(mctx android.TopDownMutatorContext, module string, scope string, apiver string, path string) {
@@ -93,7 +93,7 @@
}{}
filegroupProps.Name = proptools.StringPtr(fgName)
filegroupProps.Srcs = []string{path}
- mctx.CreateModule(android.ModuleFactoryAdaptor(android.FileGroupFactory), &filegroupProps)
+ mctx.CreateModule(android.FileGroupFactory, &filegroupProps)
}
func getPrebuiltFiles(mctx android.TopDownMutatorContext, name string) []string {
diff --git a/java/robolectric.go b/java/robolectric.go
index 9669e1b..dbf54c9 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -177,32 +177,32 @@
TransformResourcesToJar(ctx, outputFile, srcJarArgs, srcJarDeps)
}
-func (r *robolectricTest) AndroidMk() android.AndroidMkData {
- data := r.Library.AndroidMk()
+func (r *robolectricTest) AndroidMkEntries() android.AndroidMkEntries {
+ entries := r.Library.AndroidMkEntries()
- data.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- android.WriteAndroidMkData(w, data)
+ entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ if s := r.robolectricProperties.Test_options.Shards; s != nil && *s > 1 {
+ shards := shardTests(r.tests, int(*s))
+ for i, shard := range shards {
+ r.writeTestRunner(w, name, "Run"+name+strconv.Itoa(i), shard)
+ }
- if s := r.robolectricProperties.Test_options.Shards; s != nil && *s > 1 {
- shards := shardTests(r.tests, int(*s))
- for i, shard := range shards {
- r.writeTestRunner(w, name, "Run"+name+strconv.Itoa(i), shard)
+ // TODO: add rules to dist the outputs of the individual tests, or combine them together?
+ fmt.Fprintln(w, "")
+ fmt.Fprintln(w, ".PHONY:", "Run"+name)
+ fmt.Fprintln(w, "Run"+name, ": \\")
+ for i := range shards {
+ fmt.Fprintln(w, " ", "Run"+name+strconv.Itoa(i), "\\")
+ }
+ fmt.Fprintln(w, "")
+ } else {
+ r.writeTestRunner(w, name, "Run"+name, r.tests)
}
-
- // TODO: add rules to dist the outputs of the individual tests, or combine them together?
- fmt.Fprintln(w, "")
- fmt.Fprintln(w, ".PHONY:", "Run"+name)
- fmt.Fprintln(w, "Run"+name, ": \\")
- for i := range shards {
- fmt.Fprintln(w, " ", "Run"+name+strconv.Itoa(i), "\\")
- }
- fmt.Fprintln(w, "")
- } else {
- r.writeTestRunner(w, name, "Run"+name, r.tests)
- }
+ },
}
- return data
+ return entries
}
func (r *robolectricTest) writeTestRunner(w io.Writer, module, name string, tests []string) {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 30fd1c4..476e549 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -197,65 +197,65 @@
})
}
-func (module *SdkLibrary) AndroidMk() android.AndroidMkData {
- data := module.Library.AndroidMk()
- data.Required = append(data.Required, module.xmlFileName())
+func (module *SdkLibrary) AndroidMkEntries() android.AndroidMkEntries {
+ entries := module.Library.AndroidMkEntries()
+ entries.Required = append(entries.Required, module.xmlFileName())
- data.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- android.WriteAndroidMkData(w, data)
-
- module.Library.AndroidMkHostDex(w, name, data)
- if !Bool(module.sdkLibraryProperties.No_dist) {
- // Create a phony module that installs the impl library, for the case when this lib is
- // in PRODUCT_PACKAGES.
- owner := module.ModuleBase.Owner()
- if owner == "" {
- if Bool(module.sdkLibraryProperties.Core_lib) {
- owner = "core"
- } else {
- owner = "android"
+ entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ module.Library.AndroidMkHostDex(w, name, entries)
+ if !Bool(module.sdkLibraryProperties.No_dist) {
+ // Create a phony module that installs the impl library, for the case when this lib is
+ // in PRODUCT_PACKAGES.
+ owner := module.ModuleBase.Owner()
+ if owner == "" {
+ if Bool(module.sdkLibraryProperties.Core_lib) {
+ owner = "core"
+ } else {
+ owner = "android"
+ }
+ }
+ // Create dist rules to install the stubs libs to the dist dir
+ if len(module.publicApiStubsPath) == 1 {
+ fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
+ module.publicApiStubsImplPath.Strings()[0]+
+ ":"+path.Join("apistubs", owner, "public",
+ module.BaseModuleName()+".jar")+")")
+ }
+ if len(module.systemApiStubsPath) == 1 {
+ fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
+ module.systemApiStubsImplPath.Strings()[0]+
+ ":"+path.Join("apistubs", owner, "system",
+ module.BaseModuleName()+".jar")+")")
+ }
+ if len(module.testApiStubsPath) == 1 {
+ fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
+ module.testApiStubsImplPath.Strings()[0]+
+ ":"+path.Join("apistubs", owner, "test",
+ module.BaseModuleName()+".jar")+")")
+ }
+ if module.publicApiFilePath != nil {
+ fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
+ module.publicApiFilePath.String()+
+ ":"+path.Join("apistubs", owner, "public", "api",
+ module.BaseModuleName()+".txt")+")")
+ }
+ if module.systemApiFilePath != nil {
+ fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
+ module.systemApiFilePath.String()+
+ ":"+path.Join("apistubs", owner, "system", "api",
+ module.BaseModuleName()+".txt")+")")
+ }
+ if module.testApiFilePath != nil {
+ fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
+ module.testApiFilePath.String()+
+ ":"+path.Join("apistubs", owner, "test", "api",
+ module.BaseModuleName()+".txt")+")")
}
}
- // Create dist rules to install the stubs libs to the dist dir
- if len(module.publicApiStubsPath) == 1 {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.publicApiStubsImplPath.Strings()[0]+
- ":"+path.Join("apistubs", owner, "public",
- module.BaseModuleName()+".jar")+")")
- }
- if len(module.systemApiStubsPath) == 1 {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.systemApiStubsImplPath.Strings()[0]+
- ":"+path.Join("apistubs", owner, "system",
- module.BaseModuleName()+".jar")+")")
- }
- if len(module.testApiStubsPath) == 1 {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.testApiStubsImplPath.Strings()[0]+
- ":"+path.Join("apistubs", owner, "test",
- module.BaseModuleName()+".jar")+")")
- }
- if module.publicApiFilePath != nil {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.publicApiFilePath.String()+
- ":"+path.Join("apistubs", owner, "public", "api",
- module.BaseModuleName()+".txt")+")")
- }
- if module.systemApiFilePath != nil {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.systemApiFilePath.String()+
- ":"+path.Join("apistubs", owner, "system", "api",
- module.BaseModuleName()+".txt")+")")
- }
- if module.testApiFilePath != nil {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.testApiFilePath.String()+
- ":"+path.Join("apistubs", owner, "test", "api",
- module.BaseModuleName()+".txt")+")")
- }
- }
+ },
}
- return data
+ return entries
}
// Module name of the stubs library
@@ -422,7 +422,7 @@
props.Product_specific = proptools.BoolPtr(true)
}
- mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory), &props)
+ mctx.CreateModule(LibraryFactory, &props)
}
// Creates a droiddoc module that creates stubs source files from the given full source
@@ -522,7 +522,7 @@
module.latestRemovedApiFilegroupName(apiScope))
props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true)
- mctx.CreateModule(android.ModuleFactoryAdaptor(DroidstubsFactory), &props)
+ mctx.CreateModule(DroidstubsFactory, &props)
}
// Creates the xml file that publicizes the runtime library
@@ -560,7 +560,7 @@
genruleProps.Name = proptools.StringPtr(module.xmlFileName() + "-gen")
genruleProps.Cmd = proptools.StringPtr("echo '" + xmlContent + "' > $(out)")
genruleProps.Out = []string{module.xmlFileName()}
- mctx.CreateModule(android.ModuleFactoryAdaptor(genrule.GenRuleFactory), &genruleProps)
+ mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
// creates a prebuilt_etc module to actually place the xml file under
// <partition>/etc/permissions
@@ -582,7 +582,7 @@
} else if module.ProductSpecific() {
etcProps.Product_specific = proptools.BoolPtr(true)
}
- mctx.CreateModule(android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory), &etcProps)
+ mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps)
}
func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
@@ -815,7 +815,7 @@
props.Product_specific = proptools.BoolPtr(true)
}
- mctx.CreateModule(android.ModuleFactoryAdaptor(ImportFactory), &props, &module.properties)
+ mctx.CreateModule(ImportFactory, &props, &module.properties)
javaSdkLibraries := javaSdkLibraries(mctx.Config())
javaSdkLibrariesLock.Lock()
diff --git a/java/testing.go b/java/testing.go
index 5315b85..acbefb9 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -103,7 +103,6 @@
`
systemModules := []string{
- "core-system-modules",
"core-current-stubs-system-modules",
"core-platform-api-stubs-system-modules",
"android_stubs_current_system_modules",
diff --git a/python/binary.go b/python/binary.go
index 140f07a..695fa12 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -47,6 +47,11 @@
// false it will act much like the normal `python` executable, but with the sources and
// libraries automatically included in the PYTHONPATH.
Autorun *bool `android:"arch_variant"`
+
+ // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
+ // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
+ // explicitly.
+ Auto_gen_config *bool
}
type binaryDecorator struct {
diff --git a/python/test.go b/python/test.go
index 55b0ab5..f684fd5 100644
--- a/python/test.go
+++ b/python/test.go
@@ -50,7 +50,8 @@
func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) {
test.testConfig = tradefed.AutoGenPythonBinaryHostTestConfig(ctx, test.testProperties.Test_config,
- test.testProperties.Test_config_template, test.binaryDecorator.binaryProperties.Test_suites)
+ test.testProperties.Test_config_template, test.binaryDecorator.binaryProperties.Test_suites,
+ test.binaryDecorator.binaryProperties.Auto_gen_config)
test.binaryDecorator.pythonInstaller.dir = "nativetest"
test.binaryDecorator.pythonInstaller.dir64 = "nativetest64"
diff --git a/rust/compiler.go b/rust/compiler.go
index f45744b..6c603df 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -25,7 +25,8 @@
func NewBaseCompiler(dir, dir64 string) *baseCompiler {
return &baseCompiler{
Properties: BaseCompilerProperties{
- Edition: &config.DefaultEdition,
+ Edition: &config.DefaultEdition,
+ Deny_warnings: config.DefaultDenyWarnings,
},
dir: dir,
dir64: dir64,
@@ -33,6 +34,9 @@
}
type BaseCompilerProperties struct {
+ // whether to pass "-D warnings" to rustc. Defaults to true.
+ Deny_warnings *bool
+
// flags to pass to rustc
Flags []string `android:"path,arch_variant"`
@@ -109,6 +113,9 @@
func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flags {
+ if Bool(compiler.Properties.Deny_warnings) {
+ flags.RustFlags = append(flags.RustFlags, "-D warnings")
+ }
flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...)
flags.RustFlags = append(flags.RustFlags, compiler.featuresToFlags(compiler.Properties.Features)...)
flags.RustFlags = append(flags.RustFlags, "--edition="+*compiler.Properties.Edition)
diff --git a/rust/config/global.go b/rust/config/global.go
index cec5a74..c66c3c1 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -17,6 +17,8 @@
import (
"strings"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
_ "android/soong/cc/config"
)
@@ -33,6 +35,8 @@
"libtest",
}
+ DefaultDenyWarnings = proptools.BoolPtr(true)
+
deviceGlobalRustFlags = []string{}
deviceGlobalLinkFlags = []string{
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 5eb7fa9..a876341 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -362,7 +362,7 @@
ccProps.Recovery_available = m.properties.Recovery_available
ccProps.Vendor_available = m.properties.Vendor_available
- ctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProps)
+ ctx.CreateModule(cc.LibraryFactory, &ccProps)
// internal scope contains all properties
// public scope only contains public properties
@@ -390,7 +390,7 @@
Name: proptools.StringPtr(m.javaGenModuleName()),
}
- ctx.CreateModule(android.ModuleFactoryAdaptor(syspropJavaGenFactory), &javaGenProps)
+ ctx.CreateModule(syspropJavaGenFactory, &javaGenProps)
javaProps := struct {
Name *string
@@ -413,7 +413,7 @@
javaProps.Sdk_version = proptools.StringPtr("core_current")
javaProps.Libs = []string{stub}
- ctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProps)
+ ctx.CreateModule(java.LibraryFactory, &javaProps)
}
func syspropDepsMutator(ctx android.BottomUpMutatorContext) {
diff --git a/tradefed/autogen.go b/tradefed/autogen.go
index 1400345..3d30cfa 100644
--- a/tradefed/autogen.go
+++ b/tradefed/autogen.go
@@ -44,10 +44,11 @@
CommandDeps: []string{"$template"},
}, "name", "template", "extraConfigs")
-func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string) (path android.Path, autogenPath android.WritablePath) {
- if p := getTestConfig(ctx, prop); p != nil {
+func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string, autoGenConfig *bool) (path android.Path, autogenPath android.WritablePath) {
+ p := getTestConfig(ctx, prop)
+ if !Bool(autoGenConfig) && p != nil {
return p, nil
- } else if !android.InList("cts", testSuites) {
+ } else if !android.InList("cts", testSuites) && BoolDefault(autoGenConfig, true) {
outputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".config")
return nil, outputFile
} else {
@@ -124,8 +125,8 @@
}
func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, config []Config) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
+ testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool) android.Path {
+ path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig)
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
@@ -143,8 +144,8 @@
}
func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, configs []Config) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
+ testConfigTemplateProp *string, testSuites []string, configs []Config, autoGenConfig *bool) android.Path {
+ path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig)
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
@@ -157,8 +158,9 @@
return path
}
-func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string, testSuites []string) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
+func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string,
+ testSuites []string, autoGenConfig *bool) android.Path {
+ path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig)
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
@@ -176,9 +178,9 @@
}
func AutoGenPythonBinaryHostTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string) android.Path {
+ testConfigTemplateProp *string, testSuites []string, autoGenConfig *bool) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
+ path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig)
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
@@ -200,8 +202,9 @@
},
}, "name", "template")
-func AutoGenInstrumentationTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string, manifest android.Path, testSuites []string) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
+func AutoGenInstrumentationTestConfig(ctx android.ModuleContext, testConfigProp *string,
+ testConfigTemplateProp *string, manifest android.Path, testSuites []string, autoGenConfig *bool) android.Path {
+ path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig)
if autogenPath != nil {
template := "${InstrumentationTestConfigTemplate}"
moduleTemplate := getTestConfigTemplate(ctx, testConfigTemplateProp)
@@ -222,3 +225,6 @@
}
return path
}
+
+var Bool = proptools.Bool
+var BoolDefault = proptools.BoolDefault
diff --git a/ui/build/config.go b/ui/build/config.go
index 665d2f0..def3345 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -16,7 +16,6 @@
import (
"io/ioutil"
- "log"
"os"
"path/filepath"
"runtime"
@@ -189,27 +188,27 @@
checkTopDir(ctx)
if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') {
- log.Println("You are building in a directory whose absolute path contains a space character:")
- log.Println()
- log.Printf("%q\n", srcDir)
- log.Println()
- log.Fatalln("Directory names containing spaces are not supported")
+ ctx.Println("You are building in a directory whose absolute path contains a space character:")
+ ctx.Println()
+ ctx.Printf("%q\n", srcDir)
+ ctx.Println()
+ ctx.Fatalln("Directory names containing spaces are not supported")
}
if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') {
- log.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
- log.Println()
- log.Printf("%q\n", outDir)
- log.Println()
- log.Fatalln("Directory names containing spaces are not supported")
+ ctx.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
+ ctx.Println()
+ ctx.Printf("%q\n", outDir)
+ ctx.Println()
+ ctx.Fatalln("Directory names containing spaces are not supported")
}
if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') {
- log.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
- log.Println()
- log.Printf("%q\n", distDir)
- log.Println()
- log.Fatalln("Directory names containing spaces are not supported")
+ ctx.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
+ ctx.Println()
+ ctx.Printf("%q\n", distDir)
+ ctx.Println()
+ ctx.Fatalln("Directory names containing spaces are not supported")
}
// Configure Java-related variables, including adding it to $PATH
diff --git a/ui/terminal/smart_status.go b/ui/terminal/smart_status.go
index 57f71ab..efcfd43 100644
--- a/ui/terminal/smart_status.go
+++ b/ui/terminal/smart_status.go
@@ -189,7 +189,7 @@
fmt.Fprintf(s.writer, ansi.resetScrollingMargins())
_, height, _ := termSize(s.writer)
// Move the cursor to the top of the now-blank, previously non-scrolling region
- fmt.Fprintf(s.writer, ansi.setCursor(height-s.tableHeight, 0))
+ fmt.Fprintf(s.writer, ansi.setCursor(height-s.tableHeight, 1))
// Turn the cursor back on
fmt.Fprintf(s.writer, ansi.showCursor())
}
@@ -334,52 +334,44 @@
scrollingHeight := s.termHeight - s.tableHeight
// Update the scrolling region in case the height of the terminal changed
- fmt.Fprint(s.writer, ansi.setScrollingMargins(0, scrollingHeight))
- // Move the cursor to the first line of the non-scrolling region
- fmt.Fprint(s.writer, ansi.setCursor(scrollingHeight+1, 0))
+
+ fmt.Fprint(s.writer, ansi.setScrollingMargins(1, scrollingHeight))
// Write as many status lines as fit in the table
- var tableLine int
- var runningAction actionTableEntry
- for tableLine, runningAction = range s.runningActions {
+ for tableLine := 0; tableLine < s.tableHeight; tableLine++ {
if tableLine >= s.tableHeight {
break
}
+ // Move the cursor to the correct line of the non-scrolling region
+ fmt.Fprint(s.writer, ansi.setCursor(scrollingHeight+1+tableLine, 1))
- seconds := int(time.Since(runningAction.startTime).Round(time.Second).Seconds())
+ if tableLine < len(s.runningActions) {
+ runningAction := s.runningActions[tableLine]
- desc := runningAction.action.Description
- if desc == "" {
- desc = runningAction.action.Command
+ seconds := int(time.Since(runningAction.startTime).Round(time.Second).Seconds())
+
+ desc := runningAction.action.Description
+ if desc == "" {
+ desc = runningAction.action.Command
+ }
+
+ color := ""
+ if seconds >= 60 {
+ color = ansi.red() + ansi.bold()
+ } else if seconds >= 30 {
+ color = ansi.yellow() + ansi.bold()
+ }
+
+ durationStr := fmt.Sprintf(" %2d:%02d ", seconds/60, seconds%60)
+ desc = elide(desc, s.termWidth-len(durationStr))
+ durationStr = color + durationStr + ansi.regular()
+ fmt.Fprint(s.writer, durationStr, desc)
}
-
- color := ""
- if seconds >= 60 {
- color = ansi.red() + ansi.bold()
- } else if seconds >= 30 {
- color = ansi.yellow() + ansi.bold()
- }
-
- durationStr := fmt.Sprintf(" %2d:%02d ", seconds/60, seconds%60)
- desc = elide(desc, s.termWidth-len(durationStr))
- durationStr = color + durationStr + ansi.regular()
-
- fmt.Fprint(s.writer, durationStr, desc, ansi.clearToEndOfLine())
- if tableLine < s.tableHeight-1 {
- fmt.Fprint(s.writer, "\n")
- }
- }
-
- // Clear any remaining lines in the table
- for ; tableLine < s.tableHeight; tableLine++ {
fmt.Fprint(s.writer, ansi.clearToEndOfLine())
- if tableLine < s.tableHeight-1 {
- fmt.Fprint(s.writer, "\n")
- }
}
// Move the cursor back to the last line of the scrolling region
- fmt.Fprint(s.writer, ansi.setCursor(scrollingHeight, 0))
+ fmt.Fprint(s.writer, ansi.setCursor(scrollingHeight, 1))
}
var ansi = ansiImpl{}
diff --git a/ui/terminal/status.go b/ui/terminal/status.go
index 69a2a09..60dfc70 100644
--- a/ui/terminal/status.go
+++ b/ui/terminal/status.go
@@ -26,10 +26,10 @@
//
// statusFormat takes nearly all the same options as NINJA_STATUS.
// %c is currently unsupported.
-func NewStatusOutput(w io.Writer, statusFormat string, quietBuild bool) status.StatusOutput {
+func NewStatusOutput(w io.Writer, statusFormat string, forceDumbOutput, quietBuild bool) status.StatusOutput {
formatter := newFormatter(statusFormat, quietBuild)
- if isSmartTerminal(w) {
+ if !forceDumbOutput && isSmartTerminal(w) {
return NewSmartStatusOutput(w, formatter)
} else {
return NewDumbStatusOutput(w, formatter)
diff --git a/ui/terminal/status_test.go b/ui/terminal/status_test.go
index 81aa238..9f60829 100644
--- a/ui/terminal/status_test.go
+++ b/ui/terminal/status_test.go
@@ -94,7 +94,7 @@
t.Run("smart", func(t *testing.T) {
smart := &fakeSmartTerminal{termWidth: 40}
- stat := NewStatusOutput(smart, "", false)
+ stat := NewStatusOutput(smart, "", false, false)
tt.calls(stat)
stat.Flush()
@@ -105,7 +105,7 @@
t.Run("dumb", func(t *testing.T) {
dumb := &bytes.Buffer{}
- stat := NewStatusOutput(dumb, "", false)
+ stat := NewStatusOutput(dumb, "", false, false)
tt.calls(stat)
stat.Flush()
@@ -113,6 +113,17 @@
t.Errorf("want:\n%q\ngot:\n%q", w, g)
}
})
+
+ t.Run("force dumb", func(t *testing.T) {
+ smart := &fakeSmartTerminal{termWidth: 40}
+ stat := NewStatusOutput(smart, "", true, false)
+ tt.calls(stat)
+ stat.Flush()
+
+ if g, w := smart.String(), tt.dumb; g != w {
+ t.Errorf("want:\n%q\ngot:\n%q", w, g)
+ }
+ })
})
}
}
@@ -258,7 +269,7 @@
os.Setenv(tableHeightEnVar, "")
smart := &fakeSmartTerminal{termWidth: 40}
- stat := NewStatusOutput(smart, "", false)
+ stat := NewStatusOutput(smart, "", false, false)
smartStat := stat.(*smartStatusOutput)
smartStat.sigwinchHandled = make(chan bool)
diff --git a/vnames.json b/vnames.json
new file mode 100644
index 0000000..7b34c52
--- /dev/null
+++ b/vnames.json
@@ -0,0 +1,18 @@
+[
+ {
+ "pattern": "out/(.*)",
+ "vname": {
+ "corpus": "CORPUS",
+ "root": "out",
+ "path": "@1@"
+ }
+ },
+ {
+ "pattern": "(.*)",
+ "vname": {
+ "corpus": "CORPUS",
+ "path": "@1@"
+ }
+ }
+]
+