blob: 6a511a53a98fa778088dc90538054f6ac36ef8f9 [file] [log] [blame]
Jakub Pawlowski5b790fe2017-09-18 09:00:20 -07001// Copyright 2016 The Android Open Source Project
Jack Hee2eeff42016-12-07 18:25:17 -08002//
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.
14package fluoride
15
16import (
Colin Cross2cf6e712017-06-27 11:15:25 -070017 "strings"
Jack Hea643b5b2017-01-18 17:14:08 -080018
Colin Cross2cf6e712017-06-27 11:15:25 -070019 "android/soong/android"
20 "android/soong/cc"
Jack Hee2eeff42016-12-07 18:25:17 -080021)
22
23func init() {
Colin Cross2cf6e712017-06-27 11:15:25 -070024 android.RegisterModuleType("fluoride_defaults", fluorideDefaultsFactory)
Jack Hee2eeff42016-12-07 18:25:17 -080025}
26
Colin Cross5e7f1a32017-06-27 11:05:21 -070027func fluorideDefaultsFactory() android.Module {
28 module := cc.DefaultsFactory()
Colin Cross2cf6e712017-06-27 11:15:25 -070029 android.AddLoadHook(module, fluorideDefaults)
Jack Hee2eeff42016-12-07 18:25:17 -080030
Colin Cross5e7f1a32017-06-27 11:05:21 -070031 return module
Jack Hee2eeff42016-12-07 18:25:17 -080032}
33
34func fluorideDefaults(ctx android.LoadHookContext) {
Colin Cross2cf6e712017-06-27 11:15:25 -070035 type props struct {
36 Include_dirs []string
37 Cflags []string
38 }
Jack Hee2eeff42016-12-07 18:25:17 -080039
Colin Cross2cf6e712017-06-27 11:15:25 -070040 p := &props{}
41 p.Cflags, p.Include_dirs = globalDefaults(ctx)
Jack Hee2eeff42016-12-07 18:25:17 -080042
Colin Cross2cf6e712017-06-27 11:15:25 -070043 ctx.AppendProperties(p)
Jack Hee2eeff42016-12-07 18:25:17 -080044}
45
46func globalDefaults(ctx android.BaseContext) ([]string, []string) {
Colin Cross2cf6e712017-06-27 11:15:25 -070047 var cflags []string
48 var includeDirs []string
Jack Hee2eeff42016-12-07 18:25:17 -080049
Colin Cross2cf6e712017-06-27 11:15:25 -070050 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 Hee2eeff42016-12-07 18:25:17 -080061
Colin Cross2cf6e712017-06-27 11:15:25 -070062 return cflags, includeDirs
Jack Hee2eeff42016-12-07 18:25:17 -080063}