Add support for sysprop description files to c++

From now on, a c++ shared library can be built only with adding
".sysprop" description file to srcs. Sysprop library generator will
automatically generate a .cpp and .h files, and the header file will be
exposed to any clients linking against the shared library. For the full
schema of description file, see system/tools/sysprop/sysprop.proto.

Bug: 80125326
Test: 1) write a .sysprop description file.
2) create cc_library_shared and add description file to srcs.
3) create another module, link against library of 2), include generated
header, and access generated sysprop functions
4) see compile succeeded.

Change-Id: I95005a0724aeb8f11a856b7aee92787a16a5374d
This commit is contained in:
Inseob Kim
2018-09-06 00:55:20 +09:00
parent 55e095b6d8
commit 21f26907cc
3 changed files with 51 additions and 1 deletions

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)
}
}