fluoride.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.
  14. package fluoride
  15. import (
  16. "strings"
  17. "android/soong/android"
  18. "android/soong/cc"
  19. )
  20. func init() {
  21. android.RegisterModuleType("fluoride_defaults", fluorideDefaultsFactory)
  22. }
  23. func fluorideDefaultsFactory() android.Module {
  24. module := cc.DefaultsFactory()
  25. android.AddLoadHook(module, fluorideDefaults)
  26. return module
  27. }
  28. func fluorideDefaults(ctx android.LoadHookContext) {
  29. type props struct {
  30. Include_dirs []string
  31. Cflags []string
  32. }
  33. p := &props{}
  34. p.Cflags, p.Include_dirs = globalDefaults(ctx)
  35. ctx.AppendProperties(p)
  36. }
  37. func globalDefaults(ctx android.BaseContext) ([]string, []string) {
  38. var cflags []string
  39. var includeDirs []string
  40. board_bt_buildcfg_include_dir := ctx.DeviceConfig().BtConfigIncludeDir()
  41. if len(board_bt_buildcfg_include_dir) > 0 {
  42. cflags = append(cflags, "-DHAS_BDROID_BUILDCFG")
  43. board_bt_buildcfg_include_dir_list :=
  44. strings.Fields(board_bt_buildcfg_include_dir)
  45. for _, buildcfg_dir := range board_bt_buildcfg_include_dir_list {
  46. includeDirs = append(includeDirs, buildcfg_dir)
  47. }
  48. } else {
  49. cflags = append(cflags, "-DHAS_NO_BDROID_BUILDCFG")
  50. }
  51. return cflags, includeDirs
  52. }