Merge "Add support for sysprop description files to c++" am: 5b9fde2d15

am: 34af6a3dba

Change-Id: Ied7ded11302e4add21d3b8d9a6ee1a30cb647694
This commit is contained in:
Inseob Kim
2018-10-22 21:15:52 -07:00
committed by android-build-merger
3 changed files with 51 additions and 1 deletions

View File

@@ -224,6 +224,10 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
}
if compiler.hasSrcExt(".sysprop") {
deps.SharedLibs = append(deps.SharedLibs, "libbase")
}
if Bool(compiler.Properties.Openmp) {
deps.StaticLibs = append(deps.StaticLibs, "libomp")
}
@@ -489,6 +493,11 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags = rsFlags(ctx, flags, &compiler.Properties)
}
if compiler.hasSrcExt(".sysprop") {
flags.GlobalFlags = append(flags.GlobalFlags,
"-I"+android.PathForModuleGen(ctx, "sysprop", "include").String())
}
if len(compiler.Properties.Srcs) > 0 {
module := ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName()
if inList("-Wno-error", flags.CFlags) || inList("-Wno-error", flags.CppFlags) {

View File

@@ -19,6 +19,8 @@ package cc
// functions.
import (
"path/filepath"
"github.com/google/blueprint"
"android/soong/android"
@@ -30,6 +32,7 @@ func init() {
pctx.SourcePathVariable("yaccDataDir", "prebuilts/build-tools/common/bison")
pctx.HostBinToolVariable("aidlCmd", "aidl-cpp")
pctx.HostBinToolVariable("syspropCmd", "sysprop_cpp")
}
var (
@@ -55,6 +58,13 @@ var (
},
"aidlFlags", "outDir")
sysprop = pctx.AndroidStaticRule("sysprop",
blueprint.RuleParams{
Command: "$syspropCmd --header-output-dir=$headerOutDir --source-output-dir=$srcOutDir --include-name=$includeName $in",
CommandDeps: []string{"$syspropCmd"},
},
"headerOutDir", "srcOutDir", "includeName")
windmc = pctx.AndroidStaticRule("windmc",
blueprint.RuleParams{
Command: "$windmcCmd -r$$(dirname $out) -h$$(dirname $out) $in",
@@ -82,7 +92,6 @@ func genYacc(ctx android.ModuleContext, yaccFile android.Path, outFile android.M
}
func genAidl(ctx android.ModuleContext, aidlFile android.Path, outFile android.ModuleGenPath, aidlFlags string) android.Paths {
ctx.Build(pctx, android.BuildParams{
Rule: aidl,
Description: "aidl " + aidlFile.Rel(),
@@ -107,6 +116,26 @@ func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.Mod
})
}
func genSysprop(ctx android.ModuleContext, syspropFile android.Path) (android.Path, android.Path) {
headerFile := android.PathForModuleGen(ctx, "sysprop", "include", syspropFile.Rel()+".h")
cppFile := android.PathForModuleGen(ctx, "sysprop", syspropFile.Rel()+".cpp")
ctx.Build(pctx, android.BuildParams{
Rule: sysprop,
Description: "sysprop " + syspropFile.Rel(),
Output: cppFile,
ImplicitOutput: headerFile,
Input: syspropFile,
Args: map[string]string{
"headerOutDir": filepath.Dir(headerFile.String()),
"srcOutDir": filepath.Dir(cppFile.String()),
"includeName": syspropFile.Rel() + ".h",
},
})
return cppFile, headerFile
}
func genWinMsg(ctx android.ModuleContext, srcFile android.Path, flags builderFlags) (android.Path, android.Path) {
headerFile := android.GenPathWithExt(ctx, "windmc", srcFile, "h")
rcFile := android.GenPathWithExt(ctx, "windmc", srcFile, "rc")
@@ -169,6 +198,10 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
rcFile, headerFile := genWinMsg(ctx, srcFile, buildFlags)
srcFiles[i] = rcFile
deps = append(deps, headerFile)
case ".sysprop":
cppFile, headerFile := genSysprop(ctx, srcFile)
srcFiles[i] = cppFile
deps = append(deps, headerFile)
}
}

View File

@@ -678,6 +678,14 @@ func (library *libraryDecorator) link(ctx ModuleContext,
}
}
if library.baseCompiler.hasSrcExt(".sysprop") {
flags := []string{
"-I" + android.PathForModuleGen(ctx, "sysprop", "include").String(),
}
library.reexportFlags(flags)
library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
}
return out
}