2015-03-18 21:28:46 +01: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 genrule
|
|
|
|
|
|
|
|
import (
|
2016-11-04 23:32:58 +01:00
|
|
|
"fmt"
|
2019-03-19 06:15:32 +01:00
|
|
|
"io"
|
2019-09-24 00:55:30 +02:00
|
|
|
"strconv"
|
2016-11-04 23:32:58 +01:00
|
|
|
"strings"
|
2016-09-29 01:19:10 +02:00
|
|
|
|
2015-03-23 20:57:34 +01:00
|
|
|
"github.com/google/blueprint"
|
2017-09-14 01:07:44 +02:00
|
|
|
"github.com/google/blueprint/bootstrap"
|
2017-11-09 06:20:04 +01:00
|
|
|
"github.com/google/blueprint/proptools"
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2017-03-30 02:29:06 +02:00
|
|
|
"android/soong/shared"
|
2020-02-14 00:55:10 +01:00
|
|
|
"crypto/sha256"
|
2017-03-30 02:29:06 +02:00
|
|
|
"path/filepath"
|
2015-03-18 21:28:46 +01:00
|
|
|
)
|
|
|
|
|
2015-06-17 23:20:06 +02:00
|
|
|
func init() {
|
2020-01-16 16:12:04 +01:00
|
|
|
registerGenruleBuildComponents(android.InitRegistrationContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
func registerGenruleBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("genrule_defaults", defaultsFactory)
|
|
|
|
|
|
|
|
ctx.RegisterModuleType("gensrcs", GenSrcsFactory)
|
|
|
|
ctx.RegisterModuleType("genrule", GenRuleFactory)
|
2018-12-10 17:13:18 +01:00
|
|
|
|
2020-01-16 16:12:04 +01:00
|
|
|
ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.BottomUp("genrule_tool_deps", toolDepsMutator).Parallel()
|
|
|
|
})
|
2015-06-17 23:20:06 +02:00
|
|
|
}
|
|
|
|
|
2015-03-18 21:28:46 +01:00
|
|
|
var (
|
2016-05-19 00:37:25 +02:00
|
|
|
pctx = android.NewPackageContext("android/soong/genrule")
|
2019-09-24 00:55:30 +02:00
|
|
|
|
|
|
|
gensrcsMerge = pctx.AndroidStaticRule("gensrcsMerge", blueprint.RuleParams{
|
|
|
|
Command: "${soongZip} -o ${tmpZip} @${tmpZip}.rsp && ${zipSync} -d ${genDir} ${tmpZip}",
|
|
|
|
CommandDeps: []string{"${soongZip}", "${zipSync}"},
|
|
|
|
Rspfile: "${tmpZip}.rsp",
|
|
|
|
RspfileContent: "${zipArgs}",
|
|
|
|
}, "tmpZip", "genDir", "zipArgs")
|
2015-03-18 21:28:46 +01:00
|
|
|
)
|
|
|
|
|
2017-03-30 02:29:06 +02:00
|
|
|
func init() {
|
Expose all deps on genrules
For remote builds, we actually need to know that we depend on all
outputs from a genrule, not just the first one. But having every user
depend on every genrule output increases the ninja file size by >40%.
So to work around the increase in file size, use a ninja phony rule to
produce a single alias to all of the files. Unlike make, where phony
rules are always dirty, ninja does not attempt to stat phony rules as
long as they have inputs, so they act as an alias. (If they don't have
inputs, it will stat the file an only consider it dirty if it doesn't
exist.)
My remote build tooling can then see that it's a phony rule with inputs,
and collapse all of these inputs onto the actual rule.
This only applies to genrules that have >6 outputs, in order to keep the
graph simpler and easier to read for the common case. That's ~10% of the
genrules in AOSP, and it increases the ninja file size by ~1.3%.
Test: manual ninja file inspection
Test: treehugger
Change-Id: I1a26a02fe983f0c92ce726ada3133707223e662e
2019-08-10 01:21:29 +02:00
|
|
|
pctx.Import("android/soong/android")
|
2017-03-30 02:29:06 +02:00
|
|
|
pctx.HostBinToolVariable("sboxCmd", "sbox")
|
2019-09-24 00:55:30 +02:00
|
|
|
|
|
|
|
pctx.HostBinToolVariable("soongZip", "soong_zip")
|
|
|
|
pctx.HostBinToolVariable("zipSync", "zipsync")
|
2017-03-30 02:29:06 +02:00
|
|
|
}
|
|
|
|
|
2015-03-18 21:28:46 +01:00
|
|
|
type SourceFileGenerator interface {
|
2016-05-19 00:37:25 +02:00
|
|
|
GeneratedSourceFiles() android.Paths
|
2016-11-22 21:55:55 +01:00
|
|
|
GeneratedHeaderDirs() android.Paths
|
2018-02-22 03:28:18 +01:00
|
|
|
GeneratedDeps() android.Paths
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
|
|
|
|
2019-03-29 03:30:56 +01:00
|
|
|
// Alias for android.HostToolProvider
|
|
|
|
// Deprecated: use android.HostToolProvider instead.
|
2015-04-28 22:25:36 +02:00
|
|
|
type HostToolProvider interface {
|
2019-03-29 03:30:56 +01:00
|
|
|
android.HostToolProvider
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2017-09-14 00:46:47 +02:00
|
|
|
type hostToolDependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
2018-10-05 08:29:14 +02:00
|
|
|
label string
|
2017-09-14 00:46:47 +02:00
|
|
|
}
|
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
type generatorProperties struct {
|
2017-03-30 02:29:06 +02:00
|
|
|
// The command to run on one or more input files. Cmd supports substitution of a few variables
|
|
|
|
//
|
|
|
|
// Available variables for substitution:
|
|
|
|
//
|
2017-10-18 06:38:14 +02:00
|
|
|
// $(location): the path to the first entry in tools or tool_files
|
2018-10-05 08:29:14 +02:00
|
|
|
// $(location <label>): the path to the tool, tool_file, input or output with name <label>
|
2017-10-18 06:38:14 +02:00
|
|
|
// $(in): one or more input files
|
|
|
|
// $(out): a single output file
|
|
|
|
// $(depfile): a file to which dependencies will be written, if the depfile property is set to true
|
|
|
|
// $(genDir): the sandbox directory for this tool; contains $(out)
|
|
|
|
// $$: a literal $
|
2017-11-09 06:20:04 +01:00
|
|
|
Cmd *string
|
2015-05-11 22:39:40 +02:00
|
|
|
|
2016-11-22 02:23:08 +01:00
|
|
|
// Enable reading a file containing dependencies in gcc format after the command completes
|
2017-11-09 06:20:04 +01:00
|
|
|
Depfile *bool
|
2016-11-22 02:23:08 +01:00
|
|
|
|
2016-11-04 23:32:58 +01:00
|
|
|
// name of the modules (if any) that produces the host executable. Leave empty for
|
2015-05-11 22:39:40 +02:00
|
|
|
// prebuilts or scripts that do not need a module to build them.
|
2016-11-04 23:32:58 +01:00
|
|
|
Tools []string
|
2016-04-20 23:54:32 +02:00
|
|
|
|
|
|
|
// Local file that is used as the tool
|
2019-03-05 07:35:41 +01:00
|
|
|
Tool_files []string `android:"path"`
|
2016-11-22 21:55:55 +01:00
|
|
|
|
|
|
|
// List of directories to export generated headers from
|
|
|
|
Export_include_dirs []string
|
2017-01-14 03:05:49 +01:00
|
|
|
|
|
|
|
// list of input files
|
2019-03-05 07:35:41 +01:00
|
|
|
Srcs []string `android:"path,arch_variant"`
|
2018-11-17 23:01:18 +01:00
|
|
|
|
|
|
|
// input files to exclude
|
2019-03-05 07:35:41 +01:00
|
|
|
Exclude_srcs []string `android:"path,arch_variant"`
|
2015-05-11 22:39:40 +02:00
|
|
|
}
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
type Module struct {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.ModuleBase
|
2018-12-10 17:13:18 +01:00
|
|
|
android.DefaultableModuleBase
|
2019-06-12 06:27:29 +02:00
|
|
|
android.ApexModuleBase
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
// For other packages to make their own genrules with extra
|
|
|
|
// properties
|
|
|
|
Extra interface{}
|
2019-11-19 01:00:16 +01:00
|
|
|
android.ImageInterface
|
2017-09-14 03:37:08 +02:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
properties generatorProperties
|
2015-04-28 22:25:36 +02:00
|
|
|
|
2017-11-08 21:38:00 +01:00
|
|
|
taskGenerator taskFunc
|
2015-04-28 22:25:36 +02:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
deps android.Paths
|
|
|
|
rule blueprint.Rule
|
|
|
|
rawCommands []string
|
2015-04-28 22:25:36 +02:00
|
|
|
|
2016-11-22 21:55:55 +01:00
|
|
|
exportedIncludeDirs android.Paths
|
2016-04-20 23:21:14 +02:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
outputFiles android.Paths
|
2018-02-22 03:28:18 +01:00
|
|
|
outputDeps android.Paths
|
2019-03-19 06:15:32 +01:00
|
|
|
|
|
|
|
subName string
|
2019-09-24 00:55:30 +02:00
|
|
|
subDir string
|
2020-05-21 04:11:59 +02:00
|
|
|
|
|
|
|
// Collect the module directory for IDE info in java/jdeps.go.
|
|
|
|
modulePaths []string
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
type taskFunc func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2015-04-28 22:25:36 +02:00
|
|
|
type generateTask struct {
|
2018-02-21 23:07:48 +01:00
|
|
|
in android.Paths
|
|
|
|
out android.WritablePaths
|
2019-09-24 00:55:30 +02:00
|
|
|
copyTo android.WritablePaths
|
|
|
|
genDir android.WritablePath
|
2018-02-21 23:07:48 +01:00
|
|
|
sandboxOuts []string
|
|
|
|
cmd string
|
2019-09-24 00:55:30 +02:00
|
|
|
shard int
|
|
|
|
shards int
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
func (g *Module) GeneratedSourceFiles() android.Paths {
|
2015-04-28 22:25:36 +02:00
|
|
|
return g.outputFiles
|
|
|
|
}
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
func (g *Module) Srcs() android.Paths {
|
2018-03-28 01:19:42 +02:00
|
|
|
return append(android.Paths{}, g.outputFiles...)
|
2016-12-14 00:23:47 +01:00
|
|
|
}
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
func (g *Module) GeneratedHeaderDirs() android.Paths {
|
2016-11-22 21:55:55 +01:00
|
|
|
return g.exportedIncludeDirs
|
2016-04-20 23:21:14 +02:00
|
|
|
}
|
|
|
|
|
2018-02-22 03:28:18 +01:00
|
|
|
func (g *Module) GeneratedDeps() android.Paths {
|
|
|
|
return g.outputDeps
|
|
|
|
}
|
|
|
|
|
2020-01-16 16:12:04 +01:00
|
|
|
func toolDepsMutator(ctx android.BottomUpMutatorContext) {
|
2017-09-14 03:37:08 +02:00
|
|
|
if g, ok := ctx.Module().(*Module); ok {
|
2018-10-05 08:29:14 +02:00
|
|
|
for _, tool := range g.properties.Tools {
|
|
|
|
tag := hostToolDependencyTag{label: tool}
|
|
|
|
if m := android.SrcIsModule(tool); m != "" {
|
|
|
|
tool = m
|
|
|
|
}
|
2019-10-16 20:03:10 +02:00
|
|
|
ctx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), tag, tool)
|
2015-10-29 23:25:03 +01:00
|
|
|
}
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2019-03-19 06:15:32 +01:00
|
|
|
g.subName = ctx.ModuleSubDir()
|
|
|
|
|
2020-05-21 04:11:59 +02:00
|
|
|
// Collect the module directory for IDE info in java/jdeps.go.
|
|
|
|
g.modulePaths = append(g.modulePaths, ctx.ModuleDir())
|
|
|
|
|
2016-11-22 21:55:55 +01:00
|
|
|
if len(g.properties.Export_include_dirs) > 0 {
|
|
|
|
for _, dir := range g.properties.Export_include_dirs {
|
|
|
|
g.exportedIncludeDirs = append(g.exportedIncludeDirs,
|
2019-09-24 00:55:30 +02:00
|
|
|
android.PathForModuleGen(ctx, g.subDir, ctx.ModuleDir(), dir))
|
2016-11-22 21:55:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2019-09-24 00:55:30 +02:00
|
|
|
g.exportedIncludeDirs = append(g.exportedIncludeDirs, android.PathForModuleGen(ctx, g.subDir))
|
2016-11-22 21:55:55 +01:00
|
|
|
}
|
2016-09-29 01:19:10 +02:00
|
|
|
|
2018-10-05 08:29:14 +02:00
|
|
|
locationLabels := map[string][]string{}
|
|
|
|
firstLabel := ""
|
|
|
|
|
|
|
|
addLocationLabel := func(label string, paths []string) {
|
|
|
|
if firstLabel == "" {
|
|
|
|
firstLabel = label
|
|
|
|
}
|
|
|
|
if _, exists := locationLabels[label]; !exists {
|
|
|
|
locationLabels[label] = paths
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("multiple labels for %q, %q and %q",
|
|
|
|
label, strings.Join(locationLabels[label], " "), strings.Join(paths, " "))
|
|
|
|
}
|
|
|
|
}
|
2016-09-29 01:19:10 +02:00
|
|
|
|
2016-11-04 23:32:58 +01:00
|
|
|
if len(g.properties.Tools) > 0 {
|
2019-03-18 20:12:48 +01:00
|
|
|
seenTools := make(map[string]bool)
|
|
|
|
|
2017-11-16 09:11:20 +01:00
|
|
|
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
2018-10-05 08:29:14 +02:00
|
|
|
switch tag := ctx.OtherModuleDependencyTag(module).(type) {
|
|
|
|
case hostToolDependencyTag:
|
2017-09-14 00:46:47 +02:00
|
|
|
tool := ctx.OtherModuleName(module)
|
2017-09-14 01:07:44 +02:00
|
|
|
var path android.OptionalPath
|
2017-09-14 00:46:47 +02:00
|
|
|
|
2019-03-29 03:30:56 +01:00
|
|
|
if t, ok := module.(android.HostToolProvider); ok {
|
2017-11-16 09:11:20 +01:00
|
|
|
if !t.(android.Module).Enabled() {
|
2017-11-29 09:27:14 +01:00
|
|
|
if ctx.Config().AllowMissingDependencies() {
|
2017-11-16 09:11:20 +01:00
|
|
|
ctx.AddMissingDependencies([]string{tool})
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("depends on disabled module %q", tool)
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
2017-09-14 01:07:44 +02:00
|
|
|
path = t.HostToolPath()
|
|
|
|
} else if t, ok := module.(bootstrap.GoBinaryTool); ok {
|
|
|
|
if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {
|
|
|
|
path = android.OptionalPathForPath(android.PathForOutput(ctx, s))
|
2016-11-04 23:32:58 +01:00
|
|
|
} else {
|
2017-09-14 01:07:44 +02:00
|
|
|
ctx.ModuleErrorf("cannot find path for %q: %v", tool, err)
|
|
|
|
break
|
2016-11-04 23:32:58 +01:00
|
|
|
}
|
2016-04-20 23:54:32 +02:00
|
|
|
} else {
|
2017-09-14 00:46:47 +02:00
|
|
|
ctx.ModuleErrorf("%q is not a host tool provider", tool)
|
2017-09-14 01:07:44 +02:00
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
if path.Valid() {
|
|
|
|
g.deps = append(g.deps, path.Path())
|
2018-10-05 08:29:14 +02:00
|
|
|
addLocationLabel(tag.label, []string{path.Path().String()})
|
2019-03-18 20:12:48 +01:00
|
|
|
seenTools[tag.label] = true
|
2017-09-14 01:07:44 +02:00
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("host tool %q missing output file", tool)
|
2016-04-20 23:54:32 +02:00
|
|
|
}
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
2016-04-20 23:54:32 +02:00
|
|
|
})
|
2019-03-18 20:12:48 +01:00
|
|
|
|
|
|
|
// If AllowMissingDependencies is enabled, the build will not have stopped when
|
|
|
|
// AddFarVariationDependencies was called on a missing tool, which will result in nonsensical
|
2020-07-28 20:32:07 +02:00
|
|
|
// "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.
|
2019-03-18 20:12:48 +01:00
|
|
|
if ctx.Config().AllowMissingDependencies() {
|
|
|
|
for _, tool := range g.properties.Tools {
|
|
|
|
if !seenTools[tool] {
|
|
|
|
addLocationLabel(tool, []string{"***missing tool " + tool + "***"})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-20 23:54:32 +02:00
|
|
|
}
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2017-09-14 00:46:47 +02:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-10-05 08:29:14 +02:00
|
|
|
for _, toolFile := range g.properties.Tool_files {
|
2019-03-06 07:25:09 +01:00
|
|
|
paths := android.PathsForModuleSrc(ctx, []string{toolFile})
|
2018-10-05 08:29:14 +02:00
|
|
|
g.deps = append(g.deps, paths...)
|
|
|
|
addLocationLabel(toolFile, paths.Strings())
|
2016-11-04 23:32:58 +01:00
|
|
|
}
|
|
|
|
|
2018-10-05 08:29:14 +02:00
|
|
|
var srcFiles android.Paths
|
|
|
|
for _, in := range g.properties.Srcs {
|
2019-03-18 20:12:48 +01:00
|
|
|
paths, missingDeps := android.PathsAndMissingDepsForModuleSrcExcludes(ctx, []string{in}, g.properties.Exclude_srcs)
|
|
|
|
if len(missingDeps) > 0 {
|
|
|
|
if !ctx.Config().AllowMissingDependencies() {
|
|
|
|
panic(fmt.Errorf("should never get here, the missing dependencies %q should have been reported in DepsMutator",
|
|
|
|
missingDeps))
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2020-07-28 20:32:07 +02:00
|
|
|
// "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.
|
2019-03-18 20:12:48 +01:00
|
|
|
ctx.AddMissingDependencies(missingDeps)
|
|
|
|
addLocationLabel(in, []string{"***missing srcs " + in + "***"})
|
|
|
|
} else {
|
|
|
|
srcFiles = append(srcFiles, paths...)
|
|
|
|
addLocationLabel(in, paths.Strings())
|
|
|
|
}
|
2018-10-05 08:29:14 +02:00
|
|
|
}
|
2017-10-27 23:59:27 +02:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
var copyFrom android.Paths
|
|
|
|
var outputFiles android.WritablePaths
|
|
|
|
var zipArgs strings.Builder
|
2018-10-05 08:29:14 +02:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
for _, task := range g.taskGenerator(ctx, String(g.properties.Cmd), srcFiles) {
|
|
|
|
for _, out := range task.out {
|
|
|
|
addLocationLabel(out.Rel(), []string{filepath.Join("__SBOX_OUT_DIR__", out.Rel())})
|
2018-07-09 18:45:06 +02:00
|
|
|
}
|
|
|
|
|
2020-02-14 00:55:10 +01:00
|
|
|
referencedIn := false
|
2019-09-24 00:55:30 +02:00
|
|
|
referencedDepfile := false
|
|
|
|
|
|
|
|
rawCommand, err := android.ExpandNinjaEscaped(task.cmd, func(name string) (string, bool, error) {
|
|
|
|
// report the error directly without returning an error to android.Expand to catch multiple errors in a
|
|
|
|
// single run
|
|
|
|
reportError := func(fmt string, args ...interface{}) (string, bool, error) {
|
|
|
|
ctx.PropertyErrorf("cmd", fmt, args...)
|
|
|
|
return "SOONG_ERROR", false, nil
|
2016-11-22 02:23:08 +01:00
|
|
|
}
|
2019-09-24 00:55:30 +02:00
|
|
|
|
|
|
|
switch name {
|
|
|
|
case "location":
|
|
|
|
if len(g.properties.Tools) == 0 && len(g.properties.Tool_files) == 0 {
|
|
|
|
return reportError("at least one `tools` or `tool_files` is required if $(location) is used")
|
|
|
|
}
|
|
|
|
paths := locationLabels[firstLabel]
|
|
|
|
if len(paths) == 0 {
|
|
|
|
return reportError("default label %q has no files", firstLabel)
|
|
|
|
} else if len(paths) > 1 {
|
|
|
|
return reportError("default label %q has multiple files, use $(locations %s) to reference it",
|
|
|
|
firstLabel, firstLabel)
|
|
|
|
}
|
|
|
|
return locationLabels[firstLabel][0], false, nil
|
|
|
|
case "in":
|
2020-02-14 00:55:10 +01:00
|
|
|
referencedIn = true
|
2019-09-24 00:55:30 +02:00
|
|
|
return "${in}", true, nil
|
|
|
|
case "out":
|
|
|
|
return "__SBOX_OUT_FILES__", false, nil
|
|
|
|
case "depfile":
|
|
|
|
referencedDepfile = true
|
|
|
|
if !Bool(g.properties.Depfile) {
|
|
|
|
return reportError("$(depfile) used without depfile property")
|
2016-11-04 23:32:58 +01:00
|
|
|
}
|
2019-09-24 00:55:30 +02:00
|
|
|
return "__SBOX_DEPFILE__", false, nil
|
|
|
|
case "genDir":
|
|
|
|
return "__SBOX_OUT_DIR__", false, nil
|
|
|
|
default:
|
|
|
|
if strings.HasPrefix(name, "location ") {
|
|
|
|
label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
|
|
|
|
if paths, ok := locationLabels[label]; ok {
|
|
|
|
if len(paths) == 0 {
|
|
|
|
return reportError("label %q has no files", label)
|
|
|
|
} else if len(paths) > 1 {
|
|
|
|
return reportError("label %q has multiple files, use $(locations %s) to reference it",
|
|
|
|
label, label)
|
|
|
|
}
|
|
|
|
return paths[0], false, nil
|
|
|
|
} else {
|
|
|
|
return reportError("unknown location label %q", label)
|
|
|
|
}
|
|
|
|
} else if strings.HasPrefix(name, "locations ") {
|
|
|
|
label := strings.TrimSpace(strings.TrimPrefix(name, "locations "))
|
|
|
|
if paths, ok := locationLabels[label]; ok {
|
|
|
|
if len(paths) == 0 {
|
|
|
|
return reportError("label %q has no files", label)
|
|
|
|
}
|
|
|
|
return strings.Join(paths, " "), false, nil
|
|
|
|
} else {
|
|
|
|
return reportError("unknown locations label %q", label)
|
2018-10-05 08:29:14 +02:00
|
|
|
}
|
|
|
|
} else {
|
2019-09-24 00:55:30 +02:00
|
|
|
return reportError("unknown variable '$(%s)'", name)
|
2018-10-05 08:29:14 +02:00
|
|
|
}
|
2016-11-04 23:32:58 +01:00
|
|
|
}
|
2019-09-24 00:55:30 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("cmd", "%s", err.Error())
|
|
|
|
return
|
2016-11-04 23:32:58 +01:00
|
|
|
}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
if Bool(g.properties.Depfile) && !referencedDepfile {
|
|
|
|
ctx.PropertyErrorf("cmd", "specified depfile=true but did not include a reference to '${depfile}' in cmd")
|
|
|
|
return
|
|
|
|
}
|
2016-11-04 23:32:58 +01:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
// tell the sbox command which directory to use as its sandbox root
|
|
|
|
buildDir := android.PathForOutput(ctx).String()
|
|
|
|
sandboxPath := shared.TempDirForOutDir(buildDir)
|
2018-07-09 18:45:06 +02:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
// recall that Sprintf replaces percent sign expressions, whereas dollar signs expressions remain as written,
|
|
|
|
// to be replaced later by ninja_strings.go
|
|
|
|
depfilePlaceholder := ""
|
|
|
|
if Bool(g.properties.Depfile) {
|
|
|
|
depfilePlaceholder = "$depfileArgs"
|
|
|
|
}
|
2017-03-30 02:29:06 +02:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
// Escape the command for the shell
|
|
|
|
rawCommand = "'" + strings.Replace(rawCommand, "'", `'\''`, -1) + "'"
|
|
|
|
g.rawCommands = append(g.rawCommands, rawCommand)
|
2020-02-14 00:55:10 +01:00
|
|
|
|
|
|
|
sandboxCommand := fmt.Sprintf("rm -rf %s && $sboxCmd --sandbox-path %s --output-root %s",
|
|
|
|
task.genDir, sandboxPath, task.genDir)
|
|
|
|
|
|
|
|
if !referencedIn {
|
|
|
|
sandboxCommand = sandboxCommand + hashSrcFiles(srcFiles)
|
|
|
|
}
|
|
|
|
|
|
|
|
sandboxCommand = sandboxCommand + fmt.Sprintf(" -c %s %s $allouts",
|
|
|
|
rawCommand, depfilePlaceholder)
|
2019-09-24 00:55:30 +02:00
|
|
|
|
|
|
|
ruleParams := blueprint.RuleParams{
|
|
|
|
Command: sandboxCommand,
|
|
|
|
CommandDeps: []string{"$sboxCmd"},
|
|
|
|
}
|
|
|
|
args := []string{"allouts"}
|
|
|
|
if Bool(g.properties.Depfile) {
|
|
|
|
ruleParams.Deps = blueprint.DepsGCC
|
|
|
|
args = append(args, "depfileArgs")
|
|
|
|
}
|
|
|
|
name := "generator"
|
|
|
|
if task.shards > 1 {
|
|
|
|
name += strconv.Itoa(task.shard)
|
|
|
|
}
|
|
|
|
rule := ctx.Rule(pctx, name, ruleParams, args...)
|
2017-11-06 23:15:16 +01:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
g.generateSourceFile(ctx, task, rule)
|
2017-03-30 02:29:06 +02:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
if len(task.copyTo) > 0 {
|
|
|
|
outputFiles = append(outputFiles, task.copyTo...)
|
|
|
|
copyFrom = append(copyFrom, task.out.Paths()...)
|
|
|
|
zipArgs.WriteString(" -C " + task.genDir.String())
|
|
|
|
zipArgs.WriteString(android.JoinWithPrefix(task.out.Strings(), " -f "))
|
|
|
|
} else {
|
|
|
|
outputFiles = append(outputFiles, task.out...)
|
|
|
|
}
|
2016-11-22 02:23:08 +01:00
|
|
|
}
|
2019-09-24 00:55:30 +02:00
|
|
|
|
|
|
|
if len(copyFrom) > 0 {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: gensrcsMerge,
|
|
|
|
Implicits: copyFrom,
|
|
|
|
Outputs: outputFiles,
|
|
|
|
Args: map[string]string{
|
|
|
|
"zipArgs": zipArgs.String(),
|
|
|
|
"tmpZip": android.PathForModuleGen(ctx, g.subDir+".zip").String(),
|
|
|
|
"genDir": android.PathForModuleGen(ctx, g.subDir).String(),
|
|
|
|
},
|
|
|
|
})
|
2016-11-22 02:23:08 +01:00
|
|
|
}
|
2016-11-04 23:32:58 +01:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
g.outputFiles = outputFiles.Paths()
|
|
|
|
|
|
|
|
// For <= 6 outputs, just embed those directly in the users. Right now, that covers >90% of
|
|
|
|
// the genrules on AOSP. That will make things simpler to look at the graph in the common
|
|
|
|
// case. For larger sets of outputs, inject a phony target in between to limit ninja file
|
|
|
|
// growth.
|
|
|
|
if len(g.outputFiles) <= 6 {
|
|
|
|
g.outputDeps = g.outputFiles
|
|
|
|
} else {
|
|
|
|
phonyFile := android.PathForModuleGen(ctx, "genrule-phony")
|
|
|
|
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Output: phonyFile,
|
|
|
|
Inputs: g.outputFiles,
|
|
|
|
})
|
|
|
|
|
|
|
|
g.outputDeps = android.Paths{phonyFile}
|
|
|
|
}
|
2017-11-08 21:38:00 +01:00
|
|
|
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
|
|
|
|
2020-02-14 00:55:10 +01:00
|
|
|
func hashSrcFiles(srcFiles android.Paths) string {
|
|
|
|
h := sha256.New()
|
|
|
|
for _, src := range srcFiles {
|
|
|
|
h.Write([]byte(src.String()))
|
|
|
|
}
|
|
|
|
return fmt.Sprintf(" --input-hash %x", h.Sum(nil))
|
|
|
|
}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
func (g *Module) generateSourceFile(ctx android.ModuleContext, task generateTask, rule blueprint.Rule) {
|
2017-05-09 22:45:28 +02:00
|
|
|
desc := "generate"
|
2017-10-21 00:07:08 +02:00
|
|
|
if len(task.out) == 0 {
|
|
|
|
ctx.ModuleErrorf("must have at least one output file")
|
|
|
|
return
|
|
|
|
}
|
2017-05-09 22:45:28 +02:00
|
|
|
if len(task.out) == 1 {
|
|
|
|
desc += " " + task.out[0].Base()
|
|
|
|
}
|
|
|
|
|
2017-10-27 23:59:27 +02:00
|
|
|
var depFile android.ModuleGenPath
|
2017-11-09 06:20:04 +01:00
|
|
|
if Bool(g.properties.Depfile) {
|
2017-10-27 23:59:27 +02:00
|
|
|
depFile = android.PathForModuleGen(ctx, task.out[0].Rel()+".d")
|
|
|
|
}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
if task.shards > 1 {
|
|
|
|
desc += " " + strconv.Itoa(task.shard)
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
params := android.BuildParams{
|
2019-09-24 00:55:30 +02:00
|
|
|
Rule: rule,
|
|
|
|
Description: desc,
|
2017-10-21 00:07:08 +02:00
|
|
|
Output: task.out[0],
|
|
|
|
ImplicitOutputs: task.out[1:],
|
|
|
|
Inputs: task.in,
|
|
|
|
Implicits: g.deps,
|
|
|
|
Args: map[string]string{
|
2018-02-21 23:07:48 +01:00
|
|
|
"allouts": strings.Join(task.sandboxOuts, " "),
|
2017-10-21 00:07:08 +02:00
|
|
|
},
|
2016-11-22 02:23:08 +01:00
|
|
|
}
|
2017-11-09 06:20:04 +01:00
|
|
|
if Bool(g.properties.Depfile) {
|
2017-10-27 23:59:27 +02:00
|
|
|
params.Depfile = android.PathForModuleGen(ctx, task.out[0].Rel()+".d")
|
|
|
|
params.Args["depfileArgs"] = "--depfile-out " + depFile.String()
|
2016-11-22 02:23:08 +01:00
|
|
|
}
|
2017-10-27 23:59:27 +02:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, params)
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
|
|
|
|
2018-08-16 00:35:38 +02:00
|
|
|
// Collect information for opening IDE project files in java/jdeps.go.
|
|
|
|
func (g *Module) IDEInfo(dpInfo *android.IdeInfo) {
|
|
|
|
dpInfo.Srcs = append(dpInfo.Srcs, g.Srcs().Strings()...)
|
|
|
|
for _, src := range g.properties.Srcs {
|
|
|
|
if strings.HasPrefix(src, ":") {
|
|
|
|
src = strings.Trim(src, ":")
|
|
|
|
dpInfo.Deps = append(dpInfo.Deps, src)
|
|
|
|
}
|
|
|
|
}
|
2020-05-21 04:11:59 +02:00
|
|
|
dpInfo.Paths = append(dpInfo.Paths, g.modulePaths...)
|
2018-08-16 00:35:38 +02:00
|
|
|
}
|
|
|
|
|
2019-03-19 06:15:32 +01:00
|
|
|
func (g *Module) AndroidMk() android.AndroidMkData {
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Include: "$(BUILD_PHONY_PACKAGE)",
|
|
|
|
Class: "FAKE",
|
|
|
|
OutputFile: android.OptionalPathForPath(g.outputFiles[0]),
|
|
|
|
SubName: g.subName,
|
|
|
|
Extra: []android.AndroidMkExtraFunc{
|
|
|
|
func(w io.Writer, outputFile android.Path) {
|
2019-09-24 00:55:30 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES :=", strings.Join(g.outputDeps.Strings(), " "))
|
2019-03-19 06:15:32 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
|
|
|
android.WriteAndroidMkData(w, data)
|
|
|
|
if data.SubName != "" {
|
|
|
|
fmt.Fprintln(w, ".PHONY:", name)
|
|
|
|
fmt.Fprintln(w, name, ":", name+g.subName)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-15 04:03:39 +02:00
|
|
|
func (g *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error {
|
|
|
|
// Because generated outputs are checked by client modules(e.g. cc_library, ...)
|
|
|
|
// we can safely ignore the check here.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-11-08 21:38:00 +01:00
|
|
|
func generatorFactory(taskGenerator taskFunc, props ...interface{}) *Module {
|
2017-09-14 03:37:08 +02:00
|
|
|
module := &Module{
|
2017-11-08 21:38:00 +01:00
|
|
|
taskGenerator: taskGenerator,
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
2015-04-28 22:25:36 +02:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
module.AddProperties(props...)
|
|
|
|
module.AddProperties(&module.properties)
|
2015-04-28 22:25:36 +02:00
|
|
|
|
2019-11-19 01:00:16 +01:00
|
|
|
module.ImageInterface = noopImageInterface{}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
return module
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
|
|
|
|
2019-11-19 01:00:16 +01:00
|
|
|
type noopImageInterface struct{}
|
|
|
|
|
|
|
|
func (x noopImageInterface) ImageMutatorBegin(android.BaseModuleContext) {}
|
|
|
|
func (x noopImageInterface) CoreVariantNeeded(android.BaseModuleContext) bool { return false }
|
2020-01-22 00:53:22 +01:00
|
|
|
func (x noopImageInterface) RamdiskVariantNeeded(android.BaseModuleContext) bool { return false }
|
2019-11-19 01:00:16 +01:00
|
|
|
func (x noopImageInterface) RecoveryVariantNeeded(android.BaseModuleContext) bool { return false }
|
|
|
|
func (x noopImageInterface) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil }
|
|
|
|
func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
|
|
|
|
}
|
|
|
|
|
2018-02-21 23:07:48 +01:00
|
|
|
// replace "out" with "__SBOX_OUT_DIR__/<the value of ${out}>"
|
|
|
|
func pathToSandboxOut(path android.Path, genDir android.Path) string {
|
|
|
|
relOut, err := filepath.Rel(genDir.String(), path.String())
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Could not make ${out} relative: %v", err))
|
|
|
|
}
|
|
|
|
return filepath.Join("__SBOX_OUT_DIR__", relOut)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
func NewGenSrcs() *Module {
|
2015-04-28 22:25:36 +02:00
|
|
|
properties := &genSrcsProperties{}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
taskGenerator := func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask {
|
|
|
|
genDir := android.PathForModuleGen(ctx, "gensrcs")
|
|
|
|
shardSize := defaultShardSize
|
|
|
|
if s := properties.Shard_size; s != nil {
|
|
|
|
shardSize = int(*s)
|
|
|
|
}
|
|
|
|
|
|
|
|
shards := android.ShardPaths(srcFiles, shardSize)
|
|
|
|
var generateTasks []generateTask
|
|
|
|
|
|
|
|
for i, shard := range shards {
|
|
|
|
var commands []string
|
|
|
|
var outFiles android.WritablePaths
|
|
|
|
var copyTo android.WritablePaths
|
|
|
|
var shardDir android.WritablePath
|
|
|
|
var sandboxOuts []string
|
|
|
|
|
|
|
|
if len(shards) > 1 {
|
|
|
|
shardDir = android.PathForModuleGen(ctx, strconv.Itoa(i))
|
|
|
|
} else {
|
|
|
|
shardDir = genDir
|
2017-11-08 21:38:00 +01:00
|
|
|
}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
for _, in := range shard {
|
|
|
|
outFile := android.GenPathWithExt(ctx, "gensrcs", in, String(properties.Output_extension))
|
|
|
|
sandboxOutfile := pathToSandboxOut(outFile, genDir)
|
2017-11-08 21:38:00 +01:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
if len(shards) > 1 {
|
|
|
|
shardFile := android.GenPathWithExt(ctx, strconv.Itoa(i), in, String(properties.Output_extension))
|
|
|
|
copyTo = append(copyTo, outFile)
|
|
|
|
outFile = shardFile
|
|
|
|
}
|
|
|
|
|
|
|
|
outFiles = append(outFiles, outFile)
|
|
|
|
sandboxOuts = append(sandboxOuts, sandboxOutfile)
|
|
|
|
|
|
|
|
command, err := android.Expand(rawCommand, func(name string) (string, error) {
|
|
|
|
switch name {
|
|
|
|
case "in":
|
|
|
|
return in.String(), nil
|
|
|
|
case "out":
|
|
|
|
return sandboxOutfile, nil
|
|
|
|
default:
|
|
|
|
return "$(" + name + ")", nil
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("cmd", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// escape the command in case for example it contains '#', an odd number of '"', etc
|
|
|
|
command = fmt.Sprintf("bash -c %v", proptools.ShellEscape(command))
|
|
|
|
commands = append(commands, command)
|
|
|
|
}
|
|
|
|
fullCommand := strings.Join(commands, " && ")
|
|
|
|
|
|
|
|
generateTasks = append(generateTasks, generateTask{
|
|
|
|
in: shard,
|
|
|
|
out: outFiles,
|
|
|
|
copyTo: copyTo,
|
|
|
|
genDir: shardDir,
|
|
|
|
sandboxOuts: sandboxOuts,
|
|
|
|
cmd: fullCommand,
|
|
|
|
shard: i,
|
|
|
|
shards: len(shards),
|
|
|
|
})
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
2019-09-24 00:55:30 +02:00
|
|
|
|
|
|
|
return generateTasks
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
g := generatorFactory(taskGenerator, properties)
|
|
|
|
g.subDir = "gensrcs"
|
|
|
|
return g
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
|
|
|
|
2017-10-10 00:34:10 +02:00
|
|
|
func GenSrcsFactory() android.Module {
|
2017-09-14 03:37:08 +02:00
|
|
|
m := NewGenSrcs()
|
|
|
|
android.InitAndroidModule(m)
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2015-04-28 22:25:36 +02:00
|
|
|
type genSrcsProperties struct {
|
2015-05-11 22:39:40 +02:00
|
|
|
// extension that will be substituted for each output file
|
2017-11-10 07:42:32 +01:00
|
|
|
Output_extension *string
|
2019-09-24 00:55:30 +02:00
|
|
|
|
|
|
|
// maximum number of files that will be passed on a single command line.
|
|
|
|
Shard_size *int64
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
const defaultShardSize = 100
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
func NewGenRule() *Module {
|
2015-04-28 22:25:36 +02:00
|
|
|
properties := &genRuleProperties{}
|
|
|
|
|
2019-09-24 00:55:30 +02:00
|
|
|
taskGenerator := func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask {
|
2016-09-29 01:21:00 +02:00
|
|
|
outs := make(android.WritablePaths, len(properties.Out))
|
2018-02-21 23:07:48 +01:00
|
|
|
sandboxOuts := make([]string, len(properties.Out))
|
|
|
|
genDir := android.PathForModuleGen(ctx)
|
2016-09-29 01:21:00 +02:00
|
|
|
for i, out := range properties.Out {
|
|
|
|
outs[i] = android.PathForModuleGen(ctx, out)
|
2018-02-21 23:07:48 +01:00
|
|
|
sandboxOuts[i] = pathToSandboxOut(outs[i], genDir)
|
2016-09-29 01:21:00 +02:00
|
|
|
}
|
2019-09-24 00:55:30 +02:00
|
|
|
return []generateTask{{
|
2018-02-21 23:07:48 +01:00
|
|
|
in: srcFiles,
|
|
|
|
out: outs,
|
2019-09-24 00:55:30 +02:00
|
|
|
genDir: android.PathForModuleGen(ctx),
|
2018-02-21 23:07:48 +01:00
|
|
|
sandboxOuts: sandboxOuts,
|
|
|
|
cmd: rawCommand,
|
2019-09-24 00:55:30 +02:00
|
|
|
}}
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
|
|
|
|
2017-11-08 21:38:00 +01:00
|
|
|
return generatorFactory(taskGenerator, properties)
|
2015-04-28 22:25:36 +02:00
|
|
|
}
|
|
|
|
|
2017-10-10 00:34:10 +02:00
|
|
|
func GenRuleFactory() android.Module {
|
2017-09-14 03:37:08 +02:00
|
|
|
m := NewGenRule()
|
|
|
|
android.InitAndroidModule(m)
|
2018-12-10 17:13:18 +01:00
|
|
|
android.InitDefaultableModule(m)
|
2017-09-14 03:37:08 +02:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2015-04-28 22:25:36 +02:00
|
|
|
type genRuleProperties struct {
|
2016-09-29 01:21:00 +02:00
|
|
|
// names of the output files that will be generated
|
2018-10-23 20:27:50 +02:00
|
|
|
Out []string `android:"arch_variant"`
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
2017-11-09 06:20:04 +01:00
|
|
|
|
|
|
|
var Bool = proptools.Bool
|
|
|
|
var String = proptools.String
|
2018-12-10 17:13:18 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Defaults
|
|
|
|
//
|
|
|
|
type Defaults struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultsModuleBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultsFactory() android.Module {
|
|
|
|
return DefaultsFactory()
|
|
|
|
}
|
|
|
|
|
|
|
|
func DefaultsFactory(props ...interface{}) android.Module {
|
|
|
|
module := &Defaults{}
|
|
|
|
|
|
|
|
module.AddProperties(props...)
|
|
|
|
module.AddProperties(
|
|
|
|
&generatorProperties{},
|
|
|
|
&genRuleProperties{},
|
|
|
|
)
|
|
|
|
|
|
|
|
android.InitDefaultsModule(module)
|
|
|
|
|
|
|
|
return module
|
|
|
|
}
|