2015-04-08 22:03:43 +02:00
|
|
|
// 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 java
|
|
|
|
|
|
|
|
// This file generates the final rules for compiling all C/C++. All properties related to
|
|
|
|
// compiling should have been translated into builderFlags or another argument to the Transform*
|
|
|
|
// functions.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/google/blueprint"
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2015-04-08 22:03:43 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2015-09-24 00:26:20 +02:00
|
|
|
pctx.HostBinToolVariable("aidlCmd", "aidl")
|
|
|
|
pctx.SourcePathVariable("logtagsCmd", "build/tools/java-event-log-tags.py")
|
|
|
|
pctx.SourcePathVariable("mergeLogtagsCmd", "build/tools/merge-event-log-tags.py")
|
2015-04-11 02:45:20 +02:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
pctx.IntermediatesPathVariable("allLogtagsFile", "all-event-log-tags.txt")
|
2015-04-08 22:03:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2016-08-30 01:14:13 +02:00
|
|
|
aidl = pctx.AndroidStaticRule("aidl",
|
2015-04-08 22:03:43 +02:00
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "$aidlCmd -d$depFile $aidlFlags $in $out",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$aidlCmd"},
|
2015-04-08 22:03:43 +02:00
|
|
|
},
|
|
|
|
"depFile", "aidlFlags")
|
2015-04-11 02:45:20 +02:00
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
logtags = pctx.AndroidStaticRule("logtags",
|
2015-04-11 02:45:20 +02:00
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "$logtagsCmd -o $out $in $allLogtagsFile",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$logtagsCmd"},
|
2015-04-11 02:45:20 +02:00
|
|
|
})
|
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
mergeLogtags = pctx.AndroidStaticRule("mergeLogtags",
|
2015-04-11 02:45:20 +02:00
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "$mergeLogtagsCmd -o $out $in",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$mergeLogtagsCmd"},
|
2015-04-11 02:45:20 +02:00
|
|
|
})
|
2015-04-08 22:03:43 +02:00
|
|
|
)
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string) android.Path {
|
2016-11-03 04:43:13 +01:00
|
|
|
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
|
2015-09-24 00:26:20 +02:00
|
|
|
depFile := javaFile.String() + ".d"
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: aidl,
|
|
|
|
Description: "aidl " + aidlFile.Rel(),
|
|
|
|
Output: javaFile,
|
|
|
|
Input: aidlFile,
|
2015-04-08 22:03:43 +02:00
|
|
|
Args: map[string]string{
|
|
|
|
"depFile": depFile,
|
|
|
|
"aidlFlags": aidlFlags,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
return javaFile
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Path {
|
2016-11-03 04:43:13 +01:00
|
|
|
javaFile := android.GenPathWithExt(ctx, "logtags", logtagsFile, "java")
|
2015-04-11 02:45:20 +02:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: logtags,
|
|
|
|
Description: "logtags " + logtagsFile.Rel(),
|
|
|
|
Output: javaFile,
|
|
|
|
Input: logtagsFile,
|
2015-04-11 02:45:20 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return javaFile
|
|
|
|
}
|
|
|
|
|
2017-06-23 01:51:17 +02:00
|
|
|
func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
2017-09-20 21:59:05 +02:00
|
|
|
flags javaBuilderFlags) (android.Paths, android.Paths) {
|
2015-04-08 22:03:43 +02:00
|
|
|
|
2017-09-20 21:59:05 +02:00
|
|
|
var protoFiles android.Paths
|
|
|
|
outSrcFiles := make(android.Paths, 0, len(srcFiles))
|
|
|
|
|
|
|
|
for _, srcFile := range srcFiles {
|
2015-09-24 00:26:20 +02:00
|
|
|
switch srcFile.Ext() {
|
2015-04-08 22:03:43 +02:00
|
|
|
case ".aidl":
|
|
|
|
javaFile := genAidl(ctx, srcFile, flags.aidlFlags)
|
2017-09-20 21:59:05 +02:00
|
|
|
outSrcFiles = append(outSrcFiles, javaFile)
|
2015-04-11 02:45:20 +02:00
|
|
|
case ".logtags":
|
|
|
|
j.logtagsSrcs = append(j.logtagsSrcs, srcFile)
|
|
|
|
javaFile := genLogtags(ctx, srcFile)
|
2017-09-20 21:59:05 +02:00
|
|
|
outSrcFiles = append(outSrcFiles, javaFile)
|
|
|
|
case ".proto":
|
|
|
|
protoFiles = append(protoFiles, srcFile)
|
|
|
|
default:
|
|
|
|
outSrcFiles = append(outSrcFiles, srcFile)
|
2015-04-08 22:03:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-20 21:59:05 +02:00
|
|
|
var outSrcFileLists android.Paths
|
|
|
|
|
|
|
|
if len(protoFiles) > 0 {
|
|
|
|
protoFileList := genProto(ctx, protoFiles,
|
|
|
|
flags.protoFlags, flags.protoOutFlag, "")
|
|
|
|
|
|
|
|
outSrcFileLists = append(outSrcFileLists, protoFileList)
|
|
|
|
}
|
|
|
|
|
|
|
|
return outSrcFiles, outSrcFileLists
|
2015-04-08 22:03:43 +02:00
|
|
|
}
|
2015-04-11 02:45:20 +02:00
|
|
|
|
|
|
|
func LogtagsSingleton() blueprint.Singleton {
|
|
|
|
return &logtagsSingleton{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type logtagsProducer interface {
|
2016-05-19 00:37:25 +02:00
|
|
|
logtags() android.Paths
|
2015-04-11 02:45:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type logtagsSingleton struct{}
|
|
|
|
|
|
|
|
func (l *logtagsSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
2016-05-19 00:37:25 +02:00
|
|
|
var allLogtags android.Paths
|
2015-04-11 02:45:20 +02:00
|
|
|
ctx.VisitAllModules(func(module blueprint.Module) {
|
|
|
|
if logtags, ok := module.(logtagsProducer); ok {
|
|
|
|
allLogtags = append(allLogtags, logtags.logtags()...)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: mergeLogtags,
|
|
|
|
Description: "merge logtags",
|
|
|
|
Outputs: []string{"$allLogtagsFile"},
|
|
|
|
Inputs: allLogtags.Strings(),
|
2015-04-11 02:45:20 +02:00
|
|
|
})
|
|
|
|
}
|