Add support for sysprop description files to Java
From now on, a java shared library can be built only with adding ".sysprop" description file to srcs. Sysprop library generator will automatically generate a .java file, and soong will wrap it into .srcjar file which will finally be contained in the java library. For the schema of description file, see system/tools/sysprop/sysprop.proto. Bug: 80125326 Test: 1) write a .sysprop description file. 2) create java_library and add description file to srcs. 3) create a test app, link against library of 2), and call generated sysprop methods. 4) see compile succeeded. Change-Id: I3ff87bc0a20f5a1aa126ef6d0f4d874a2ff4af8d
This commit is contained in:
28
java/gen.go
28
java/gen.go
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
func init() {
|
||||
pctx.HostBinToolVariable("aidlCmd", "aidl")
|
||||
pctx.HostBinToolVariable("syspropCmd", "sysprop_java")
|
||||
pctx.SourcePathVariable("logtagsCmd", "build/tools/java-event-log-tags.py")
|
||||
pctx.SourcePathVariable("mergeLogtagsCmd", "build/tools/merge-event-log-tags.py")
|
||||
}
|
||||
@@ -49,6 +50,17 @@ var (
|
||||
Command: "$mergeLogtagsCmd -o $out $in",
|
||||
CommandDeps: []string{"$mergeLogtagsCmd"},
|
||||
})
|
||||
|
||||
sysprop = pctx.AndroidStaticRule("sysprop",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf $out.tmp && mkdir -p $out.tmp && ` +
|
||||
`$syspropCmd --java-output-dir $out.tmp $in && ` +
|
||||
`${config.SoongZipCmd} -jar -o $out -C $out.tmp -D $out.tmp && rm -rf $out.tmp`,
|
||||
CommandDeps: []string{
|
||||
"$syspropCmd",
|
||||
"${config.SoongZipCmd}",
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string) android.Path {
|
||||
@@ -82,6 +94,19 @@ func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Pat
|
||||
return javaFile
|
||||
}
|
||||
|
||||
func genSysprop(ctx android.ModuleContext, syspropFile android.Path) android.Path {
|
||||
srcJarFile := android.GenPathWithExt(ctx, "sysprop", syspropFile, "srcjar")
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: sysprop,
|
||||
Description: "sysprop_java " + syspropFile.Rel(),
|
||||
Output: srcJarFile,
|
||||
Input: syspropFile,
|
||||
})
|
||||
|
||||
return srcJarFile
|
||||
}
|
||||
|
||||
func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
flags javaBuilderFlags) android.Paths {
|
||||
|
||||
@@ -99,6 +124,9 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
case ".proto":
|
||||
srcJarFile := genProto(ctx, srcFile, flags)
|
||||
outSrcFiles = append(outSrcFiles, srcJarFile)
|
||||
case ".sysprop":
|
||||
srcJarFile := genSysprop(ctx, srcFile)
|
||||
outSrcFiles = append(outSrcFiles, srcJarFile)
|
||||
default:
|
||||
outSrcFiles = append(outSrcFiles, srcFile)
|
||||
}
|
||||
|
Reference in New Issue
Block a user