binding.gyp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. {
  2. 'conditions': [
  3. ['OS=="win"', {
  4. 'variables': {
  5. 'GTK_Root%': 'C:/GTK', # Set the location of GTK all-in-one bundle
  6. 'with_jpeg%': 'false',
  7. 'with_gif%': 'false',
  8. 'with_rsvg%': 'false',
  9. 'variables': { # Nest jpeg_root to evaluate it before with_jpeg
  10. 'jpeg_root%': '<!(node ./util/win_jpeg_lookup)'
  11. },
  12. 'jpeg_root%': '<(jpeg_root)', # Take value of nested variable
  13. 'conditions': [
  14. ['jpeg_root==""', {
  15. 'with_jpeg%': 'false'
  16. }, {
  17. 'with_jpeg%': 'true'
  18. }]
  19. ]
  20. }
  21. }, { # 'OS!="win"'
  22. 'variables': {
  23. 'with_jpeg%': '<!(node ./util/has_lib.js jpeg)',
  24. 'with_gif%': '<!(node ./util/has_lib.js gif)',
  25. 'with_rsvg%': '<!(node ./util/has_lib.js rsvg)'
  26. }
  27. }]
  28. ],
  29. 'targets': [
  30. {
  31. 'target_name': 'canvas-postbuild',
  32. 'dependencies': ['canvas'],
  33. 'conditions': [
  34. ['OS=="win"', {
  35. 'copies': [{
  36. 'destination': '<(PRODUCT_DIR)',
  37. 'files': [
  38. '<(GTK_Root)/bin/zlib1.dll',
  39. '<(GTK_Root)/bin/libintl-8.dll',
  40. '<(GTK_Root)/bin/libpng14-14.dll',
  41. '<(GTK_Root)/bin/libpangocairo-1.0-0.dll',
  42. '<(GTK_Root)/bin/libpango-1.0-0.dll',
  43. '<(GTK_Root)/bin/libpangoft2-1.0-0.dll',
  44. '<(GTK_Root)/bin/libpangowin32-1.0-0.dll',
  45. '<(GTK_Root)/bin/libcairo-2.dll',
  46. '<(GTK_Root)/bin/libfontconfig-1.dll',
  47. '<(GTK_Root)/bin/libfreetype-6.dll',
  48. '<(GTK_Root)/bin/libglib-2.0-0.dll',
  49. '<(GTK_Root)/bin/libgobject-2.0-0.dll',
  50. '<(GTK_Root)/bin/libgmodule-2.0-0.dll',
  51. '<(GTK_Root)/bin/libgthread-2.0-0.dll',
  52. '<(GTK_Root)/bin/libexpat-1.dll'
  53. ]
  54. }]
  55. }]
  56. ]
  57. },
  58. {
  59. 'target_name': 'canvas',
  60. 'include_dirs': ["<!(node -e \"require('nan')\")"],
  61. 'sources': [
  62. 'src/backend/Backend.cc',
  63. 'src/backend/ImageBackend.cc',
  64. 'src/backend/PdfBackend.cc',
  65. 'src/backend/SvgBackend.cc',
  66. 'src/bmp/BMPParser.cc',
  67. 'src/Backends.cc',
  68. 'src/Canvas.cc',
  69. 'src/CanvasGradient.cc',
  70. 'src/CanvasPattern.cc',
  71. 'src/CanvasRenderingContext2d.cc',
  72. 'src/closure.cc',
  73. 'src/color.cc',
  74. 'src/Image.cc',
  75. 'src/ImageData.cc',
  76. 'src/init.cc',
  77. 'src/register_font.cc'
  78. ],
  79. 'conditions': [
  80. ['OS=="win"', {
  81. 'libraries': [
  82. '-l<(GTK_Root)/lib/cairo.lib',
  83. '-l<(GTK_Root)/lib/libpng.lib',
  84. '-l<(GTK_Root)/lib/pangocairo-1.0.lib',
  85. '-l<(GTK_Root)/lib/pango-1.0.lib',
  86. '-l<(GTK_Root)/lib/freetype.lib',
  87. '-l<(GTK_Root)/lib/glib-2.0.lib',
  88. '-l<(GTK_Root)/lib/gobject-2.0.lib'
  89. ],
  90. 'include_dirs': [
  91. '<(GTK_Root)/include',
  92. '<(GTK_Root)/include/cairo',
  93. '<(GTK_Root)/include/pango-1.0',
  94. '<(GTK_Root)/include/glib-2.0',
  95. '<(GTK_Root)/include/freetype2',
  96. '<(GTK_Root)/lib/glib-2.0/include'
  97. ],
  98. 'defines': [
  99. '_USE_MATH_DEFINES', # for M_PI
  100. 'NOMINMAX' # allow std::min/max to work
  101. ],
  102. 'configurations': {
  103. 'Debug': {
  104. 'msvs_settings': {
  105. 'VCCLCompilerTool': {
  106. 'WarningLevel': 4,
  107. 'ExceptionHandling': 1,
  108. 'DisableSpecificWarnings': [
  109. 4100, 4611
  110. ]
  111. }
  112. }
  113. },
  114. 'Release': {
  115. 'msvs_settings': {
  116. 'VCCLCompilerTool': {
  117. 'WarningLevel': 4,
  118. 'ExceptionHandling': 1,
  119. 'DisableSpecificWarnings': [
  120. 4100, 4611
  121. ]
  122. }
  123. }
  124. }
  125. }
  126. }, { # 'OS!="win"'
  127. 'libraries': [
  128. '<!@(pkg-config pixman-1 --libs)',
  129. '<!@(pkg-config cairo --libs)',
  130. '<!@(pkg-config libpng --libs)',
  131. '<!@(pkg-config pangocairo --libs)',
  132. '<!@(pkg-config freetype2 --libs)'
  133. ],
  134. 'include_dirs': [
  135. '<!@(pkg-config cairo --cflags-only-I | sed s/-I//g)',
  136. '<!@(pkg-config libpng --cflags-only-I | sed s/-I//g)',
  137. '<!@(pkg-config pangocairo --cflags-only-I | sed s/-I//g)',
  138. '<!@(pkg-config freetype2 --cflags-only-I | sed s/-I//g)'
  139. ],
  140. 'cflags': ['-Wno-cast-function-type'],
  141. 'cflags!': ['-fno-exceptions'],
  142. 'cflags_cc!': ['-fno-exceptions']
  143. }],
  144. ['OS=="mac"', {
  145. 'xcode_settings': {
  146. 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
  147. }
  148. }],
  149. ['with_jpeg=="true"', {
  150. 'defines': [
  151. 'HAVE_JPEG'
  152. ],
  153. 'conditions': [
  154. ['OS=="win"', {
  155. 'copies': [{
  156. 'destination': '<(PRODUCT_DIR)',
  157. 'files': [
  158. '<(jpeg_root)/bin/jpeg62.dll',
  159. ]
  160. }],
  161. 'include_dirs': [
  162. '<(jpeg_root)/include'
  163. ],
  164. 'libraries': [
  165. '-l<(jpeg_root)/lib/jpeg.lib',
  166. ]
  167. }, {
  168. 'include_dirs': [
  169. '<!@(pkg-config libjpeg --cflags-only-I | sed s/-I//g)'
  170. ],
  171. 'libraries': [
  172. '<!@(pkg-config libjpeg --libs)'
  173. ]
  174. }]
  175. ]
  176. }],
  177. ['with_gif=="true"', {
  178. 'defines': [
  179. 'HAVE_GIF'
  180. ],
  181. 'conditions': [
  182. ['OS=="win"', {
  183. 'libraries': [
  184. '-l<(GTK_Root)/lib/gif.lib'
  185. ]
  186. }, {
  187. 'include_dirs': [
  188. '/opt/homebrew/include'
  189. ],
  190. 'libraries': [
  191. '-L/opt/homebrew/lib',
  192. '-lgif'
  193. ]
  194. }]
  195. ]
  196. }],
  197. ['with_rsvg=="true"', {
  198. 'defines': [
  199. 'HAVE_RSVG'
  200. ],
  201. 'conditions': [
  202. ['OS=="win"', {
  203. 'copies': [{
  204. 'destination': '<(PRODUCT_DIR)',
  205. 'files': [
  206. '<(GTK_Root)/bin/librsvg-2-2.dll',
  207. '<(GTK_Root)/bin/libgdk_pixbuf-2.0-0.dll',
  208. '<(GTK_Root)/bin/libgio-2.0-0.dll',
  209. '<(GTK_Root)/bin/libcroco-0.6-3.dll',
  210. '<(GTK_Root)/bin/libgsf-1-114.dll',
  211. '<(GTK_Root)/bin/libxml2-2.dll'
  212. ]
  213. }],
  214. 'libraries': [
  215. '-l<(GTK_Root)/lib/librsvg-2-2.lib'
  216. ]
  217. }, {
  218. 'include_dirs': [
  219. '<!@(pkg-config librsvg-2.0 --cflags-only-I | sed s/-I//g)'
  220. ],
  221. 'libraries': [
  222. '<!@(pkg-config librsvg-2.0 --libs)'
  223. ]
  224. }]
  225. ]
  226. }]
  227. ]
  228. }
  229. ]
  230. }