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': 'unix/ibus',
33    'gen_out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(relative_dir)',
34    'ibus_mozc_icon_path%': '/usr/share/ibus-mozc/product_icon.png',
35    'ibus_mozc_path%': '/usr/lib/ibus-mozc/ibus-engine-mozc',
36    # enable_x11_selection_monitor represents if ibus_mozc uses X11 selection
37    # monitor or not.
38    'enable_x11_selection_monitor%': 1,
39  },
40  'targets': [
41    {
42      # Meta target to set up build environment for ibus. Required 'cflags'
43      # and 'link_settings' will be automatically injected into any target
44      # which directly or indirectly depends on this target.
45      'target_name': 'ibus_build_environment',
46      'type': 'none',
47      'variables': {
48        'target_libs': [
49          'glib-2.0',
50          'gobject-2.0',
51          'ibus-1.0',
52        ],
53      },
54      'all_dependent_settings': {
55        'cflags': [
56          '<!@(pkg-config --cflags <@(target_libs))',
57        ],
58        'link_settings': {
59          'libraries': [
60            '<!@(pkg-config --libs-only-l <@(target_libs))',
61          ],
62          'ldflags': [
63            '<!@(pkg-config --libs-only-L <@(target_libs))',
64          ],
65        },
66      },
67    },
68    {
69      'target_name': 'gen_mozc_xml',
70      'type': 'none',
71      'actions': [
72        {
73          'action_name': 'gen_mozc_xml',
74          'inputs': [
75            './gen_mozc_xml.py',
76          ],
77          'outputs': [
78            '<(gen_out_dir)/mozc.xml',
79          ],
80          'action': [
81            '/usr/local/bin/python3.8', '../../build_tools/redirect.py',
82            '<(gen_out_dir)/mozc.xml',
83            './gen_mozc_xml.py',
84            '--branding=Mozc',
85            '--server_dir=<(server_dir)',
86	    '--renderer_dir=<(renderer_dir)',
87	    '--tool_dir=<(tool_dir)',
88            '--ibus_mozc_path=<(ibus_mozc_path)',
89            '--ibus_mozc_icon_path=<(ibus_mozc_icon_path)',
90          ],
91        },
92      ],
93    },
94    {
95      'target_name': 'ibus_mozc_metadata',
96      'type': 'static_library',
97      'sources': [
98        'mozc_engine_property.cc',
99      ],
100      'dependencies': [
101        '../../base/base.gyp:base',
102        '../../protocol/protocol.gyp:commands_proto',
103        'ibus_build_environment',
104      ],
105    },
106    {
107      'target_name': 'ibus_property_handler',
108      'type': 'static_library',
109      'sources': [
110        'property_handler.cc',
111      ],
112      'dependencies': [
113        '../../protocol/protocol.gyp:commands_proto',
114        'ibus_build_environment',
115        'message_translator',
116        'path_util',
117      ],
118    },
119    {
120      'target_name': 'path_util',
121      'type': 'static_library',
122      'sources': [
123        'path_util.cc',
124      ],
125      'dependencies': [
126        '../../base/base.gyp:base',
127      ],
128    },
129    {
130      'target_name': 'message_translator',
131      'type': 'static_library',
132      'sources': [
133        'message_translator.cc',
134      ],
135      'dependencies': [
136        '../../base/base.gyp:base',
137      ],
138    },
139    {
140      'target_name': 'ibus_mozc_lib',
141      'type': 'static_library',
142      'sources': [
143        'engine_registrar.cc',
144        'ibus_candidate_window_handler.cc',
145        'key_event_handler.cc',
146        'key_translator.cc',
147        'mozc_engine.cc',
148        'preedit_handler.cc',
149        'surrounding_text_util.cc',
150      ],
151      'dependencies': [
152        '../../client/client.gyp:client',
153        '../../protocol/protocol.gyp:commands_proto',
154        '../../session/session_base.gyp:ime_switch_util',
155        'ibus_property_handler',
156        'message_translator',
157        'path_util',
158      ],
159      'conditions': [
160        ['enable_gtk_renderer==1', {
161          'dependencies': [
162            'gtk_candidate_window_handler',
163          ],
164        }],
165        ['enable_x11_selection_monitor==1', {
166          'dependencies': [
167            'selection_monitor',
168          ],
169        }],
170      ],
171    },
172    {
173      'target_name': 'ibus_mozc',
174      'type': 'executable',
175      'sources': [
176        'main.cc',
177        '<(gen_out_dir)/main.h',
178      ],
179      'actions': [
180        {
181          'action_name': 'gen_main_h',
182          'inputs': [
183            './gen_mozc_xml.py',
184          ],
185          'outputs': [
186            '<(gen_out_dir)/main.h',
187          ],
188          'action': [
189            '/usr/local/bin/python3.8', '../../build_tools/redirect.py',
190            '<(gen_out_dir)/main.h',
191            './gen_mozc_xml.py',
192            '--branding=Mozc',
193            '--output_cpp',
194            '--ibus_mozc_path=<(ibus_mozc_path)',
195            '--ibus_mozc_icon_path=<(ibus_mozc_icon_path)',
196          ],
197        },
198      ],
199      'dependencies': [
200        '../../base/base.gyp:base',
201        'gen_mozc_xml',
202        'ibus_mozc_lib',
203        'ibus_mozc_metadata',
204      ],
205    },
206    {
207      'target_name': 'ibus_mozc_test',
208      'type': 'executable',
209      'sources': [
210        'key_event_handler_test.cc',
211        'key_translator_test.cc',
212        'message_translator_test.cc',
213        'mozc_engine_test.cc',
214        'path_util_test.cc',
215        'surrounding_text_util_test.cc',
216      ],
217      'dependencies': [
218        '../../base/base.gyp:base',
219        '../../client/client.gyp:client',
220        '../../client/client.gyp:client_mock',
221        '../../composer/composer.gyp:key_event_util',
222        '../../protocol/protocol.gyp:commands_proto',
223        '../../testing/testing.gyp:gtest_main',
224        'ibus_mozc_lib',
225        'ibus_mozc_metadata',
226      ],
227      'variables': {
228        'test_size': 'small',
229      },
230    },
231    # Test cases meta target: this target is referred from gyp/tests.gyp
232    {
233      'target_name': 'ibus_all_test',
234      'type': 'none',
235      'dependencies': [
236        'ibus_mozc_test',
237      ],
238      'conditions': [
239        ['enable_gtk_renderer==1', {
240          'dependencies': [
241            'gtk_candidate_window_handler_test',
242          ],
243        }],
244      ],
245    },
246  ],
247  'conditions': [
248    ['enable_gtk_renderer==1', {
249      'targets': [
250        {
251          'target_name': 'gtk_candidate_window_handler',
252          'type': 'static_library',
253          'sources': [
254            'gtk_candidate_window_handler.cc',
255          ],
256          'dependencies': [
257            '../../protocol/protocol.gyp:renderer_proto',
258            '../../renderer/renderer.gyp:renderer_client',
259            'ibus_build_environment',
260          ],
261        },
262        {
263          'target_name': 'gtk_candidate_window_handler_test',
264          'type': 'executable',
265          'sources': [
266            'gtk_candidate_window_handler_test.cc',
267          ],
268          'dependencies': [
269            'gtk_candidate_window_handler',
270            '../../testing/testing.gyp:gtest_main',
271          ],
272        },
273      ],
274    }],
275    ['enable_x11_selection_monitor==1', {
276      'targets': [
277        {
278          # Meta target to set up build environment for ibus. Required 'cflags'
279          # and 'link_settings' will be automatically injected into any target
280          # which directly or indirectly depends on this target.
281          'target_name': 'xcb_build_environment',
282          'type': 'none',
283          'variables': {
284            'target_libs': [
285              'xcb',
286              'xcb-xfixes',
287            ],
288          },
289          'all_dependent_settings': {
290            'cflags': [
291              '<!@(pkg-config --cflags <@(target_libs))',
292            ],
293            'link_settings': {
294              'libraries': [
295                '<!@(pkg-config --libs-only-l <@(target_libs))',
296              ],
297              'ldflags': [
298                '<!@(pkg-config --libs-only-L <@(target_libs))',
299              ],
300            },
301            'defines': [
302              'MOZC_ENABLE_X11_SELECTION_MONITOR=1'
303            ],
304          },
305        },
306        {
307          'target_name': 'selection_monitor',
308          'type': 'static_library',
309          'sources': [
310            'selection_monitor.cc',
311          ],
312          'dependencies': [
313            '../../base/base.gyp:base',
314            'xcb_build_environment',
315          ],
316        },
317      ],
318    }],
319  ],
320}
321