binding.gyp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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_pango%': 'false',
  9. 'with_freetype%': 'false'
  10. }
  11. }, { # 'OS!="win"'
  12. 'variables': {
  13. 'with_jpeg%': '<!(./util/has_lib.sh jpeg)',
  14. 'with_gif%': '<!(./util/has_lib.sh gif)',
  15. 'with_pango%': '<!(./util/has_lib.sh pango)',
  16. 'with_freetype%': '<!(./util/has_lib.sh freetype)'
  17. }
  18. }]
  19. ],
  20. 'targets': [
  21. {
  22. 'target_name': 'canvas-postbuild',
  23. 'dependencies': ['canvas'],
  24. 'conditions': [
  25. ['OS=="win"', {
  26. 'copies': [{
  27. 'destination': '<(PRODUCT_DIR)',
  28. 'files': [
  29. '<(GTK_Root)/bin/libcairo-2.dll',
  30. '<(GTK_Root)/bin/libexpat-1.dll',
  31. '<(GTK_Root)/bin/libfontconfig-1.dll',
  32. '<(GTK_Root)/bin/libfreetype-6.dll',
  33. '<(GTK_Root)/bin/libpng14-14.dll',
  34. '<(GTK_Root)/bin/zlib1.dll',
  35. ]
  36. }]
  37. }]
  38. ]
  39. },
  40. {
  41. 'target_name': 'canvas',
  42. 'include_dirs': ["<!(node -e \"require('nan')\")"],
  43. 'sources': [
  44. 'src/Canvas.cc',
  45. 'src/CanvasGradient.cc',
  46. 'src/CanvasPattern.cc',
  47. 'src/CanvasRenderingContext2d.cc',
  48. 'src/color.cc',
  49. 'src/Image.cc',
  50. 'src/ImageData.cc',
  51. 'src/init.cc'
  52. ],
  53. 'conditions': [
  54. ['OS=="win"', {
  55. 'libraries': [
  56. '-l<(GTK_Root)/lib/cairo.lib',
  57. '-l<(GTK_Root)/lib/libpng.lib'
  58. ],
  59. 'include_dirs': [
  60. '<(GTK_Root)/include',
  61. '<(GTK_Root)/include/cairo',
  62. ],
  63. 'defines': [
  64. '_USE_MATH_DEFINES' # for M_PI
  65. ],
  66. 'configurations': {
  67. 'Debug': {
  68. 'msvs_settings': {
  69. 'VCCLCompilerTool': {
  70. 'WarningLevel': 4,
  71. 'ExceptionHandling': 1,
  72. 'DisableSpecificWarnings': [4100, 4127, 4201, 4244, 4267, 4506, 4611, 4714, 4512]
  73. }
  74. }
  75. },
  76. 'Release': {
  77. 'msvs_settings': {
  78. 'VCCLCompilerTool': {
  79. 'WarningLevel': 4,
  80. 'ExceptionHandling': 1,
  81. 'DisableSpecificWarnings': [4100, 4127, 4201, 4244, 4267, 4506, 4611, 4714, 4512]
  82. }
  83. }
  84. }
  85. }
  86. }, { # 'OS!="win"'
  87. 'libraries': [
  88. '<!@(pkg-config pixman-1 --libs)',
  89. '<!@(pkg-config cairo --libs)',
  90. '<!@(pkg-config libpng --libs)'
  91. ],
  92. 'include_dirs': [
  93. '<!@(pkg-config cairo --cflags-only-I | sed s/-I//g)',
  94. '<!@(pkg-config libpng --cflags-only-I | sed s/-I//g)'
  95. ]
  96. }],
  97. ['with_freetype=="true"', {
  98. 'defines': [
  99. 'HAVE_FREETYPE'
  100. ],
  101. 'sources': [
  102. 'src/FontFace.cc'
  103. ],
  104. 'conditions': [
  105. ['OS=="win"', {
  106. # No support for windows right now.
  107. }, { # 'OS!="win"'
  108. 'include_dirs': [ # tried to pass through cflags but failed.
  109. # Need to include the header files of cairo AND freetype.
  110. # Looking up the includes of cairo does both.
  111. '<!@(pkg-config cairo --cflags-only-I | sed s/-I//g)'
  112. ]
  113. }]
  114. ]
  115. }],
  116. ['with_pango=="true"', {
  117. 'defines': [
  118. 'HAVE_PANGO'
  119. ],
  120. 'conditions': [
  121. ['OS=="win"', {
  122. 'libraries': [
  123. '-l<(GTK_Root)/lib/pangocairo.lib'
  124. ]
  125. }, { # 'OS!="win"'
  126. 'include_dirs': [ # tried to pass through cflags but failed
  127. '<!@(pkg-config pangocairo --cflags-only-I | sed s/-I//g)'
  128. ],
  129. 'libraries': [
  130. '<!@(pkg-config pangocairo --libs)'
  131. ]
  132. }]
  133. ]
  134. }],
  135. ['with_jpeg=="true"', {
  136. 'defines': [
  137. 'HAVE_JPEG'
  138. ],
  139. 'conditions': [
  140. ['OS=="win"', {
  141. 'libraries': [
  142. '-l<(GTK_Root)/lib/jpeg.lib'
  143. ]
  144. }, {
  145. 'libraries': [
  146. '-ljpeg'
  147. ]
  148. }]
  149. ]
  150. }],
  151. ['with_gif=="true"', {
  152. 'defines': [
  153. 'HAVE_GIF'
  154. ],
  155. 'conditions': [
  156. ['OS=="win"', {
  157. 'libraries': [
  158. '-l<(GTK_Root)/lib/gif.lib'
  159. ]
  160. }, {
  161. 'libraries': [
  162. '-lgif'
  163. ]
  164. }]
  165. ]
  166. }]
  167. ]
  168. }
  169. ]
  170. }