1 // Copyright (C) 2016 The Android Open Source Project 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 ( 17 "strings" 18 19 "android/soong/android" 20 "android/soong/cc" 21 22 "github.com/google/blueprint" 23 ) 24 25 func init() { 26 android.RegisterModuleType("fluoride_defaults", fluorideDefaultsFactory) 27 } 28 29 func fluorideDefaultsFactory() (blueprint.Module, []interface{}) { 30 module, props := cc.DefaultsFactory() 31 android.AddLoadHook(module, fluorideDefaults) 32 33 return module, props 34 } 35 36 func fluorideDefaults(ctx android.LoadHookContext) { 37 type props struct { 38 Include_dirs []string 39 Cflags []string 40 } 41 42 p := &props{} 43 p.Cflags, p.Include_dirs = globalDefaults(ctx) 44 45 ctx.AppendProperties(p) 46 } 47 48 func globalDefaults(ctx android.BaseContext) ([]string, []string) { 49 var cflags []string 50 var includeDirs []string 51 52 board_bt_buildcfg_include_dir := ctx.DeviceConfig().BtConfigIncludeDir() 53 if (len(board_bt_buildcfg_include_dir) > 0) { 54 cflags = append(cflags, "-DHAS_BDROID_BUILDCFG") 55 board_bt_buildcfg_include_dir_list := 56 strings.Fields(board_bt_buildcfg_include_dir) 57 for _, buildcfg_dir := range board_bt_buildcfg_include_dir_list { 58 includeDirs = append(includeDirs, buildcfg_dir) 59 } 60 } else { 61 cflags = append(cflags, "-DHAS_NO_BDROID_BUILDCFG") 62 } 63 64 return cflags, includeDirs 65 } 66