OLD | NEW |
| (Empty) |
1 #!/usr/bin/python2.4 | |
2 # | |
3 # Copyright 2009 Google Inc. | |
4 # | |
5 # Licensed under the Apache License, Version 2.0 (the "License"); | |
6 # you may not use this file except in compliance with the License. | |
7 # You may obtain a copy of the License at | |
8 # | |
9 # http://www.apache.org/licenses/LICENSE-2.0 | |
10 # | |
11 # Unless required by applicable law or agreed to in writing, software | |
12 # distributed under the License is distributed on an "AS IS" BASIS, | |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 # See the License for the specific language governing permissions and | |
15 # limitations under the License. | |
16 # ======================================================================== | |
17 | |
18 | |
19 Import('env') | |
20 | |
21 # Need to do all these modifications to the non-default env because calling | |
22 # EnablePrecompile on the main environment, which customization_test_env clones. | |
23 # causes the opt build to fail. | |
24 # TODO(omaha): How much of this needs to be used by all libraries that get built | |
25 # and how much can be moved to BuildNpGoogleUpdateDll? | |
26 update_env = env.Clone() | |
27 update_env.Append( | |
28 CPPDEFINES = [ | |
29 # TODO(omaha): ActiveX plugins are usually apartment-threaded. There's | |
30 # no problem with compiling at a higher threading level than required, | |
31 # but there is a slight performance penalty for AddRef()/Release(). At | |
32 # some point, it may be desirable to switch back to apartment threaded, | |
33 # once the unit tests are fixed. | |
34 # We also take a 1KiB penalty for using _ATL_FREE_THREADED =) | |
35 '_ATL_FREE_THREADED', | |
36 ], | |
37 CPPFLAGS = [ | |
38 # TODO(omaha): use PCH so we get /Wall. Need to figure out why half of | |
39 # the old plugin builds with PCH, and the other half of it builds | |
40 # without... | |
41 '/Wall', | |
42 # omaha/third_party/base/basictypes.h | |
43 '/wd4310', # cast truncates constant value | |
44 # ATL | |
45 '/wd4263', # member function does not override any base class virtual | |
46 # member function | |
47 '/wd4264', # no override available for virtual member function; | |
48 # function is hidden | |
49 '/wd4265', # class has virtual functions, but destructor is not virtual | |
50 # vector | |
51 '/wd4548', # expression before comma has no effect; expected expression | |
52 # with side-effect | |
53 ], | |
54 CPPPATH = [ | |
55 '$OBJ_ROOT', # Needed for generated files. | |
56 ], | |
57 LIBS = [ | |
58 '$LIB_DIR/base.lib', | |
59 '$LIB_DIR/breakpad.lib', | |
60 '$LIB_DIR/client.lib', | |
61 '$LIB_DIR/core.lib', | |
62 '$LIB_DIR/google_update_recovery.lib', | |
63 '$LIB_DIR/goopdate_lib.lib', | |
64 '$LIB_DIR/logging.lib', | |
65 '$LIB_DIR/net.lib', | |
66 '$LIB_DIR/omaha3_idl.lib', | |
67 '$LIB_DIR/security.lib', | |
68 '$LIB_DIR/service.lib', | |
69 '$LIB_DIR/setup.lib', | |
70 '$LIB_DIR/statsreport.lib', | |
71 '$LIB_DIR/ui.lib', | |
72 ('atls.lib', 'atlsd.lib')[env.Bit('debug')], | |
73 ('libcmt.lib', 'libcmtd.lib')[env.Bit('debug')], | |
74 ('libcpmt.lib', 'libcpmtd.lib')[env.Bit('debug')], | |
75 'bits.lib', | |
76 'comctl32.lib', | |
77 'crypt32.lib', | |
78 'iphlpapi.lib', | |
79 'msi.lib', | |
80 'msimg32.lib', | |
81 'mstask.lib', | |
82 'psapi.lib', | |
83 'netapi32.lib', | |
84 'rasapi32.lib', | |
85 'shlwapi.lib', | |
86 'taskschd.lib', | |
87 'userenv.lib', | |
88 'version.lib', | |
89 'wintrust.lib', | |
90 'wtsapi32.lib', | |
91 ], | |
92 LINKFLAGS = [ | |
93 '/DYNAMICBASE', # Enable ASLR. | |
94 '/NXCOMPAT', # Enable NX support. | |
95 ], | |
96 ) | |
97 | |
98 | |
99 # COM stuff. | |
100 midl_env = env.Clone() | |
101 midl_env.Tool('midl') | |
102 # Generate optimized, stubless proxy/stub code. | |
103 midl_env['MIDLFLAGS'] += [ '/Oicf', ] | |
104 | |
105 # For some reason, calling TypeLibrary() twice on the same environment causes a | |
106 # re-link of the test executable when alternating between "hammer" and | |
107 # "hammer run_all_tests". | |
108 # To work around this, clone the original environment and call TypeLibrary once | |
109 # on each. Note that: | |
110 # 1) Cloning midl_env BEFORE TypeLibrary() is called does not solve this | |
111 # problem. The environment must be cloned from the original env. | |
112 # 2) Moving the following code down near npapi_testing_midl_env.TypeLibrary | |
113 # does not solve the problem either. | |
114 # 3) This problem does not occur if 'update_npapi_testing.lib' is passed as | |
115 # a source to other builders instead of as a LIB. | |
116 npapi_testing_midl_env = env.Clone() | |
117 npapi_testing_midl_env.Tool('midl') | |
118 # Generate optimized, stubless proxy/stub code. | |
119 npapi_testing_midl_env['MIDLFLAGS'] += [ '/Oicf', ] | |
120 | |
121 midl_env.TypeLibrary('activex/update_control_idl.idl') | |
122 | |
123 # Generate the GUIDs with no precompile option set, otherwise we get an error. | |
124 update_control_idl_guids_lib = env.ComponentStaticLibrary( | |
125 lib_name='update_control_idl_guids_lib', | |
126 source='$OBJ_ROOT/plugins/update/activex/update_control_idl_i.c', | |
127 use_pch_default=False, | |
128 ) | |
129 | |
130 # Built as library to enable unit testing. | |
131 inputs = [ | |
132 'activex/update3web_control.cc', | |
133 'activex/oneclick_control.cc', | |
134 'npapi/dispatch_host.cc', | |
135 'npapi/npfunction_host.cc', | |
136 'npapi/urlpropbag.cc', | |
137 'npapi/np_update.cc', | |
138 'npapi/variant_utils.cc', | |
139 'config.cc', | |
140 'site_lock.cc', | |
141 ] | |
142 update_lib = update_env.ComponentStaticLibrary( | |
143 lib_name='update', | |
144 source=inputs, | |
145 ) | |
146 | |
147 | |
148 def BuildNpGoogleUpdateDll(omaha_version_info): | |
149 version_string = omaha_version_info.GetVersionString() | |
150 prefix = omaha_version_info.filename_prefix | |
151 | |
152 plugin_env = update_env.Clone(COMPONENT_STATIC = False) | |
153 | |
154 if prefix == 'TEST_': | |
155 plugin_env['OBJPREFIX'] = plugin_env.subst('test/$OBJPREFIX') | |
156 elif prefix: | |
157 raise Exception('ERROR: Unrecognized prefix "%s"' % prefix) | |
158 | |
159 plugin_env.Append( | |
160 LIBS = [ | |
161 '$LIB_DIR/common.lib', | |
162 '$LIB_DIR/plugin_base.lib', | |
163 'wininet.lib', | |
164 update_control_idl_guids_lib, | |
165 update_lib, | |
166 ], | |
167 RCFLAGS = [ | |
168 '/DVERSION_MAJOR=%d' % omaha_version_info.version_major, | |
169 '/DVERSION_MINOR=%d' % omaha_version_info.version_minor, | |
170 '/DVERSION_BUILD=%d' % omaha_version_info.version_build, | |
171 '/DVERSION_PATCH=%d' % omaha_version_info.version_patch, | |
172 '/DVERSION_NUMBER_STRING=\\"%s\\"' % version_string, | |
173 ], | |
174 ) | |
175 | |
176 | |
177 resource = plugin_env.RES(target='%sresource.res' % prefix, | |
178 source='resource.rc') | |
179 plugin_env.Depends( | |
180 resource, | |
181 ['$MAIN_DIR/VERSION', | |
182 '$OBJ_ROOT/plugins/update/activex/update_control_idl.tlb', | |
183 'oneclick.rgs']) | |
184 | |
185 target_name = '%s%s' % ( | |
186 prefix, | |
187 omaha_version_info.plugin_signed_file_info.unsigned_filename_base) | |
188 | |
189 inputs = [ | |
190 'module.def', | |
191 'module.cc', | |
192 resource, | |
193 ] | |
194 | |
195 unsigned_dll = plugin_env.ComponentDll( | |
196 lib_name=target_name, | |
197 source=inputs, | |
198 ) | |
199 | |
200 signed_dll = plugin_env.SignedBinary( | |
201 target='%s%s' % (prefix, | |
202 omaha_version_info.plugin_signed_file_info.filename), | |
203 source=unsigned_dll, | |
204 ) | |
205 | |
206 env.Replicate('$STAGING_DIR', signed_dll) | |
207 env.Replicate('$STAGING_DIR', [f for f in unsigned_dll if f.suffix == '.pdb']) | |
208 | |
209 | |
210 for omaha_version_info in env['omaha_versions_info']: | |
211 BuildNpGoogleUpdateDll(omaha_version_info) | |
212 | |
213 | |
214 # | |
215 # Tests | |
216 # | |
217 | |
218 # NPAPI unit test helper library | |
219 npapi_testing_midl_env.TypeLibrary('npapi/testing/dispatch_host_test_idl.idl') | |
220 inputs = [ | |
221 'npapi/testing/dispatch_host_test_interface.cc', | |
222 'npapi/testing/stubs.cc', | |
223 ] | |
224 update_test_helpers_lib = update_env.ComponentStaticLibrary( | |
225 lib_name='update_test_helpers', | |
226 source=inputs, | |
227 ) | |
228 | |
229 npapi_test_lib_resources = update_env.RES( | |
230 target='npapi/testing/dispatch_host_test.res', | |
231 source='npapi/testing/dispatch_host_test.rc'), | |
232 # TODO(omaha): we should really just make a proper .rc file scanner. | |
233 update_env.Depends( | |
234 npapi_test_lib_resources, | |
235 '$OBJ_ROOT/plugins/update/npapi/testing/dispatch_host_test_idl.tlb') | |
236 | |
237 # TODO(omaha): Fix OmahaUnittest() so that MODE=all does not break. | |
238 update_env.OmahaUnittest( | |
239 name='update_plugin_unittest', | |
240 source=[ | |
241 'activex/update3web_control_unittest.cc', | |
242 'npapi/dispatch_host_unittest.cc', | |
243 'npapi/npfunction_host_unittest.cc', | |
244 'npapi/variant_utils_unittest.cc', | |
245 'site_lock_unittest.cc', | |
246 npapi_test_lib_resources, | |
247 ], | |
248 LIBS=[ | |
249 '$LIB_DIR/common.lib', | |
250 'wininet', | |
251 update_control_idl_guids_lib, | |
252 update_lib, | |
253 update_test_helpers_lib, | |
254 ], | |
255 all_in_one=False, | |
256 COMPONENT_TEST_SIZE='small', | |
257 ) | |
258 | |
259 | |
260 customization_test_env = env.Clone() | |
261 customization_test_env.Append( | |
262 LIBS = [ | |
263 '$LIB_DIR/common.lib', | |
264 ] | |
265 ) | |
266 customization_test_env['CPPPATH'] += [ | |
267 '$OBJ_ROOT', # Needed for generated files. | |
268 ] | |
269 customization_test = customization_test_env.OmahaUnittest( | |
270 name='omaha_customization_update_apis_unittest', | |
271 source=[ | |
272 'omaha_customization_update_apis_unittest.cc', | |
273 'omaha_customization_update_unittest.cc', | |
274 ], | |
275 LIBS=[ | |
276 update_control_idl_guids_lib, # Needed for LIBID_*. | |
277 update_lib, | |
278 ], | |
279 all_in_one=False, | |
280 COMPONENT_TEST_SIZE='small', | |
281 ) | |
282 | |
283 # The test uses the DLL for its TypeLib. | |
284 customization_test_env.Depends( | |
285 customization_test, | |
286 '$STAGING_DIR/%s' % env['omaha_versions_info'][0].update_plugin_filename) | |
OLD | NEW |