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': 'server',
33    'gen_out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(relative_dir)',
34    'conditions': [
35      ['branding=="GoogleJapaneseInput"', {
36        'converter_product_name_win': 'GoogleIMEJaConverter',
37        'cache_service_product_name_win': 'GoogleIMEJaCacheService',
38      }, {  # else
39        'converter_product_name_win': 'mozc_server',
40        'cache_service_product_name_win': 'mozc_cache_service',
41      }],
42    ],
43  },
44  'targets': [
45    {
46      'target_name': 'mozc_server',
47      'type': 'executable',
48      'sources': [
49        'mozc_server_main.cc',
50      ],
51      'dependencies': [
52        '../base/base.gyp:base',
53        '../engine/engine.gyp:engine_factory',
54        '../session/session.gyp:session',
55        'mozc_server_lib',
56      ],
57      'conditions': [
58        ['OS=="mac"', {
59          'product_name': '<(branding)Converter',
60          'sources': [
61            '../data/mac/mozc_server_info',
62          ],
63          'dependencies': [
64            'gen_mozc_server_info_plist',
65          ],
66          'mac_bundle': 1,
67          'mac_bundle_resources': [
68            '../data/images/mac/product_icon.icns'
69          ],
70          'xcode_settings': {
71            # Currently metadata in the Info.plist file like version
72            # info go away because the generated xcodeproj don't know
73            # version info.
74            # TODO(mukai): write a script to expand those variables
75            # and use that script instead of this INFOPLIST_FILE.
76            'INFOPLIST_FILE': '<(gen_out_dir)/mozc_server_info',
77          },
78          'variables': {
79            # This product name is used in postbuilds_mac.gypi.
80            'product_name': '<(branding)Converter',
81          },
82          'includes': [
83            '../gyp/postbuilds_mac.gypi',
84          ],
85        }],
86        ['OS=="win"', {
87          'product_name': '<(converter_product_name_win)',
88          'sources': [
89            '<(gen_out_dir)/mozc_server_autogen.rc',
90          ],
91          'dependencies': [
92            'gen_mozc_server_resource_header',
93          ],
94          'msvs_settings': {
95            'VCManifestTool': {
96              'AdditionalManifestFiles': 'mozc_server.exe.manifest',
97              'EmbedManifest': 'true',
98            },
99          },
100        }],
101      ],
102    },
103    {
104      'target_name': 'mozc_server_lib',
105      'type': 'static_library',
106      'sources': [
107        'mozc_server.cc',
108      ],
109      'dependencies': [
110        '../base/base.gyp:crash_report_handler',
111        '../session/session.gyp:session_server',
112        '../usage_stats/usage_stats_base.gyp:usage_stats',
113      ],
114    },
115    {
116      'target_name': 'mozc_rpc_server_main',
117      'type': 'executable',
118      'sources': [
119        'mozc_rpc_server_main.cc',
120      ],
121      'dependencies': [
122        '../base/base.gyp:base',
123        '../engine/engine.gyp:engine_factory',
124        '../session/session.gyp:session_handler',
125        '../session/session.gyp:session_server',
126        '../session/session.gyp:random_keyevents_generator',
127      ],
128    },
129  ],
130  'conditions': [
131    ['OS=="win"', {
132      'targets': [
133        {
134          'target_name': 'genproto_server',
135          'type': 'none',
136          'sources': [
137            'win32_service_state.proto',
138          ],
139          'includes': [
140            '../protobuf/genproto.gypi',
141          ],
142        },
143        {
144          'target_name': 'server_protocol',
145          'type': 'static_library',
146          'hard_dependency': 1,
147          'sources': [
148            '<(proto_out_dir)/<(relative_dir)/win32_service_state.pb.cc',
149          ],
150          'dependencies': [
151            '../protobuf/protobuf.gyp:protobuf',
152            'genproto_server',
153          ],
154          'export_dependent_settings': [
155            'genproto_server',
156          ],
157        },
158        {
159          'target_name': 'gen_mozc_server_resource_header',
160          'variables': {
161            'gen_resource_proj_name': 'mozc_server',
162            'gen_main_resource_path': 'server/mozc_server.rc',
163            'gen_output_resource_path':
164                '<(gen_out_dir)/mozc_server_autogen.rc',
165          },
166          'includes': [
167            '../gyp/gen_win32_resource_header.gypi',
168          ],
169        },
170        {
171          'target_name': 'gen_mozc_cache_service_resource_header',
172          'variables': {
173            'gen_resource_proj_name': 'mozc_cache_service',
174            'gen_main_resource_path': 'server/mozc_cache_service.rc',
175            'gen_output_resource_path':
176                '<(gen_out_dir)/mozc_cache_service_autogen.rc',
177          },
178          'includes': [
179            '../gyp/gen_win32_resource_header.gypi',
180          ],
181        },
182        {
183          'target_name': 'cache_service_manager',
184          'type': 'static_library',
185          'sources': [
186            'cache_service_manager.cc',
187          ],
188          'dependencies': [
189            '../base/base.gyp:base',
190            '../base/base.gyp:encryptor',
191            'server_protocol',
192          ],
193        },
194        {
195          'target_name': 'mozc_cache_service',
196          'product_name': '<(cache_service_product_name_win)',
197          'type': 'executable',
198          'sources': [
199            'mozc_cache_service.cc',
200            '<(gen_out_dir)/mozc_cache_service_autogen.rc',
201          ],
202          'dependencies': [
203            'cache_service_manager',
204            'gen_mozc_cache_service_resource_header',
205          ],
206          'msvs_settings': {
207            'VCManifestTool': {
208              'AdditionalManifestFiles': 'mozc_cache_service.exe.manifest',
209              'EmbedManifest': 'true',
210            },
211            'VCLinkerTool': {
212              'AdditionalDependencies': [
213                'crypt32.lib',  # used in 'mozc_cache_service.cc'
214              ],
215            },
216          },
217        },
218      ],
219    }],
220    ['OS=="mac"', {
221      'targets': [
222        {
223          'target_name': 'gen_mozc_server_info_plist',
224          'type': 'none',
225          'actions': [
226            {
227              'action_name': 'generate',
228              'inputs': [
229                '../data/mac/mozc_server_info',
230              ],
231              'outputs': [
232                '<(gen_out_dir)/mozc_server_info',
233              ],
234              'action': [
235                '/usr/local/bin/python3.8', '../build_tools/tweak_info_plist.py',
236                '--output', '<(gen_out_dir)/mozc_server_info',
237                '--input', '../data/mac/mozc_server_info',
238                '--version_file', '../mozc_version.txt',
239                '--branding', '<(branding)',
240              ],
241            },
242          ],
243        },
244      ],
245    }],
246  ],
247}
248