• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 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 (
17	"strings"
18
19	"android/soong/android"
20	"android/soong/cc"
21)
22
23func init() {
24	android.RegisterModuleType("fluoride_defaults", fluorideDefaultsFactory)
25}
26
27func fluorideDefaultsFactory() android.Module {
28	module := cc.DefaultsFactory()
29	android.AddLoadHook(module, fluorideDefaults)
30
31	return module
32}
33
34func fluorideDefaults(ctx android.LoadHookContext) {
35	type props struct {
36		Include_dirs []string
37		Cflags       []string
38	}
39
40	p := &props{}
41	p.Cflags, p.Include_dirs = globalDefaults(ctx)
42
43	ctx.AppendProperties(p)
44}
45
46func globalDefaults(ctx android.BaseContext) ([]string, []string) {
47	var cflags []string
48	var includeDirs []string
49
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	}
61
62	return cflags, includeDirs
63}
64