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 ( |
| 18 | "strings" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | ) |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 22 | |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 23 | var ( |
| 24 | // 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] | 25 | ErrorProneClasspath []string |
| 26 | ErrorProneChecksError []string |
| 27 | ErrorProneChecksWarning []string |
| 28 | ErrorProneChecksDefaultDisabled []string |
| 29 | ErrorProneChecksOff []string |
| 30 | ErrorProneFlags []string |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | // Wrapper that grabs value of val late so it can be initialized by a later module's init function |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 34 | func errorProneVar(name string, val *[]string, sep string) { |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 35 | pctx.VariableFunc(name, func(android.PackageVarContext) string { |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 36 | return strings.Join(*val, sep) |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 37 | }) |
| 38 | } |
| 39 | |
| 40 | func init() { |
Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 41 | errorProneVar("ErrorProneClasspath", &ErrorProneClasspath, ":") |
| 42 | errorProneVar("ErrorProneChecksError", &ErrorProneChecksError, " ") |
| 43 | errorProneVar("ErrorProneChecksWarning", &ErrorProneChecksWarning, " ") |
| 44 | errorProneVar("ErrorProneChecksDefaultDisabled", &ErrorProneChecksDefaultDisabled, " ") |
| 45 | errorProneVar("ErrorProneChecksOff", &ErrorProneChecksOff, " ") |
| 46 | errorProneVar("ErrorProneFlags", &ErrorProneFlags, " ") |
| 47 | pctx.StaticVariable("ErrorProneChecks", strings.Join([]string{ |
| 48 | "${ErrorProneChecksOff}", |
| 49 | "${ErrorProneChecksError}", |
| 50 | "${ErrorProneChecksWarning}", |
| 51 | "${ErrorProneChecksDefaultDisabled}", |
| 52 | }, " ")) |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 53 | } |