BUILDCONFIG.gn 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. is_skia_standalone = true
  6. # It's best to keep the names and defaults of is_foo flags consistent with Chrome.
  7. declare_args() {
  8. is_official_build = false
  9. is_component_build = false
  10. ndk = ""
  11. # Android 5.0, Lollipop
  12. ndk_api = 21
  13. sanitize = ""
  14. ar = "ar"
  15. cc = "cc"
  16. cxx = "c++"
  17. win_sdk = "C:/Program Files (x86)/Windows Kits/10"
  18. win_sdk_version = ""
  19. win_vc = ""
  20. win_toolchain_version = ""
  21. clang_win = ""
  22. skia_moltenvk_path = ""
  23. werror = false
  24. }
  25. declare_args() {
  26. is_debug = !is_official_build
  27. }
  28. assert(!(is_debug && is_official_build))
  29. if (target_cpu == "wasm") {
  30. target_os = "wasm"
  31. }
  32. # Platform detection
  33. if (target_os == "") {
  34. target_os = host_os
  35. if (ndk != "") {
  36. target_os = "android"
  37. }
  38. }
  39. if (current_os == "") {
  40. current_os = target_os
  41. }
  42. is_android = current_os == "android"
  43. is_fuchsia = current_os == "fuchsia"
  44. is_ios = current_os == "ios" || current_os == "tvos"
  45. is_tvos = current_os == "tvos"
  46. is_linux = current_os == "linux"
  47. is_mac = current_os == "mac"
  48. is_win = current_os == "win"
  49. if (target_cpu == "") {
  50. target_cpu = host_cpu
  51. if (is_android || is_ios) {
  52. target_cpu = "arm64"
  53. }
  54. }
  55. if (target_cpu == "x86_64") {
  56. target_cpu = "x64"
  57. }
  58. if (current_cpu == "") {
  59. current_cpu = target_cpu
  60. }
  61. is_clang = false
  62. if (is_android) {
  63. ndk_host = ""
  64. ndk_target = ""
  65. ndk_gdbserver = ""
  66. if (host_os == "linux") {
  67. ndk_host = "linux-x86_64"
  68. } else if (host_os == "mac") {
  69. ndk_host = "darwin-x86_64"
  70. } else if (host_os == "win") {
  71. ndk_host = "windows-x86_64"
  72. }
  73. if (target_cpu == "arm64") {
  74. ndk_target = "aarch64-linux-android"
  75. ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
  76. } else if (target_cpu == "arm") {
  77. ndk_target = "armv7a-linux-androideabi"
  78. ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
  79. } else if (target_cpu == "x64") {
  80. ndk_target = "x86_64-linux-android"
  81. ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
  82. } else if (target_cpu == "x86") {
  83. ndk_target = "i686-linux-android"
  84. ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
  85. }
  86. }
  87. if (target_os == "win") {
  88. # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a
  89. # non-default location, you can set win_vc to inform us where it is.
  90. if (win_vc == "") {
  91. win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
  92. }
  93. assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC directory.
  94. }
  95. if (target_os == "win") {
  96. if (win_toolchain_version == "") {
  97. win_toolchain_version = exec_script("//gn/highest_version_dir.py",
  98. [
  99. "$win_vc/Tools/MSVC",
  100. "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
  101. ],
  102. "trim string")
  103. }
  104. if (win_sdk_version == "") {
  105. win_sdk_version = exec_script("//gn/highest_version_dir.py",
  106. [
  107. "$win_sdk/Include",
  108. "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
  109. ],
  110. "trim string")
  111. }
  112. }
  113. # A component is either a static or a shared library.
  114. template("component") {
  115. _component_mode = "static_library"
  116. if (is_component_build) {
  117. _component_mode = "shared_library"
  118. }
  119. target(_component_mode, target_name) {
  120. forward_variables_from(invoker, "*")
  121. }
  122. }
  123. # Default configs
  124. default_configs = [
  125. "//gn:default",
  126. "//gn:no_exceptions",
  127. "//gn:no_rtti",
  128. ]
  129. if (!is_debug) {
  130. default_configs += [
  131. "//gn:optimize",
  132. "//gn:NDEBUG",
  133. ]
  134. }
  135. if (!is_official_build) {
  136. default_configs += [
  137. "//gn:debug_symbols",
  138. "//gn:warnings",
  139. ]
  140. }
  141. default_configs += [
  142. "//gn:warnings_except_public_headers",
  143. "//gn:extra_flags",
  144. ]
  145. if (sanitize == "MSVC") {
  146. default_configs += [ "//gn:msvc_rtc" ]
  147. }
  148. set_defaults("executable") {
  149. configs = [ "//gn:executable" ] + default_configs
  150. }
  151. set_defaults("source_set") {
  152. configs = default_configs
  153. }
  154. set_defaults("static_library") {
  155. configs = default_configs
  156. }
  157. set_defaults("shared_library") {
  158. configs = default_configs
  159. }
  160. set_defaults("component") {
  161. configs = default_configs
  162. if (!is_component_build) {
  163. complete_static_lib = true
  164. }
  165. }
  166. if (is_win) {
  167. # Windows tool chain
  168. set_default_toolchain("//gn/toolchain:msvc")
  169. default_toolchain_name = "msvc"
  170. host_toolchain = "msvc"
  171. } else {
  172. # GCC-like toolchains, including Clang.
  173. set_default_toolchain("//gn/toolchain:gcc_like")
  174. default_toolchain_name = "gcc_like"
  175. host_toolchain = "gcc_like_host"
  176. }