third_party.gni 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright 2016 Google Inc.
  2. #
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. template("third_party") {
  6. enabled = !defined(invoker.enabled) || invoker.enabled
  7. config(target_name + "_public") {
  8. if (enabled) {
  9. cflags = []
  10. if (defined(invoker.public_defines)) {
  11. defines = invoker.public_defines
  12. }
  13. if (is_win) {
  14. include_dirs = invoker.public_include_dirs
  15. if (is_clang) {
  16. foreach(dir, invoker.public_include_dirs) {
  17. cflags += [
  18. "/imsvc",
  19. rebase_path(dir),
  20. ]
  21. }
  22. }
  23. } else {
  24. foreach(dir, invoker.public_include_dirs) {
  25. if (werror) {
  26. cflags += [
  27. "-isystem",
  28. rebase_path(dir),
  29. ]
  30. } else {
  31. cflags += [
  32. "-I",
  33. rebase_path(dir),
  34. ]
  35. }
  36. }
  37. }
  38. } else {
  39. not_needed(invoker, "*")
  40. }
  41. }
  42. # You can't make a static_library() without object files to archive,
  43. # but we can treat targets without object files as a source_set().
  44. if (defined(invoker.sources)) {
  45. _mode = "static_library"
  46. } else {
  47. _mode = "source_set"
  48. }
  49. target(_mode, target_name) {
  50. if (enabled) {
  51. forward_variables_from(invoker, "*", [ "public_include_dirs" ])
  52. public_configs = [ ":" + target_name + "_public" ]
  53. # Warnings are just noise if we're not maintaining the code.
  54. if (is_win) {
  55. cflags = [ "/w" ]
  56. } else {
  57. cflags = [ "-w" ]
  58. }
  59. }
  60. }
  61. }
  62. set_defaults("third_party") {
  63. configs = default_configs
  64. if (!is_official_build) {
  65. # Official builds don't have warnings to begin with.
  66. configs -= [ "//gn:warnings" ]
  67. }
  68. # Don't want to to deal with this (especially /RTCc)
  69. if (sanitize == "MSVC") {
  70. configs -= [ "//gn:msvc_rtc" ]
  71. }
  72. if (is_debug) {
  73. configs += [ "//gn:optimize" ]
  74. }
  75. }
  76. template("system") {
  77. config(target_name + "_public") {
  78. forward_variables_from(invoker, "*", [])
  79. }
  80. group(target_name) {
  81. public_configs = [ ":" + target_name + "_public" ]
  82. }
  83. }