| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved. | 
|  | 2 | // | 
|  | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | // you may not use this file except in compliance with the License. | 
|  | 5 | // You may obtain a copy of the License at | 
|  | 6 | // | 
|  | 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | // | 
|  | 9 | // Unless required by applicable law or agreed to in writing, software | 
|  | 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | // See the License for the specific language governing permissions and | 
|  | 13 | // limitations under the License. | 
|  | 14 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 15 | package android | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 16 |  | 
|  | 17 | import ( | 
|  | 18 | "fmt" | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 19 | "strings" | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 20 |  | 
|  | 21 | "github.com/google/blueprint" | 
|  | 22 | ) | 
|  | 23 |  | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 24 | // PackageContext is a wrapper for blueprint.PackageContext that adds | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 25 | // some android-specific helper functions. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 26 | type PackageContext struct { | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 27 | blueprint.PackageContext | 
|  | 28 | } | 
|  | 29 |  | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 30 | func NewPackageContext(pkgPath string) PackageContext { | 
|  | 31 | return PackageContext{blueprint.NewPackageContext(pkgPath)} | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 32 | } | 
|  | 33 |  | 
|  | 34 | // configErrorWrapper can be used with Path functions when a Context is not | 
|  | 35 | // available. A Config can be provided, and errors are stored as a list for | 
|  | 36 | // later retrieval. | 
|  | 37 | // | 
|  | 38 | // The most common use here will be with VariableFunc, where only a config is | 
|  | 39 | // provided, and an error should be returned. | 
|  | 40 | type configErrorWrapper struct { | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 41 | pctx   PackageContext | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 42 | config Config | 
|  | 43 | errors []error | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 | var _ PathContext = &configErrorWrapper{} | 
|  | 47 | var _ errorfContext = &configErrorWrapper{} | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 48 | var _ PackageVarContext = &configErrorWrapper{} | 
|  | 49 | var _ PackagePoolContext = &configErrorWrapper{} | 
|  | 50 | var _ PackageRuleContext = &configErrorWrapper{} | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 51 |  | 
| Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 52 | func (e *configErrorWrapper) Config() Config { | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 53 | return e.config | 
|  | 54 | } | 
|  | 55 | func (e *configErrorWrapper) Errorf(format string, args ...interface{}) { | 
|  | 56 | e.errors = append(e.errors, fmt.Errorf(format, args...)) | 
|  | 57 | } | 
| Dan Willemsen | 7b310ee | 2015-12-18 15:11:17 -0800 | [diff] [blame] | 58 | func (e *configErrorWrapper) AddNinjaFileDeps(deps ...string) { | 
|  | 59 | e.pctx.AddNinjaFileDeps(deps...) | 
|  | 60 | } | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 61 |  | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 62 | type PackageVarContext interface { | 
|  | 63 | PathContext | 
|  | 64 | errorfContext | 
|  | 65 | } | 
|  | 66 |  | 
|  | 67 | type PackagePoolContext PackageVarContext | 
|  | 68 | type PackageRuleContext PackageVarContext | 
|  | 69 |  | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 70 | // VariableFunc wraps blueprint.PackageContext.VariableFunc, converting the interface{} config | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 71 | // argument to a PackageVarContext. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 72 | func (p PackageContext) VariableFunc(name string, | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 73 | f func(PackageVarContext) string) blueprint.Variable { | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 74 |  | 
|  | 75 | return p.PackageContext.VariableFunc(name, func(config interface{}) (string, error) { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 76 | ctx := &configErrorWrapper{p, config.(Config), nil} | 
|  | 77 | ret := f(ctx) | 
|  | 78 | if len(ctx.errors) > 0 { | 
|  | 79 | return "", ctx.errors[0] | 
|  | 80 | } | 
|  | 81 | return ret, nil | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 82 | }) | 
|  | 83 | } | 
|  | 84 |  | 
|  | 85 | // PoolFunc wraps blueprint.PackageContext.PoolFunc, converting the interface{} config | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 86 | // argument to a Context that supports Config(). | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 87 | func (p PackageContext) PoolFunc(name string, | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 88 | f func(PackagePoolContext) blueprint.PoolParams) blueprint.Pool { | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 89 |  | 
|  | 90 | return p.PackageContext.PoolFunc(name, func(config interface{}) (blueprint.PoolParams, error) { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 91 | ctx := &configErrorWrapper{p, config.(Config), nil} | 
|  | 92 | params := f(ctx) | 
|  | 93 | if len(ctx.errors) > 0 { | 
|  | 94 | return params, ctx.errors[0] | 
|  | 95 | } | 
|  | 96 | return params, nil | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 97 | }) | 
|  | 98 | } | 
|  | 99 |  | 
|  | 100 | // RuleFunc wraps blueprint.PackageContext.RuleFunc, converting the interface{} config | 
| Colin Cross | 2e2dbc2 | 2019-09-25 13:31:46 -0700 | [diff] [blame] | 101 | // argument to a Context that supports Config(), and provides a default Pool if none is | 
|  | 102 | // specified. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 103 | func (p PackageContext) RuleFunc(name string, | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 104 | f func(PackageRuleContext) blueprint.RuleParams, argNames ...string) blueprint.Rule { | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 105 |  | 
|  | 106 | return p.PackageContext.RuleFunc(name, func(config interface{}) (blueprint.RuleParams, error) { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 107 | ctx := &configErrorWrapper{p, config.(Config), nil} | 
|  | 108 | params := f(ctx) | 
|  | 109 | if len(ctx.errors) > 0 { | 
|  | 110 | return params, ctx.errors[0] | 
|  | 111 | } | 
| Colin Cross | 8b8bec3 | 2019-11-15 13:18:43 -0800 | [diff] [blame] | 112 | if ctx.Config().UseRemoteBuild() && params.Pool == nil { | 
| Ramy Medhat | dd0418a | 2019-11-04 18:16:11 -0500 | [diff] [blame] | 113 | // When USE_GOMA=true or USE_RBE=true are set and the rule is not supported by | 
|  | 114 | // goma/RBE, restrict jobs to the local parallelism value | 
| Colin Cross | 2e2dbc2 | 2019-09-25 13:31:46 -0700 | [diff] [blame] | 115 | params.Pool = localPool | 
|  | 116 | } | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 117 | return params, nil | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 118 | }, argNames...) | 
|  | 119 | } | 
|  | 120 |  | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 121 | // SourcePathVariable returns a Variable whose value is the source directory | 
|  | 122 | // appended with the supplied path. It may only be called during a Go package's | 
|  | 123 | // initialization - either from the init() function or as part of a | 
|  | 124 | // package-scoped variable's initialization. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 125 | func (p PackageContext) SourcePathVariable(name, path string) blueprint.Variable { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 126 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
| Colin Cross | fe4bc36 | 2018-09-12 10:02:13 -0700 | [diff] [blame] | 127 | p, err := safePathForSource(ctx, path) | 
|  | 128 | if err != nil { | 
|  | 129 | ctx.Errorf("%s", err.Error()) | 
|  | 130 | } | 
|  | 131 | return p.String() | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 132 | }) | 
|  | 133 | } | 
|  | 134 |  | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 135 | // SourcePathsVariable returns a Variable whose value is the source directory | 
|  | 136 | // appended with the supplied paths, joined with separator. It may only be | 
|  | 137 | // called during a Go package's initialization - either from the init() | 
|  | 138 | // function or as part of a package-scoped variable's initialization. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 139 | func (p PackageContext) SourcePathsVariable(name, separator string, paths ...string) blueprint.Variable { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 140 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 141 | var ret []string | 
|  | 142 | for _, path := range paths { | 
| Colin Cross | fe4bc36 | 2018-09-12 10:02:13 -0700 | [diff] [blame] | 143 | p, err := safePathForSource(ctx, path) | 
|  | 144 | if err != nil { | 
|  | 145 | ctx.Errorf("%s", err.Error()) | 
|  | 146 | } | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 147 | ret = append(ret, p.String()) | 
|  | 148 | } | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 149 | return strings.Join(ret, separator) | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 150 | }) | 
|  | 151 | } | 
|  | 152 |  | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 153 | // SourcePathVariableWithEnvOverride returns a Variable whose value is the source directory | 
|  | 154 | // appended with the supplied path, or the value of the given environment variable if it is set. | 
|  | 155 | // The environment variable is not required to point to a path inside the source tree. | 
|  | 156 | // It may only be called during a Go package's initialization - either from the init() function or | 
|  | 157 | // as part of a package-scoped variable's initialization. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 158 | func (p PackageContext) SourcePathVariableWithEnvOverride(name, path, env string) blueprint.Variable { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 159 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
| Colin Cross | fe4bc36 | 2018-09-12 10:02:13 -0700 | [diff] [blame] | 160 | p, err := safePathForSource(ctx, path) | 
|  | 161 | if err != nil { | 
|  | 162 | ctx.Errorf("%s", err.Error()) | 
|  | 163 | } | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 164 | return ctx.Config().GetenvWithDefault(env, p.String()) | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 165 | }) | 
|  | 166 | } | 
|  | 167 |  | 
| Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 168 | // HostBinToolVariable returns a Variable whose value is the path to a host tool | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 169 | // in the bin directory for host targets. It may only be called during a Go | 
|  | 170 | // package's initialization - either from the init() function or as part of a | 
|  | 171 | // package-scoped variable's initialization. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 172 | func (p PackageContext) HostBinToolVariable(name, path string) blueprint.Variable { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 173 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 174 | return ctx.Config().HostToolPath(ctx, path).String() | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 175 | }) | 
|  | 176 | } | 
|  | 177 |  | 
| Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 178 | // HostJNIToolVariable returns a Variable whose value is the path to a host tool | 
|  | 179 | // in the lib directory for host targets. It may only be called during a Go | 
|  | 180 | // package's initialization - either from the init() function or as part of a | 
|  | 181 | // package-scoped variable's initialization. | 
|  | 182 | func (p PackageContext) HostJNIToolVariable(name, path string) blueprint.Variable { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 183 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 184 | return ctx.Config().HostJNIToolPath(ctx, path).String() | 
| Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 185 | }) | 
|  | 186 | } | 
|  | 187 |  | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 188 | // HostJavaToolVariable returns a Variable whose value is the path to a host | 
|  | 189 | // tool in the frameworks directory for host targets. It may only be called | 
|  | 190 | // during a Go package's initialization - either from the init() function or as | 
|  | 191 | // part of a package-scoped variable's initialization. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 192 | func (p PackageContext) HostJavaToolVariable(name, path string) blueprint.Variable { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 193 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 194 | return ctx.Config().HostJavaToolPath(ctx, path).String() | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 195 | }) | 
|  | 196 | } | 
|  | 197 |  | 
|  | 198 | // IntermediatesPathVariable returns a Variable whose value is the intermediate | 
|  | 199 | // directory appended with the supplied path. It may only be called during a Go | 
|  | 200 | // package's initialization - either from the init() function or as part of a | 
|  | 201 | // package-scoped variable's initialization. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 202 | func (p PackageContext) IntermediatesPathVariable(name, path string) blueprint.Variable { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 203 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
|  | 204 | return PathForIntermediates(ctx, path).String() | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 205 | }) | 
|  | 206 | } | 
|  | 207 |  | 
| Jeff Gaston | 734e380 | 2017-04-10 15:47:24 -0700 | [diff] [blame] | 208 | // PrefixedExistentPathsForSourcesVariable returns a Variable whose value is the | 
| Dan Willemsen | 7b310ee | 2015-12-18 15:11:17 -0800 | [diff] [blame] | 209 | // list of present source paths prefixed with the supplied prefix. It may only | 
|  | 210 | // be called during a Go package's initialization - either from the init() | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 211 | // function or as part of a package-scoped variable's initialization. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 212 | func (p PackageContext) PrefixedExistentPathsForSourcesVariable( | 
| Dan Willemsen | 7b310ee | 2015-12-18 15:11:17 -0800 | [diff] [blame] | 213 | name, prefix string, paths []string) blueprint.Variable { | 
|  | 214 |  | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 215 | return p.VariableFunc(name, func(ctx PackageVarContext) string { | 
| Colin Cross | 32f3898 | 2018-02-22 11:47:25 -0800 | [diff] [blame] | 216 | paths := ExistentPathsForSources(ctx, paths) | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 217 | return JoinWithPrefix(paths.Strings(), prefix) | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 218 | }) | 
|  | 219 | } | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 220 |  | 
| Colin Cross | 2e2dbc2 | 2019-09-25 13:31:46 -0700 | [diff] [blame] | 221 | // AndroidStaticRule is an alias for StaticRule. | 
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 222 | func (p PackageContext) AndroidStaticRule(name string, params blueprint.RuleParams, | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 223 | argNames ...string) blueprint.Rule { | 
| Colin Cross | 2e2dbc2 | 2019-09-25 13:31:46 -0700 | [diff] [blame] | 224 | return p.StaticRule(name, params, argNames...) | 
|  | 225 | } | 
|  | 226 |  | 
|  | 227 | // StaticRule wraps blueprint.StaticRule and provides a default Pool if none is specified. | 
|  | 228 | func (p PackageContext) StaticRule(name string, params blueprint.RuleParams, | 
|  | 229 | argNames ...string) blueprint.Rule { | 
|  | 230 | return p.RuleFunc(name, func(PackageRuleContext) blueprint.RuleParams { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 231 | return params | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 232 | }, argNames...) | 
|  | 233 | } | 
|  | 234 |  | 
| Ramy Medhat | 8ea054a | 2020-01-27 14:19:44 -0500 | [diff] [blame] | 235 | // RemoteRuleSupports configures rules with whether they have Goma and/or RBE support. | 
|  | 236 | type RemoteRuleSupports struct { | 
| Ramy Medhat | 1dcc27e | 2020-04-21 21:36:23 -0400 | [diff] [blame] | 237 | Goma bool | 
|  | 238 | RBE  bool | 
| Ramy Medhat | 8ea054a | 2020-01-27 14:19:44 -0500 | [diff] [blame] | 239 | } | 
|  | 240 |  | 
| Ramy Medhat | dd0418a | 2019-11-04 18:16:11 -0500 | [diff] [blame] | 241 | // AndroidRemoteStaticRule wraps blueprint.StaticRule but uses goma or RBE's parallelism if goma or RBE are enabled | 
|  | 242 | // and the appropriate SUPPORTS_* flag is set. | 
|  | 243 | func (p PackageContext) AndroidRemoteStaticRule(name string, supports RemoteRuleSupports, params blueprint.RuleParams, | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 244 | argNames ...string) blueprint.Rule { | 
| Ramy Medhat | dd0418a | 2019-11-04 18:16:11 -0500 | [diff] [blame] | 245 |  | 
|  | 246 | return p.PackageContext.RuleFunc(name, func(config interface{}) (blueprint.RuleParams, error) { | 
|  | 247 | ctx := &configErrorWrapper{p, config.(Config), nil} | 
| Ramy Medhat | 8ea054a | 2020-01-27 14:19:44 -0500 | [diff] [blame] | 248 | if ctx.Config().UseGoma() && !supports.Goma { | 
| Ramy Medhat | dd0418a | 2019-11-04 18:16:11 -0500 | [diff] [blame] | 249 | // When USE_GOMA=true is set and the rule is not supported by goma, restrict jobs to the | 
|  | 250 | // local parallelism value | 
|  | 251 | params.Pool = localPool | 
|  | 252 | } | 
|  | 253 |  | 
| Ramy Medhat | 8ea054a | 2020-01-27 14:19:44 -0500 | [diff] [blame] | 254 | if ctx.Config().UseRBE() && !supports.RBE { | 
| Ramy Medhat | dd0418a | 2019-11-04 18:16:11 -0500 | [diff] [blame] | 255 | // When USE_RBE=true is set and the rule is not supported by RBE, restrict jobs to the | 
|  | 256 | // local parallelism value | 
|  | 257 | params.Pool = localPool | 
|  | 258 | } | 
|  | 259 |  | 
|  | 260 | return params, nil | 
|  | 261 | }, argNames...) | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 262 | } |