| @@ -1,172 +1,172 @@ | | | @@ -1,172 +1,172 @@ |
1 | $NetBSD: patch-build__mozc.py,v 1.5 2014/07/19 09:03:04 ryoon Exp $ | | 1 | $NetBSD: patch-build__mozc.py,v 1.6 2014/11/07 23:28:36 ryoon Exp $ |
2 | | | 2 | |
3 | --- build_mozc.py.orig 2014-07-14 10:14:21.000000000 +0000 | | 3 | --- build_mozc.py.orig 2014-11-03 05:13:03.000000000 +0000 |
4 | +++ build_mozc.py | | 4 | +++ build_mozc.py |
5 | @@ -60,6 +60,7 @@ from build_tools.util import FindFileFro | | 5 | @@ -60,6 +60,7 @@ from build_tools.util import FindFileFro |
6 | from build_tools.util import GetNumberOfProcessors | | 6 | from build_tools.util import GetNumberOfProcessors |
7 | from build_tools.util import GetRelPath | | 7 | from build_tools.util import GetRelPath |
8 | from build_tools.util import IsLinux | | 8 | from build_tools.util import IsLinux |
9 | +from build_tools.util import IsNetBSD | | 9 | +from build_tools.util import IsNetBSD |
10 | from build_tools.util import IsMac | | 10 | from build_tools.util import IsMac |
11 | from build_tools.util import IsWindows | | 11 | from build_tools.util import IsWindows |
12 | from build_tools.util import PrintErrorAndExit | | 12 | from build_tools.util import PrintErrorAndExit |
13 | @@ -121,6 +122,8 @@ def GetBuildShortBaseName(options, targe | | 13 | @@ -121,6 +122,8 @@ def GetBuildShortBaseName(options, targe |
14 | build_base = 'out_mac' | | 14 | build_base = 'out_mac' |
15 | elif target_platform == 'Linux': | | 15 | elif target_platform == 'Linux': |
16 | build_base = 'out_linux' | | 16 | build_base = 'out_linux' |
17 | + elif target_platform == 'NetBSD': | | 17 | + elif target_platform == 'NetBSD': |
18 | + build_base = 'out_bsd' | | 18 | + build_base = 'out_bsd' |
19 | elif target_platform == 'Android': | | 19 | elif target_platform == 'Android': |
20 | build_base = 'out_android' | | 20 | build_base = 'out_android' |
21 | elif target_platform == 'NaCl': | | 21 | elif target_platform == 'NaCl': |
22 | @@ -220,6 +223,14 @@ def GetGypFileNames(options): | | 22 | @@ -219,6 +222,14 @@ def GetGypFileNames(options): |
23 | if not PkgExists('ibus-1.0 >= 1.4.1'): | | 23 | if not PkgExists('ibus-1.0 >= 1.4.1'): |
24 | logging.info('removing ibus.gyp.') | | 24 | logging.info('removing ibus.gyp.') |
25 | gyp_file_names.remove('%s/unix/ibus/ibus.gyp' % SRC_DIR) | | 25 | gyp_file_names.remove('%s/unix/ibus/ibus.gyp' % SRC_DIR) |
26 | + elif options.target_platform == 'NetBSD': | | 26 | + elif options.target_platform == 'NetBSD': |
27 | + gyp_file_names.extend(glob.glob('%s/unix/*/*.gyp' % SRC_DIR)) | | 27 | + gyp_file_names.extend(glob.glob('%s/unix/*/*.gyp' % SRC_DIR)) |
28 | + # Add ibus.gyp if ibus version is >=1.4.1. | | 28 | + # Add ibus.gyp if ibus version is >=1.4.1. |
29 | + if not PkgExists('ibus-1.0 >= 1.4.1'): | | 29 | + if not PkgExists('ibus-1.0 >= 1.4.1'): |
30 | + logging.info('removing ibus.gyp.') | | 30 | + logging.info('removing ibus.gyp.') |
31 | + gyp_file_names.remove('%s/unix/ibus/ibus.gyp' % SRC_DIR) | | 31 | + gyp_file_names.remove('%s/unix/ibus/ibus.gyp' % SRC_DIR) |
32 | + elif options.target_platform == 'ChromeOS': | | 32 | + elif options.target_platform == 'ChromeOS': |
33 | + gyp_file_names.extend(glob.glob('%s/unix/ibus/*.gyp' % SRC_DIR)) | | 33 | + gyp_file_names.extend(glob.glob('%s/unix/ibus/*.gyp' % SRC_DIR)) |
34 | elif options.target_platform == 'NaCl': | | 34 | elif options.target_platform == 'NaCl': |
35 | # Add chrome NaCl Mozc gyp scripts. | | 35 | # Add chrome NaCl Mozc gyp scripts. |
36 | gyp_file_names.append('%s/chrome/nacl/nacl_extension.gyp' % SRC_DIR) | | 36 | gyp_file_names.append('%s/chrome/nacl/nacl_extension.gyp' % SRC_DIR) |
37 | @@ -315,6 +326,8 @@ def AddTargetPlatformOption(parser): | | 37 | @@ -314,6 +325,8 @@ def AddTargetPlatformOption(parser): |
38 | # If you want Android build, specify "Android". | | 38 | # If you want Android build, specify "Android". |
39 | if IsLinux(): | | 39 | if IsLinux(): |
40 | default_target = 'Linux' | | 40 | default_target = 'Linux' |
41 | + elif IsNetBSD(): | | 41 | + elif IsNetBSD(): |
42 | + default_target = 'NetBSD' | | 42 | + default_target = 'NetBSD' |
43 | elif IsWindows(): | | 43 | elif IsWindows(): |
44 | default_target = 'Windows' | | 44 | default_target = 'Windows' |
45 | elif IsMac(): | | 45 | elif IsMac(): |
46 | @@ -512,6 +525,14 @@ def ExpandMetaTarget(options, meta_targe | | 46 | @@ -511,6 +524,14 @@ def ExpandMetaTarget(options, meta_targe |
47 | SRC_DIR + '/gui/gui.gyp:mozc_tool'] | | 47 | SRC_DIR + '/gui/gui.gyp:mozc_tool'] |
48 | if PkgExists('ibus-1.0 >= 1.4.1'): | | 48 | if PkgExists('ibus-1.0 >= 1.4.1'): |
49 | targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc') | | 49 | targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc') |
50 | + elif target_platform == 'NetBSD': | | 50 | + elif target_platform == 'NetBSD': |
51 | + targets = [SRC_DIR + '/server/server.gyp:mozc_server', | | 51 | + targets = [SRC_DIR + '/server/server.gyp:mozc_server', |
52 | + SRC_DIR + '/renderer/renderer.gyp:mozc_renderer', | | 52 | + SRC_DIR + '/renderer/renderer.gyp:mozc_renderer', |
53 | + SRC_DIR + '/gui/gui.gyp:mozc_tool'] | | 53 | + SRC_DIR + '/gui/gui.gyp:mozc_tool'] |
54 | + if PkgExists('ibus-1.0 >= 1.4.1'): | | 54 | + if PkgExists('ibus-1.0 >= 1.4.1'): |
55 | + targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc') | | 55 | + targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc') |
56 | + elif target_platform == 'ChromeOS': | | 56 | + elif target_platform == 'ChromeOS': |
57 | + targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc') | | 57 | + targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc') |
58 | elif target_platform == 'Mac': | | 58 | elif target_platform == 'Mac': |
59 | targets = [SRC_DIR + '/mac/mac.gyp:DiskImage'] | | 59 | targets = [SRC_DIR + '/mac/mac.gyp:DiskImage'] |
60 | elif target_platform == 'Windows': | | 60 | elif target_platform == 'Windows': |
61 | @@ -537,7 +558,7 @@ def ParseBuildOptions(args=None, values= | | 61 | @@ -536,7 +557,7 @@ def ParseBuildOptions(args=None, values= |
62 | """Parses command line options for the build command.""" | | 62 | """Parses command line options for the build command.""" |
63 | parser = optparse.OptionParser(usage='Usage: %prog build [options]') | | 63 | parser = optparse.OptionParser(usage='Usage: %prog build [options]') |
64 | AddCommonOptions(parser) | | 64 | AddCommonOptions(parser) |
65 | - if IsLinux(): | | 65 | - if IsLinux(): |
66 | + if IsLinux() or IsNetBSD(): | | 66 | + if IsLinux() or IsNetBSD(): |
67 | default_build_concurrency = GetNumberOfProcessors() * 2 | | 67 | default_build_concurrency = GetNumberOfProcessors() * 2 |
68 | parser.add_option('--jobs', '-j', dest='jobs', | | 68 | parser.add_option('--jobs', '-j', dest='jobs', |
69 | default=('%d' % default_build_concurrency), | | 69 | default=('%d' % default_build_concurrency), |
70 | @@ -566,7 +587,7 @@ def ParseRunTestsOptions(args=None, valu | | 70 | @@ -565,7 +586,7 @@ def ParseRunTestsOptions(args=None, valu |
71 | parser = optparse.OptionParser( | | 71 | parser = optparse.OptionParser( |
72 | usage='Usage: %prog runtests [options] [test_targets] [-- build options]') | | 72 | usage='Usage: %prog runtests [options] [test_targets] [-- build options]') |
73 | AddCommonOptions(parser) | | 73 | AddCommonOptions(parser) |
74 | - if IsLinux(): | | 74 | - if IsLinux(): |
75 | + if IsLinux() or ISNetBSD(): | | 75 | + if IsLinux() or ISNetBSD(): |
76 | default_build_concurrency = GetNumberOfProcessors() * 2 | | 76 | default_build_concurrency = GetNumberOfProcessors() * 2 |
77 | parser.add_option('--jobs', '-j', dest='jobs', | | 77 | parser.add_option('--jobs', '-j', dest='jobs', |
78 | default=('%d' % default_build_concurrency), | | 78 | default=('%d' % default_build_concurrency), |
79 | @@ -787,7 +808,8 @@ def GypMain(options, unused_args, _): | | 79 | @@ -788,7 +809,8 @@ def GypMain(options, unused_args, _): |
80 | gyp_options.extend(['-D', 'channel_dev=1']) | | 80 | gyp_options.extend(['-D', 'channel_dev=1']) |
81 | | | 81 | |
82 | def SetCommandLineForFeature(option_name, windows=False, mac=False, | | 82 | def SetCommandLineForFeature(option_name, windows=False, mac=False, |
83 | - linux=False, android=False, nacl=False): | | 83 | - linux=False, android=False, nacl=False): |
84 | + linux=False, android=False, nacl=False, | | 84 | + linux=False, android=False, nacl=False, |
85 | + netbsd=False): | | 85 | + netbsd=False): |
86 | """Updates an option like '--enable_foober' and add a -D argument for gyp. | | 86 | """Updates an option like '--enable_foober' and add a -D argument for gyp. |
87 | | | 87 | |
88 | This function ensures an option like '--enable_foober' exists and it has a | | 88 | This function ensures an option like '--enable_foober' exists and it has a |
89 | @@ -809,6 +831,8 @@ def GypMain(options, unused_args, _): | | 89 | @@ -810,6 +832,8 @@ def GypMain(options, unused_args, _): |
90 | option on Android platform. | | 90 | option on Android platform. |
91 | nacl: A boolean which replesents the default value of the target | | 91 | nacl: A boolean which replesents the default value of the target |
92 | option on NaCl. | | 92 | option on NaCl. |
93 | + netbsd: boolean which replesents the default value of the target option | | 93 | + netbsd: boolean which replesents the default value of the target option |
94 | + on NetBSD platform. | | 94 | + on NetBSD platform. |
95 | | | 95 | |
96 | Raises: | | 96 | Raises: |
97 | ValueError: An error occurred when 'option_name' is empty. | | 97 | ValueError: An error occurred when 'option_name' is empty. |
98 | @@ -821,6 +845,7 @@ def GypMain(options, unused_args, _): | | 98 | @@ -822,6 +846,7 @@ def GypMain(options, unused_args, _): |
99 | 'Mac': mac, | | 99 | 'Mac': mac, |
100 | 'Linux': linux, | | 100 | 'Linux': linux, |
101 | 'Android': android, | | 101 | 'Android': android, |
102 | + 'NetBSD' : netbsd, | | 102 | + 'NetBSD' : netbsd, |
103 | 'NaCl': nacl}[options.target_platform] | | 103 | 'NaCl': nacl}[options.target_platform] |
104 | enable_option_name = 'enable_%s' % option_name | | 104 | enable_option_name = 'enable_%s' % option_name |
105 | enabled = options.ensure_value(enable_option_name, default_enabled) | | 105 | enabled = options.ensure_value(enable_option_name, default_enabled) |
106 | @@ -832,10 +857,12 @@ def GypMain(options, unused_args, _): | | 106 | @@ -833,10 +858,12 @@ def GypMain(options, unused_args, _): |
107 | | | 107 | |
108 | SetCommandLineForFeature(option_name='cloud_handwriting', | | 108 | SetCommandLineForFeature(option_name='cloud_handwriting', |
109 | linux=is_official_dev, | | 109 | linux=is_official_dev, |
110 | + netbsd=is_official_dev, | | 110 | + netbsd=is_official_dev, |
111 | windows=is_official_dev, | | 111 | windows=is_official_dev, |
112 | mac=is_official_dev) | | 112 | mac=is_official_dev) |
113 | SetCommandLineForFeature(option_name='http_client', | | 113 | SetCommandLineForFeature(option_name='http_client', |
114 | linux=is_official, | | 114 | linux=is_official, |
115 | + netbsd=is_official, | | 115 | + netbsd=is_official, |
116 | windows=is_official, | | 116 | windows=is_official, |
117 | mac=is_official, | | 117 | mac=is_official, |
118 | android=is_official, | | 118 | android=is_official, |
119 | @@ -873,7 +900,8 @@ def GypMain(options, unused_args, _): | | 119 | @@ -874,7 +901,8 @@ def GypMain(options, unused_args, _): |
120 | else: | | 120 | else: |
121 | gyp_options.extend(['-D', 'use_zinnia=NO']) | | 121 | gyp_options.extend(['-D', 'use_zinnia=NO']) |
122 | | | 122 | |
123 | - if (options.target_platform == 'Linux' and | | 123 | - if (options.target_platform == 'Linux' and |
124 | + if ((options.target_platform == 'Linux' or | | 124 | + if ((options.target_platform == 'Linux' or |
125 | + options.target_platform == 'NetBSD') and | | 125 | + options.target_platform == 'NetBSD') and |
126 | '%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names): | | 126 | '%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names): |
127 | gyp_options.extend(['-D', 'use_libibus=1']) | | 127 | gyp_options.extend(['-D', 'use_libibus=1']) |
128 | | | 128 | |
129 | @@ -906,7 +934,7 @@ def GypMain(options, unused_args, _): | | 129 | @@ -907,7 +935,7 @@ def GypMain(options, unused_args, _): |
130 | # command for pkg-config. Here we catch the environment variable | | 130 | # command for pkg-config. Here we catch the environment variable |
131 | # and use the specified command instead of actual pkg-config | | 131 | # and use the specified command instead of actual pkg-config |
132 | # command. | | 132 | # command. |
133 | - if IsLinux(): | | 133 | - if IsLinux(): |
134 | + if IsLinux() or IsNetBSD(): | | 134 | + if IsLinux() or IsNetBSD(): |
135 | gyp_options.extend(['-D', 'pkg_config_command=%s' % GetPkgConfigCommand()]) | | 135 | gyp_options.extend(['-D', 'pkg_config_command=%s' % GetPkgConfigCommand()]) |
136 | else: | | 136 | else: |
137 | gyp_options.extend(['-D', 'pkg_config_command=']) | | 137 | gyp_options.extend(['-D', 'pkg_config_command=']) |
138 | @@ -1050,6 +1078,25 @@ def BuildOnMac(options, targets, origina | | 138 | @@ -1045,6 +1073,25 @@ def BuildOnMac(options, targets, origina |
139 | '-parallelizeTargets', | | 139 | '-parallelizeTargets', |
140 | 'BUILD_WITH_GYP=1']) | | 140 | 'BUILD_WITH_GYP=1']) |
141 | | | 141 | |
142 | +def BuildOnBSD(options, targets, unused_original_directory_name): | | 142 | +def BuildOnBSD(options, targets, unused_original_directory_name): |
143 | + """Build the targets on BSD.""" | | 143 | + """Build the targets on BSD.""" |
144 | + target_names = [] | | 144 | + target_names = [] |
145 | + for target in targets: | | 145 | + for target in targets: |
146 | + (unused_gyp_file_name, target_name) = ( | | 146 | + (unused_gyp_file_name, target_name) = ( |
147 | + CanonicalTargetToGypFileAndTargetName(target)) | | 147 | + CanonicalTargetToGypFileAndTargetName(target)) |
148 | + target_names.append(target_name) | | 148 | + target_names.append(target_name) |
149 | + | | 149 | + |
150 | + ninja = 'ninja' | | 150 | + ninja = 'ninja' |
151 | + if hasattr(options, 'android_device'): | | 151 | + if hasattr(options, 'android_device'): |
152 | + # Only for android testing. | | 152 | + # Only for android testing. |
153 | + os.environ['ANDROID_DEVICES'] = options.android_device | | 153 | + os.environ['ANDROID_DEVICES'] = options.android_device |
154 | + | | 154 | + |
155 | + short_basename = GetBuildShortBaseName(options, | | 155 | + short_basename = GetBuildShortBaseName(options, |
156 | + GetMozcVersion().GetTargetPlatform()) | | 156 | + GetMozcVersion().GetTargetPlatform()) |
157 | + make_command = ninja | | 157 | + make_command = ninja |
158 | + build_args = ['-j %s' % options.jobs, | | 158 | + build_args = ['-j %s' % options.jobs, |
159 | + '-C', '%s/%s' % (short_basename, options.configuration)] | | 159 | + '-C', '%s/%s' % (short_basename, options.configuration)] |
160 | + RunOrDie([make_command] + build_args + target_names) | | 160 | + RunOrDie([make_command] + build_args + target_names) |
161 | | | 161 | |
162 | def BuildOnWindows(targets): | | 162 | def BuildOnWindows(targets): |
163 | """Build the target on Windows.""" | | 163 | """Build the target on Windows.""" |
164 | @@ -1077,6 +1124,8 @@ def BuildMain(options, targets, original | | 164 | @@ -1072,6 +1119,8 @@ def BuildMain(options, targets, original |
165 | BuildOnMac(options, targets, original_directory_name) | | 165 | BuildOnMac(options, targets, original_directory_name) |
166 | elif IsLinux(): | | 166 | elif IsLinux(): |
167 | BuildOnLinux(options, targets, original_directory_name) | | 167 | BuildOnLinux(options, targets, original_directory_name) |
168 | + elif IsNetBSD(): | | 168 | + elif IsNetBSD(): |
169 | + BuildOnBSD(options, targets, original_directory_name) | | 169 | + BuildOnBSD(options, targets, original_directory_name) |
170 | elif IsWindows(): | | 170 | elif IsWindows(): |
171 | BuildOnWindows(targets) | | 171 | BuildOnWindows(targets) |
172 | else: | | 172 | else: |