toolchain.gypi 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. 'variables': {
  8. # The minimum macOS SDK version to use.
  9. 'mac_sdk_min%': '10.10',
  10. # Set ARM architecture version.
  11. 'arm_version%': 7,
  12. # Set NEON compilation flags.
  13. 'arm_neon%': 1,
  14. # Abosulte path to source root.
  15. 'source_root%': '<!(node <(DEPTH)/tools/atom_source_root.js)',
  16. },
  17. # Copy conditionally-set variables out one scope.
  18. 'mac_sdk_min%': '<(mac_sdk_min)',
  19. 'arm_version%': '<(arm_version)',
  20. 'arm_neon%': '<(arm_neon)',
  21. 'source_root%': '<(source_root)',
  22. # Variables to control Link-Time Optimization (LTO).
  23. 'use_lto%': 0,
  24. 'use_lto_o2%': 0,
  25. 'conditions': [
  26. # Do not use Clang on Windows.
  27. ['OS=="win"', {
  28. 'clang%': 0,
  29. }], # OS=="win"
  30. # Search for the available version of SDK.
  31. ['OS=="mac"', {
  32. 'mac_sdk%': '<!(python <(DEPTH)/tools/mac/find_sdk.py <(mac_sdk_min))',
  33. }],
  34. ['OS=="linux"', {
  35. 'variables': {
  36. # The system libdir used for this ABI.
  37. 'system_libdir%': 'lib',
  38. # Setting the path to sysroot.
  39. 'conditions': [
  40. ['target_arch=="arm"', {
  41. # sysroot needs to be an absolute path otherwise it generates
  42. # incorrect results when passed to pkg-config
  43. 'sysroot%': '<(source_root)/vendor/debian_wheezy_arm-sysroot',
  44. }],
  45. ['target_arch=="ia32"', {
  46. 'sysroot%': '<(source_root)/vendor/debian_wheezy_i386-sysroot',
  47. }],
  48. ['target_arch=="x64"', {
  49. 'sysroot%': '<(source_root)/vendor/debian_wheezy_amd64-sysroot',
  50. }],
  51. ],
  52. },
  53. # Copy conditionally-set variables out one scope.
  54. 'sysroot%': '<(sysroot)',
  55. 'system_libdir%': '<(system_libdir)',
  56. # Redirect pkg-config to search from sysroot.
  57. 'pkg-config%': '<(source_root)/tools/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)" "<(system_libdir)"',
  58. }],
  59. # Set default compiler flags depending on ARM version.
  60. ['arm_version==6', {
  61. 'arm_arch%': 'armv6',
  62. 'arm_tune%': '',
  63. 'arm_fpu%': 'vfp',
  64. 'arm_float_abi%': 'softfp',
  65. 'arm_thumb%': 0,
  66. }], # arm_version==6
  67. ['arm_version==7', {
  68. 'arm_arch%': 'armv7-a',
  69. 'arm_tune%': 'generic-armv7-a',
  70. 'conditions': [
  71. ['arm_neon==1', {
  72. 'arm_fpu%': 'neon',
  73. }, {
  74. 'arm_fpu%': 'vfpv3-d16',
  75. }],
  76. ],
  77. 'arm_float_abi%': 'hard',
  78. 'arm_thumb%': 1,
  79. }], # arm_version==7
  80. ],
  81. },
  82. 'conditions': [
  83. # Setup building with clang.
  84. ['clang==1', {
  85. 'make_global_settings': [
  86. ['CC', '<(make_clang_dir)/bin/clang'],
  87. ['CXX', '<(make_clang_dir)/bin/clang++'],
  88. ['CC.host', '$(CC)'],
  89. ['CXX.host', '$(CXX)'],
  90. ],
  91. 'target_defaults': {
  92. 'cflags_cc': [
  93. '-std=c++11',
  94. ],
  95. 'xcode_settings': {
  96. 'CC': '<(make_clang_dir)/bin/clang',
  97. 'LDPLUSPLUS': '<(make_clang_dir)/bin/clang++',
  98. 'OTHER_CFLAGS': [
  99. '-fcolor-diagnostics',
  100. ],
  101. 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
  102. 'CLANG_CXX_LIBRARY': 'libc++', # -stdlib=libc++
  103. 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', # -std=c++11
  104. },
  105. 'target_conditions': [
  106. ['_type in ["executable", "shared_library"]', {
  107. 'xcode_settings': {
  108. # On some machines setting CLANG_CXX_LIBRARY doesn't work for
  109. # linker.
  110. 'OTHER_LDFLAGS': [ '-stdlib=libc++' ],
  111. },
  112. }],
  113. ],
  114. },
  115. }], # clang==1
  116. # Specify the SDKROOT.
  117. ['OS=="mac"', {
  118. 'target_defaults': {
  119. 'xcode_settings': {
  120. 'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
  121. },
  122. },
  123. }],
  124. # Setup sysroot environment.
  125. ['OS=="linux" and target_arch in ["arm", "ia32", "x64"]', {
  126. 'target_defaults': {
  127. 'target_conditions': [
  128. ['_toolset=="target"', {
  129. 'cflags': [
  130. '--sysroot=<(sysroot)',
  131. ],
  132. 'ldflags': [
  133. '--sysroot=<(sysroot)',
  134. '<!(<(source_root)/tools/linux/sysroot_ld_path.sh <(sysroot))',
  135. ],
  136. }]
  137. ],
  138. },
  139. }], # sysroot
  140. # Setup cross-compilation on Linux.
  141. ['OS=="linux"', {
  142. 'target_defaults': {
  143. 'target_conditions': [
  144. ['target_arch=="ia32" and _toolset=="target"', {
  145. 'asflags': [
  146. '-32',
  147. ],
  148. 'cflags': [
  149. '-msse2',
  150. '-mfpmath=sse',
  151. '-mmmx', # Allows mmintrin.h for MMX intrinsics.
  152. '-m32',
  153. ],
  154. 'ldflags': [
  155. '-m32',
  156. ],
  157. }], # target_arch=="ia32" and _toolset=="target"
  158. ['target_arch=="x64" and _toolset=="target"', {
  159. 'cflags': [
  160. '-m64',
  161. '-march=x86-64',
  162. ],
  163. 'ldflags': [
  164. '-m64',
  165. ],
  166. }], # target_arch=="x64" and _toolset=="target"
  167. ['target_arch=="arm" and _toolset=="target"', {
  168. 'conditions': [
  169. ['clang==0', {
  170. 'cflags_cc': [
  171. '-Wno-abi',
  172. ],
  173. }],
  174. ['clang==1 and arm_arch!=""', {
  175. 'cflags': [
  176. '-target arm-linux-gnueabihf',
  177. ],
  178. 'ldflags': [
  179. '-target arm-linux-gnueabihf',
  180. ],
  181. }],
  182. ['arm_arch!=""', {
  183. 'cflags': [
  184. '-march=<(arm_arch)',
  185. ],
  186. 'conditions': [
  187. ['use_lto==1 or use_lto_o2==1', {
  188. 'ldflags': [
  189. '-march=<(arm_arch)',
  190. ],
  191. }],
  192. ],
  193. }],
  194. ['arm_tune!=""', {
  195. 'cflags': [
  196. '-mtune=<(arm_tune)',
  197. ],
  198. 'conditions': [
  199. ['use_lto==1 or use_lto_o2==1', {
  200. 'ldflags': [
  201. '-mtune=<(arm_tune)',
  202. ],
  203. }],
  204. ],
  205. }],
  206. ['arm_fpu!=""', {
  207. 'cflags': [
  208. '-mfpu=<(arm_fpu)',
  209. ],
  210. 'conditions': [
  211. ['use_lto==1 or use_lto_o2==1', {
  212. 'ldflags': [
  213. '-mfpu=<(arm_fpu)',
  214. ],
  215. }],
  216. ],
  217. }],
  218. ['arm_float_abi!=""', {
  219. 'cflags': [
  220. '-mfloat-abi=<(arm_float_abi)',
  221. ],
  222. 'conditions': [
  223. ['use_lto==1 or use_lto_o2==1', {
  224. 'ldflags': [
  225. '-mfloat-abi=<(arm_float_abi)',
  226. ],
  227. }],
  228. ],
  229. }],
  230. ['arm_thumb==1', {
  231. 'cflags': [
  232. '-mthumb',
  233. ],
  234. 'conditions': [
  235. ['use_lto==1 or use_lto_o2==1', {
  236. 'ldflags': [
  237. '-mthumb',
  238. ],
  239. }],
  240. ],
  241. }],
  242. ],
  243. }], # target_arch=="arm" and _toolset=="target"
  244. ],
  245. },
  246. }], # OS=="linux"
  247. ],
  248. }