blob: c96d5fe0aac23161b225c3c3cf7ff2fdbfcb0f3c [file] [log] [blame]
Jack Hee2eeff42016-12-07 18:25:17 -08001// 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.
14package fluoride
15
16import (
Jack Hea643b5b2017-01-18 17:14:08 -080017 "strings"
18
Jack Hee2eeff42016-12-07 18:25:17 -080019 "android/soong/android"
20 "android/soong/cc"
21
22 "github.com/google/blueprint"
23)
24
25func init() {
26 android.RegisterModuleType("fluoride_defaults", fluorideDefaultsFactory)
27}
28
29func fluorideDefaultsFactory() (blueprint.Module, []interface{}) {
30 module, props := cc.DefaultsFactory()
31 android.AddLoadHook(module, fluorideDefaults)
32
33 return module, props
34}
35
36func 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
48func 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")
Jack Hea643b5b2017-01-18 17:14:08 -080055 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 }
Jack Hee2eeff42016-12-07 18:25:17 -080060 } else {
61 cflags = append(cflags, "-DHAS_NO_BDROID_BUILDCFG")
62 }
63
Jack Hee2eeff42016-12-07 18:25:17 -080064 return cflags, includeDirs
65}