Skip to content

Commit c65bfb9

Browse files
committed
Static build
Extracted code for static build from #571 to make it easier to review and approve. It's a squashed version with the final code, for references on the development history and commit logs go to the original issue.
1 parent 5812a8d commit c65bfb9

29 files changed

+2190
-177
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ out.pdf
1010
out.svg
1111
.pomo
1212
node_modules
13+
deps/
14+
npm-debug.log
1315

1416
# Vim cruft
1517
*.swp

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ benchmarks
44
examples
55
support
66
test
7+
deps

binding.gyp

100755100644
Lines changed: 11 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,16 @@
11
{
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': [
2+
'variables':
213
{
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-
]
4+
'has_cairo%': '<!(./util/has_lib.sh cairo)'
395
},
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-
]
6+
'conditions':
7+
[
8+
['has_cairo=="true"',
9+
{
10+
'includes': ['shared.gyp']
11+
},
12+
{
13+
'includes': ['static.gyp']
16614
}]
167-
]
168-
}
169-
]
15+
]
17016
}

canvas.gypi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
'target_name': 'canvas',
3+
'include_dirs': ["<!(node -e \"require('nan')\")"],
4+
'sources':
5+
[
6+
'src/Canvas.cc',
7+
'src/CanvasGradient.cc',
8+
'src/CanvasPattern.cc',
9+
'src/CanvasRenderingContext2d.cc',
10+
'src/color.cc',
11+
'src/Image.cc',
12+
'src/ImageData.cc',
13+
'src/init.cc',
14+
],
15+
'cflags!': ['-fno-exceptions'],
16+
'cflags_cc!': ['-fno-exceptions']
17+
}

shared.gyp

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

src/CanvasRenderingContext2d.cc

100755100644
File mode changed.

src/FontFace.cc

100755100644
File mode changed.

src/init.cc

100755100644
File mode changed.

0 commit comments

Comments
 (0)