toolchain.gypi 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. {
  2. 'variables': {
  3. # Clang stuff.
  4. 'make_clang_dir%': 'vendor/llvm-build/Release+Asserts',
  5. # Set this to true when building with Clang.
  6. 'clang%': 1,
  7. # Set this to the absolute path to sccache when building with sccache
  8. 'cc_wrapper%': '',
  9. # Path to mips64el toolchain.
  10. 'make_mips64_dir%': 'vendor/gcc-4.8.3-d197-n64-loongson/usr',
  11. 'variables': {
  12. # The minimum macOS SDK version to use.
  13. 'mac_sdk_min%': '10.12',
  14. # Set ARM architecture version.
  15. 'arm_version%': 7,
  16. # Set NEON compilation flags.
  17. 'arm_neon%': 1,
  18. # Abosulte path to source root.
  19. 'source_root%': '<!(node <(DEPTH)/tools/atom_source_root.js)',
  20. },
  21. # Copy conditionally-set variables out one scope.
  22. 'mac_sdk_min%': '<(mac_sdk_min)',
  23. 'arm_version%': '<(arm_version)',
  24. 'arm_neon%': '<(arm_neon)',
  25. 'source_root%': '<(source_root)',
  26. # Variables to control Link-Time Optimization (LTO).
  27. 'use_lto%': 0,
  28. 'use_lto_o2%': 0,
  29. 'conditions': [
  30. # Do not use Clang on Windows or when building for mips64el.
  31. ['OS=="win" or target_arch=="mips64el"', {
  32. 'clang%': 0,
  33. }], # OS=="win"
  34. # Search for the available version of SDK.
  35. ['OS=="mac"', {
  36. 'mac_sdk%': '<!(python <(DEPTH)/tools/mac/find_sdk.py <(mac_sdk_min))',
  37. }],
  38. ['OS=="linux"', {
  39. 'variables': {
  40. # The system libdir used for this ABI.
  41. 'system_libdir%': 'lib',
  42. # Setting the path to sysroot.
  43. 'conditions': [
  44. ['target_arch=="arm"', {
  45. # sysroot needs to be an absolute path otherwise it generates
  46. # incorrect results when passed to pkg-config
  47. 'sysroot%': '<(source_root)/vendor/debian_stretch_arm-sysroot',
  48. }],
  49. ['target_arch=="arm64"', {
  50. 'sysroot%': '<(source_root)/vendor/debian_stretch_arm64-sysroot',
  51. }],
  52. ['target_arch=="ia32"', {
  53. 'sysroot%': '<(source_root)/vendor/debian_stretch_i386-sysroot',
  54. }],
  55. ['target_arch=="x64"', {
  56. 'sysroot%': '<(source_root)/vendor/debian_stretch_amd64-sysroot',
  57. }],
  58. ['target_arch=="mips64el"', {
  59. 'sysroot%': '<(source_root)/vendor/debian_jessie_mips64-sysroot',
  60. }],
  61. ],
  62. },
  63. # Copy conditionally-set variables out one scope.
  64. 'sysroot%': '<(sysroot)',
  65. 'system_libdir%': '<(system_libdir)',
  66. # Redirect pkg-config to search from sysroot.
  67. 'pkg-config%': '<(source_root)/tools/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)" "<(system_libdir)"',
  68. }],
  69. # Set default compiler flags depending on ARM version.
  70. ['arm_version==6', {
  71. 'arm_arch%': 'armv6',
  72. 'arm_tune%': '',
  73. 'arm_fpu%': 'vfp',
  74. 'arm_float_abi%': 'softfp',
  75. 'arm_thumb%': 0,
  76. }], # arm_version==6
  77. ['arm_version==7', {
  78. 'arm_arch%': 'armv7-a',
  79. 'arm_tune%': 'generic-armv7-a',
  80. 'conditions': [
  81. ['arm_neon==1', {
  82. 'arm_fpu%': 'neon',
  83. }, {
  84. 'arm_fpu%': 'vfpv3-d16',
  85. }],
  86. ],
  87. 'arm_float_abi%': 'hard',
  88. 'arm_thumb%': 1,
  89. }], # arm_version==7
  90. ],
  91. },
  92. 'conditions': [
  93. # Setup cc_wrapper
  94. ['cc_wrapper!=""', {
  95. 'make_global_settings': [
  96. ['CC_wrapper', '<(cc_wrapper)'],
  97. ['CXX_wrapper', '<(cc_wrapper)'],
  98. ['CC.host_wrapper', '<(cc_wrapper)'],
  99. ['CXX.host_wrapper', '<(cc_wrapper)']
  100. ],
  101. }],
  102. # Setup building with clang.
  103. ['clang==1', {
  104. 'make_global_settings': [
  105. ['CC', '<(make_clang_dir)/bin/clang'],
  106. ['CXX', '<(make_clang_dir)/bin/clang++'],
  107. ['CC.host', '$(CC)'],
  108. ['CXX.host', '$(CXX)'],
  109. ],
  110. 'target_defaults': {
  111. 'xcode_settings': {
  112. 'CC': '<(make_clang_dir)/bin/clang',
  113. 'LDPLUSPLUS': '<(make_clang_dir)/bin/clang++',
  114. 'OTHER_CFLAGS': [
  115. '-fcolor-diagnostics',
  116. ],
  117. 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
  118. 'CLANG_CXX_LIBRARY': 'libc++', # -stdlib=libc++
  119. 'CLANG_CXX_LANGUAGE_STANDARD': 'c++14', # -std=c++14
  120. },
  121. 'target_conditions': [
  122. ['_target_name in ["electron", "brightray"]', {
  123. 'conditions': [
  124. ['OS=="mac"', {
  125. 'xcode_settings': {
  126. 'OTHER_CFLAGS': [
  127. "-Xclang",
  128. "-load",
  129. "-Xclang",
  130. "<(source_root)/<(make_clang_dir)/lib/libFindBadConstructs.dylib",
  131. "-Xclang",
  132. "-add-plugin",
  133. "-Xclang",
  134. "find-bad-constructs",
  135. ],
  136. },
  137. }, { # OS=="mac"
  138. 'cflags_cc': [
  139. "-Xclang",
  140. "-load",
  141. "-Xclang",
  142. "<(source_root)/<(make_clang_dir)/lib/libFindBadConstructs.so",
  143. "-Xclang",
  144. "-add-plugin",
  145. "-Xclang",
  146. "find-bad-constructs",
  147. ],
  148. }],
  149. ],
  150. }],
  151. ['OS=="mac" and _type in ["executable", "shared_library"]', {
  152. 'xcode_settings': {
  153. # On some machines setting CLANG_CXX_LIBRARY doesn't work for
  154. # linker.
  155. 'OTHER_LDFLAGS': [ '-stdlib=libc++' ],
  156. },
  157. }],
  158. ['OS=="linux" and _toolset=="target"', {
  159. 'cflags_cc': [
  160. '-std=c++14',
  161. '-nostdinc++',
  162. '-isystem<(libchromiumcontent_src_dir)/buildtools/third_party/libc++/trunk/include',
  163. '-isystem<(libchromiumcontent_src_dir)/buildtools/third_party/libc++abi/trunk/include',
  164. ],
  165. 'ldflags': [
  166. '-nostdlib++',
  167. ],
  168. }],
  169. ['OS=="linux" and _toolset=="host"', {
  170. 'cflags_cc': [
  171. '-std=c++14',
  172. ],
  173. }],
  174. ],
  175. },
  176. }], # clang==1
  177. ['target_arch=="mips64el"', {
  178. 'make_global_settings': [
  179. ['CC', '<(make_mips64_dir)/bin/mips64el-redhat-linux-gcc'],
  180. ['CXX', '<(make_mips64_dir)/bin/mips64el-redhat-linux-g++'],
  181. ['CC.host', '$(CC)'],
  182. ['CXX.host', '$(CXX)'],
  183. ],
  184. 'target_defaults': {
  185. 'cflags_cc': [
  186. '-std=c++14',
  187. ],
  188. },
  189. }],
  190. # Specify the SDKROOT.
  191. ['OS=="mac"', {
  192. 'target_defaults': {
  193. 'xcode_settings': {
  194. 'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
  195. },
  196. },
  197. }],
  198. # Setup sysroot environment.
  199. ['OS=="linux" and target_arch in ["arm", "ia32", "x64", "arm64", "mips64el"]', {
  200. 'target_defaults': {
  201. 'target_conditions': [
  202. ['_toolset=="target"', {
  203. # Do not use 'cflags' to make sure sysroot is appended at last.
  204. 'cflags_cc': [
  205. '--sysroot=<(sysroot)',
  206. ],
  207. 'cflags_c': [
  208. '--sysroot=<(sysroot)',
  209. ],
  210. 'ldflags': [
  211. '--sysroot=<(sysroot)',
  212. '<!(<(source_root)/tools/linux/sysroot_ld_path.sh <(sysroot))',
  213. ],
  214. }]
  215. ],
  216. },
  217. }], # sysroot
  218. # Setup cross-compilation on Linux.
  219. ['OS=="linux"', {
  220. 'target_defaults': {
  221. 'target_conditions': [
  222. ['target_arch=="ia32" and _toolset=="target"', {
  223. 'asflags': [
  224. '-32',
  225. ],
  226. 'cflags': [
  227. '-msse2',
  228. '-mfpmath=sse',
  229. '-mmmx', # Allows mmintrin.h for MMX intrinsics.
  230. '-m32',
  231. ],
  232. 'ldflags': [
  233. '-m32',
  234. ],
  235. }], # target_arch=="ia32" and _toolset=="target"
  236. ['target_arch=="x64" and _toolset=="target"', {
  237. 'cflags': [
  238. '-m64',
  239. '-march=x86-64',
  240. ],
  241. 'ldflags': [
  242. '-m64',
  243. ],
  244. }], # target_arch=="x64" and _toolset=="target"
  245. ['target_arch=="arm" and _toolset=="target"', {
  246. 'conditions': [
  247. ['clang==0', {
  248. 'cflags_cc': [
  249. '-Wno-abi',
  250. ],
  251. }],
  252. ['clang==1 and arm_arch!=""', {
  253. 'cflags': [
  254. '-target arm-linux-gnueabihf',
  255. ],
  256. 'ldflags': [
  257. '-target arm-linux-gnueabihf',
  258. ],
  259. }],
  260. ['arm_arch!=""', {
  261. 'cflags': [
  262. '-march=<(arm_arch)',
  263. ],
  264. 'conditions': [
  265. ['use_lto==1 or use_lto_o2==1', {
  266. 'ldflags': [
  267. '-march=<(arm_arch)',
  268. ],
  269. }],
  270. ],
  271. }],
  272. ['arm_tune!=""', {
  273. 'cflags': [
  274. '-mtune=<(arm_tune)',
  275. ],
  276. 'conditions': [
  277. ['use_lto==1 or use_lto_o2==1', {
  278. 'ldflags': [
  279. '-mtune=<(arm_tune)',
  280. ],
  281. }],
  282. ],
  283. }],
  284. ['arm_fpu!=""', {
  285. 'cflags': [
  286. '-mfpu=<(arm_fpu)',
  287. ],
  288. 'conditions': [
  289. ['use_lto==1 or use_lto_o2==1', {
  290. 'ldflags': [
  291. '-mfpu=<(arm_fpu)',
  292. ],
  293. }],
  294. ],
  295. }],
  296. ['arm_float_abi!=""', {
  297. 'cflags': [
  298. '-mfloat-abi=<(arm_float_abi)',
  299. ],
  300. 'conditions': [
  301. ['use_lto==1 or use_lto_o2==1', {
  302. 'ldflags': [
  303. '-mfloat-abi=<(arm_float_abi)',
  304. ],
  305. }],
  306. ],
  307. }],
  308. ['arm_thumb==1', {
  309. 'cflags': [
  310. '-mthumb',
  311. ],
  312. 'conditions': [
  313. ['use_lto==1 or use_lto_o2==1', {
  314. 'ldflags': [
  315. '-mthumb',
  316. ],
  317. }],
  318. ],
  319. }],
  320. ],
  321. }], # target_arch=="arm64" and _toolset=="target"
  322. ['target_arch=="arm64" and _toolset=="target"', {
  323. 'conditions': [
  324. ['clang==0', {
  325. 'cflags_cc': [
  326. '-Wno-abi',
  327. ],
  328. }],
  329. ['clang==1 and arm_arch!=""', {
  330. 'cflags': [
  331. '-target aarch64-linux-gnu',
  332. ],
  333. 'ldflags': [
  334. '-target aarch64-linux-gnu',
  335. ],
  336. }],
  337. ],
  338. }], # target_arch=="arm" and _toolset=="target"
  339. ],
  340. },
  341. }], # OS=="linux"
  342. ],
  343. }