Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 1 | // Copyright 2016 The Android Open Source Project |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 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 | package fluoride |
| 15 | |
| 16 | import ( |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 17 | "strings" |
Jack He | a643b5b | 2017-01-18 17:14:08 -0800 | [diff] [blame] | 18 | |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 19 | "android/soong/android" |
| 20 | "android/soong/cc" |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 21 | ) |
| 22 | |
| 23 | func init() { |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 24 | android.RegisterModuleType("fluoride_defaults", fluorideDefaultsFactory) |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 25 | } |
| 26 | |
Colin Cross | 5e7f1a3 | 2017-06-27 11:05:21 -0700 | [diff] [blame] | 27 | func fluorideDefaultsFactory() android.Module { |
| 28 | module := cc.DefaultsFactory() |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 29 | android.AddLoadHook(module, fluorideDefaults) |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 30 | |
Colin Cross | 5e7f1a3 | 2017-06-27 11:05:21 -0700 | [diff] [blame] | 31 | return module |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | func fluorideDefaults(ctx android.LoadHookContext) { |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 35 | type props struct { |
| 36 | Include_dirs []string |
| 37 | Cflags []string |
| 38 | } |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 39 | |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 40 | p := &props{} |
| 41 | p.Cflags, p.Include_dirs = globalDefaults(ctx) |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 42 | |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 43 | ctx.AppendProperties(p) |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | func globalDefaults(ctx android.BaseContext) ([]string, []string) { |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 47 | var cflags []string |
| 48 | var includeDirs []string |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 49 | |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 50 | board_bt_buildcfg_include_dir := ctx.DeviceConfig().BtConfigIncludeDir() |
| 51 | if len(board_bt_buildcfg_include_dir) > 0 { |
| 52 | cflags = append(cflags, "-DHAS_BDROID_BUILDCFG") |
| 53 | board_bt_buildcfg_include_dir_list := |
| 54 | strings.Fields(board_bt_buildcfg_include_dir) |
| 55 | for _, buildcfg_dir := range board_bt_buildcfg_include_dir_list { |
| 56 | includeDirs = append(includeDirs, buildcfg_dir) |
| 57 | } |
| 58 | } else { |
| 59 | cflags = append(cflags, "-DHAS_NO_BDROID_BUILDCFG") |
| 60 | } |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 61 | |
Colin Cross | 2cf6e71 | 2017-06-27 11:15:25 -0700 | [diff] [blame] | 62 | return cflags, includeDirs |
Jack He | e2eeff4 | 2016-12-07 18:25:17 -0800 | [diff] [blame] | 63 | } |