2015-01-23 23:15:10 +01:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2014-05-28 01:34:41 +02:00
|
|
|
package blueprint
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-12-11 23:39:10 +01:00
|
|
|
|
2017-02-01 22:21:35 +01:00
|
|
|
"github.com/google/blueprint/pathtools"
|
2014-05-28 01:34:41 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Singleton interface {
|
|
|
|
GenerateBuildActions(SingletonContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
type SingletonContext interface {
|
2019-05-20 23:51:55 +02:00
|
|
|
// Config returns the config object that was passed to Context.PrepareBuildActions.
|
2014-06-12 03:31:16 +02:00
|
|
|
Config() interface{}
|
2014-05-28 01:34:41 +02:00
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// Name returns the name of the current singleton passed to Context.RegisterSingletonType
|
2019-02-26 03:07:44 +01:00
|
|
|
Name() string
|
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// ModuleName returns the name of the given Module. See BaseModuleContext.ModuleName for more information.
|
2014-05-28 01:34:41 +02:00
|
|
|
ModuleName(module Module) string
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// ModuleDir returns the directory of the given Module. See BaseModuleContext.ModuleDir for more information.
|
2014-05-28 01:34:41 +02:00
|
|
|
ModuleDir(module Module) string
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// ModuleSubDir returns the unique subdirectory name of the given Module. See ModuleContext.ModuleSubDir for
|
|
|
|
// more information.
|
2015-12-18 03:02:11 +01:00
|
|
|
ModuleSubDir(module Module) string
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// ModuleType returns the type of the given Module. See BaseModuleContext.ModuleType for more information.
|
2016-07-26 00:51:50 +02:00
|
|
|
ModuleType(module Module) string
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// BlueprintFile returns the path of the Blueprint file that defined the given module.
|
2014-05-28 01:34:41 +02:00
|
|
|
BlueprintFile(module Module) string
|
|
|
|
|
2020-07-02 19:08:12 +02:00
|
|
|
// ModuleProvider returns the value, if any, for the provider for a module. If the value for the
|
|
|
|
// provider was not set it returns the zero value of the type of the provider, which means the
|
|
|
|
// return value can always be type-asserted to the type of the provider. The return value should
|
|
|
|
// always be considered read-only. It panics if called before the appropriate mutator or
|
|
|
|
// GenerateBuildActions pass for the provider on the module.
|
|
|
|
ModuleProvider(module Module, provider ProviderKey) interface{}
|
|
|
|
|
|
|
|
// ModuleHasProvider returns true if the provider for the given module has been set.
|
|
|
|
ModuleHasProvider(m Module, provider ProviderKey) bool
|
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// ModuleErrorf reports an error at the line number of the module type in the module definition.
|
2014-05-28 01:34:41 +02:00
|
|
|
ModuleErrorf(module Module, format string, args ...interface{})
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// Errorf reports an error at the specified position of the module definition file.
|
2014-05-28 01:34:41 +02:00
|
|
|
Errorf(format string, args ...interface{})
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// Failed returns true if any errors have been reported. In most cases the singleton can continue with generating
|
|
|
|
// build rules after an error, allowing it to report additional errors in a single run, but in cases where the error
|
|
|
|
// has prevented the singleton from creating necessary data it can return early when Failed returns true.
|
2015-12-10 03:06:23 +01:00
|
|
|
Failed() bool
|
2014-05-28 01:34:41 +02:00
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// Variable creates a new ninja variable scoped to the singleton. It can be referenced by calls to Rule and Build
|
|
|
|
// in the same singleton.
|
2015-11-26 00:29:32 +01:00
|
|
|
Variable(pctx PackageContext, name, value string)
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// Rule creates a new ninja rule scoped to the singleton. It can be referenced by calls to Build in the same
|
|
|
|
// singleton.
|
2015-11-26 00:29:32 +01:00
|
|
|
Rule(pctx PackageContext, name string, params RuleParams, argNames ...string) Rule
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// Build creates a new ninja build statement.
|
2015-11-26 00:29:32 +01:00
|
|
|
Build(pctx PackageContext, params BuildParams)
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// RequireNinjaVersion sets the generated ninja manifest to require at least the specified version of ninja.
|
2014-05-28 01:34:41 +02:00
|
|
|
RequireNinjaVersion(major, minor, micro int)
|
|
|
|
|
2021-08-26 15:08:09 +02:00
|
|
|
// SetOutDir sets the value of the top-level "builddir" Ninja variable
|
2014-05-28 01:34:41 +02:00
|
|
|
// that controls where Ninja stores its build log files. This value can be
|
2015-11-19 01:01:01 +01:00
|
|
|
// set at most one time for a single build, later calls are ignored.
|
2021-08-26 15:08:09 +02:00
|
|
|
SetOutDir(pctx PackageContext, value string)
|
2014-05-28 01:34:41 +02:00
|
|
|
|
Run globs during earlier bootstrap phases
Instead of sometimes re-running minibp/the primary builder during the
next phase, run bpglob earlier to check dependencies.
We've run into issues where the environment is slightly different
between bootstrapping phase and the main build phase. It's also a
problem because our primary builder (Soong) exports information used by
another tool (Kati) that runs in between the bootstrapping phases and
the main phase. When Soong would run in the main phase, it could get out
of sync, and would require the build to be run again.
To do this, add a "subninja" include a build-globs.ninja file to each
build.ninja file. The first time, this will be an empty file, but we'll
always run minibp / the primary builder anyway. When the builder runs,
in addition to writing a dependency file, write out the
build-globs.ninja file with the rules to run bpglob.
Since bpglob may need to be run very early, before it would normally be
built, build it with microfactory.
Change-Id: I89fcd849a8729e892f163d40060ab90b5d4dfa5d
2018-07-06 06:56:59 +02:00
|
|
|
// AddSubninja adds a ninja file to include with subninja. This should likely
|
|
|
|
// only ever be used inside bootstrap to handle glob rules.
|
|
|
|
AddSubninja(file string)
|
|
|
|
|
2016-01-15 00:42:54 +01:00
|
|
|
// Eval takes a string with embedded ninja variables, and returns a string
|
|
|
|
// with all of the variables recursively expanded. Any variables references
|
|
|
|
// are expanded in the scope of the PackageContext.
|
|
|
|
Eval(pctx PackageContext, ninjaStr string) (string, error)
|
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// VisitAllModules calls visit for each defined variant of each module in an unspecified order.
|
2014-05-28 01:34:41 +02:00
|
|
|
VisitAllModules(visit func(Module))
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// VisitAllModules calls pred for each defined variant of each module in an unspecified order, and if pred returns
|
|
|
|
// true calls visit.
|
2014-05-28 01:34:41 +02:00
|
|
|
VisitAllModulesIf(pred func(Module) bool, visit func(Module))
|
2019-05-20 23:51:55 +02:00
|
|
|
|
2019-09-20 13:01:01 +02:00
|
|
|
// VisitDirectDeps calls visit for each direct dependency of the Module. If there are
|
|
|
|
// multiple direct dependencies on the same module visit will be called multiple times on
|
|
|
|
// that module and OtherModuleDependencyTag will return a different tag for each.
|
|
|
|
//
|
|
|
|
// The Module passed to the visit function should not be retained outside of the visit
|
|
|
|
// function, it may be invalidated by future mutators.
|
|
|
|
VisitDirectDeps(module Module, visit func(Module))
|
|
|
|
|
|
|
|
// VisitDirectDepsIf calls pred for each direct dependency of the Module, and if pred
|
|
|
|
// returns true calls visit. If there are multiple direct dependencies on the same module
|
|
|
|
// pred and visit will be called multiple times on that module and OtherModuleDependencyTag
|
|
|
|
// will return a different tag for each.
|
|
|
|
//
|
|
|
|
// The Module passed to the visit function should not be retained outside of the visit
|
|
|
|
// function, it may be invalidated by future mutators.
|
|
|
|
VisitDirectDepsIf(module Module, pred func(Module) bool, visit func(Module))
|
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// VisitDepsDepthFirst calls visit for each transitive dependency, traversing the dependency tree in depth first
|
|
|
|
// order. visit will only be called once for any given module, even if there are multiple paths through the
|
|
|
|
// dependency tree to the module or multiple direct dependencies with different tags.
|
2014-06-17 19:24:24 +02:00
|
|
|
VisitDepsDepthFirst(module Module, visit func(Module))
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// VisitDepsDepthFirst calls pred for each transitive dependency, and if pred returns true calls visit, traversing
|
|
|
|
// the dependency tree in depth first order. visit will only be called once for any given module, even if there are
|
|
|
|
// multiple paths through the dependency tree to the module or multiple direct dependencies with different tags.
|
2014-06-17 19:24:24 +02:00
|
|
|
VisitDepsDepthFirstIf(module Module, pred func(Module) bool,
|
|
|
|
visit func(Module))
|
2014-06-26 02:21:54 +02:00
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// VisitAllModuleVariants calls visit for each variant of the given module.
|
2015-11-18 01:22:29 +01:00
|
|
|
VisitAllModuleVariants(module Module, visit func(Module))
|
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// PrimaryModule returns the first variant of the given module. This can be used to perform
|
|
|
|
// // singleton actions that are only done once for all variants of a module.
|
2015-11-18 01:22:29 +01:00
|
|
|
PrimaryModule(module Module) Module
|
2019-05-20 23:51:55 +02:00
|
|
|
|
|
|
|
// FinalModule returns the last variant of the given module. This can be used to perform
|
|
|
|
// singleton actions that are only done once for all variants of a module.
|
2015-11-18 01:22:29 +01:00
|
|
|
FinalModule(module Module) Module
|
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// AddNinjaFileDeps adds dependencies on the specified files to the rule that creates the ninja manifest. The
|
|
|
|
// primary builder will be rerun whenever the specified files are modified.
|
2014-06-26 02:21:54 +02:00
|
|
|
AddNinjaFileDeps(deps ...string)
|
2016-11-01 19:10:51 +01:00
|
|
|
|
2018-02-23 23:49:45 +01:00
|
|
|
// GlobWithDeps returns a list of files and directories that match the
|
|
|
|
// specified pattern but do not match any of the patterns in excludes.
|
|
|
|
// Any directories will have a '/' suffix. It also adds efficient
|
|
|
|
// dependencies to rerun the primary builder whenever a file matching
|
|
|
|
// the pattern as added or removed, without rerunning if a file that
|
|
|
|
// does not match the pattern is added to a searched directory.
|
2016-11-01 19:10:51 +01:00
|
|
|
GlobWithDeps(pattern string, excludes []string) ([]string, error)
|
2017-02-01 22:21:35 +01:00
|
|
|
|
2019-05-20 23:51:55 +02:00
|
|
|
// Fs returns a pathtools.Filesystem that can be used to interact with files. Using the Filesystem interface allows
|
|
|
|
// the singleton to be used in build system tests that run against a mock filesystem.
|
2017-02-01 22:21:35 +01:00
|
|
|
Fs() pathtools.FileSystem
|
2022-05-16 21:28:06 +02:00
|
|
|
|
|
|
|
// ModuleVariantsFromName returns the list of module variants named `name` in the same namespace as `referer`.
|
|
|
|
// Allows generating build actions for `referer` based on the metadata for `name` deferred until the singleton context.
|
|
|
|
ModuleVariantsFromName(referer Module, name string) []Module
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ SingletonContext = (*singletonContext)(nil)
|
|
|
|
|
|
|
|
type singletonContext struct {
|
2019-02-26 03:07:44 +01:00
|
|
|
name string
|
2014-05-28 01:34:41 +02:00
|
|
|
context *Context
|
2014-06-12 03:31:16 +02:00
|
|
|
config interface{}
|
2014-05-28 01:34:41 +02:00
|
|
|
scope *localScope
|
2016-01-15 00:42:54 +01:00
|
|
|
globals *liveTracker
|
2014-05-28 01:34:41 +02:00
|
|
|
|
2014-06-26 02:21:54 +02:00
|
|
|
ninjaFileDeps []string
|
|
|
|
errs []error
|
2014-05-28 01:34:41 +02:00
|
|
|
|
|
|
|
actionDefs localBuildActions
|
|
|
|
}
|
|
|
|
|
2014-06-12 03:31:16 +02:00
|
|
|
func (s *singletonContext) Config() interface{} {
|
2014-05-28 01:34:41 +02:00
|
|
|
return s.config
|
|
|
|
}
|
|
|
|
|
2019-02-26 03:07:44 +01:00
|
|
|
func (s *singletonContext) Name() string {
|
|
|
|
return s.name
|
|
|
|
}
|
|
|
|
|
2014-12-18 01:12:41 +01:00
|
|
|
func (s *singletonContext) ModuleName(logicModule Module) string {
|
2015-05-13 23:36:24 +02:00
|
|
|
return s.context.ModuleName(logicModule)
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
2014-12-18 01:12:41 +01:00
|
|
|
func (s *singletonContext) ModuleDir(logicModule Module) string {
|
2015-05-13 23:36:24 +02:00
|
|
|
return s.context.ModuleDir(logicModule)
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 03:02:11 +01:00
|
|
|
func (s *singletonContext) ModuleSubDir(logicModule Module) string {
|
|
|
|
return s.context.ModuleSubDir(logicModule)
|
|
|
|
}
|
|
|
|
|
2016-07-26 00:51:50 +02:00
|
|
|
func (s *singletonContext) ModuleType(logicModule Module) string {
|
|
|
|
return s.context.ModuleType(logicModule)
|
|
|
|
}
|
|
|
|
|
2020-07-02 19:08:12 +02:00
|
|
|
func (s *singletonContext) ModuleProvider(logicModule Module, provider ProviderKey) interface{} {
|
|
|
|
return s.context.ModuleProvider(logicModule, provider)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModuleHasProvider returns true if the provider for the given module has been set.
|
|
|
|
func (s *singletonContext) ModuleHasProvider(logicModule Module, provider ProviderKey) bool {
|
|
|
|
return s.context.ModuleHasProvider(logicModule, provider)
|
|
|
|
}
|
|
|
|
|
2014-12-18 01:12:41 +01:00
|
|
|
func (s *singletonContext) BlueprintFile(logicModule Module) string {
|
2015-05-13 23:36:24 +02:00
|
|
|
return s.context.BlueprintFile(logicModule)
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
2016-01-07 22:43:09 +01:00
|
|
|
func (s *singletonContext) error(err error) {
|
|
|
|
if err != nil {
|
|
|
|
s.errs = append(s.errs, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-18 01:12:41 +01:00
|
|
|
func (s *singletonContext) ModuleErrorf(logicModule Module, format string,
|
2014-05-28 01:34:41 +02:00
|
|
|
args ...interface{}) {
|
|
|
|
|
2016-01-07 22:43:09 +01:00
|
|
|
s.error(s.context.ModuleErrorf(logicModule, format, args...))
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *singletonContext) Errorf(format string, args ...interface{}) {
|
|
|
|
// TODO: Make this not result in the error being printed as "internal error"
|
2016-01-07 22:43:09 +01:00
|
|
|
s.error(fmt.Errorf(format, args...))
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
2015-12-10 03:06:23 +01:00
|
|
|
func (s *singletonContext) Failed() bool {
|
|
|
|
return len(s.errs) > 0
|
|
|
|
}
|
|
|
|
|
2015-11-26 00:29:32 +01:00
|
|
|
func (s *singletonContext) Variable(pctx PackageContext, name, value string) {
|
2014-10-03 11:49:58 +02:00
|
|
|
s.scope.ReparentTo(pctx)
|
2014-07-01 03:07:17 +02:00
|
|
|
|
2014-05-28 01:34:41 +02:00
|
|
|
v, err := s.scope.AddLocalVariable(name, value)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.actionDefs.variables = append(s.actionDefs.variables, v)
|
|
|
|
}
|
|
|
|
|
2015-11-26 00:29:32 +01:00
|
|
|
func (s *singletonContext) Rule(pctx PackageContext, name string,
|
2014-10-03 11:49:58 +02:00
|
|
|
params RuleParams, argNames ...string) Rule {
|
2014-06-06 05:00:22 +02:00
|
|
|
|
2014-10-03 11:49:58 +02:00
|
|
|
s.scope.ReparentTo(pctx)
|
2014-07-01 03:07:17 +02:00
|
|
|
|
2014-06-06 05:00:22 +02:00
|
|
|
r, err := s.scope.AddLocalRule(name, ¶ms, argNames...)
|
2014-05-28 01:34:41 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.actionDefs.rules = append(s.actionDefs.rules, r)
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2015-11-26 00:29:32 +01:00
|
|
|
func (s *singletonContext) Build(pctx PackageContext, params BuildParams) {
|
2014-10-03 11:49:58 +02:00
|
|
|
s.scope.ReparentTo(pctx)
|
2014-07-01 03:07:17 +02:00
|
|
|
|
2023-06-21 02:17:22 +02:00
|
|
|
def, err := parseBuildParams(s.scope, ¶ms, map[string]string{
|
|
|
|
"module_name": s.name,
|
|
|
|
"module_type": "singleton",
|
|
|
|
})
|
2014-05-28 01:34:41 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.actionDefs.buildDefs = append(s.actionDefs.buildDefs, def)
|
|
|
|
}
|
|
|
|
|
2016-01-15 00:42:54 +01:00
|
|
|
func (s *singletonContext) Eval(pctx PackageContext, str string) (string, error) {
|
|
|
|
s.scope.ReparentTo(pctx)
|
|
|
|
|
|
|
|
ninjaStr, err := parseNinjaString(s.scope, str)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = s.globals.addNinjaStringDeps(ninjaStr)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
2023-07-11 21:58:01 +02:00
|
|
|
return s.globals.Eval(ninjaStr)
|
2016-01-15 00:42:54 +01:00
|
|
|
}
|
|
|
|
|
2014-05-28 01:34:41 +02:00
|
|
|
func (s *singletonContext) RequireNinjaVersion(major, minor, micro int) {
|
|
|
|
s.context.requireNinjaVersion(major, minor, micro)
|
|
|
|
}
|
|
|
|
|
2021-08-26 15:08:09 +02:00
|
|
|
func (s *singletonContext) SetOutDir(pctx PackageContext, value string) {
|
2014-10-03 11:49:58 +02:00
|
|
|
s.scope.ReparentTo(pctx)
|
2014-09-25 02:51:52 +02:00
|
|
|
|
2014-05-28 01:34:41 +02:00
|
|
|
ninjaValue, err := parseNinjaString(s.scope, value)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-08-26 15:08:09 +02:00
|
|
|
s.context.setOutDir(ninjaValue)
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
Run globs during earlier bootstrap phases
Instead of sometimes re-running minibp/the primary builder during the
next phase, run bpglob earlier to check dependencies.
We've run into issues where the environment is slightly different
between bootstrapping phase and the main build phase. It's also a
problem because our primary builder (Soong) exports information used by
another tool (Kati) that runs in between the bootstrapping phases and
the main phase. When Soong would run in the main phase, it could get out
of sync, and would require the build to be run again.
To do this, add a "subninja" include a build-globs.ninja file to each
build.ninja file. The first time, this will be an empty file, but we'll
always run minibp / the primary builder anyway. When the builder runs,
in addition to writing a dependency file, write out the
build-globs.ninja file with the rules to run bpglob.
Since bpglob may need to be run very early, before it would normally be
built, build it with microfactory.
Change-Id: I89fcd849a8729e892f163d40060ab90b5d4dfa5d
2018-07-06 06:56:59 +02:00
|
|
|
func (s *singletonContext) AddSubninja(file string) {
|
|
|
|
s.context.subninjas = append(s.context.subninjas, file)
|
|
|
|
}
|
|
|
|
|
2014-05-28 01:34:41 +02:00
|
|
|
func (s *singletonContext) VisitAllModules(visit func(Module)) {
|
2018-09-19 22:37:29 +02:00
|
|
|
var visitingModule Module
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
panic(newPanicErrorf(r, "VisitAllModules(%s) for module %s",
|
2019-03-25 23:04:09 +01:00
|
|
|
funcName(visit), s.context.moduleInfo[visitingModule]))
|
2018-09-19 22:37:29 +02:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
s.context.VisitAllModules(func(m Module) {
|
|
|
|
visitingModule = m
|
|
|
|
visit(m)
|
|
|
|
})
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *singletonContext) VisitAllModulesIf(pred func(Module) bool,
|
|
|
|
visit func(Module)) {
|
|
|
|
|
2015-05-13 23:36:24 +02:00
|
|
|
s.context.VisitAllModulesIf(pred, visit)
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
2014-06-17 19:24:24 +02:00
|
|
|
|
2019-09-20 13:01:01 +02:00
|
|
|
func (s *singletonContext) VisitDirectDeps(module Module, visit func(Module)) {
|
|
|
|
s.context.VisitDirectDeps(module, visit)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *singletonContext) VisitDirectDepsIf(module Module, pred func(Module) bool, visit func(Module)) {
|
|
|
|
s.context.VisitDirectDepsIf(module, pred, visit)
|
|
|
|
}
|
|
|
|
|
2014-06-17 19:24:24 +02:00
|
|
|
func (s *singletonContext) VisitDepsDepthFirst(module Module,
|
|
|
|
visit func(Module)) {
|
|
|
|
|
2015-05-13 23:36:24 +02:00
|
|
|
s.context.VisitDepsDepthFirst(module, visit)
|
2014-06-17 19:24:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *singletonContext) VisitDepsDepthFirstIf(module Module,
|
|
|
|
pred func(Module) bool, visit func(Module)) {
|
|
|
|
|
2015-05-13 23:36:24 +02:00
|
|
|
s.context.VisitDepsDepthFirstIf(module, pred, visit)
|
2014-06-17 19:24:24 +02:00
|
|
|
}
|
2014-06-26 02:21:54 +02:00
|
|
|
|
2015-11-18 01:22:29 +01:00
|
|
|
func (s *singletonContext) PrimaryModule(module Module) Module {
|
|
|
|
return s.context.PrimaryModule(module)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *singletonContext) FinalModule(module Module) Module {
|
|
|
|
return s.context.FinalModule(module)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *singletonContext) VisitAllModuleVariants(module Module, visit func(Module)) {
|
|
|
|
s.context.VisitAllModuleVariants(module, visit)
|
|
|
|
}
|
|
|
|
|
2014-06-26 02:21:54 +02:00
|
|
|
func (s *singletonContext) AddNinjaFileDeps(deps ...string) {
|
|
|
|
s.ninjaFileDeps = append(s.ninjaFileDeps, deps...)
|
|
|
|
}
|
2016-11-01 19:10:51 +01:00
|
|
|
|
|
|
|
func (s *singletonContext) GlobWithDeps(pattern string,
|
|
|
|
excludes []string) ([]string, error) {
|
|
|
|
return s.context.glob(pattern, excludes)
|
|
|
|
}
|
2017-02-01 22:21:35 +01:00
|
|
|
|
|
|
|
func (s *singletonContext) Fs() pathtools.FileSystem {
|
|
|
|
return s.context.fs
|
|
|
|
}
|
2022-05-16 21:28:06 +02:00
|
|
|
|
|
|
|
func (s *singletonContext) ModuleVariantsFromName(referer Module, name string) []Module {
|
|
|
|
c := s.context
|
|
|
|
|
|
|
|
refererInfo := c.moduleInfo[referer]
|
|
|
|
if refererInfo == nil {
|
|
|
|
s.ModuleErrorf(referer, "could not find module %q", referer.Name())
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
moduleGroup, exists := c.nameInterface.ModuleFromName(name, refererInfo.namespace())
|
|
|
|
if !exists {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
result := make([]Module, 0, len(moduleGroup.modules))
|
|
|
|
for _, module := range moduleGroup.modules {
|
|
|
|
moduleInfo := module.module()
|
|
|
|
if moduleInfo != nil {
|
|
|
|
result = append(result, moduleInfo.logicModule)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|