Initial Implementation of Node prelaunch
[platform/framework/web/crosswalk-tizen.git] / electron.gyp
1 {
2   'variables': {
3     'project_name%': 'electron',
4     'product_name%': 'Electron',
5     'company_name%': 'GitHub, Inc',
6     'company_abbr%': 'github',
7     'version%': '1.6.7',
8     'js2c_input_dir': '<(SHARED_INTERMEDIATE_DIR)/js2c',
9   },
10   'includes': [
11     'filenames.gypi',
12     'vendor/native_mate/native_mate_files.gypi',
13   ],
14   'target_defaults': {
15     'defines': [
16       'ATOM_PRODUCT_NAME="<(product_name)"',
17       'ATOM_PROJECT_NAME="<(project_name)"',
18     ],
19     'conditions': [
20       ['OS=="mac"', {
21         'mac_framework_dirs': [
22           '<(source_root)/external_binaries',
23         ],
24       }],
25     ],
26   },
27   'targets': [
28     {
29       'target_name': '<(project_name)',
30       'type': 'executable',
31       'dependencies': [
32         'js2asar',
33         'app2asar',
34         '<(project_name)_lib',
35       ],
36       'sources': [
37         '<@(app_sources)',
38       ],
39       'include_dirs': [
40         '.',
41       ],
42       'conditions': [
43         ['OS=="mac"', {
44           'product_name': '<(product_name)',
45           'mac_bundle': 1,
46           'dependencies!': [
47             '<(project_name)_lib',
48           ],
49           'dependencies': [
50             '<(project_name)_framework',
51             '<(project_name)_helper',
52           ],
53           'xcode_settings': {
54             'ATOM_BUNDLE_ID': 'com.<(company_abbr).<(project_name)',
55             'INFOPLIST_FILE': 'atom/browser/resources/mac/Info.plist',
56             'LD_RUNPATH_SEARCH_PATHS': [
57               '@executable_path/../Frameworks',
58             ],
59           },
60           'mac_bundle_resources': [
61             '<@(bundle_sources)',
62           ],
63           'copies': [
64             {
65               'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Frameworks',
66               'files': [
67                 '<(PRODUCT_DIR)/<(product_name) Helper.app',
68                 '<(PRODUCT_DIR)/<(product_name) Framework.framework',
69               ],
70             },
71           ],
72           'postbuilds': [
73             {
74               # This postbuid step is responsible for creating the following
75               # helpers:
76               #
77               # <(product_name) EH.app and <(product_name) NP.app are created
78               # from <(product_name).app.
79               #
80               # The EH helper is marked for an executable heap. The NP helper
81               # is marked for no PIE (ASLR).
82               'postbuild_name': 'Make More Helpers',
83               'action': [
84                 'vendor/brightray/tools/mac/make_more_helpers.sh',
85                 'Frameworks',
86                 '<(product_name)',
87               ],
88             },
89               # The application doesn't have real localizations, it just has
90               # empty .lproj directories, which is enough to convince Cocoa
91               # that Electron supports those languages.
92             {
93               'postbuild_name': 'Make Empty Localizations',
94               'variables': {
95                 'apply_locales_cmd': ['python', 'tools/mac/apply_locales.py'],
96                 'locale_dirs': [
97                   '>!@(<(apply_locales_cmd) -d ZZLOCALE.lproj <(locales))',
98                 ],
99               },
100               'action': [
101                 'tools/mac/make_locale_dirs.sh',
102                 '<@(locale_dirs)',
103               ],
104             },
105           ],
106           'conditions': [
107             ['mas_build==0', {
108               'copies': [
109                 {
110                   'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Frameworks',
111                   'files': [
112                     'external_binaries/Squirrel.framework',
113                     'external_binaries/ReactiveCocoa.framework',
114                     'external_binaries/Mantle.framework',
115                   ],
116                 },
117               ],
118             }],
119           ],
120         }],  # OS!="mac"
121         ['OS=="win"', {
122           'include_dirs': [
123             '<(libchromiumcontent_dir)/gen/ui/resources',
124           ],
125           'msvs_settings': {
126             'VCManifestTool': {
127               'EmbedManifest': 'true',
128               'AdditionalManifestFiles': 'atom/browser/resources/win/atom.manifest',
129             },
130             'VCLinkerTool': {
131               # Chrome builds with this minimum environment which makes e.g.
132               # GetSystemMetrics(SM_CXSIZEFRAME) return Windows XP/2003
133               # compatible metrics. See: https://crbug.com/361720
134               #
135               # The following two settings translate to a linker flag
136               # of /SUBSYSTEM:WINDOWS,5.02
137               'MinimumRequiredVersion': '5.02',
138               'SubSystem': '2',
139             },
140           },
141           'copies': [
142             {
143               'variables': {
144                 'conditions': [
145                   ['libchromiumcontent_component', {
146                     'copied_libraries': [
147                       '<@(libchromiumcontent_shared_libraries)',
148                       '<@(libchromiumcontent_shared_v8_libraries)',
149                     ],
150                   }, {
151                     'copied_libraries': [
152                       '<(libchromiumcontent_dir)/ffmpeg.dll',
153                     ],
154                   }],
155                 ],
156               },
157               'destination': '<(PRODUCT_DIR)',
158               'files': [
159                 '<@(copied_libraries)',
160                 '<(libchromiumcontent_dir)/locales',
161                 '<(libchromiumcontent_dir)/libEGL.dll',
162                 '<(libchromiumcontent_dir)/libGLESv2.dll',
163                 '<(libchromiumcontent_dir)/icudtl.dat',
164                 '<(libchromiumcontent_dir)/blink_image_resources_200_percent.pak',
165                 '<(libchromiumcontent_dir)/content_resources_200_percent.pak',
166                 '<(libchromiumcontent_dir)/content_shell.pak',
167                 '<(libchromiumcontent_dir)/ui_resources_200_percent.pak',
168                 '<(libchromiumcontent_dir)/views_resources_200_percent.pak',
169                 '<(libchromiumcontent_dir)/natives_blob.bin',
170                 '<(libchromiumcontent_dir)/snapshot_blob.bin',
171                 'external_binaries/d3dcompiler_47.dll',
172               ],
173             },
174           ],
175         }, {
176           'dependencies': [
177             'vendor/breakpad/breakpad.gyp:dump_syms#host',
178           ],
179         }],  # OS=="win"
180         ['OS=="linux"', {
181           'copies': [
182             {
183               'variables': {
184                 'conditions': [
185                   ['libchromiumcontent_component', {
186                     'copied_libraries': [
187                       '<(PRODUCT_DIR)/lib/libnode.so',
188                       '<@(libchromiumcontent_shared_libraries)',
189                       '<@(libchromiumcontent_shared_v8_libraries)',
190                     ],
191                   }, {
192                     'copied_libraries': [
193                       '<(PRODUCT_DIR)/lib/libnode.so',
194                       '<(libchromiumcontent_dir)/libffmpeg.so',
195                     ],
196                   }],
197                 ],
198               },
199               'destination': '<(PRODUCT_DIR)',
200               'files': [
201                 '<@(copied_libraries)',
202                 '<(libchromiumcontent_dir)/locales',
203                 '<(libchromiumcontent_dir)/icudtl.dat',
204                 '<(libchromiumcontent_dir)/blink_image_resources_200_percent.pak',
205                 '<(libchromiumcontent_dir)/content_resources_200_percent.pak',
206                 '<(libchromiumcontent_dir)/content_shell.pak',
207                 '<(libchromiumcontent_dir)/ui_resources_200_percent.pak',
208                 '<(libchromiumcontent_dir)/views_resources_200_percent.pak',
209                 '<(libchromiumcontent_dir)/natives_blob.bin',
210                 '<(libchromiumcontent_dir)/snapshot_blob.bin',
211               ],
212             },
213           ],
214         }],  # OS=="linux"
215       ],
216     },  # target <(project_name)
217     {
218       'target_name': '<(project_name)_lib',
219       'type': 'static_library',
220       'dependencies': [
221         'atom_js2c',
222         'vendor/pdf_viewer/pdf_viewer.gyp:pdf_viewer',
223         'vendor/brightray/brightray.gyp:brightray',
224         'vendor/node/node.gyp:node',
225       ],
226       'defines': [
227         # We need to access internal implementations of Node.
228         'NODE_WANT_INTERNALS=1',
229         'NODE_SHARED_MODE',
230         # This is defined in skia/skia_common.gypi.
231         'SK_SUPPORT_LEGACY_GETTOPDEVICE',
232         # Disable warnings for g_settings_list_schemas.
233         'GLIB_DISABLE_DEPRECATION_WARNINGS',
234         # Defined in Chromium but not exposed in its gyp file.
235         'V8_USE_EXTERNAL_STARTUP_DATA',
236         'V8_SHARED',
237         'USING_V8_SHARED',
238         'USING_V8_PLATFORM_SHARED',
239         'USING_V8_BASE_SHARED',
240         # Remove this after enable_plugins becomes a feature flag.
241         'ENABLE_PLUGINS',
242         'USE_PROPRIETARY_CODECS',
243       ],
244       'sources': [
245         '<@(lib_sources)',
246       ],
247       'include_dirs': [
248         '.',
249         'chromium_src',
250         'vendor/brightray',
251         'vendor/native_mate',
252         # Include atom_natives.h.
253         '<(SHARED_INTERMEDIATE_DIR)',
254         # Include directories for uv and node.
255         'vendor/node/src',
256         'vendor/node/deps/http_parser',
257         'vendor/node/deps/uv/include',
258         # The `node.h` is using `#include"v8.h"`.
259         '<(libchromiumcontent_src_dir)/v8/include',
260         # The `node.h` is using `#include"ares.h"`.
261         'vendor/node/deps/cares/include',
262         # The `third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h` is using `platform/PlatformExport.h`.
263         '<(libchromiumcontent_src_dir)/third_party/WebKit/Source',
264         # The 'third_party/libyuv/include/libyuv/scale_argb.h' is using 'libyuv/basic_types.h'.
265         '<(libchromiumcontent_src_dir)/third_party/libyuv/include',
266         # The 'third_party/webrtc/modules/desktop_capture/desktop_frame.h' is using 'webrtc/base/scoped_ptr.h'.
267         '<(libchromiumcontent_src_dir)/third_party/',
268         '<(libchromiumcontent_src_dir)/components/cdm',
269         '<(libchromiumcontent_src_dir)/third_party/widevine',
270       ],
271       'direct_dependent_settings': {
272         'include_dirs': [
273           '.',
274         ],
275       },
276       'export_dependent_settings': [
277         'vendor/brightray/brightray.gyp:brightray',
278       ],
279       'conditions': [
280         ['libchromiumcontent_component', {
281           'link_settings': {
282             'libraries': [ '<@(libchromiumcontent_v8_libraries)' ],
283           },
284         }],
285         ['OS=="win"', {
286           'sources': [
287             '<@(lib_sources_win)',
288           ],
289           'link_settings': {
290             'libraries': [
291               '-limm32.lib',
292               '-loleacc.lib',
293               '-lcomctl32.lib',
294               '-lcomdlg32.lib',
295               '-lwininet.lib',
296               '-lwinmm.lib',
297               '-lcrypt32.lib',
298               '-luiautomationcore.lib',
299             ],
300           },
301           'dependencies': [
302             # Node is built as static_library on Windows, so we also need to
303             # include its dependencies here.
304             'vendor/node/deps/cares/cares.gyp:cares',
305             'vendor/node/deps/http_parser/http_parser.gyp:http_parser',
306             'vendor/node/deps/uv/uv.gyp:libuv',
307             'vendor/node/deps/zlib/zlib.gyp:zlib',
308             # Build with breakpad support.
309             'vendor/breakpad/breakpad.gyp:breakpad_handler',
310             'vendor/breakpad/breakpad.gyp:breakpad_sender',
311           ],
312         }],  # OS=="win"
313         ['OS=="mac" and mas_build==0', {
314           'dependencies': [
315             'vendor/crashpad/client/client.gyp:crashpad_client',
316             'vendor/crashpad/handler/handler.gyp:crashpad_handler',
317           ],
318           'link_settings': {
319             # Do not link with QTKit for mas build.
320             'libraries': [
321               '$(SDKROOT)/System/Library/Frameworks/QTKit.framework',
322             ],
323           },
324           'xcode_settings': {
325             # ReactiveCocoa which is used by Squirrel requires using __weak.
326             'CLANG_ENABLE_OBJC_WEAK': 'YES',
327           },
328         }],  # OS=="mac" and mas_build==0
329         ['OS=="mac" and mas_build==1', {
330           'defines': [
331             'MAS_BUILD',
332           ],
333           'sources!': [
334             'atom/browser/auto_updater_mac.mm',
335             'atom/common/crash_reporter/crash_reporter_mac.h',
336             'atom/common/crash_reporter/crash_reporter_mac.mm',
337           ],
338         }],  # OS=="mac" and mas_build==1
339         ['OS=="linux"', {
340           'sources': [
341             '<@(lib_sources_linux)',
342             '<@(lib_sources_nss)',
343           ],
344           'link_settings': {
345             'ldflags': [
346               # Make binary search for libraries under current directory, so we
347               # don't have to manually set $LD_LIBRARY_PATH:
348               # http://serverfault.com/questions/279068/cant-find-so-in-the-same-directory-as-the-executable
349               '-rpath \$$ORIGIN',
350               # Make native module dynamic loading work.
351               '-rdynamic',
352             ],
353           },
354           # Required settings of using breakpad.
355           'cflags_cc': [
356             '-Wno-empty-body',
357             '-Wno-reserved-user-defined-literal',
358           ],
359           'include_dirs': [
360             'vendor/breakpad/src',
361           ],
362           'dependencies': [
363             'vendor/breakpad/breakpad.gyp:breakpad_client',
364           ],
365         }],  # OS=="linux"
366       ],
367     },  # target <(product_name)_lib
368     {
369       'target_name': 'js2asar',
370       'type': 'none',
371       'actions': [
372         {
373           'action_name': 'js2asar',
374           'variables': {
375             'conditions': [
376               ['OS=="mac"', {
377                 'resources_path': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
378               },{
379                 'resources_path': '<(PRODUCT_DIR)/resources',
380               }],
381             ],
382           },
383           'inputs': [
384             '<@(js_sources)',
385           ],
386           'outputs': [
387             '<(resources_path)/electron.asar',
388           ],
389           'action': [
390             'python',
391             'tools/js2asar.py',
392             '<@(_outputs)',
393             'lib',
394             '<@(_inputs)',
395           ],
396         }
397       ],
398     },  # target js2asar
399     {
400       'target_name': 'app2asar',
401       'type': 'none',
402       'actions': [
403         {
404           'action_name': 'app2asar',
405           'variables': {
406             'conditions': [
407               ['OS=="mac"', {
408                 'resources_path': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
409               },{
410                 'resources_path': '<(PRODUCT_DIR)/resources',
411               }],
412             ],
413           },
414           'inputs': [
415             '<@(default_app_sources)',
416           ],
417           'outputs': [
418             '<(resources_path)/default_app.asar',
419           ],
420           'action': [
421             'python',
422             'tools/js2asar.py',
423             '<@(_outputs)',
424             'default_app',
425             '<@(_inputs)',
426           ],
427         }
428       ],
429     },  # target app2asar
430     {
431       'target_name': 'atom_js2c_copy',
432       'type': 'none',
433       'copies': [
434         {
435           'destination': '<(js2c_input_dir)',
436           'files': [
437             '<@(js2c_sources)',
438           ],
439         },
440       ],
441     },  # target atom_js2c_copy
442     {
443       'target_name': 'atom_browserify',
444       'type': 'none',
445       'dependencies': [
446         # depend on this target to ensure the '<(js2c_input_dir)' is created
447         'atom_js2c_copy',
448       ],
449       'variables': {
450         'sandbox_args': [
451           './lib/sandboxed_renderer/init.js',
452           '-r',
453           './lib/sandboxed_renderer/api/exports/electron.js:electron',
454           '-r',
455           './lib/sandboxed_renderer/api/exports/fs.js:fs',
456           '-r',
457           './lib/sandboxed_renderer/api/exports/os.js:os',
458           '-r',
459           './lib/sandboxed_renderer/api/exports/path.js:path',
460           '-r',
461           './lib/sandboxed_renderer/api/exports/child_process.js:child_process'
462         ],
463         'isolated_args': [
464           'lib/isolated_renderer/init.js',
465         ]
466       },
467       'actions': [
468         {
469           'action_name': 'atom_browserify_sandbox',
470           'inputs': [
471             '<!@(python tools/list-browserify-deps.py <(sandbox_args))'
472           ],
473           'outputs': [
474             '<(js2c_input_dir)/preload_bundle.js',
475           ],
476           'action': [
477             'npm',
478             'run',
479             '--silent',
480             'browserify',
481             '--',
482             '<@(sandbox_args)',
483             '-o',
484             '<@(_outputs)',
485           ],
486         },
487         {
488           'action_name': 'atom_browserify_isolated_context',
489           'inputs': [
490             '<!@(python tools/list-browserify-deps.py <(isolated_args))'
491           ],
492           'outputs': [
493             '<(js2c_input_dir)/isolated_bundle.js',
494           ],
495           'action': [
496             'npm',
497             'run',
498             '--silent',
499             'browserify',
500             '--',
501             '<@(isolated_args)',
502             '-o',
503             '<@(_outputs)',
504           ],
505         },
506       ],
507     },  # target atom_browserify
508     {
509       'target_name': 'atom_js2c',
510       'type': 'none',
511       'dependencies': [
512         'atom_js2c_copy',
513         'atom_browserify',
514       ],
515       'actions': [
516         {
517           'action_name': 'atom_js2c',
518           'inputs': [
519             # List all input files that should trigger a rebuild with js2c
520             '<@(js2c_sources)',
521             '<(js2c_input_dir)/preload_bundle.js',
522             '<(js2c_input_dir)/isolated_bundle.js',
523           ],
524           'outputs': [
525             '<(SHARED_INTERMEDIATE_DIR)/atom_natives.h',
526           ],
527           'action': [
528             'python',
529             'tools/js2c.py',
530             '<@(_outputs)',
531             '<(js2c_input_dir)',
532           ],
533         }
534       ],
535     },  # target atom_js2c
536   ],
537   'conditions': [
538     ['OS=="mac"', {
539       'targets': [
540         {
541           'target_name': '<(project_name)_framework',
542           'product_name': '<(product_name) Framework',
543           'type': 'shared_library',
544           'dependencies': [
545             '<(project_name)_lib',
546           ],
547           'sources': [
548             '<@(framework_sources)',
549           ],
550           'include_dirs': [
551             '.',
552             'vendor',
553             '<(libchromiumcontent_src_dir)',
554           ],
555           'export_dependent_settings': [
556             '<(project_name)_lib',
557           ],
558           'link_settings': {
559             'libraries': [
560               '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
561               '$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
562               '$(SDKROOT)/System/Library/Frameworks/Quartz.framework',
563               '$(SDKROOT)/System/Library/Frameworks/Security.framework',
564               '$(SDKROOT)/System/Library/Frameworks/SecurityInterface.framework',
565             ],
566           },
567           'mac_bundle': 1,
568           'mac_bundle_resources': [
569             'atom/common/resources/mac/MainMenu.xib',
570             '<(libchromiumcontent_dir)/content_shell.pak',
571             '<(libchromiumcontent_dir)/icudtl.dat',
572             '<(libchromiumcontent_dir)/natives_blob.bin',
573             '<(libchromiumcontent_dir)/snapshot_blob.bin',
574             '<(PRODUCT_DIR)/pdf_viewer_resources.pak',
575           ],
576           'xcode_settings': {
577             'ATOM_BUNDLE_ID': 'com.<(company_abbr).<(project_name).framework',
578             'INFOPLIST_FILE': 'atom/common/resources/mac/Info.plist',
579             'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name) Framework.framework/<(product_name) Framework',
580             'LD_RUNPATH_SEARCH_PATHS': [
581               '@loader_path/Libraries',
582             ],
583             'OTHER_LDFLAGS': [
584               '-ObjC',
585             ],
586           },
587           'copies': [
588             {
589               'variables': {
590                 'conditions': [
591                   ['libchromiumcontent_component', {
592                     'copied_libraries': [
593                       '<(PRODUCT_DIR)/libnode.dylib',
594                       '<@(libchromiumcontent_shared_libraries)',
595                       '<@(libchromiumcontent_shared_v8_libraries)',
596                     ],
597                   }, {
598                     'copied_libraries': [
599                       '<(PRODUCT_DIR)/libnode.dylib',
600                       '<(libchromiumcontent_dir)/libffmpeg.dylib',
601                     ],
602                   }],
603                 ],
604               },
605               'destination': '<(PRODUCT_DIR)/<(product_name) Framework.framework/Versions/A/Libraries',
606               'files': [
607                 '<@(copied_libraries)',
608               ],
609             },
610           ],
611           'postbuilds': [
612             {
613               'postbuild_name': 'Fix path of libnode',
614               'action': [
615                 'install_name_tool',
616                 '-change',
617                 '/usr/local/lib/libnode.dylib',
618                 '@rpath/libnode.dylib',
619                 '${BUILT_PRODUCTS_DIR}/<(product_name) Framework.framework/Versions/A/<(product_name) Framework',
620               ],
621             },
622             {
623               'postbuild_name': 'Add symlinks for framework subdirectories',
624               'action': [
625                 'tools/mac/create-framework-subdir-symlinks.sh',
626                 '<(product_name) Framework',
627                 'Libraries',
628               ],
629             },
630             {
631               'postbuild_name': 'Copy locales',
632               'action': [
633                 'tools/mac/copy-locales.py',
634                 '-d',
635                 '<(libchromiumcontent_dir)/locales',
636                 '${BUILT_PRODUCTS_DIR}/<(product_name) Framework.framework/Resources',
637                 '<@(locales)',
638               ],
639             },
640           ],
641           'conditions': [
642             ['mas_build==0', {
643               'link_settings': {
644                 'libraries': [
645                   'external_binaries/Squirrel.framework',
646                   'external_binaries/ReactiveCocoa.framework',
647                   'external_binaries/Mantle.framework',
648                 ],
649               },
650               'copies': [
651                 {
652                   'destination': '<(PRODUCT_DIR)/<(product_name) Framework.framework/Versions/A/Resources',
653                   'files': [
654                     '<(PRODUCT_DIR)/crashpad_handler',
655                   ],
656                 },
657               ],
658             }],
659           ],
660         },  # target framework
661         {
662           'target_name': '<(project_name)_helper',
663           'product_name': '<(product_name) Helper',
664           'type': 'executable',
665           'dependencies': [
666             '<(project_name)_framework',
667           ],
668           'sources': [
669             '<@(app_sources)',
670           ],
671           'include_dirs': [
672             '.',
673           ],
674           'mac_bundle': 1,
675           'xcode_settings': {
676             'ATOM_BUNDLE_ID': 'com.<(company_abbr).<(project_name).helper',
677             'INFOPLIST_FILE': 'atom/renderer/resources/mac/Info.plist',
678             'LD_RUNPATH_SEARCH_PATHS': [
679               '@executable_path/../../..',
680             ],
681           },
682         },  # target helper
683       ],
684     }],  # OS!="mac"
685   ],
686 }