Merge "Propagate LTO type from binary/DSO to object files"
diff --git a/Android.bp b/Android.bp
index 643e8df..ebf1038 100644
--- a/Android.bp
+++ b/Android.bp
@@ -61,6 +61,7 @@
"android/testing.go",
"android/util.go",
"android/variable.go",
+ "android/writedocs.go",
// Lock down environment access last
"android/env.go",
diff --git a/OWNERS b/OWNERS
index 89b446a..004d638 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,2 +1,7 @@
ccross@android.com
dwillemsen@google.com
+
+per-file * = ccross@android.com
+per-file * = dwillemsen@google.com
+per-file *gen_stub_libs.py = danalbert@google.com
+per-file ndk_*.go = danalbert@google.com
diff --git a/android/config.go b/android/config.go
index 0eebb5f..56e9525 100644
--- a/android/config.go
+++ b/android/config.go
@@ -25,6 +25,7 @@
"strings"
"sync"
+ "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
)
@@ -67,6 +68,7 @@
FileConfigurableOptions
ProductVariables productVariables
+ PrimaryBuilder string
ConfigFileName string
ProductVariablesFileName string
@@ -91,6 +93,8 @@
useOpenJDK9 bool // Use OpenJDK9, but possibly target 1.8
targetOpenJDK9 bool // Use OpenJDK9 and target 1.9
+ stopBefore bootstrap.StopBefore
+
OncePer
}
@@ -312,14 +316,22 @@
return nil
}
-func (c *config) RemoveAbandonedFiles() bool {
- return false
+func (c *config) StopBefore() bootstrap.StopBefore {
+ return c.stopBefore
}
+func (c *config) SetStopBefore(stopBefore bootstrap.StopBefore) {
+ c.stopBefore = stopBefore
+}
+
+var _ bootstrap.ConfigStopBefore = (*config)(nil)
+
func (c *config) BlueprintToolLocation() string {
return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin")
}
+var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil)
+
// HostSystemTool looks for non-hermetic tools from the system we're running on.
// Generally shouldn't be used, but useful to find the XCode SDK, etc.
func (c *config) HostSystemTool(name string) string {
@@ -499,12 +511,13 @@
}
}
-func (c *config) DefaultAppCertificate(ctx PathContext) SourcePath {
+func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
defaultCert := String(c.ProductVariables.DefaultAppCertificate)
if defaultCert != "" {
- return PathForSource(ctx, defaultCert)
+ return PathForSource(ctx, defaultCert+".x509.pem"), PathForSource(ctx, defaultCert+".pk8")
} else {
- return c.DefaultAppCertificateDir(ctx).Join(ctx, "testkey")
+ defaultDir := c.DefaultAppCertificateDir(ctx)
+ return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8")
}
}
@@ -636,6 +649,10 @@
return String(c.config.ProductVariables.DeviceVndkVersion)
}
+func (c *deviceConfig) PlatformVndkVersion() string {
+ return String(c.config.ProductVariables.Platform_vndk_version)
+}
+
func (c *deviceConfig) ExtraVndkVersions() []string {
return c.config.ProductVariables.ExtraVndkVersions
}
diff --git a/android/package_ctx.go b/android/package_ctx.go
index 3f6a253..0dbcea5 100644
--- a/android/package_ctx.go
+++ b/android/package_ctx.go
@@ -248,11 +248,6 @@
})
}
-type RuleParams struct {
- blueprint.RuleParams
- GomaSupported bool
-}
-
// AndroidStaticRule wraps blueprint.StaticRule and provides a default Pool if none is specified
func (p PackageContext) AndroidStaticRule(name string, params blueprint.RuleParams,
argNames ...string) blueprint.Rule {
diff --git a/android/singleton.go b/android/singleton.go
index 87910fd..f577b0a 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -34,7 +34,7 @@
Failed() bool
Variable(pctx PackageContext, name, value string)
- Rule(pctx PackageContext, name string, params RuleParams, argNames ...string) blueprint.Rule
+ Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
Build(pctx PackageContext, params BuildParams)
RequireNinjaVersion(major, minor, micro int)
@@ -94,8 +94,8 @@
s.SingletonContext.Variable(pctx.PackageContext, name, value)
}
-func (s singletonContextAdaptor) Rule(pctx PackageContext, name string, params RuleParams, argNames ...string) blueprint.Rule {
- return s.SingletonContext.Rule(pctx.PackageContext, name, params.RuleParams, argNames...)
+func (s singletonContextAdaptor) Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule {
+ return s.SingletonContext.Rule(pctx.PackageContext, name, params, argNames...)
}
func (s singletonContextAdaptor) Build(pctx PackageContext, params BuildParams) {
diff --git a/android/variable.go b/android/variable.go
index ab8103a..b8aad18 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -67,10 +67,17 @@
Cflags []string
}
- // treble is true when a build is a Treble compliant device. This is automatically set when
- // a build is shipped with Android O, but can be overriden. This controls such things as
- // the sepolicy split and enabling the Treble linker namespaces.
- Treble struct {
+ // treble_linker_namespaces is true when the system/vendor linker namespace separation is
+ // enabled.
+ Treble_linker_namespaces struct {
+ Cflags []string
+ }
+ // sepolicy_split is true when system/vendor sepolicy split is enabled.
+ Sepolicy_split struct {
+ Cflags []string
+ }
+ // enforce_vintf_manifest is true when a device is required to have a vintf manifest.
+ Enforce_vintf_manifest struct {
Cflags []string
}
@@ -111,6 +118,7 @@
Platform_sdk_final *bool `json:",omitempty"`
Platform_version_active_codenames []string `json:",omitempty"`
Platform_version_future_codenames []string `json:",omitempty"`
+ Platform_vndk_version *string `json:",omitempty"`
DeviceName *string `json:",omitempty"`
DeviceArch *string `json:",omitempty"`
@@ -156,7 +164,9 @@
Debuggable *bool `json:",omitempty"`
Eng *bool `json:",omitempty"`
Device_uses_hwc2 *bool `json:",omitempty"`
- Treble *bool `json:",omitempty"`
+ Treble_linker_namespaces *bool `json:",omitempty"`
+ Sepolicy_split *bool `json:",omitempty"`
+ Enforce_vintf_manifest *bool `json:",omitempty"`
Pdk *bool `json:",omitempty"`
Uml *bool `json:",omitempty"`
MinimizeJavaDebugInfo *bool `json:",omitempty"`
diff --git a/android/writedocs.go b/android/writedocs.go
new file mode 100644
index 0000000..9737030
--- /dev/null
+++ b/android/writedocs.go
@@ -0,0 +1,73 @@
+// Copyright 2015 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 android
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/google/blueprint"
+)
+
+func init() {
+ RegisterSingletonType("writedocs", DocsSingleton)
+}
+
+func DocsSingleton() Singleton {
+ return &docsSingleton{}
+}
+
+type docsSingleton struct{}
+
+func primaryBuilderPath(ctx SingletonContext) Path {
+ primaryBuilder, err := filepath.Rel(ctx.Config().BuildDir(), os.Args[0])
+ if err != nil {
+ ctx.Errorf("path to primary builder %q is not in build dir %q",
+ os.Args[0], ctx.Config().BuildDir())
+ }
+
+ return PathForOutput(ctx, primaryBuilder)
+}
+
+func (c *docsSingleton) GenerateBuildActions(ctx SingletonContext) {
+ // Generate build system docs for the primary builder. Generating docs reads the source
+ // files used to build the primary builder, but that dependency will be picked up through
+ // the dependency on the primary builder itself. There are no dependencies on the
+ // Blueprints files, as any relevant changes to the Blueprints files would have caused
+ // a rebuild of the primary builder.
+ docsFile := PathForOutput(ctx, "docs", "soong_build.html")
+ primaryBuilder := primaryBuilderPath(ctx)
+ soongDocs := ctx.Rule(pctx, "soongDocs",
+ blueprint.RuleParams{
+ Command: fmt.Sprintf("%s --soong_docs %s %s",
+ primaryBuilder.String(), docsFile.String(), strings.Join(os.Args[1:], " ")),
+ CommandDeps: []string{primaryBuilder.String()},
+ Description: fmt.Sprintf("%s docs $out", primaryBuilder.Base()),
+ })
+
+ ctx.Build(pctx, BuildParams{
+ Rule: soongDocs,
+ Output: docsFile,
+ })
+
+ // Add a phony target for building the documentation
+ ctx.Build(pctx, BuildParams{
+ Rule: blueprint.Phony,
+ Output: PathForPhony(ctx, "soong_docs"),
+ Input: docsFile,
+ })
+}
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index 4022a5e..c6e90f0 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -153,6 +153,7 @@
"LOCAL_PROPRIETARY_MODULE": "proprietary",
"LOCAL_VENDOR_MODULE": "vendor",
"LOCAL_EXPORT_PACKAGE_RESOURCES": "export_package_resources",
+ "LOCAL_PRIVILEGED_MODULE": "privileged",
"LOCAL_DEX_PREOPT": "dex_preopt.enabled",
"LOCAL_DEX_PREOPT_APP_IMAGE": "dex_preopt.app_image",
@@ -636,22 +637,15 @@
return "."
}
-func allJavaFilesUnder(args []string) string {
- dir := ""
- if len(args) > 0 {
- dir = strings.TrimSpace(args[0])
+func allFilesUnder(wildcard string) func(args []string) string {
+ return func(args []string) string {
+ dir := ""
+ if len(args) > 0 {
+ dir = strings.TrimSpace(args[0])
+ }
+
+ return fmt.Sprintf("%s/**/"+wildcard, dir)
}
-
- return fmt.Sprintf("%s/**/*.java", dir)
-}
-
-func allProtoFilesUnder(args []string) string {
- dir := ""
- if len(args) > 0 {
- dir = strings.TrimSpace(args[0])
- }
-
- return fmt.Sprintf("%s/**/*.proto", dir)
}
func allSubdirJavaFiles(args []string) string {
@@ -695,8 +689,11 @@
globalScope := mkparser.NewScope(nil)
globalScope.Set("CLEAR_VARS", clear_vars)
globalScope.SetFunc("my-dir", mydir)
- globalScope.SetFunc("all-java-files-under", allJavaFilesUnder)
- globalScope.SetFunc("all-proto-files-under", allProtoFilesUnder)
+ globalScope.SetFunc("all-java-files-under", allFilesUnder("*.java"))
+ globalScope.SetFunc("all-proto-files-under", allFilesUnder("*.proto"))
+ globalScope.SetFunc("all-aidl-files-under", allFilesUnder("*.aidl"))
+ globalScope.SetFunc("all-Iaidl-files-under", allFilesUnder("I*.aidl"))
+ globalScope.SetFunc("all-logtags-files-under", allFilesUnder("*.logtags"))
globalScope.SetFunc("all-subdir-java-files", allSubdirJavaFiles)
globalScope.SetFunc("all-makefiles-under", includeIgnored)
globalScope.SetFunc("first-makefiles-under", includeIgnored)
diff --git a/cc/builder.go b/cc/builder.go
index b5f4c5c..e583834 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -231,27 +231,28 @@
}
type builderFlags struct {
- globalFlags string
- arFlags string
- asFlags string
- cFlags string
- toolingCFlags string // A separate set of Cflags for clang LibTooling tools
- conlyFlags string
- cppFlags string
- ldFlags string
- libFlags string
- yaccFlags string
- protoFlags string
- tidyFlags string
- sAbiFlags string
- yasmFlags string
- aidlFlags string
- rsFlags string
- toolchain config.Toolchain
- clang bool
- tidy bool
- coverage bool
- sAbiDump bool
+ globalFlags string
+ arFlags string
+ asFlags string
+ cFlags string
+ toolingCFlags string // A separate set of Cflags for clang LibTooling tools
+ conlyFlags string
+ cppFlags string
+ ldFlags string
+ libFlags string
+ yaccFlags string
+ protoFlags string
+ protoOutParams string
+ tidyFlags string
+ sAbiFlags string
+ yasmFlags string
+ aidlFlags string
+ rsFlags string
+ toolchain config.Toolchain
+ clang bool
+ tidy bool
+ coverage bool
+ sAbiDump bool
systemIncludeFlags string
diff --git a/cc/cc.go b/cc/cc.go
index fa33bc6..6e28522 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -116,6 +116,7 @@
ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
YaccFlags []string // Flags that apply to Yacc source files
protoFlags []string // Flags that apply to proto source files
+ protoOutParams []string // Flags that modify the output of proto generated files
aidlFlags []string // Flags that apply to aidl source files
rsFlags []string // Flags that apply to renderscript source files
LdFlags []string // Flags that apply to linker command lines
@@ -1422,7 +1423,9 @@
mctx.CreateVariations(vendorMode)
} else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
// ... and LL-NDK headers as well
- mctx.CreateVariations(vendorMode)
+ mod := mctx.CreateVariations(vendorMode)
+ vendor := mod[0].(*Module)
+ vendor.Properties.UseVndk = true
} else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
// PRODUCT_EXTRA_VNDK_VERSIONS.
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 148b4dd..15e45d0 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -61,6 +61,7 @@
ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory))
ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(toolchainLibraryFactory))
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(llndkLibraryFactory))
+ ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory))
ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(objectFactory))
ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(genrule.FileGroupFactory))
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -138,6 +139,7 @@
"bar.c": nil,
"a.proto": nil,
"b.aidl": nil,
+ "my_include": nil,
})
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
@@ -583,6 +585,34 @@
}
}
+func TestLlndkHeaders(t *testing.T) {
+ ctx := testCc(t, `
+ llndk_headers {
+ name: "libllndk_headers",
+ export_include_dirs: ["my_include"],
+ }
+ llndk_library {
+ name: "libllndk",
+ export_llndk_headers: ["libllndk_headers"],
+ }
+ cc_library {
+ name: "libvendor",
+ shared_libs: ["libllndk"],
+ vendor: true,
+ srcs: ["foo.c"],
+ no_libgcc : true,
+ nocrt : true,
+ }
+ `)
+
+ // _static variant is used since _shared reuses *.o from the static variant
+ cc := ctx.ModuleForTests("libvendor", "android_arm_armv7-a-neon_vendor_static").Rule("cc")
+ cflags := cc.Args["cFlags"]
+ if !strings.Contains(cflags, "-Imy_include") {
+ t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags)
+ }
+}
+
var compilerFlagsTestCases = []struct {
in string
out bool
diff --git a/cc/config/global.go b/cc/config/global.go
index 6f27822..6f4b3e2 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -120,20 +120,14 @@
ClangDefaultShortVersion = "5.0.1"
WarningAllowedProjects = []string{
- "external/libese/third_party/NXPNFC_P61_JCOP_Kit/",
"external/skia/",
"device/",
- "frameworks/av/media/libeffects/factory/",
- "frameworks/av/media/libstagefright/codecs/",
- "frameworks/native/libs/vr/libbufferhub/",
"vendor/",
}
// Some Android.mk files still have warnings.
WarningAllowedOldProjects = []string{
"frameworks/av/drm/mediacas/plugins/",
- "frameworks/av/services/mediaextractor/",
- "frameworks/webview/chromium/",
"hardware/libhardware/modules/",
"hardware/qcom/",
"tools/adt/idea/android/ultimate/get_modification_time/jni/",
diff --git a/cc/gen.go b/cc/gen.go
index 15b37b5..e9d1e2a 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -153,7 +153,8 @@
srcFiles[i] = cppFile
genLex(ctx, srcFile, cppFile)
case ".proto":
- ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags)
+ ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags,
+ buildFlags.protoOutParams)
srcFiles[i] = ccFile
deps = append(deps, headerFile)
case ".aidl":
diff --git a/cc/library.go b/cc/library.go
index cf10617..b664a5e 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -720,13 +720,14 @@
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
if library.shared() {
- if ctx.Device() {
- if ctx.useVndk() {
- if ctx.isVndkSp() {
- library.baseInstaller.subDir = "vndk-sp"
- } else if ctx.isVndk() {
- library.baseInstaller.subDir = "vndk"
- }
+ if ctx.Device() && ctx.useVndk() {
+ if ctx.isVndkSp() {
+ library.baseInstaller.subDir = "vndk-sp"
+ } else if ctx.isVndk() {
+ library.baseInstaller.subDir = "vndk"
+ }
+ if ctx.isVndk() && ctx.DeviceConfig().PlatformVndkVersion() != "current" {
+ library.baseInstaller.subDir += "-" + ctx.DeviceConfig().PlatformVndkVersion()
}
}
library.baseInstaller.install(ctx, file)
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 9a29964..e824d0f 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -191,7 +191,6 @@
func llndkHeadersFactory() android.Module {
module, library := NewLibrary(android.DeviceSupported)
library.HeaderOnly()
- library.setStatic()
decorator := &llndkHeadersDecorator{
libraryDecorator: library,
diff --git a/cc/pgo.go b/cc/pgo.go
index 9fea154..fef962e 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -42,6 +42,9 @@
Profile_file *string `android:"arch_variant"`
Benchmarks []string
Enable_profile_use *bool `android:"arch_variant"`
+ // Additional compiler flags to use when building this module
+ // for profiling (either instrumentation or sampling).
+ Cflags []string `android:"arch_variant"`
} `android:"arch_variant"`
PgoPresent bool `blueprint:"mutated"`
@@ -65,6 +68,8 @@
}
func (props *PgoProperties) addProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
+ flags.CFlags = append(flags.CFlags, props.Pgo.Cflags...)
+
if props.isInstrumentation() {
flags.CFlags = append(flags.CFlags, profileInstrumentFlag)
// The profile runtime is added below in deps(). Add the below
diff --git a/cc/proto.go b/cc/proto.go
index e7f1d41..3b5fd3b 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -16,6 +16,7 @@
import (
"github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
"android/soong/android"
)
@@ -27,15 +28,15 @@
var (
proto = pctx.AndroidStaticRule("protoc",
blueprint.RuleParams{
- Command: "$protocCmd --cpp_out=$outDir $protoFlags $in",
+ Command: "$protocCmd --cpp_out=$protoOutParams:$outDir $protoFlags $in",
CommandDeps: []string{"$protocCmd"},
- }, "protoFlags", "outDir")
+ }, "protoFlags", "protoOutParams", "outDir")
)
// genProto creates a rule to convert a .proto file to generated .pb.cc and .pb.h files and returns
// the paths to the generated files.
func genProto(ctx android.ModuleContext, protoFile android.Path,
- protoFlags string) (ccFile, headerFile android.WritablePath) {
+ protoFlags string, protoOutParams string) (ccFile, headerFile android.WritablePath) {
ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc")
headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
@@ -46,8 +47,9 @@
Outputs: android.WritablePaths{ccFile, headerFile},
Input: protoFile,
Args: map[string]string{
- "outDir": android.ProtoDir(ctx).String(),
- "protoFlags": protoFlags,
+ "outDir": android.ProtoDir(ctx).String(),
+ "protoFlags": protoFlags,
+ "protoOutParams": protoOutParams,
},
})
@@ -97,5 +99,9 @@
flags.protoFlags = android.ProtoFlags(ctx, p)
+ if proptools.String(p.Proto.Type) == "lite" {
+ flags.protoOutParams = []string{"lite"}
+ }
+
return flags
}
diff --git a/cc/util.go b/cc/util.go
index cc89af6..7041029 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -97,27 +97,28 @@
func flagsToBuilderFlags(in Flags) builderFlags {
return builderFlags{
- globalFlags: strings.Join(in.GlobalFlags, " "),
- arFlags: strings.Join(in.ArFlags, " "),
- asFlags: strings.Join(in.AsFlags, " "),
- cFlags: strings.Join(in.CFlags, " "),
- toolingCFlags: strings.Join(in.ToolingCFlags, " "),
- conlyFlags: strings.Join(in.ConlyFlags, " "),
- cppFlags: strings.Join(in.CppFlags, " "),
- yaccFlags: strings.Join(in.YaccFlags, " "),
- protoFlags: strings.Join(in.protoFlags, " "),
- aidlFlags: strings.Join(in.aidlFlags, " "),
- rsFlags: strings.Join(in.rsFlags, " "),
- ldFlags: strings.Join(in.LdFlags, " "),
- libFlags: strings.Join(in.libFlags, " "),
- tidyFlags: strings.Join(in.TidyFlags, " "),
- sAbiFlags: strings.Join(in.SAbiFlags, " "),
- yasmFlags: strings.Join(in.YasmFlags, " "),
- toolchain: in.Toolchain,
- clang: in.Clang,
- coverage: in.Coverage,
- tidy: in.Tidy,
- sAbiDump: in.SAbiDump,
+ globalFlags: strings.Join(in.GlobalFlags, " "),
+ arFlags: strings.Join(in.ArFlags, " "),
+ asFlags: strings.Join(in.AsFlags, " "),
+ cFlags: strings.Join(in.CFlags, " "),
+ toolingCFlags: strings.Join(in.ToolingCFlags, " "),
+ conlyFlags: strings.Join(in.ConlyFlags, " "),
+ cppFlags: strings.Join(in.CppFlags, " "),
+ yaccFlags: strings.Join(in.YaccFlags, " "),
+ protoFlags: strings.Join(in.protoFlags, " "),
+ protoOutParams: strings.Join(in.protoOutParams, ":"),
+ aidlFlags: strings.Join(in.aidlFlags, " "),
+ rsFlags: strings.Join(in.rsFlags, " "),
+ ldFlags: strings.Join(in.LdFlags, " "),
+ libFlags: strings.Join(in.libFlags, " "),
+ tidyFlags: strings.Join(in.TidyFlags, " "),
+ sAbiFlags: strings.Join(in.SAbiFlags, " "),
+ yasmFlags: strings.Join(in.YasmFlags, " "),
+ toolchain: in.Toolchain,
+ clang: in.Clang,
+ coverage: in.Coverage,
+ tidy: in.Tidy,
+ sAbiDump: in.SAbiDump,
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
diff --git a/cmd/soong_build/Android.bp b/cmd/soong_build/Android.bp
index d9daafc..2536a53 100644
--- a/cmd/soong_build/Android.bp
+++ b/cmd/soong_build/Android.bp
@@ -23,6 +23,7 @@
],
srcs: [
"main.go",
+ "writedocs.go",
],
primaryBuilder: true,
}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index ddde1c5..40beab8 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -25,6 +25,14 @@
"android/soong/android"
)
+var (
+ docFile string
+)
+
+func init() {
+ flag.StringVar(&docFile, "soong_docs", "", "build documentation file to output")
+}
+
func newNameResolver(config android.Config) *android.NameResolver {
namespacePathsToExport := make(map[string]bool)
@@ -56,9 +64,17 @@
os.Exit(1)
}
+ if docFile != "" {
+ configuration.SetStopBefore(bootstrap.StopBeforePrepareBuildActions)
+ }
+
ctx.SetNameInterface(newNameResolver(configuration))
ctx.SetAllowMissingDependencies(configuration.AllowMissingDependencies())
bootstrap.Main(ctx.Context, configuration, configuration.ConfigFileName, configuration.ProductVariablesFileName)
+
+ if docFile != "" {
+ writeDocs(ctx, docFile)
+ }
}
diff --git a/cmd/soong_build/writedocs.go b/cmd/soong_build/writedocs.go
new file mode 100644
index 0000000..a6686c0
--- /dev/null
+++ b/cmd/soong_build/writedocs.go
@@ -0,0 +1,129 @@
+// Copyright 2017 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 (
+ "android/soong/android"
+ "bytes"
+ "html/template"
+ "io/ioutil"
+
+ "github.com/google/blueprint/bootstrap"
+)
+
+func writeDocs(ctx *android.Context, filename string) error {
+ moduleTypeList, err := bootstrap.ModuleTypeDocs(ctx.Context)
+ if err != nil {
+ return err
+ }
+
+ buf := &bytes.Buffer{}
+
+ unique := 0
+
+ tmpl, err := template.New("file").Funcs(map[string]interface{}{
+ "unique": func() int {
+ unique++
+ return unique
+ }}).Parse(fileTemplate)
+ if err != nil {
+ return err
+ }
+
+ err = tmpl.Execute(buf, moduleTypeList)
+ if err != nil {
+ return err
+ }
+
+ err = ioutil.WriteFile(filename, buf.Bytes(), 0666)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+const (
+ fileTemplate = `
+<html>
+<head>
+<title>Build Docs</title>
+<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
+<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
+</head>
+<body>
+<h1>Build Docs</h1>
+<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
+ {{range .}}
+ {{ $collapseIndex := unique }}
+ <div class="panel panel-default">
+ <div class="panel-heading" role="tab" id="heading{{$collapseIndex}}">
+ <h2 class="panel-title">
+ <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{$collapseIndex}}" aria-expanded="false" aria-controls="collapse{{$collapseIndex}}">
+ {{.Name}}
+ </a>
+ </h2>
+ </div>
+ </div>
+ <div id="collapse{{$collapseIndex}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{$collapseIndex}}">
+ <div class="panel-body">
+ <p>{{.Text}}</p>
+ {{range .PropertyStructs}}
+ <p>{{.Text}}</p>
+ {{template "properties" .Properties}}
+ {{end}}
+ </div>
+ </div>
+ {{end}}
+</div>
+</body>
+</html>
+
+{{define "properties"}}
+ <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
+ {{range .}}
+ {{$collapseIndex := unique}}
+ {{if .Properties}}
+ <div class="panel panel-default">
+ <div class="panel-heading" role="tab" id="heading{{$collapseIndex}}">
+ <h4 class="panel-title">
+ <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{$collapseIndex}}" aria-expanded="false" aria-controls="collapse{{$collapseIndex}}">
+ {{.Name}}{{range .OtherNames}}, {{.}}{{end}}
+ </a>
+ </h4>
+ </div>
+ </div>
+ <div id="collapse{{$collapseIndex}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{$collapseIndex}}">
+ <div class="panel-body">
+ <p>{{.Text}}</p>
+ {{range .OtherTexts}}<p>{{.}}</p>{{end}}
+ {{template "properties" .Properties}}
+ </div>
+ </div>
+ {{else}}
+ <div>
+ <h4>{{.Name}}{{range .OtherNames}}, {{.}}{{end}}</h4>
+ <p>{{.Text}}</p>
+ {{range .OtherTexts}}<p>{{.}}</p>{{end}}
+ <p><i>Type: {{.Type}}</i></p>
+ {{if .Default}}<p><i>Default: {{.Default}}</i></p>{{end}}
+ </div>
+ {{end}}
+ {{end}}
+ </div>
+{{end}}
+`
+)
diff --git a/java/androidmk.go b/java/androidmk.go
index af91a33..40ebe5b 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -152,30 +152,36 @@
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
- if Bool(app.appProperties.Export_package_resources) {
- if app.dexJarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
- }
- fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
-
- if app.jacocoReportClassesFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
- }
-
- if app.Name() == "framework-res" {
- fmt.Fprintln(w, "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")
- }
-
- if len(app.rroDirs) > 0 {
- fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(app.rroDirs.Strings(), " "))
- }
- fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES :=",
- Bool(app.appProperties.Export_package_resources))
- fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
+ fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
+ if app.dexJarFile != nil {
+ fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
}
+ if app.jacocoReportClassesFile != nil {
+ fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
+ }
+
+ if app.Name() == "framework-res" {
+ fmt.Fprintln(w, "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")
+ }
+
+ if len(app.rroDirs) > 0 {
+ fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(app.rroDirs.Strings(), " "))
+ }
+
+ if Bool(app.appProperties.Export_package_resources) {
+ fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
+ }
+
+ fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
+
+ if Bool(app.appProperties.Privileged) {
+ fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
+ }
+
+ fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.pem.String())
},
},
}
diff --git a/java/app.go b/java/app.go
index ed6a9db..df53375 100644
--- a/java/app.go
+++ b/java/app.go
@@ -61,6 +61,11 @@
Resource_dirs []string
Instrumentation_for *string
+
+ // Specifies that this app should be installed to the priv-app directory,
+ // where the system will grant it additional privileges not available to
+ // normal apps.
+ Privileged *bool
}
type AndroidApp struct {
@@ -72,6 +77,11 @@
exportPackage android.Path
rroDirs android.Paths
manifestPath android.Path
+ certificate certificate
+}
+
+type certificate struct {
+ pem, key android.Path
}
func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -127,18 +137,30 @@
a.Module.compile(ctx, a.aaptSrcJar)
}
- certificate := String(a.appProperties.Certificate)
- if certificate == "" {
- certificate = ctx.Config().DefaultAppCertificate(ctx).String()
- } else if dir, _ := filepath.Split(certificate); dir == "" {
- certificate = filepath.Join(ctx.Config().DefaultAppCertificateDir(ctx).String(), certificate)
- } else {
- certificate = filepath.Join(android.PathForSource(ctx).String(), certificate)
+ c := String(a.appProperties.Certificate)
+ switch {
+ case c == "":
+ pem, key := ctx.Config().DefaultAppCertificate(ctx)
+ a.certificate = certificate{pem, key}
+ case strings.ContainsRune(c, '/'):
+ a.certificate = certificate{
+ android.PathForSource(ctx, c+".x509.pem"),
+ android.PathForSource(ctx, c+".pk8"),
+ }
+ default:
+ defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
+ a.certificate = certificate{
+ defaultDir.Join(ctx, c+".x509.pem"),
+ defaultDir.Join(ctx, c+".pk8"),
+ }
}
- certificates := []string{certificate}
+ certificates := []certificate{a.certificate}
for _, c := range a.appProperties.Additional_certificates {
- certificates = append(certificates, filepath.Join(android.PathForSource(ctx).String(), c))
+ certificates = append(certificates, certificate{
+ android.PathForSource(ctx, c+".x509.pem"),
+ android.PathForSource(ctx, c+".pk8"),
+ })
}
packageFile := android.PathForModuleOut(ctx, "package.apk")
@@ -152,6 +174,8 @@
if ctx.ModuleName() == "framework-res" {
// framework-res.apk is installed as system/framework/framework-res.apk
ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".apk", a.outputFile)
+ } else if Bool(a.appProperties.Privileged) {
+ ctx.InstallFile(android.PathForModuleInstall(ctx, "priv-app"), ctx.ModuleName()+".apk", a.outputFile)
} else {
ctx.InstallFile(android.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile)
}
diff --git a/java/app_builder.go b/java/app_builder.go
index 676ed58..945d7bd 100644
--- a/java/app_builder.go
+++ b/java/app_builder.go
@@ -61,7 +61,7 @@
})
func CreateAppPackage(ctx android.ModuleContext, outputFile android.WritablePath,
- resJarFile, dexJarFile android.Path, certificates []string) {
+ resJarFile, dexJarFile android.Path, certificates []certificate) {
// TODO(ccross): JNI libs
@@ -80,7 +80,7 @@
var certificateArgs []string
for _, c := range certificates {
- certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8")
+ certificateArgs = append(certificateArgs, c.pem.String(), c.key.String())
}
// TODO(ccross): sometimes uncompress dex
diff --git a/java/builder.go b/java/builder.go
index 10dfe06..48fba23 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -200,8 +200,9 @@
kotlincFlags string
kotlincClasspath classpath
- protoFlags []string
- protoOutFlag string
+ protoFlags []string
+ protoOutTypeFlag string // The flag itself: --java_out
+ protoOutParams string // Parameters to that flag: --java_out=$protoOutParams:$outDir
}
func TransformKotlinToClasses(ctx android.ModuleContext, outputFile android.WritablePath,
diff --git a/java/gen.go b/java/gen.go
index 7a0dcac..4893e88 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -107,7 +107,7 @@
if len(protoFiles) > 0 {
protoSrcJar := android.PathForModuleGen(ctx, "proto.srcjar")
genProto(ctx, protoSrcJar, protoFiles,
- flags.protoFlags, flags.protoOutFlag, "")
+ flags.protoFlags, flags.protoOutTypeFlag, flags.protoOutParams)
outSrcFiles = append(outSrcFiles, protoSrcJar)
}
diff --git a/java/proto.go b/java/proto.go
index 17f02a3..428413f 100644
--- a/java/proto.go
+++ b/java/proto.go
@@ -31,17 +31,17 @@
proto = pctx.AndroidStaticRule("protoc",
blueprint.RuleParams{
Command: `rm -rf $outDir && mkdir -p $outDir && ` +
- `$protocCmd $protoOut=$protoOutFlags:$outDir $protoFlags $in && ` +
+ `$protocCmd $protoOut=$protoOutParams:$outDir $protoFlags $in && ` +
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
CommandDeps: []string{
"$protocCmd",
"${config.SoongZipCmd}",
},
- }, "protoFlags", "protoOut", "protoOutFlags", "outDir")
+ }, "protoFlags", "protoOut", "protoOutParams", "outDir")
)
func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
- protoFiles android.Paths, protoFlags []string, protoOut, protoOutFlags string) {
+ protoFiles android.Paths, protoFlags []string, protoOut, protoOutParams string) {
ctx.Build(pctx, android.BuildParams{
Rule: proto,
@@ -49,10 +49,10 @@
Output: outputSrcJar,
Inputs: protoFiles,
Args: map[string]string{
- "outDir": android.ProtoDir(ctx).String(),
- "protoOut": protoOut,
- "protoOutFlags": protoOutFlags,
- "protoFlags": strings.Join(protoFlags, " "),
+ "outDir": android.ProtoDir(ctx).String(),
+ "protoOut": protoOut,
+ "protoOutParams": protoOutParams,
+ "protoFlags": strings.Join(protoFlags, " "),
},
})
}
@@ -80,11 +80,14 @@
func protoFlags(ctx android.ModuleContext, p *android.ProtoProperties, flags javaBuilderFlags) javaBuilderFlags {
switch proptools.String(p.Proto.Type) {
case "micro":
- flags.protoOutFlag = "--javamicro_out"
+ flags.protoOutTypeFlag = "--javamicro_out"
case "nano":
- flags.protoOutFlag = "--javanano_out"
- case "lite", "full", "":
- flags.protoOutFlag = "--java_out"
+ flags.protoOutTypeFlag = "--javanano_out"
+ case "lite":
+ flags.protoOutTypeFlag = "--java_out"
+ flags.protoOutParams = "lite"
+ case "full", "":
+ flags.protoOutTypeFlag = "--java_out"
default:
ctx.PropertyErrorf("proto.type", "unknown proto type %q",
proptools.String(p.Proto.Type))