1# Copyright 2010-2018, Google Inc.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8#     * Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10#     * Redistributions in binary form must reproduce the above
11# copyright notice, this list of conditions and the following disclaimer
12# in the documentation and/or other materials provided with the
13# distribution.
14#     * Neither the name of Google Inc. nor the names of its
15# contributors may be used to endorse or promote products derived from
16# this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30{
31  'variables': {
32    'relative_dir': 'renderer',
33    'gen_out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(relative_dir)',
34    'conditions': [
35      ['branding=="GoogleJapaneseInput"', {
36        'renderer_product_name_win': 'GoogleIMEJaRenderer',
37      }, {  # else
38        'renderer_product_name_win': 'mozc_renderer',
39      }],
40    ],
41  },
42  'targets': [
43    {
44      'target_name': 'table_layout',
45      'type': 'static_library',
46      'sources': [
47        'table_layout.cc',
48      ],
49      'dependencies': [
50        '../base/base.gyp:base',
51      ],
52    },
53    {
54      'target_name': 'window_util',
55      'type': 'static_library',
56      'sources': [
57        'window_util.cc',
58      ],
59      'dependencies': [
60        '../base/base.gyp:base',
61      ],
62    },
63    {
64      'target_name': 'renderer_client',
65      'type': 'static_library',
66      'sources': [
67        'renderer_client.cc',
68      ],
69      'dependencies': [
70        '../base/base.gyp:base',
71        '../ipc/ipc.gyp:ipc',
72        '../protocol/protocol.gyp:commands_proto',
73        '../protocol/protocol.gyp:config_proto',
74        '../protocol/protocol.gyp:renderer_proto',
75      ],
76    },
77    {
78      'target_name': 'renderer_server',
79      'type': 'static_library',
80      'sources': [
81        'renderer_server.cc',
82      ],
83      'dependencies': [
84        '../base/base.gyp:base',
85        '../client/client.gyp:client',
86        '../config/config.gyp:config_handler',
87        '../ipc/ipc.gyp:ipc',
88        '../protocol/protocol.gyp:commands_proto',
89        '../protocol/protocol.gyp:renderer_proto',
90      ],
91    },
92    {
93      'target_name': 'renderer_client_test',
94      'type': 'executable',
95      'sources': [
96        'renderer_client_test.cc',
97      ],
98      'dependencies': [
99        '../testing/testing.gyp:gtest_main',
100        'renderer_client',
101      ],
102      'variables': {
103        'test_size': 'small',
104      },
105    },
106    {
107      'target_name': 'renderer_server_test',
108      'type': 'executable',
109      'sources': [
110        'renderer_server_test.cc',
111      ],
112      'dependencies': [
113        '../ipc/ipc.gyp:ipc_test_util',
114        '../testing/testing.gyp:gtest_main',
115        'renderer_client',
116        'renderer_server',
117      ],
118      'variables': {
119        'test_size': 'small',
120      },
121    },
122    {
123      'target_name': 'table_layout_test',
124      'type': 'executable',
125      'sources': [
126        'table_layout_test.cc',
127      ],
128      'dependencies': [
129        '../testing/testing.gyp:gtest_main',
130        'table_layout',
131      ],
132      'variables': {
133        'test_size': 'small',
134      },
135    },
136    {
137      'target_name': 'window_util_test',
138      'type': 'executable',
139      'sources': [
140        'window_util_test.cc',
141      ],
142      'dependencies': [
143        '../testing/testing.gyp:gtest_main',
144        'window_util',
145      ],
146      'variables': {
147        'test_size': 'small',
148      },
149    },
150    {
151      'target_name': 'renderer_style_handler',
152      'type': 'static_library',
153      'sources': [
154        'renderer_style_handler.cc',
155      ],
156      'dependencies': [
157        '../protocol/protocol.gyp:renderer_proto',
158      ],
159      'variables': {
160        'test_size': 'small',
161      },
162    },
163    {
164      'target_name': 'renderer_style_handler_test',
165      'type': 'executable',
166      'sources': [
167        'renderer_style_handler_test.cc',
168      ],
169      'dependencies': [
170        '../protocol/protocol.gyp:renderer_proto',
171        '../testing/testing.gyp:gtest_main',
172        'renderer_style_handler',
173      ],
174      'variables': {
175        'test_size': 'small',
176      },
177    },
178    # Test cases meta target: this target is referred from gyp/tests.gyp
179    {
180      'target_name': 'renderer_all_test',
181      'type': 'none',
182      'dependencies': [
183        'renderer_client_test',
184        'renderer_server_test',
185        'renderer_style_handler_test',
186        'table_layout_test',
187        'window_util_test',
188      ],
189      'conditions': [
190        ['OS=="win"', {
191          'dependencies': [
192            'win32_font_util_test',
193            'win32_renderer_core_test',
194          ],
195        }],
196        ['target_platform=="Linux" and enable_gtk_renderer==1', {
197          'dependencies': [
198            'gtk_renderer_test',
199          ],
200        }],
201        # Android runs nothing.
202        ['target_platform=="Android"', {
203          'dependencies=': [],
204        },
205      ],
206      ],
207    },
208  ],
209  'conditions': [
210    ['OS=="win"', {
211      'targets': [
212        {
213          'target_name': 'gen_mozc_renderer_resource_header',
214          'toolsets': ['host'],
215          'variables': {
216            'gen_resource_proj_name': 'mozc_renderer',
217            'gen_main_resource_path': 'renderer/mozc_renderer.rc',
218            'gen_output_resource_path':
219                '<(gen_out_dir)/mozc_renderer_autogen.rc',
220          },
221          'includes': [
222            '../gyp/gen_win32_resource_header.gypi',
223          ],
224        },
225        {
226          'target_name': 'win32_font_util',
227          'type': 'static_library',
228          'sources': [
229            'win32/win32_font_util.cc',
230          ],
231          'dependencies': [
232            '../base/base.gyp:base',
233            '../protocol/protocol.gyp:commands_proto',
234            '../protocol/protocol.gyp:config_proto',
235            '../protocol/protocol.gyp:renderer_proto',
236          ],
237        },
238        {
239          'target_name': 'win32_font_util_test',
240          'type': 'executable',
241          'sources': [
242            'win32/win32_font_util_test.cc',
243          ],
244          'dependencies': [
245            '../testing/testing.gyp:gtest_main',
246            'win32_font_util',
247          ],
248          'variables': {
249            'test_size': 'small',
250          },
251        },
252        {
253          'target_name': 'win32_renderer_core',
254          'type': 'static_library',
255          'sources': [
256            'win32/win32_image_util.cc',
257            'win32/win32_renderer_util.cc',
258          ],
259          'dependencies': [
260            '../base/base.gyp:base',
261            '../protocol/protocol.gyp:commands_proto',
262            '../protocol/protocol.gyp:config_proto',
263            '../protocol/protocol.gyp:renderer_proto',
264            'win32_font_util',
265          ],
266        },
267        {
268          'target_name': 'install_renderer_core_test_data',
269          'type': 'none',
270          'variables': {
271            'test_data': [
272              '../<(test_data_subdir)/balloon_blur_alpha_-1.png',
273              '../<(test_data_subdir)/balloon_blur_alpha_-1.png.json',
274              '../<(test_data_subdir)/balloon_blur_alpha_0.png',
275              '../<(test_data_subdir)/balloon_blur_alpha_0.png.json',
276              '../<(test_data_subdir)/balloon_blur_alpha_10.png',
277              '../<(test_data_subdir)/balloon_blur_alpha_10.png.json',
278              '../<(test_data_subdir)/balloon_blur_color_32_64_128.png',
279              '../<(test_data_subdir)/balloon_blur_color_32_64_128.png.json',
280              '../<(test_data_subdir)/balloon_blur_offset_-20_-10.png',
281              '../<(test_data_subdir)/balloon_blur_offset_-20_-10.png.json',
282              '../<(test_data_subdir)/balloon_blur_offset_0_0.png',
283              '../<(test_data_subdir)/balloon_blur_offset_0_0.png.json',
284              '../<(test_data_subdir)/balloon_blur_offset_20_5.png',
285              '../<(test_data_subdir)/balloon_blur_offset_20_5.png.json',
286              '../<(test_data_subdir)/balloon_blur_sigma_0.0.png',
287              '../<(test_data_subdir)/balloon_blur_sigma_0.0.png.json',
288              '../<(test_data_subdir)/balloon_blur_sigma_0.5.png',
289              '../<(test_data_subdir)/balloon_blur_sigma_0.5.png.json',
290              '../<(test_data_subdir)/balloon_blur_sigma_1.0.png',
291              '../<(test_data_subdir)/balloon_blur_sigma_1.0.png.json',
292              '../<(test_data_subdir)/balloon_blur_sigma_2.0.png',
293              '../<(test_data_subdir)/balloon_blur_sigma_2.0.png.json',
294              '../<(test_data_subdir)/balloon_frame_thickness_-1.png',
295              '../<(test_data_subdir)/balloon_frame_thickness_-1.png.json',
296              '../<(test_data_subdir)/balloon_frame_thickness_0.png',
297              '../<(test_data_subdir)/balloon_frame_thickness_0.png.json',
298              '../<(test_data_subdir)/balloon_frame_thickness_1.5.png',
299              '../<(test_data_subdir)/balloon_frame_thickness_1.5.png.json',
300              '../<(test_data_subdir)/balloon_frame_thickness_3.png',
301              '../<(test_data_subdir)/balloon_frame_thickness_3.png.json',
302              '../<(test_data_subdir)/balloon_inside_color_32_64_128.png',
303              '../<(test_data_subdir)/balloon_inside_color_32_64_128.png.json',
304              '../<(test_data_subdir)/balloon_no_label.png',
305              '../<(test_data_subdir)/balloon_no_label.png.json',
306              '../<(test_data_subdir)/balloon_tail_bottom.png',
307              '../<(test_data_subdir)/balloon_tail_bottom.png.json',
308              '../<(test_data_subdir)/balloon_tail_left.png',
309              '../<(test_data_subdir)/balloon_tail_left.png.json',
310              '../<(test_data_subdir)/balloon_tail_right.png',
311              '../<(test_data_subdir)/balloon_tail_right.png.json',
312              '../<(test_data_subdir)/balloon_tail_top.png',
313              '../<(test_data_subdir)/balloon_tail_top.png.json',
314              '../<(test_data_subdir)/balloon_tail_width_height_-10_-10.png',
315              '../<(test_data_subdir)/balloon_tail_width_height_-10_-10.png.json',
316              '../<(test_data_subdir)/balloon_tail_width_height_0_0.png',
317              '../<(test_data_subdir)/balloon_tail_width_height_0_0.png.json',
318              '../<(test_data_subdir)/balloon_tail_width_height_10_20.png',
319              '../<(test_data_subdir)/balloon_tail_width_height_10_20.png.json',
320              '../<(test_data_subdir)/balloon_width_height_40_30.png',
321              '../<(test_data_subdir)/balloon_width_height_40_30.png.json',
322            ],
323            'test_data_subdir': 'data/test/renderer/win32',
324          },
325          'includes': ['../gyp/install_testdata.gypi'],
326        },
327        {
328          'target_name': 'win32_renderer_core_test',
329          'type': 'executable',
330          'sources': [
331            'win32/win32_image_util_test.cc',
332            'win32/win32_renderer_util_test.cc',
333          ],
334          'dependencies': [
335            '../base/base.gyp:win_font_test_helper',
336            '../net/jsoncpp.gyp:jsoncpp',
337            '../testing/testing.gyp:gtest_main',
338            '../testing/testing.gyp:mozctest',
339            'install_renderer_core_test_data',
340            'win32_renderer_core',
341          ],
342          'variables': {
343            'test_size': 'small',
344          },
345          'msvs_settings': {
346            'VCLinkerTool': {
347              'AdditionalDependencies': [
348                'gdiplus.lib',  # used in 'win32_image_util_test.cc'
349              ],
350            },
351          },
352        },
353        {
354          'target_name': 'win32_text_renderer',
355          'type': 'static_library',
356          'sources': [
357            'win32/text_renderer.cc',
358          ],
359          'dependencies': [
360            '../base/base.gyp:base',
361            '../protocol/protocol.gyp:renderer_proto',
362            'renderer_style_handler',
363          ],
364          'link_settings': {
365            'msvs_settings': {
366              'VCLinkerTool': {
367                'AdditionalDependencies': [
368                  'd2d1.lib',
369                  'dwrite.lib',
370                ],
371              },
372            },
373          },
374        },
375        {
376          'target_name': 'gen_pbgra32_bitmap',
377          'type': 'executable',
378          'sources': [
379            'win32/gen_pbgra32_bitmap.cc',
380          ],
381          'dependencies': [
382            '../base/base.gyp:base_core',
383            '../base/base.gyp:scoped_handle',
384          ],
385          'msvs_settings': {
386            'VCLinkerTool': {
387              'AdditionalDependencies': [
388                'gdiplus.lib',  # used in 'gen_pbgra32_bitmap.cc'
389              ],
390              'SubSystem': '1',  # 1 == subSystemConsole
391            },
392          },
393        },
394        {
395          'target_name': 'mozc_renderer',
396          'product_name': '<(renderer_product_name_win)',
397          'type': 'executable',
398          'sources': [
399            'mozc_renderer_main.cc',
400            'win32/win32_server.cc',
401            'win32/window_manager.cc',
402            'win32/candidate_window.cc',
403            'win32/composition_window.cc',
404            'win32/infolist_window.cc',
405            'win32/indicator_window.cc',
406            '<(gen_out_dir)/mozc_renderer_autogen.rc',
407          ],
408          'dependencies': [
409            '../base/base.gyp:base',
410            '../base/base.gyp:crash_report_handler',
411            '../client/client.gyp:client',
412            '../config/config.gyp:stats_config_util',
413            '../ipc/ipc.gyp:ipc',
414            '../protocol/protocol.gyp:commands_proto',
415            '../protocol/protocol.gyp:config_proto',
416            '../protocol/protocol.gyp:renderer_proto',
417            'gen_mozc_renderer_resource_header#host',
418            'renderer_server',
419            'renderer_style_handler',
420            'table_layout',
421            'win32_renderer_core',
422            'win32_text_renderer',
423            'window_util',
424          ],
425          'msvs_settings': {
426            'VCManifestTool': {
427              'AdditionalManifestFiles': 'mozc_renderer.exe.manifest',
428              'EmbedManifest': 'true',
429            },
430          },
431        },
432        {
433          'target_name': 'win32_renderer_client',
434          'type': 'static_library',
435          'sources': [
436            'win32/win32_renderer_client.cc',
437          ],
438          'dependencies': [
439            '../base/base.gyp:base',
440            '../protocol/protocol.gyp:renderer_proto',
441            'renderer_client',
442          ],
443        },
444      ],
445    }],
446    ['OS=="mac"', {
447      'targets': [
448        {
449          'target_name': 'mozc_renderer',
450          'type': 'executable',
451          'mac_bundle': 1,
452          'product_name': '<(branding)Renderer',
453          'sources': [
454            'mozc_renderer_main.cc',
455            'mac/mac_server.mm',
456            'mac/mac_server_send_command.mm',
457            'mac/CandidateController.mm',
458            'mac/CandidateWindow.mm',
459            'mac/CandidateView.mm',
460            'mac/InfolistWindow.mm',
461            'mac/InfolistView.mm',
462            'mac/RendererBaseWindow.mm',
463            'mac/mac_view_util.mm',
464          ],
465          'mac_bundle_resources': [
466            '../data/images/mac/candidate_window_logo.tiff',
467            '../data/images/mac/product_icon.icns',
468          ],
469          'dependencies': [
470            '../base/base.gyp:base',
471            '../base/base.gyp:crash_report_handler',
472            '../client/client.gyp:client',
473            '../config/config.gyp:stats_config_util',
474            '../ipc/ipc.gyp:ipc',
475            '../protocol/protocol.gyp:commands_proto',
476            '../protocol/protocol.gyp:config_proto',
477            '../protocol/protocol.gyp:renderer_proto',
478            'gen_renderer_files#host',
479            'renderer_server',
480            'renderer_style_handler',
481            'table_layout',
482            'window_util',
483          ],
484          'xcode_settings': {
485            'INFOPLIST_FILE': '<(gen_out_dir)/Info.plist',
486          },
487          'link_settings': {
488            'libraries': [
489              '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
490            ],
491          },
492
493          'variables': {
494            # This product name is used in postbuilds_mac.gypi.
495            'product_name': '<(branding)Renderer',
496          },
497          'includes': [
498            '../gyp/postbuilds_mac.gypi',
499          ],
500        },
501        {
502          'target_name': 'gen_renderer_files',
503          'type': 'none',
504          'toolsets': ['host'],
505          'actions': [
506            {
507              'action_name': 'generate_infoplist',
508              'inputs': [
509                'mac/Info.plist',
510              ],
511              'outputs': [
512                '<(gen_out_dir)/Info.plist',
513              ],
514              'action': [
515                '/usr/local/bin/python3.8', '../build_tools/tweak_info_plist.py',
516                '--output', '<(gen_out_dir)/Info.plist',
517                '--input', 'mac/Info.plist',
518                '--version_file', '../mozc_version.txt',
519                '--branding', '<(branding)',
520              ],
521            },
522          ],
523        },
524      ],
525    }],
526    ['target_platform=="Linux" and enable_gtk_renderer==1', {
527      'targets': [
528        {
529          # Meta target to set up build environment for gtk+-2.0.
530          # Required 'cflags' and 'link_settings' will be automatically
531          # injected into any target which directly or indirectly depends
532          # on this target.
533          'target_name': 'gtk2_build_environment',
534          'type': 'none',
535          'variables': {
536            'target_pkgs' : [
537              'glib-2.0',
538              'gobject-2.0',
539              'gthread-2.0',
540              'gtk+-2.0',
541              'gdk-2.0',
542            ],
543          },
544          'all_dependent_settings': {
545            'cflags': [
546              '<!@(pkg-config --cflags <@(target_pkgs))',
547            ],
548            'link_settings': {
549              'libraries': [
550                '<!@(pkg-config --libs-only-l <@(target_pkgs))',
551              ],
552              'ldflags': [
553                '<!@(pkg-config --libs-only-L <@(target_pkgs))',
554              ],
555            },
556          },
557        },
558        {
559          'target_name': 'mozc_renderer_lib',
560          'type': 'static_library',
561          'sources': [
562            'unix/cairo_factory.cc',
563            'unix/cairo_wrapper.cc',
564            'unix/candidate_window.cc',
565            'unix/draw_tool.cc',
566            'unix/font_spec.cc',
567            'unix/gtk_window_base.cc',
568            'unix/gtk_wrapper.cc',
569            'unix/infolist_window.cc',
570            'unix/pango_wrapper.cc',
571            'unix/text_renderer.cc',
572            'unix/unix_renderer.cc',
573            'unix/unix_server.cc',
574            'unix/window_manager.cc',
575          ],
576          'dependencies': [
577            '../base/base.gyp:base',
578            '../client/client.gyp:client',
579            '../config/config.gyp:stats_config_util',
580            '../ipc/ipc.gyp:ipc',
581            '../protocol/protocol.gyp:genproto_config_proto#host',
582            '../protocol/protocol.gyp:renderer_proto',
583            'gtk2_build_environment',
584            'renderer_server',
585            'renderer_style_handler',
586            'table_layout',
587            'window_util',
588          ],
589        },
590        {
591          'target_name': 'mozc_renderer',
592          'type': 'executable',
593          'sources': [
594            'mozc_renderer_main.cc',
595          ],
596          'dependencies': [
597            '../base/base.gyp:crash_report_handler',
598            'mozc_renderer_lib',
599          ],
600        },
601        {
602          'target_name': 'gtk_renderer_test',
603          'type': 'executable',
604          'sources': [
605            'unix/candidate_window_test.cc',
606            'unix/draw_tool_test.cc',
607            'unix/font_spec_test.cc',
608            'unix/gtk_window_base_test.cc',
609            'unix/infolist_window_test.cc',
610            'unix/text_renderer_test.cc',
611            'unix/unix_renderer_test.cc',
612            'unix/unix_server_test.cc',
613            'unix/window_manager_test.cc',
614          ],
615          'dependencies': [
616            '../testing/testing.gyp:gtest_main',
617            'mozc_renderer_lib',
618          ],
619        },
620      ],
621    }],
622  ],
623}
624