Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 1 | // Copyright 2017 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 | |
| 15 | package config |
| 16 | |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 17 | import ( |
Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 18 | "android/soong/android" |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 19 | "strings" |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 20 | ) |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 21 | |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 22 | var ( |
| 23 | // These will be filled out by external/error_prone/soong/error_prone.go if it is available |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 24 | ErrorProneClasspath []string |
| 25 | ErrorProneChecksError []string |
| 26 | ErrorProneChecksWarning []string |
| 27 | ErrorProneChecksDefaultDisabled []string |
| 28 | ErrorProneChecksOff []string |
| 29 | ErrorProneFlags []string |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 30 | ) |
| 31 | |
| 32 | // Wrapper that grabs value of val late so it can be initialized by a later module's init function |
Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 33 | func errorProneVar(val *[]string, sep string) func(android.PackageVarContext) string { |
| 34 | return func(android.PackageVarContext) string { |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 35 | return strings.Join(*val, sep) |
Sam Delmerico | 932c01c | 2022-03-25 16:33:26 +0000 | [diff] [blame] | 36 | } |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | func init() { |
Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 40 | pctx.VariableFunc("ErrorProneClasspath", errorProneVar(&ErrorProneClasspath, ":")) |
| 41 | pctx.VariableFunc("ErrorProneChecksError", errorProneVar(&ErrorProneChecksError, " ")) |
| 42 | pctx.VariableFunc("ErrorProneChecksWarning", errorProneVar(&ErrorProneChecksWarning, " ")) |
| 43 | pctx.VariableFunc("ErrorProneChecksDefaultDisabled", errorProneVar(&ErrorProneChecksDefaultDisabled, " ")) |
| 44 | pctx.VariableFunc("ErrorProneChecksOff", errorProneVar(&ErrorProneChecksOff, " ")) |
| 45 | pctx.VariableFunc("ErrorProneFlags", errorProneVar(&ErrorProneFlags, " ")) |
| 46 | pctx.StaticVariable("ErrorProneChecks", strings.Join([]string{ |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 47 | "${ErrorProneChecksOff}", |
| 48 | "${ErrorProneChecksError}", |
| 49 | "${ErrorProneChecksWarning}", |
| 50 | "${ErrorProneChecksDefaultDisabled}", |
Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 51 | }, " ")) |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 52 | } |