Merge "Add apex.use_vndk_as_stable property"
diff --git a/android/Android.bp b/android/Android.bp
index 96f0983..6ddcc14 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -39,7 +39,6 @@
"paths.go",
"phony.go",
"prebuilt.go",
- "prebuilt_build_tool.go",
"proto.go",
"register.go",
"rule_builder.go",
diff --git a/android/config.go b/android/config.go
index d680b65..cafc71b 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1252,10 +1252,6 @@
return c.productVariables.MissingUsesLibraries
}
-func (c *deviceConfig) BoardVndkRuntimeDisable() bool {
- return Bool(c.config.productVariables.BoardVndkRuntimeDisable)
-}
-
func (c *deviceConfig) DeviceArch() string {
return String(c.config.productVariables.DeviceArch)
}
diff --git a/android/defs.go b/android/defs.go
index 83daa03..4552224 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -69,7 +69,7 @@
// A symlink rule.
Symlink = pctx.AndroidStaticRule("Symlink",
blueprint.RuleParams{
- Command: "rm -f $out && ln -f -s $fromPath $out",
+ Command: "ln -f -s $fromPath $out",
Description: "symlink $out",
},
"fromPath")
diff --git a/android/prebuilt_build_tool.go b/android/prebuilt_build_tool.go
deleted file mode 100644
index d457da4..0000000
--- a/android/prebuilt_build_tool.go
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2020 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 (
- "path"
- "path/filepath"
-)
-
-func init() {
- RegisterModuleType("prebuilt_build_tool", prebuiltBuildToolFactory)
-}
-
-type prebuiltBuildToolProperties struct {
- // Source file to be executed for this build tool
- Src *string `android:"path,arch_variant"`
-
- // Extra files that should trigger rules using this tool to rebuild
- Deps []string `android:"path,arch_variant"`
-}
-
-type prebuiltBuildTool struct {
- ModuleBase
- prebuilt Prebuilt
-
- properties prebuiltBuildToolProperties
-
- toolPath OptionalPath
-}
-
-func (t *prebuiltBuildTool) Name() string {
- return t.prebuilt.Name(t.ModuleBase.Name())
-}
-
-func (t *prebuiltBuildTool) Prebuilt() *Prebuilt {
- return &t.prebuilt
-}
-
-func (t *prebuiltBuildTool) DepsMutator(ctx BottomUpMutatorContext) {
- if t.properties.Src == nil {
- ctx.PropertyErrorf("src", "missing prebuilt source file")
- }
-}
-
-func (t *prebuiltBuildTool) GenerateAndroidBuildActions(ctx ModuleContext) {
- sourcePath := t.prebuilt.SingleSourcePath(ctx)
- installedPath := PathForModuleOut(ctx, t.ModuleBase.Name())
- deps := PathsForModuleSrc(ctx, t.properties.Deps)
-
- var relPath string
- if filepath.IsAbs(installedPath.String()) {
- relPath = filepath.Join(absSrcDir, sourcePath.String())
- } else {
- var err error
- relPath, err = filepath.Rel(path.Dir(installedPath.String()), sourcePath.String())
- if err != nil {
- ctx.ModuleErrorf("Unable to generate symlink between %q and %q: %s", installedPath.String(), sourcePath.String(), err)
- }
- }
-
- ctx.Build(pctx, BuildParams{
- Rule: Symlink,
- Output: installedPath,
- Input: sourcePath,
- Implicits: deps,
- Args: map[string]string{
- "fromPath": relPath,
- },
- })
-
- t.toolPath = OptionalPathForPath(installedPath)
-}
-
-func (t *prebuiltBuildTool) HostToolPath() OptionalPath {
- return t.toolPath
-}
-
-var _ HostToolProvider = &prebuiltBuildTool{}
-
-// prebuilt_build_tool is to declare prebuilts to be used during the build, particularly for use
-// in genrules with the "tools" property.
-func prebuiltBuildToolFactory() Module {
- module := &prebuiltBuildTool{}
- module.AddProperties(&module.properties)
- InitSingleSourcePrebuiltModule(module, &module.properties, "Src")
- InitAndroidArchModule(module, HostSupportedNoCross, MultilibFirst)
- return module
-}
diff --git a/android/variable.go b/android/variable.go
index 2c8bd07..5826138 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -308,8 +308,6 @@
BoardPlatPrivateSepolicyDirs []string `json:",omitempty"`
BoardSepolicyM4Defs []string `json:",omitempty"`
- BoardVndkRuntimeDisable *bool `json:",omitempty"`
-
VendorVars map[string]map[string]string `json:",omitempty"`
Ndk_abis *bool `json:",omitempty"`
diff --git a/apex/androidmk.go b/apex/androidmk.go
index e739e2b..82a902b 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -82,9 +82,9 @@
var moduleName string
if linkToSystemLib {
- moduleName = fi.moduleName
+ moduleName = fi.androidMkModuleName
} else {
- moduleName = fi.moduleName + "." + apexBundleName + a.suffix
+ moduleName = fi.androidMkModuleName + "." + apexBundleName + a.suffix
}
if !android.InList(moduleName, moduleNames) {
@@ -250,9 +250,9 @@
}
// m <module_name> will build <module_name>.<apex_name> as well.
- if fi.moduleName != moduleName && a.primaryApexType {
- fmt.Fprintln(w, ".PHONY: "+fi.moduleName)
- fmt.Fprintln(w, fi.moduleName+": "+moduleName)
+ if fi.androidMkModuleName != moduleName && a.primaryApexType {
+ fmt.Fprintf(w, ".PHONY: %s\n", fi.androidMkModuleName)
+ fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName)
}
}
return moduleNames
diff --git a/apex/apex.go b/apex/apex.go
index b64a735..f9c902c 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1152,12 +1152,14 @@
// apexFile represents a file in an APEX bundle
type apexFile struct {
- builtFile android.Path
- stem string
- moduleName string
- installDir string
- class apexFileClass
- module android.Module
+ builtFile android.Path
+ stem string
+ // Module name of `module` in AndroidMk. Note the generated AndroidMk module for
+ // apexFile is named something like <AndroidMk module name>.<apex name>[<apex suffix>]
+ androidMkModuleName string
+ installDir string
+ class apexFileClass
+ module android.Module
// list of symlinks that will be created in installDir that point to this apexFile
symlinks []string
dataPaths []android.DataPath
@@ -1176,13 +1178,13 @@
isJniLib bool
}
-func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
+func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile {
ret := apexFile{
- builtFile: builtFile,
- moduleName: moduleName,
- installDir: installDir,
- class: class,
- module: module,
+ builtFile: builtFile,
+ androidMkModuleName: androidMkModuleName,
+ installDir: installDir,
+ class: class,
+ module: module,
}
if module != nil {
ret.moduleDir = ctx.OtherModuleDir(module)
@@ -1639,7 +1641,8 @@
}
fileToCopy := ccMod.OutputFile().Path()
- return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
+ androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName
+ return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod)
}
func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
@@ -1649,7 +1652,8 @@
}
dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
fileToCopy := cc.OutputFile().Path()
- af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
+ androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName
+ af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc)
af.symlinks = cc.Symlinks()
af.dataPaths = cc.DataPaths()
return af
@@ -1658,7 +1662,7 @@
func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
dirInApex := "bin"
fileToCopy := py.HostToolPath().Path()
- return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
+ return newApexFile(ctx, fileToCopy, py.BaseModuleName(), dirInApex, pyBinary, py)
}
func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
dirInApex := "bin"
@@ -1677,12 +1681,14 @@
func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
dirInApex := filepath.Join("bin", sh.SubDir())
fileToCopy := sh.OutputFile()
- af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
+ af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh)
af.symlinks = sh.Symlinks()
return af
}
-type javaDependency interface {
+type javaModule interface {
+ android.Module
+ BaseModuleName() string
DexJarBuildPath() android.Path
JacocoReportClassesFile() android.Path
LintDepSets() java.LintDepSets
@@ -1690,20 +1696,18 @@
Stem() string
}
-var _ javaDependency = (*java.Library)(nil)
-var _ javaDependency = (*java.SdkLibrary)(nil)
-var _ javaDependency = (*java.DexImport)(nil)
-var _ javaDependency = (*java.SdkLibraryImport)(nil)
+var _ javaModule = (*java.Library)(nil)
+var _ javaModule = (*java.SdkLibrary)(nil)
+var _ javaModule = (*java.DexImport)(nil)
+var _ javaModule = (*java.SdkLibraryImport)(nil)
-func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, module android.Module) apexFile {
+func apexFileForJavaLibrary(ctx android.BaseModuleContext, module javaModule) apexFile {
dirInApex := "javalib"
- fileToCopy := lib.DexJarBuildPath()
- // Remove prebuilt_ if necessary so the source and prebuilt modules have the same name.
- name := strings.TrimPrefix(module.Name(), "prebuilt_")
- af := newApexFile(ctx, fileToCopy, name, dirInApex, javaSharedLib, module)
- af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
- af.lintDepSets = lib.LintDepSets()
- af.stem = lib.Stem() + ".jar"
+ fileToCopy := module.DexJarBuildPath()
+ af := newApexFile(ctx, fileToCopy, module.BaseModuleName(), dirInApex, javaSharedLib, module)
+ af.jacocoReportClassesFile = module.JacocoReportClassesFile()
+ af.lintDepSets = module.LintDepSets()
+ af.stem = module.Stem() + ".jar"
return af
}
@@ -1726,6 +1730,7 @@
OutputFile() android.Path
JacocoReportClassesFile() android.Path
Certificate() java.Certificate
+ BaseModuleName() string
}) apexFile {
appDir := "app"
if aapp.Privileged() {
@@ -1733,7 +1738,7 @@
}
dirInApex := filepath.Join(appDir, aapp.InstallApkName())
fileToCopy := aapp.OutputFile()
- af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
+ af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp)
af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
af.certificate = aapp.Certificate()
@@ -2059,7 +2064,7 @@
case javaLibTag:
switch child.(type) {
case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport:
- af := apexFileForJavaLibrary(ctx, child.(javaDependency), child.(android.Module))
+ af := apexFileForJavaLibrary(ctx, child.(javaModule))
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
return false
@@ -2082,7 +2087,7 @@
if ap.Privileged() {
appDir = "priv-app"
}
- af := newApexFile(ctx, ap.OutputFile(), ap.Name(),
+ af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(),
filepath.Join(appDir, ap.BaseModuleName()), appSet, ap)
af.certificate = java.PresignedCertificate
filesInfo = append(filesInfo, af)
@@ -2199,7 +2204,7 @@
// use the name of the generated test binary (`fileToCopy`) instead of the name
// of the original test module (`depName`, shared by all `test_per_src`
// variations of that module).
- af.moduleName = filepath.Base(af.builtFile.String())
+ af.androidMkModuleName = filepath.Base(af.builtFile.String())
// these are not considered transitive dep
af.transitiveDep = false
filesInfo = append(filesInfo, af)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 9662a7f..7db61d5 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -5228,6 +5228,57 @@
ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file
}
+func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) {
+ ctx, config := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library_shared {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ shared_libs: ["myotherlib"],
+ system_shared_libs: [],
+ stl: "none",
+ apex_available: [
+ "myapex",
+ "//apex_available:platform",
+ ],
+ }
+
+ cc_prebuilt_library_shared {
+ name: "myotherlib",
+ srcs: ["prebuilt.so"],
+ system_shared_libs: [],
+ stl: "none",
+ apex_available: [
+ "myapex",
+ "//apex_available:platform",
+ ],
+ }
+ `)
+
+ apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
+ data := android.AndroidMkDataForTest(t, config, "", apexBundle)
+ var builder strings.Builder
+ data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
+ androidMk := builder.String()
+ // `myotherlib` is added to `myapex` as symlink
+ ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
+ ensureNotContains(t, androidMk, "LOCAL_MODULE := prebuilt_myotherlib.myapex\n")
+ ensureNotContains(t, androidMk, "LOCAL_MODULE := myotherlib.myapex\n")
+ // `myapex` should have `myotherlib` in its required line, not `prebuilt_myotherlib`
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += mylib.myapex myotherlib apex_manifest.pb.myapex apex_pubkey.myapex\n")
+}
+
func TestApexWithJniLibs(t *testing.T) {
ctx, _ := testApex(t, `
apex {
diff --git a/cc/cc.go b/cc/cc.go
index bea851f..57fe9ba 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -116,8 +116,6 @@
// Used for host bionic
LinkerFlagsFile string
DynamicLinker string
-
- Tools []string
}
type PathDeps struct {
@@ -160,8 +158,6 @@
// Path to the dynamic linker binary
DynamicLinker android.OptionalPath
-
- Tools map[string]android.Path
}
// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
@@ -429,12 +425,6 @@
XrefCcFiles() android.Paths
}
-type ToolDependencyTag struct {
- blueprint.BaseDependencyTag
-
- Name string
-}
-
var (
dataLibDepTag = DependencyTag{Name: "data_lib", Library: true, Shared: true}
sharedExportDepTag = DependencyTag{Name: "shared", Library: true, Shared: true, ReexportFlags: true}
@@ -1704,7 +1694,6 @@
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
- deps.Tools = android.LastUniqueStrings(deps.Tools)
for _, lib := range deps.ReexportSharedLibHeaders {
if !inList(lib, deps.SharedLibs) {
@@ -2048,11 +2037,6 @@
}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
}
}
-
- for _, tool := range deps.Tools {
- actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(),
- ToolDependencyTag{Name: tool}, tool)
- }
}
func BeginMutator(ctx android.BottomUpMutatorContext) {
@@ -2248,21 +2232,6 @@
depName := ctx.OtherModuleName(dep)
depTag := ctx.OtherModuleDependencyTag(dep)
- if toolDep, ok := depTag.(ToolDependencyTag); ok {
- if toolMod, ok := dep.(android.HostToolProvider); ok {
- if depPaths.Tools == nil {
- depPaths.Tools = make(map[string]android.Path)
- }
- toolPath := toolMod.HostToolPath()
- if !toolPath.Valid() {
- ctx.ModuleErrorf("Failed to find path for host tool %q", toolDep.Name)
- }
- depPaths.Tools[toolDep.Name] = toolPath.Path()
- } else {
- ctx.ModuleErrorf("Found module, but not host tool for %q", toolDep.Name)
- }
- }
-
ccDep, ok := dep.(LinkableInterface)
if !ok {
diff --git a/cc/compiler.go b/cc/compiler.go
index ba14dd5..d5ea2c3 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -251,14 +251,6 @@
deps.StaticLibs = append(deps.StaticLibs, "libomp")
}
- if compiler.hasSrcExt(".y") || compiler.hasSrcExt(".yy") {
- deps.Tools = append(deps.Tools, "bison", "m4")
- }
-
- if compiler.hasSrcExt(".l") || compiler.hasSrcExt(".ll") {
- deps.Tools = append(deps.Tools, "flex", "m4")
- }
-
return deps
}
@@ -589,7 +581,7 @@
srcs := append(android.Paths(nil), compiler.srcsBeforeGen...)
- srcs, genDeps := genSources(ctx, srcs, buildFlags, deps.Tools)
+ srcs, genDeps := genSources(ctx, srcs, buildFlags)
pathDeps = append(pathDeps, genDeps...)
compiler.pathDeps = pathDeps
diff --git a/cc/config/integer_overflow_blacklist.txt b/cc/config/integer_overflow_blocklist.txt
similarity index 100%
rename from cc/config/integer_overflow_blacklist.txt
rename to cc/config/integer_overflow_blocklist.txt
diff --git a/cc/gen.go b/cc/gen.go
index 6f9036b..b0aadc6 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -24,6 +24,7 @@
)
func init() {
+ pctx.SourcePathVariable("lexCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/flex")
pctx.SourcePathVariable("m4Cmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/m4")
pctx.HostBinToolVariable("aidlCmd", "aidl-cpp")
@@ -31,6 +32,12 @@
}
var (
+ lex = pctx.AndroidStaticRule("lex",
+ blueprint.RuleParams{
+ Command: "M4=$m4Cmd $lexCmd -o$out $in",
+ CommandDeps: []string{"$lexCmd", "$m4Cmd"},
+ })
+
sysprop = pctx.AndroidStaticRule("sysprop",
blueprint.RuleParams{
Command: "$syspropCmd --header-dir=$headerOutDir --public-header-dir=$publicOutDir " +
@@ -59,8 +66,7 @@
}
func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile android.Path,
- outFile android.ModuleGenPath, props *YaccProperties,
- tools map[string]android.Path) (headerFiles android.Paths) {
+ outFile android.ModuleGenPath, props *YaccProperties) (headerFiles android.Paths) {
outDir := android.PathForModuleGen(ctx, "yacc")
headerFile := android.GenPathWithExt(ctx, "yacc", yaccFile, "h")
@@ -91,17 +97,9 @@
}
}
- bison, ok := tools["bison"]
- if !ok {
- ctx.ModuleErrorf("Unable to find bison")
- }
- m4, ok := tools["m4"]
- if !ok {
- ctx.ModuleErrorf("Unable to find m4")
- }
-
- cmd.FlagWithInput("M4=", m4).
- Tool(bison).
+ cmd.Text("BISON_PKGDATADIR=prebuilts/build-tools/common/bison").
+ FlagWithInput("M4=", ctx.Config().PrebuiltBuildTool(ctx, "m4")).
+ PrebuiltBuildTool(ctx, "bison").
Flag("-d").
Flags(flags).
FlagWithOutput("--defines=", headerFile).
@@ -155,23 +153,13 @@
}
}
-func genLex(ctx android.ModuleContext, rule *android.RuleBuilder, lexFile android.Path,
- outFile android.ModuleGenPath, tools map[string]android.Path) {
-
- flex, ok := tools["flex"]
- if !ok {
- ctx.ModuleErrorf("Unable to find flex")
- }
- m4, ok := tools["m4"]
- if !ok {
- ctx.ModuleErrorf("Unable to find m4")
- }
-
- rule.Command().
- FlagWithInput("M4=", m4).
- Tool(flex).
- FlagWithOutput("-o", outFile).
- Input(lexFile)
+func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: lex,
+ Description: "lex " + lexFile.Rel(),
+ Output: outFile,
+ Input: lexFile,
+ })
}
func genSysprop(ctx android.ModuleContext, syspropFile android.Path) (android.Path, android.Paths) {
@@ -218,22 +206,14 @@
return rcFile, headerFile
}
-func genSources(ctx android.ModuleContext, srcFiles android.Paths, buildFlags builderFlags,
- tools map[string]android.Path) (android.Paths, android.Paths) {
+func genSources(ctx android.ModuleContext, srcFiles android.Paths,
+ buildFlags builderFlags) (android.Paths, android.Paths) {
var deps android.Paths
var rsFiles android.Paths
var aidlRule *android.RuleBuilder
- var lexRule_ *android.RuleBuilder
- lexRule := func() *android.RuleBuilder {
- if lexRule_ == nil {
- lexRule_ = android.NewRuleBuilder().Sbox(android.PathForModuleGen(ctx, "lex"))
- }
- return lexRule_
- }
-
var yaccRule_ *android.RuleBuilder
yaccRule := func() *android.RuleBuilder {
if yaccRule_ == nil {
@@ -247,19 +227,19 @@
case ".y":
cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c")
srcFiles[i] = cFile
- deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cFile, buildFlags.yacc, tools)...)
+ deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cFile, buildFlags.yacc)...)
case ".yy":
cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp")
srcFiles[i] = cppFile
- deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cppFile, buildFlags.yacc, tools)...)
+ deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cppFile, buildFlags.yacc)...)
case ".l":
cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c")
srcFiles[i] = cFile
- genLex(ctx, lexRule(), srcFile, cFile, tools)
+ genLex(ctx, srcFile, cFile)
case ".ll":
cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp")
srcFiles[i] = cppFile
- genLex(ctx, lexRule(), srcFile, cppFile, tools)
+ genLex(ctx, srcFile, cppFile)
case ".proto":
ccFile, headerFile := genProto(ctx, srcFile, buildFlags)
srcFiles[i] = ccFile
@@ -291,10 +271,6 @@
aidlRule.Build(pctx, ctx, "aidl", "gen aidl")
}
- if lexRule_ != nil {
- lexRule_.Build(pctx, ctx, "lex", "gen lex")
- }
-
if yaccRule_ != nil {
yaccRule_.Build(pctx, ctx, "yacc", "gen yacc")
}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 4578fd3..22e3ec3 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -396,8 +396,8 @@
return module
}
-// ndk_library creates a stub library that exposes dummy implementation
-// of functions and variables for use at build time only.
+// ndk_library creates a library that exposes a stub implementation of functions
+// and variables for use at build time only.
func NdkLibraryFactory() android.Module {
module := newStubLibrary()
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 72ad6d7..300bc8f 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -51,7 +51,7 @@
}
cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
- "-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"}
+ "-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blocklist.txt"}
// -flto and -fvisibility are required by clang when -fsanitize=cfi is
// used, but have no effect on assembly files
cfiAsflags = []string{"-flto", "-fvisibility=default"}
@@ -61,7 +61,7 @@
cfiStaticLibsMutex sync.Mutex
hwasanStaticLibsMutex sync.Mutex
- intOverflowCflags = []string{"-fsanitize-blacklist=build/soong/cc/config/integer_overflow_blacklist.txt"}
+ intOverflowCflags = []string{"-fsanitize-blacklist=build/soong/cc/config/integer_overflow_blocklist.txt"}
minimalRuntimeFlags = []string{"-fsanitize-minimal-runtime", "-fno-sanitize-trap=integer,undefined",
"-fno-sanitize-recover=integer,undefined"}
@@ -174,6 +174,8 @@
// value to pass to -fsanitize-blacklist
Blacklist *string
+ // value to pass to -fsanitize-blacklist
+ Blocklist *string
} `android:"arch_variant"`
SanitizerEnabled bool `blueprint:"mutated"`
@@ -596,6 +598,12 @@
flags.CFlagsDeps = append(flags.CFlagsDeps, blacklist.Path())
}
+ blocklist := android.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blocklist)
+ if blocklist.Valid() {
+ flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize-blacklist="+blocklist.String())
+ flags.CFlagsDeps = append(flags.CFlagsDeps, blocklist.Path())
+ }
+
return flags
}
diff --git a/cc/vndk.go b/cc/vndk.go
index 4adf9d2..15843c6 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -559,10 +559,6 @@
return
}
- if ctx.DeviceConfig().BoardVndkRuntimeDisable() {
- return
- }
-
var snapshotOutputs android.Paths
/*
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 00baa57..1cec289 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -259,9 +259,9 @@
// If AllowMissingDependencies is enabled, the build will not have stopped when
// AddFarVariationDependencies was called on a missing tool, which will result in nonsensical
- // "cmd: unknown location label ..." errors later. Add a dummy file to the local label. The
- // command that uses this dummy file will never be executed because the rule will be replaced with
- // an android.Error rule reporting the missing dependencies.
+ // "cmd: unknown location label ..." errors later. Add a placeholder file to the local label.
+ // The command that uses this placeholder file will never be executed because the rule will be
+ // replaced with an android.Error rule reporting the missing dependencies.
if ctx.Config().AllowMissingDependencies() {
for _, tool := range g.properties.Tools {
if !seenTools[tool] {
@@ -292,9 +292,9 @@
// If AllowMissingDependencies is enabled, the build will not have stopped when
// the dependency was added on a missing SourceFileProducer module, which will result in nonsensical
- // "cmd: label ":..." has no files" errors later. Add a dummy file to the local label. The
- // command that uses this dummy file will never be executed because the rule will be replaced with
- // an android.Error rule reporting the missing dependencies.
+ // "cmd: label ":..." has no files" errors later. Add a placeholder file to the local label.
+ // The command that uses this placeholder file will never be executed because the rule will be
+ // replaced with an android.Error rule reporting the missing dependencies.
ctx.AddMissingDependencies(missingDeps)
addLocationLabel(in, []string{"***missing srcs " + in + "***"})
} else {
diff --git a/java/Android.bp b/java/Android.bp
index fd06c46..e345014 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -10,6 +10,7 @@
"soong-dexpreopt",
"soong-genrule",
"soong-java-config",
+ "soong-python",
"soong-remoteexec",
"soong-tradefed",
],
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 190a052..935b839 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -1674,7 +1674,7 @@
impRule := android.NewRuleBuilder()
impCmd := impRule.Command()
- // A dummy action that copies the ninja generated rsp file to a new location. This allows us to
+ // An action that copies the ninja generated rsp file to a new location. This allows us to
// add a large number of inputs to a file without exceeding bash command length limits (which
// would happen if we use the WriteFile rule). The cp is needed because RuleBuilder sets the
// rsp file to be ${output}.rsp.
diff --git a/java/java.go b/java/java.go
index ef9613d..bd476bc 100644
--- a/java/java.go
+++ b/java/java.go
@@ -556,7 +556,20 @@
}
func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
- android.InitAndroidArchModule(module, hod, android.MultilibCommon)
+ initJavaModule(module, hod, false)
+}
+
+func InitJavaModuleMultiTargets(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
+ initJavaModule(module, hod, true)
+}
+
+func initJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported, multiTargets bool) {
+ multilib := android.MultilibCommon
+ if multiTargets {
+ android.InitAndroidMultiTargetsArchModule(module, hod, multilib)
+ } else {
+ android.InitAndroidArchModule(module, hod, multilib)
+ }
android.InitDefaultableModule(module)
}
@@ -575,6 +588,7 @@
}
var (
+ dataNativeBinsTag = dependencyTag{name: "dataNativeBins"}
staticLibTag = dependencyTag{name: "staticlib"}
libTag = dependencyTag{name: "javalib"}
java9LibTag = dependencyTag{name: "java9lib"}
@@ -2193,6 +2207,11 @@
Test_mainline_modules []string
}
+type hostTestProperties struct {
+ // list of native binary modules that should be installed alongside the test
+ Data_native_bins []string `android:"arch_variant"`
+}
+
type testHelperLibraryProperties struct {
// list of compatibility suites (for example "cts", "vts") that the module should be
// installed into.
@@ -2218,6 +2237,12 @@
data android.Paths
}
+type TestHost struct {
+ Test
+
+ testHostProperties hostTestProperties
+}
+
type TestHelperLibrary struct {
Library
@@ -2232,11 +2257,26 @@
testConfig android.Path
}
+func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) {
+ if len(j.testHostProperties.Data_native_bins) > 0 {
+ for _, target := range ctx.MultiTargets() {
+ ctx.AddVariationDependencies(target.Variations(), dataNativeBinsTag, j.testHostProperties.Data_native_bins...)
+ }
+ }
+
+ j.deps(ctx)
+}
+
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.testProperties.Auto_gen_config)
+
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
+ ctx.VisitDirectDepsWithTag(dataNativeBinsTag, func(dep android.Module) {
+ j.data = append(j.data, android.OutputFileForModule(ctx, dep, ""))
+ })
+
j.Library.GenerateAndroidBuildActions(ctx)
}
@@ -2377,14 +2417,15 @@
// A java_test_host has a single variant that produces a `.jar` file containing `.class` files that were
// compiled against the host bootclasspath.
func TestHostFactory() android.Module {
- module := &Test{}
+ module := &TestHost{}
module.addHostProperties()
module.AddProperties(&module.testProperties)
+ module.AddProperties(&module.testHostProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)
- InitJavaModule(module, android.HostSupported)
+ InitJavaModuleMultiTargets(module, android.HostSupported)
return module
}
diff --git a/java/java_test.go b/java/java_test.go
index db3f187..73e6792 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -31,6 +31,7 @@
"android/soong/cc"
"android/soong/dexpreopt"
"android/soong/genrule"
+ "android/soong/python"
)
var buildDir string
@@ -81,6 +82,7 @@
ctx.RegisterModuleType("java_plugin", PluginFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
+ ctx.RegisterModuleType("python_binary_host", python.PythonBinaryHostFactory)
RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
RegisterSdkLibraryBuildComponents(ctx)
@@ -89,6 +91,7 @@
RegisterPrebuiltApisBuildComponents(ctx)
+ ctx.PreDepsMutators(python.RegisterPythonPreDepsMutators)
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(OverlaySingletonFactory))
ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(sdkPreSingletonFactory))
@@ -2008,3 +2011,28 @@
t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag)
}
}
+
+func TestDataNativeBinaries(t *testing.T) {
+ ctx, config := testJava(t, `
+ java_test_host {
+ name: "foo",
+ srcs: ["a.java"],
+ data_native_bins: ["bin"]
+ }
+
+ python_binary_host {
+ name: "bin",
+ srcs: ["bin.py"],
+ }
+ `)
+
+ buildOS := android.BuildOs.String()
+
+ test := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost)
+ entries := android.AndroidMkEntriesForTest(t, config, "", test)[0]
+ expected := []string{buildDir + "/.intermediates/bin/" + buildOS + "_x86_64_PY3/bin:bin"}
+ actual := entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"]
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Unexpected test data - expected: %q, actual: %q", expected, actual)
+ }
+}
diff --git a/java/lint.go b/java/lint.go
index 6391067..1bf7f69 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -252,7 +252,7 @@
return projectXMLPath, configXMLPath, cacheDir, homeDir, deps
}
-// generateManifest adds a command to the rule to write a dummy manifest cat contains the
+// generateManifest adds a command to the rule to write a simple manifest that contains the
// minSdkVersion and targetSdkVersion for modules (like java_library) that don't have a manifest.
func (l *linter) generateManifest(ctx android.ModuleContext, rule *android.RuleBuilder) android.Path {
manifestPath := android.PathForModuleOut(ctx, "lint", "AndroidManifest.xml")
diff --git a/java/sdk.go b/java/sdk.go
index 6e67a13..5d79d1d 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -214,7 +214,7 @@
// "current" can be built from source and be from prebuilt SDK
return ctx.Config().UnbundledBuildUsePrebuiltSdks()
} else if s.version.isNumbered() {
- // sanity check
+ // validation check
if s.kind != sdkPublic && s.kind != sdkSystem && s.kind != sdkTest {
panic(fmt.Errorf("prebuilt SDK is not not available for sdkKind=%q", s.kind))
return false
diff --git a/java/testing.go b/java/testing.go
index e761743..1e725fa 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -22,6 +22,8 @@
"android/soong/android"
"android/soong/cc"
+ "android/soong/python"
+
"github.com/google/blueprint"
)
@@ -85,6 +87,10 @@
"prebuilts/sdk/tools/core-lambda-stubs.jar": nil,
"prebuilts/sdk/Android.bp": []byte(`prebuilt_apis { name: "sdk", api_dirs: ["14", "28", "30", "current"],}`),
+ "bin.py": nil,
+ python.StubTemplateHost: []byte(`PYTHON_BINARY = '%interpreter%'
+ MAIN_FILE = '%main%'`),
+
// For java_sdk_library
"api/module-lib-current.txt": nil,
"api/module-lib-removed.txt": nil,
diff --git a/python/binary.go b/python/binary.go
index 695fa12..5a74926 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -65,7 +65,7 @@
}
var (
- stubTemplateHost = "build/soong/python/scripts/stub_template_host.txt"
+ StubTemplateHost = "build/soong/python/scripts/stub_template_host.txt"
)
func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
diff --git a/python/builder.go b/python/builder.go
index 36baecd..dc2d1f1 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -91,7 +91,7 @@
if !embeddedLauncher {
// the path of stub_template_host.txt from source tree.
- template := android.PathForSource(ctx, stubTemplateHost)
+ template := android.PathForSource(ctx, StubTemplateHost)
implicits = append(implicits, template)
// intermediate output path for __main__.py
diff --git a/python/python.go b/python/python.go
index a6c9e2a..479c729 100644
--- a/python/python.go
+++ b/python/python.go
@@ -30,9 +30,11 @@
)
func init() {
- android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("version_split", versionSplitMutator()).Parallel()
- })
+ android.PreDepsMutators(RegisterPythonPreDepsMutators)
+}
+
+func RegisterPythonPreDepsMutators(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("version_split", versionSplitMutator()).Parallel()
}
// the version properties that apply to python libraries and binaries.
@@ -226,15 +228,20 @@
return func(mctx android.BottomUpMutatorContext) {
if base, ok := mctx.Module().(*Module); ok {
versionNames := []string{}
- if base.properties.Version.Py2.Enabled != nil &&
- *(base.properties.Version.Py2.Enabled) == true {
- versionNames = append(versionNames, pyVersion2)
- }
+ // PY3 is first so that we alias the PY3 variant rather than PY2 if both
+ // are available
if !(base.properties.Version.Py3.Enabled != nil &&
*(base.properties.Version.Py3.Enabled) == false) {
versionNames = append(versionNames, pyVersion3)
}
+ if base.properties.Version.Py2.Enabled != nil &&
+ *(base.properties.Version.Py2.Enabled) == true {
+ versionNames = append(versionNames, pyVersion2)
+ }
modules := mctx.CreateVariations(versionNames...)
+ if len(versionNames) > 0 {
+ mctx.AliasVariation(versionNames[0])
+ }
for i, v := range versionNames {
// set the actual version for Python module.
modules[i].(*Module).properties.Actual_version = v
diff --git a/python/python_test.go b/python/python_test.go
index 1245ca1..23db24e 100644
--- a/python/python_test.go
+++ b/python/python_test.go
@@ -301,7 +301,7 @@
filepath.Join("dir", "file2.py"): nil,
filepath.Join("dir", "bin.py"): nil,
filepath.Join("dir", "file4.py"): nil,
- stubTemplateHost: []byte(`PYTHON_BINARY = '%interpreter%'
+ StubTemplateHost: []byte(`PYTHON_BINARY = '%interpreter%'
MAIN_FILE = '%main%'`),
},
expectedBinaries: []pyModule{
@@ -330,9 +330,7 @@
t.Run(d.desc, func(t *testing.T) {
config := android.TestConfig(buildDir, nil, "", d.mockFiles)
ctx := android.NewTestContext()
- ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("version_split", versionSplitMutator()).Parallel()
- })
+ ctx.PreDepsMutators(RegisterPythonPreDepsMutators)
ctx.RegisterModuleType("python_library_host", PythonLibraryHostFactory)
ctx.RegisterModuleType("python_binary_host", PythonBinaryHostFactory)
ctx.RegisterModuleType("python_defaults", defaultsFactory)
diff --git a/rust/binary.go b/rust/binary.go
index 1e9e119..1a82c92 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -86,7 +86,7 @@
deps = binary.baseCompiler.compilerDeps(ctx, deps)
if ctx.toolchain().Bionic() {
- deps = binary.baseCompiler.bionicDeps(ctx, deps)
+ deps = bionicDeps(deps)
deps.CrtBegin = "crtbegin_dynamic"
deps.CrtEnd = "crtend_android"
}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 83ad560..e8bbb35 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -15,11 +15,11 @@
package rust
import (
- "github.com/google/blueprint"
"strings"
+ "github.com/google/blueprint"
+
"android/soong/android"
- "android/soong/cc"
ccConfig "android/soong/cc/config"
)
@@ -41,8 +41,10 @@
bindgen = pctx.AndroidStaticRule("bindgen",
blueprint.RuleParams{
Command: "CLANG_PATH=$bindgenClang LIBCLANG_PATH=$bindgenLibClang RUSTFMT=${config.RustBin}/rustfmt " +
- "$bindgenCmd $flags $in -o $out -- $cflags",
+ "$bindgenCmd $flags $in -o $out -- -MD -MF $out.d $cflags",
CommandDeps: []string{"$bindgenCmd"},
+ Deps: blueprint.DepsGCC,
+ Depfile: "$out.d",
},
"flags", "cflags")
)
@@ -83,40 +85,39 @@
Properties BindgenProperties
}
-func (b *bindgenDecorator) libraryExports(ctx android.ModuleContext) (android.Paths, []string) {
- var libraryPaths android.Paths
- var libraryFlags []string
-
- for _, static_lib := range b.Properties.Static_libs {
- if dep, ok := ctx.GetDirectDepWithTag(static_lib, cc.StaticDepTag).(*cc.Module); ok {
- libraryPaths = append(libraryPaths, dep.ExportedIncludeDirs()...)
- libraryFlags = append(libraryFlags, dep.ExportedFlags()...)
- }
- }
- for _, shared_lib := range b.Properties.Shared_libs {
- if dep, ok := ctx.GetDirectDepWithTag(shared_lib, cc.SharedDepTag).(*cc.Module); ok {
- libraryPaths = append(libraryPaths, dep.ExportedIncludeDirs()...)
- libraryFlags = append(libraryFlags, dep.ExportedFlags()...)
- }
- }
-
- return libraryPaths, libraryFlags
-}
-
-func (b *bindgenDecorator) generateSource(ctx android.ModuleContext) android.Path {
+func (b *bindgenDecorator) generateSource(ctx android.ModuleContext, deps PathDeps) android.Path {
ccToolchain := ccConfig.FindToolchain(ctx.Os(), ctx.Arch())
- includes, exportedFlags := b.libraryExports(ctx)
var cflags []string
- cflags = append(cflags, b.Properties.Cflags...)
+ var implicits android.Paths
+
+ implicits = append(implicits, deps.depIncludePaths...)
+ implicits = append(implicits, deps.depSystemIncludePaths...)
+
+ // Default clang flags
+ cflags = append(cflags, "${ccConfig.CommonClangGlobalCflags}")
+ if ctx.Device() {
+ cflags = append(cflags, "${ccConfig.DeviceClangGlobalCflags}")
+ }
+
+ // Toolchain clang flags
cflags = append(cflags, "-target "+ccToolchain.ClangTriple())
cflags = append(cflags, strings.ReplaceAll(ccToolchain.ToolchainClangCflags(), "${config.", "${ccConfig."))
- cflags = append(cflags, exportedFlags...)
- for _, include := range includes {
+
+ // Dependency clang flags and include paths
+ cflags = append(cflags, deps.depClangFlags...)
+ for _, include := range deps.depIncludePaths {
cflags = append(cflags, "-I"+include.String())
}
+ for _, include := range deps.depSystemIncludePaths {
+ cflags = append(cflags, "-isystem "+include.String())
+ }
+
+ // Module defined clang flags and include paths
+ cflags = append(cflags, b.Properties.Cflags...)
for _, include := range b.Properties.Local_include_dirs {
cflags = append(cflags, "-I"+android.PathForModuleSrc(ctx, include).String())
+ implicits = append(implicits, android.PathForModuleSrc(ctx, include))
}
bindgenFlags := defaultBindgenFlags
@@ -134,7 +135,7 @@
Description: "bindgen " + wrapperFile.Path().Rel(),
Output: outputFile,
Input: wrapperFile.Path(),
- Implicits: includes,
+ Implicits: implicits,
Args: map[string]string{
"flags": strings.Join(bindgenFlags, " "),
"cflags": strings.Join(cflags, " "),
@@ -176,6 +177,10 @@
func (b *bindgenDecorator) sourceProviderDeps(ctx DepsContext, deps Deps) Deps {
deps = b.baseSourceProvider.sourceProviderDeps(ctx, deps)
+ if ctx.toolchain().Bionic() {
+ deps = bionicDeps(deps)
+ }
+
deps.SharedLibs = append(deps.SharedLibs, b.Properties.Shared_libs...)
deps.StaticLibs = append(deps.StaticLibs, b.Properties.Static_libs...)
return deps
diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go
index 18e188f..2122ec1 100644
--- a/rust/bindgen_test.go
+++ b/rust/bindgen_test.go
@@ -48,9 +48,9 @@
t.Errorf("missing clang cflags in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
}
if !strings.Contains(libbindgen.Args["cflags"], "-Ishared_include") {
- t.Errorf("missing clang cflags in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
+ t.Errorf("missing shared_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
}
if !strings.Contains(libbindgen.Args["cflags"], "-Istatic_include") {
- t.Errorf("missing clang cflags in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
+ t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
}
}
diff --git a/rust/compiler.go b/rust/compiler.go
index ab3d2f4..040219d 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -199,7 +199,7 @@
return deps
}
-func (compiler *baseCompiler) bionicDeps(ctx DepsContext, deps Deps) Deps {
+func bionicDeps(deps Deps) Deps {
deps.SharedLibs = append(deps.SharedLibs, "liblog")
deps.SharedLibs = append(deps.SharedLibs, "libc")
deps.SharedLibs = append(deps.SharedLibs, "libm")
diff --git a/rust/library.go b/rust/library.go
index ac725d7..4c6da9d 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -340,7 +340,7 @@
deps = library.baseCompiler.compilerDeps(ctx, deps)
if ctx.toolchain().Bionic() && (library.dylib() || library.shared()) {
- deps = library.baseCompiler.bionicDeps(ctx, deps)
+ deps = bionicDeps(deps)
deps.CrtBegin = "crtbegin_so"
deps.CrtEnd = "crtend_so"
}
diff --git a/rust/rust.go b/rust/rust.go
index 89b89e2..78bf7ad 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -256,6 +256,11 @@
depFlags []string
//ReexportedDeps android.Paths
+ // Used by bindgen modules which call clang
+ depClangFlags []string
+ depIncludePaths android.Paths
+ depSystemIncludePaths android.Paths
+
coverageFiles android.Paths
CrtBegin android.OptionalPath
@@ -671,7 +676,7 @@
mod.compiler.install(ctx, mod.outputFile.Path())
}
} else if mod.sourceProvider != nil {
- outputFile := mod.sourceProvider.generateSource(ctx)
+ outputFile := mod.sourceProvider.generateSource(ctx, deps)
mod.outputFile = android.OptionalPathForPath(outputFile)
mod.subName = ctx.ModuleSubDir()
}
@@ -849,6 +854,11 @@
depFlag = "-lstatic=" + libName
depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
depPaths.depFlags = append(depPaths.depFlags, depFlag)
+ depPaths.depIncludePaths = append(depPaths.depIncludePaths, ccDep.IncludeDirs()...)
+ if mod, ok := ccDep.(*cc.Module); ok {
+ depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, mod.ExportedSystemIncludeDirs()...)
+ depPaths.depClangFlags = append(depPaths.depClangFlags, mod.ExportedFlags()...)
+ }
depPaths.coverageFiles = append(depPaths.coverageFiles, ccDep.CoverageFiles()...)
directStaticLibDeps = append(directStaticLibDeps, ccDep)
mod.Properties.AndroidMkStaticLibs = append(mod.Properties.AndroidMkStaticLibs, depName)
@@ -856,6 +866,11 @@
depFlag = "-ldylib=" + libName
depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
depPaths.depFlags = append(depPaths.depFlags, depFlag)
+ depPaths.depIncludePaths = append(depPaths.depIncludePaths, ccDep.IncludeDirs()...)
+ if mod, ok := ccDep.(*cc.Module); ok {
+ depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, mod.ExportedSystemIncludeDirs()...)
+ depPaths.depClangFlags = append(depPaths.depClangFlags, mod.ExportedFlags()...)
+ }
directSharedLibDeps = append(directSharedLibDeps, ccDep)
mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, depName)
exportDep = true
@@ -916,6 +931,9 @@
// Dedup exported flags from dependencies
depPaths.linkDirs = android.FirstUniqueStrings(depPaths.linkDirs)
depPaths.depFlags = android.FirstUniqueStrings(depPaths.depFlags)
+ depPaths.depClangFlags = android.FirstUniqueStrings(depPaths.depClangFlags)
+ depPaths.depIncludePaths = android.FirstUniquePaths(depPaths.depIncludePaths)
+ depPaths.depSystemIncludePaths = android.FirstUniquePaths(depPaths.depSystemIncludePaths)
return depPaths
}
diff --git a/rust/source_provider.go b/rust/source_provider.go
index e034d2c..da6147a 100644
--- a/rust/source_provider.go
+++ b/rust/source_provider.go
@@ -33,7 +33,7 @@
var _ SourceProvider = (*baseSourceProvider)(nil)
type SourceProvider interface {
- generateSource(ctx android.ModuleContext) android.Path
+ generateSource(ctx android.ModuleContext, deps PathDeps) android.Path
Srcs() android.Paths
sourceProviderProps() []interface{}
sourceProviderDeps(ctx DepsContext, deps Deps) Deps
@@ -43,7 +43,7 @@
return android.Paths{sp.outputFile}
}
-func (sp *baseSourceProvider) generateSource(ctx android.ModuleContext) android.Path {
+func (sp *baseSourceProvider) generateSource(ctx android.ModuleContext, deps PathDeps) android.Path {
panic("baseSourceProviderModule does not implement generateSource()")
}
diff --git a/third_party/zip/zip_test.go b/third_party/zip/zip_test.go
index 7373660..559c914 100644
--- a/third_party/zip/zip_test.go
+++ b/third_party/zip/zip_test.go
@@ -219,7 +219,7 @@
}
}
-// fakeHash32 is a dummy Hash32 that always returns 0.
+// fakeHash32 is a fake Hash32 that always returns 0.
type fakeHash32 struct {
hash.Hash32
}