OLD | NEW |
| (Empty) |
1 #!/usr/bin/python2.4 | |
2 # | |
3 # Copyright 2009-2010 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 # This main.scons file is the root description of the build specified in this | |
20 # directory and those under it. Individual components and the source files | |
21 # used to build them are described in subsidiary files called 'build.scons'. | |
22 # | |
23 # To build this project change the current directory to googleclient/Omaha. | |
24 # Then run hammer.bat | |
25 # | |
26 # A number of command line options can be specified. For a full list, use the | |
27 # -h and -H command options. | |
28 # | |
29 # Some useful options include: | |
30 # -h : Prints a list of which modules and build variants are available | |
31 # in this project. | |
32 # -H : Print SCons specific help. SCons is a build tool which this | |
33 # project uses in tandem with the Software Construction Toolkit | |
34 # to build. | |
35 # -c : Clean the project. I.e. delete all build output. | |
36 # -j3 : Run up to 3 build steps at once. | |
37 # | |
38 # Some useful build targets include: | |
39 # all_programs : Build all programs generated by this project. | |
40 # all_libraries : Build all libraries generated by this project. | |
41 # all_tests : Build all tests generated by this project. | |
42 # run_all_tests : Build and run all tests generated by this project. | |
43 # | |
44 # Some examples: | |
45 # Build all programs and libraries in debug mode: | |
46 # hammer | |
47 # Build and run all tests in debug mode on windows: | |
48 # hammer MODE=dbg-win run_all_tests | |
49 # Build arbitrary library in the default mode: | |
50 # hammer <library name> | |
51 | |
52 import copy | |
53 import os | |
54 import sys | |
55 | |
56 import omaha_version_utils | |
57 | |
58 # To switch the build, simply change the value of the msc_ver variable below. | |
59 # VC2003/VC71 is 1310 but not supported by the current build. | |
60 # VC2005/VC80 is 1400. | |
61 # VC2008/VC90 is 1500. | |
62 _msc_ver = 1400 | |
63 | |
64 _sdk_path = os.environ['OMAHA_VISTASDK_DIR'] | |
65 | |
66 _signtool_path = os.path.join(_sdk_path, 'bin/signtool.exe') | |
67 | |
68 # Build the "Google Update", the Google-specific version of Omaha. | |
69 # TODO(omaha): Set based on an environment variable and/or Hammer arg. | |
70 is_google_update_build = False | |
71 | |
72 # | |
73 # Begin vendor-specific constants. | |
74 # | |
75 # These values must be changed when customizing open source Omaha. | |
76 # You may also wish to replace the language-neutral constants in the individual | |
77 # *generated_resources_*.rc files with localized strings. | |
78 _FULL_COMPANY_NAME = 'OmahaCompanyName Inc.' | |
79 _SHORT_COMPANY_NAME = 'OmahaCompanyName' | |
80 _PRODUCT_NAME = 'Update' | |
81 _COMPANY_DOMAIN_BASE = 'google' | |
82 _COMPANY_DOMAIN = _COMPANY_DOMAIN_BASE + '.com' | |
83 _MAIN_EXE_BASE_NAME = 'GoogleUpdate' | |
84 # TODO(omaha): Use this throughout the build files where goopdate and | |
85 # goopdateres are referenced. | |
86 _MAIN_DLL_BASE_NAME = 'goopdate' | |
87 # "Google Inc." must not be removed from the copyright string. This literal also | |
88 # appears as LegalCopyright in the VERSIONINFO section of .rc files. | |
89 # TODO(omaha): Use this variable in .wxs files, etc. | |
90 _OMAHA_COPYRIGHT_STRING_ENGLISH = 'Copyright 2007-2010 Google Inc.' | |
91 | |
92 | |
93 # TODO(omaha): Allow open source Omaha to be built without the Recovery MSI, | |
94 # which requires an extra certificate file and is unlikely to be used, or | |
95 # ClickOnce, which requires specifying a certificate hash. Disabling Recovery | |
96 # by default also means the open source build will work by default without | |
97 # having to check in SaveArguments.exe to SVN every 100 days. | |
98 # TODO(omaha3): Allow open source Omaha to be built without support for | |
99 # Omaha 2's COM APIs. | |
100 | |
101 # The hash comes from the Thumbprint item in the Details tab of the file | |
102 # properties for the public key .cer file. | |
103 # TODO(omaha): Can we automate reading this and/or pass it on the command line? | |
104 _BUILD_SERVER_CERTIFICATE_HASH = 'cafd39335d6e76f0e26d81296e7cbbfbdf16a720' | |
105 | |
106 # | |
107 # End vendor-specific constants. | |
108 # | |
109 | |
110 | |
111 # Windows is the only environment we bulid for, so create a specialized base | |
112 # environment for Windows. | |
113 win_env = Environment( | |
114 # For internal builds only, it is a good idea to have set before the | |
115 # 'component_setup' tool is used even though we add the SDK directories to | |
116 # the appropriate environment variables manually below. | |
117 PLATFORM_SDK_DIR = _sdk_path, | |
118 tools=[ | |
119 'component_setup', | |
120 'target_platform_windows', | |
121 # Need to use 'masm' to override the 'as' tool currently used | |
122 # by default in 'target_platform_windows' | |
123 'masm', | |
124 'atlmfc_vc80', | |
125 'code_signing', | |
126 'component_targets_msvs', | |
127 'omaha_builders', | |
128 ], | |
129 msc_ver = _msc_ver, | |
130 build_server_certificate_hash = _BUILD_SERVER_CERTIFICATE_HASH, | |
131 # Visual Studio 2008 does not ship the sign tool. Use the sign tool from | |
132 # the Platform SDK. This must come after the 'code_signing' tool is used. | |
133 # Remove this if http://code.google.com/p/swtoolkit/issues/detail?id=16 is | |
134 # fixed. | |
135 SIGNTOOL = '"' + _signtool_path + '"', | |
136 ) | |
137 | |
138 # Remove this value because it conflicts with a #define | |
139 # in shlwapi.h in the Vista SDK | |
140 win_env.FilterOut(CPPDEFINES = ['OS_WINDOWS=OS_WINDOWS']) | |
141 | |
142 # We pre-generate our own manifests, so make sure hammer does not generate | |
143 # default ones for us | |
144 del win_env['MANIFEST_FILE'] | |
145 | |
146 # Hack to work around bug in Hammer (http://b/1585388). | |
147 # TODO(Omaha): Remove when bug is fixed. | |
148 if win_env['ENV'].has_key('SYSTEMROOT'): | |
149 if win_env['ENV'].has_key('SystemRoot'): | |
150 del win_env['ENV']['SYSTEMROOT'] | |
151 del os.environ['SYSTEMROOT'] | |
152 | |
153 # Work around http://code.google.com/p/swtoolkit/issues/detail?id=10. | |
154 win_env['COMPONENT_TEST_SUBSYSTEM_WINDOWS'] = 1 | |
155 | |
156 # Declare command line options relating to code signing | |
157 # authenticode_file and authenticode_password are used by the normal signing | |
158 # tool and to sign manifests for ClickOnce. | |
159 # patching_certificate is used to create patchable MSI installers and MSPs. | |
160 # authenticode_file and authenticode_password are only used if !build_server. | |
161 # patching_certificate is used in all cases. | |
162 AddOption( | |
163 '--authenticode_file', | |
164 action='store', | |
165 nargs=1, | |
166 type='string', | |
167 default='$MAIN_DIR/data/OmahaTestCert.pfx' | |
168 ) | |
169 | |
170 default_cert_password = 'test' | |
171 AddOption( | |
172 '--authenticode_password', | |
173 action='store', | |
174 nargs=1, | |
175 type='string', | |
176 default=default_cert_password | |
177 ) | |
178 | |
179 AddOption( | |
180 '--patching_certificate', | |
181 action='store', | |
182 nargs=1, | |
183 type='string', | |
184 default='$MAIN_DIR/data/OmahaTestCert.cer' | |
185 ) | |
186 | |
187 # Declare option for specifying path to new official build files | |
188 AddOption( | |
189 '--official_build_path', | |
190 action='store', | |
191 nargs=1, | |
192 type='string', | |
193 default=None | |
194 ) | |
195 | |
196 # Declare option for specifying the set of official app installers to build. | |
197 # The value describes the name of the directory containing the official | |
198 # installer manifests and definitions. | |
199 AddOption( | |
200 '--official_installer_app', | |
201 action='store', | |
202 nargs=1, | |
203 type='string', | |
204 default=None | |
205 ) | |
206 | |
207 AddOption( | |
208 '--official_installer_file', | |
209 action='store', | |
210 nargs=1, | |
211 type='string', | |
212 default=None | |
213 ) | |
214 | |
215 AddOption( | |
216 '--build_number', | |
217 action='store', | |
218 nargs=1, | |
219 type='string', | |
220 default='' | |
221 ) | |
222 | |
223 # Declare various boolean states. | |
224 DeclareBit('use_precompiled_headers', 'Use precompiled headers in build') | |
225 DeclareBit('official_installers', 'Building using checked-in binaries') | |
226 DeclareBit('build_server', 'Running on the build server') | |
227 DeclareBit('build_two_versions', 'Build second version for self-update testing') | |
228 DeclareBit('test_certificate', 'Files will be signed with the test certificate') | |
229 DeclareBit('bin', 'Building from pre-built binaries') | |
230 DeclareBit('min', 'Building minimal set of projects') | |
231 DeclareBit('all', 'Building all Projects') | |
232 DeclareBit('msvs', 'Building Visual Studio solution files') | |
233 DeclareBit('no-tests', 'Do not build the unit tests') | |
234 | |
235 # Build official installers if --official_installers is on the command line. | |
236 win_env.SetBitFromOption('official_installers', False) | |
237 | |
238 # Build as a build server if --build_server is on the command line. | |
239 win_env.SetBitFromOption('build_server', False) | |
240 | |
241 # Build two versions if --build_two_versions is on the command line. | |
242 win_env.SetBitFromOption('build_two_versions', False) | |
243 | |
244 # Store new versions of pre-built binaries if --bin is on the command line. | |
245 win_env.SetBitFromOption('bin', False) | |
246 | |
247 # Build minimal set of libs if --min is on the command line. | |
248 win_env.SetBitFromOption('min', False) | |
249 | |
250 # Build all libs if --all is on the command line. | |
251 win_env.SetBitFromOption('all', False) | |
252 | |
253 # Build Visual Studio solution files if --msvs is on the command line. | |
254 win_env.SetBitFromOption('msvs', False) | |
255 | |
256 # Do not build the unit tests if the bit is set. | |
257 win_env.SetBitFromOption('no-tests', False) | |
258 | |
259 # Build all directories and two versions if this is the build server. | |
260 if win_env.Bit('build_server'): | |
261 win_env.SetBits('all') | |
262 win_env.SetBits('build_two_versions') | |
263 | |
264 # Make sure 'all' overrides 'min'. | |
265 if win_env.Bit('all'): | |
266 win_env.ClearBits('min') | |
267 | |
268 # Allow use of command-line-specified certificates to sign with, but | |
269 # only if we're not on the build server. | |
270 if not win_env.Bit('build_server'): | |
271 win_env.Replace( | |
272 CERTIFICATE_PATH=GetOption('authenticode_file'), | |
273 CERTIFICATE_PASSWORD=GetOption('authenticode_password'), | |
274 ) | |
275 | |
276 # Store whether we're using the default test cert separately, because | |
277 # we won't always know what the default password was. | |
278 if GetOption('authenticode_password') is default_cert_password: | |
279 win_env.SetBits('test_certificate') | |
280 | |
281 | |
282 # The precompiled headers are to be used as an optional build speed up | |
283 # build facility. Individual compilation units in the project must build with | |
284 # or without precompiled headers. Building without precompiled headers is sort | |
285 # of meaningless, since all the time we should build with it. However, | |
286 # eliminating the dependency is desirable from a few reasons: | |
287 # 1. making sure the files in the project include all the definitions they need | |
288 # 2. creating different precompile headers if needed. | |
289 # 3. making sure the precompile headers do not add to the size bloat. | |
290 # There are two current limitations with the current setup. | |
291 # First, due to pushing the warning level to W4 and WAll, we rely on the | |
292 # common precompile.h to properly turn off the warnings inside system and | |
293 # library code. | |
294 # Second, to override the ATLASSERT, a file must be included before any of | |
295 # the atl headers. To do this on a case by case basis is impractical and | |
296 # error prone. | |
297 # Therefore, when building with precompile headers off, the code is | |
298 # building on W3 and it is not taking over the ATL asserts. | |
299 win_env.SetBitFromOption('use_precompiled_headers', True) | |
300 | |
301 if win_env.Bit('use_precompiled_headers'): | |
302 print 'Using precompiled headers.' | |
303 | |
304 | |
305 # | |
306 # Set up version info. | |
307 # | |
308 omaha_version_info = omaha_version_utils.OmahaVersionInfo('VERSION') | |
309 omaha_versions_info = [omaha_version_info] | |
310 | |
311 if win_env.Bit('build_two_versions'): | |
312 omaha_test_version_info = copy.deepcopy(omaha_version_info) | |
313 omaha_test_version_info.MakeTestVersion() | |
314 omaha_versions_info.append(omaha_test_version_info) | |
315 | |
316 # Print the version(s) being built. | |
317 print 'Building versions: %s' % ', '.join( | |
318 [version_info.GetVersionString() for version_info in omaha_versions_info]) | |
319 | |
320 build_number = GetOption('build_number') | |
321 if build_number: | |
322 print 'Build number: %s' % build_number | |
323 | |
324 win_env['omaha_versions_info'] = omaha_versions_info | |
325 | |
326 if is_google_update_build: | |
327 win_env.Append( | |
328 CPPDEFINES = ['GOOGLE_UPDATE_BUILD'], | |
329 RCFLAGS = ['/DGOOGLE_UPDATE_BUILD=1'], | |
330 ) | |
331 | |
332 # Make sure python.exe can be located. | |
333 win_env.AppendENVPath('PATH', os.environ['OMAHA_PYTHON_DIR']) | |
334 | |
335 win_env.Append( | |
336 # Add windows specific compiler flags. | |
337 CCFLAGS = [ | |
338 '/nologo', | |
339 '/c', | |
340 '/Zc:forScope', | |
341 '/D_HAS_EXCEPTIONS=0', | |
342 '/DCOMPILER_MSVC', | |
343 '/J', | |
344 '/DSTL_MSVC', | |
345 '/GR-', | |
346 '/D_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES=1', | |
347 '/D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1', | |
348 '/D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1', | |
349 '/WX', # warnings as errors | |
350 | |
351 # | |
352 # Disable the following level 4 warnings below. | |
353 # | |
354 '/wd4127', # conditional expression is constant | |
355 '/wd4189', # local variable is initialized but not referenced | |
356 '/wd4505', # unreferenced local function has been removed | |
357 | |
358 # | |
359 # Disable the pedantic warnings below. | |
360 # | |
361 '/wd4191', # unsafe conversion from 'type of expression' to | |
362 # 'type required' | |
363 '/wd4217', # member template functions cannot be used for | |
364 # copy-assignment... | |
365 '/wd4365', # conversion from 'type_1' to 'type_2', | |
366 # signed/unsigned mismatch | |
367 '/wd4512', # assignment operator could not be generated | |
368 '/wd4514', # unreferenced inline function has been removed | |
369 '/wd4555', # expression has no effect | |
370 '/wd4619', # #pragma warning : there is no warning number 'number' | |
371 '/wd4623', # default constructor could not be generated... | |
372 '/wd4625', # copy constructor could not be generated... | |
373 '/wd4626', # assignment operator could not be generated... | |
374 '/wd4668', # not defined as a preprocessor macro, replacing with '0'. | |
375 '/wd4710', # function not inlined | |
376 '/wd4711', # function 'function' selected for inline expansion | |
377 '/wd4738', # storing 32-bit float result in memory... | |
378 '/wd4820', # bytes padding added after construct 'member_name' | |
379 ], | |
380 | |
381 # Where to look for include files. | |
382 CPPPATH = [ | |
383 '$MAIN_DIR', | |
384 '$MAIN_DIR/..', | |
385 '$MAIN_DIR/third_party/chrome', | |
386 '$MAIN_DIR/third_party/gtest/include', | |
387 ], | |
388 | |
389 # Defines for windows environment. | |
390 CPPDEFINES = [ | |
391 'WIN32', '_WINDOWS', | |
392 'UNICODE', '_UNICODE', | |
393 'WIN32_LEAN_AND_MEAN', | |
394 'STRICT', | |
395 'SECURITY_WIN32', | |
396 '_ATL_ALL_WARNINGS', | |
397 '_ATL_CSTRING_EXPLICIT_CONSTRUCTORS', | |
398 '_ATL_CSTRING_NO_CRT', | |
399 '_ATL_NO_ACLAPI', | |
400 '_ATL_NO_DEFAULT_LIBS', | |
401 '_ATL_NO_EXCEPTIONS', | |
402 '_ATL_NO_GLOBAL_SOCKET_STARTUP', | |
403 '_ATL_NO_PERF_SUPPORT', | |
404 '_ATL_NO_TRACK_HEAP', | |
405 '_ATL_NO_UUIDOF', | |
406 '_ATL_STATIC_REGISTRY', | |
407 '_CRT_RAND_S', # rand_s support available in Windows XP only. | |
408 '_WTL_NO_CSTRING', # WTL uses ATL CString instead. | |
409 | |
410 # '_ATL_NO_CONNECTION_POINTS', | |
411 # '_ATL_NO_DOCHOSTUIHANDLER', | |
412 # '_ATL_NO_HOSTING', | |
413 | |
414 # Set these C_DEFINES when APPVER=5.0 | |
415 # (see win32.mak in Platform SDK) | |
416 # Target Windows XP and IE 6.0 and above. | |
417 'WINVER=0x0501', | |
418 '_WIN32_WINNT=0x0501', | |
419 '_WIN32_IE=0x0600', | |
420 '_RICHEDIT_VER=0x0010', | |
421 | |
422 # don't define min and max in windef.h | |
423 'NOMINMAX', | |
424 | |
425 # Logging is enabled in all modes for diagnostics purposes. | |
426 'LOGGING', | |
427 | |
428 'FULL_COMPANY_NAME_ANSI=\\"%s\\"' % _FULL_COMPANY_NAME, | |
429 'SHORT_COMPANY_NAME_ANSI=\\"%s\\"' % _SHORT_COMPANY_NAME, | |
430 'PRODUCT_NAME_ANSI=\\"%s\\"' % _PRODUCT_NAME, | |
431 'COMPANY_DOMAIN_BASE_ANSI=\\"%s\\"' % _COMPANY_DOMAIN_BASE, | |
432 'COMPANY_DOMAIN_ANSI=\\"%s\\"' % _COMPANY_DOMAIN, | |
433 'OMAHA_APP_NAME_ANSI=\\"%s %s\\"' % ( | |
434 _SHORT_COMPANY_NAME, _PRODUCT_NAME), | |
435 'MAIN_EXE_BASE_NAME_ANSI=\\"%s\\"' % _MAIN_EXE_BASE_NAME, | |
436 'MAIN_DLL_BASE_NAME_ANSI=\\"%s\\"' % _MAIN_DLL_BASE_NAME, | |
437 'OFFICIAL_BUILD=%d' % win_env.Bit('build_server'), | |
438 'TEST_CERTIFICATE=%d' % win_env.Bit('test_certificate'), | |
439 'ONECLICK_PLUGIN_NAME=_T(\\"%s\\")' % ( | |
440 omaha_version_utils.GetONECLICK_PLUGIN_NAME()), | |
441 'ONECLICK_PLUGIN_VERSION_ANSI=\\"%d\\"' % ( | |
442 omaha_version_info.oneclick_plugin_version), | |
443 'ONECLICK_PLUGIN_FILENAME=_T(\\"%s\\")' % ( | |
444 omaha_version_info.oneclick_plugin_filename), | |
445 'UPDATE_PLUGIN_NAME=_T(\\"%s\\")' % ( | |
446 omaha_version_utils.GetUPDATE_PLUGIN_NAME()), | |
447 'UPDATE_PLUGIN_VERSION_ANSI=\\"%d\\"' % ( | |
448 omaha_version_info.update_plugin_version), | |
449 'UPDATE_PLUGIN_FILENAME=_T(\\"%s\\")' % ( | |
450 omaha_version_info.update_plugin_filename), | |
451 'BHO_NAME=_T(\\"%s\\")' % omaha_version_utils.GetBHO_NAME(), | |
452 'BHO_FILENAME=_T(\\"%s\\")' % omaha_version_info.bho_filename, | |
453 'CRASH_HANDLER_NAME=_T(\\"%s\\")' % omaha_version_utils.GetCRASH_HANDLER
_NAME(), | |
454 ], | |
455 | |
456 # Link in some windows libraries. | |
457 LIBS = [ | |
458 'advapi32', | |
459 'comdlg32', | |
460 'gdi32', | |
461 'kernel32', | |
462 'odbc32', | |
463 'odbccp32', | |
464 'ole32', | |
465 'oleaut32', | |
466 'shell32', | |
467 'user32', | |
468 'uuid', | |
469 'winspool', | |
470 ], | |
471 | |
472 # Common linker flags. | |
473 LINKFLAGS = [ | |
474 '/nologo', | |
475 '/SUBSYSTEM:WINDOWS', | |
476 '/MACHINE:X86', | |
477 '/RELEASE', | |
478 '/MAP', | |
479 '/NODEFAULTLIB', | |
480 '/DYNAMICBASE', # Enable ASLR. See http://goo.gl/k2IE. | |
481 '/NXCOMPAT', # Enable NX support. See http://goo.gl/k2IE. | |
482 '/SAFESEH', | |
483 ], | |
484 | |
485 # Shared library specific linker flags. | |
486 SHLINKFLAGS = [ | |
487 '/nologo', | |
488 '/SUBSYSTEM:WINDOWS', | |
489 '/MACHINE:x86', | |
490 ], | |
491 | |
492 # Resource compiler flags. | |
493 # Defines in CCFLAGS are automatically included. | |
494 RCFLAGS = [ | |
495 '/l 1033', # /l == default language ID | |
496 '/DBUILD_NUMBER=\\"%s\\"' % build_number, | |
497 '/DOMAHA_COPYRIGHT_STRING_ENGLISH=\\"%s\\"' % ( | |
498 _OMAHA_COPYRIGHT_STRING_ENGLISH), | |
499 ], | |
500 ) | |
501 | |
502 # Allow verification of these settings in the build log. | |
503 if win_env.Bit('build_server'): | |
504 print 'OFFICIAL_BUILD=1' | |
505 print 'TEST_CERTIFICATE=%d' % win_env.Bit('test_certificate') | |
506 | |
507 | |
508 # Add the parent directory of the main omaha directory to the Python path so | |
509 # that we can import using the format "omaha.subdir.module". | |
510 sys.path.append(os.path.split(win_env.Dir('$MAIN_DIR').abspath)[0]) | |
511 | |
512 # Make sure Vista SDK in all the important paths earlier in path than VC80. | |
513 for mid_dir in ['', 'vc']: | |
514 for env_var, sub_dir in [('PATH', 'bin'), | |
515 ('INCLUDE', 'include'), | |
516 ('LIB', 'lib')]: | |
517 var_path = os.path.join(_sdk_path, mid_dir, sub_dir) | |
518 if os.path.exists(var_path): | |
519 win_env.PrependENVPath(env_var, var_path) | |
520 | |
521 if not win_env.Bit('official_installers'): | |
522 win_env.Append(CPPPATH = os.environ['OMAHA_WTL_DIR']) | |
523 | |
524 # Make sure csc.exe can be located. | |
525 win_env.AppendENVPath('PATH', os.environ['OMAHA_NET_DIR']) | |
526 | |
527 sys.path.append('tools') # for import proxy_clsid_utils.py | |
528 import proxy_clsid_utils | |
529 | |
530 # Generate uniqe proxy CLSIDs for each build. | |
531 win_env.Execute('python $MAIN_DIR\\tools\\proxy_clsid_utils.py') | |
532 win_env.Append( | |
533 CPPDEFINES = [ | |
534 'PROXY_CLSID_IS_MACHINE=%s' % proxy_clsid_utils.GetMachineProxyClsid(), | |
535 'PROXY_CLSID_IS_USER=%s' % proxy_clsid_utils.GetUserProxyClsid(), | |
536 ], | |
537 ) | |
538 | |
539 # WiX path has to be added before the WiX tool can be called. | |
540 win_env.AppendENVPath('PATH', os.environ['OMAHA_WIX_DIR']) | |
541 | |
542 win_env.Tool('wix') | |
543 | |
544 | |
545 _base_dirs = [ | |
546 '.', | |
547 'base', | |
548 'clickonce', | |
549 'client', | |
550 'common', | |
551 'core', | |
552 'google_update', | |
553 'goopdate', | |
554 'net', | |
555 'service', | |
556 'setup', | |
557 'statsreport', | |
558 'third_party', | |
559 'tools', | |
560 'ui', | |
561 ] | |
562 | |
563 _normal_dirs = [ | |
564 'installers', | |
565 'mi_exe_stub', | |
566 'plugins', | |
567 'recovery', | |
568 ] | |
569 | |
570 _official_installers_dirs = [ | |
571 'installers', | |
572 ] | |
573 | |
574 _extra_dirs = [ | |
575 'enterprise', | |
576 'standalone', | |
577 ] | |
578 | |
579 # | |
580 # Need to decide which subdirs need to be built. | |
581 # | |
582 _dirs_to_build_set = set() | |
583 | |
584 if win_env.Bit('official_installers'): | |
585 # Only want to build very specific subdirs. | |
586 win_env.SetBits('no-tests') | |
587 _dirs_to_build_set.update(_official_installers_dirs) | |
588 elif not win_env.Bit('bin'): | |
589 # All other configs get the base dirs. | |
590 _dirs_to_build_set.update(_base_dirs) | |
591 | |
592 if win_env.Bit('min'): | |
593 print '*** Building Minimal Set of Projects ***' | |
594 else: | |
595 _dirs_to_build_set.update(_normal_dirs) | |
596 | |
597 if win_env.Bit('all'): | |
598 _dirs_to_build_set.update(_extra_dirs) | |
599 | |
600 # Build Google application-specific metainstallers. | |
601 if os.path.exists(win_env.Dir('$MAIN_DIR/internal').abspath): | |
602 _dirs_to_build_set.update(['internal']) | |
603 | |
604 _dirs_to_build = list(_dirs_to_build_set) | |
605 | |
606 # This must be the last directory. | |
607 if not win_env.Bit('no-tests'): | |
608 _dirs_to_build.append('testing') | |
609 | |
610 # Instruct Hammer which dirs to build. | |
611 win_env['BUILD_SCONSCRIPTS'] = _dirs_to_build | |
612 | |
613 # These are used by the Omaha Builder OmahaUnittest(). They must be added to the | |
614 # environment because there must be one per-mode. | |
615 win_env['all_in_one_unittest_sources'] = [] | |
616 win_env['all_in_one_unittest_libs'] = set() | |
617 | |
618 | |
619 # Create the leaf debug Windows environment. | |
620 windows_debug_env = win_env.Clone( | |
621 # Give this build a name and a description. | |
622 BUILD_TYPE = 'dbg-win', | |
623 BUILD_TYPE_DESCRIPTION = 'Windows debug build', | |
624 ) | |
625 | |
626 # Use common debug settings. | |
627 windows_debug_env.Tool('target_debug') | |
628 | |
629 windows_debug_env.Append( | |
630 CCFLAGS = [ | |
631 '/RTC1', | |
632 '/Od', | |
633 '/MTd', | |
634 ], | |
635 CPPDEFINES = [ | |
636 '_DEBUG', | |
637 'DEBUG', | |
638 ], | |
639 ) | |
640 | |
641 | |
642 # Create the leaf optimized Windows environment. | |
643 windows_optimized_env = win_env.Clone( | |
644 # Give this build a name and a description. | |
645 BUILD_TYPE = 'opt-win', | |
646 BUILD_TYPE_DESCRIPTION = 'Windows optimized build', | |
647 ) | |
648 | |
649 # Use common optimized settings. | |
650 windows_optimized_env.Tool('target_optimized') | |
651 | |
652 windows_optimized_env.Append( | |
653 CCFLAGS = [ | |
654 '/O1', # Optimize for small size. | |
655 '/GS', | |
656 '/FD', | |
657 '/GL', # Global optimization goes with link flag '/LTCG' | |
658 '/MT', | |
659 ], | |
660 CPPDEFINES = [ | |
661 'NDEBUG', | |
662 'SHIPPING' # code in 'common' needs this | |
663 ], | |
664 ARFLAGS = [ | |
665 '/LTCG', # Set LTCG for creation of .lib files too. | |
666 ], | |
667 LINKFLAGS = [ | |
668 '/incremental:no', | |
669 '/opt:ref', | |
670 '/opt:icf=32', | |
671 '/opt:nowin98', | |
672 '/LTCG', # Link-time code generation goes with cl flag '/GL' | |
673 ], | |
674 ) | |
675 | |
676 | |
677 # Create an environment for coverage test builds, based on the dbg build. | |
678 windows_coverage_env = windows_debug_env.Clone( | |
679 BUILD_TYPE = 'coverage-win', | |
680 BUILD_TYPE_DESCRIPTION = 'Windows coverage build', | |
681 ) | |
682 # The Coverage build require additional tools that not everyone has. Therefore, | |
683 # it should build as part of the all group. | |
684 windows_coverage_env.FilterOut(BUILD_GROUPS=['all']) | |
685 | |
686 windows_coverage_env.Tool('code_coverage') | |
687 | |
688 # Coverage will run omaha_unittest.exe, which requires some extra environment. | |
689 for env_var in os.environ: | |
690 if not env_var in windows_coverage_env['ENV']: | |
691 windows_coverage_env['ENV'][env_var] = os.environ[env_var] | |
692 | |
693 # Create a target that covers everything in the staging dir, as many of those | |
694 # files will be required for the unittests to run successfully. | |
695 # TODO(omaha3): This may not be necessary when using ComponentTestProgram. If it | |
696 # is, it needs to be changed to use test/ instead of $STAGING_DIR/. | |
697 windows_coverage_env.Alias( | |
698 'run_omaha_unittest_for_coverage', | |
699 '$STAGING_DIR', | |
700 '$STAGING_DIR/omaha_unittest.exe' | |
701 ) | |
702 windows_coverage_env.Append( | |
703 # TODO(omaha): We cannot run our unit tests on the new build system. Ensure | |
704 # coverage works with the new test execution system. | |
705 # COVERAGE_TARGETS=['run_omaha_unittest_for_coverage'], | |
706 COVERAGE_INSTRUMENTATION_PATHS=['$STAGING_DIR'], | |
707 # This value should only be used in code if absolutely necessary. | |
708 CPPDEFINES=['COVERAGE_ENABLED'], | |
709 ) | |
710 | |
711 # TODO(omaha): Prevent the analyzer, which will fail, from running until we can | |
712 # run unit tests on the build system. See the TODO above. | |
713 windows_coverage_env['COVERAGE_START_CMD'] = '@echo Not starting coverage' | |
714 windows_coverage_env['COVERAGE_STOP_CMD'] = '@echo Not ending coverage' | |
715 | |
716 # Skip signing in coverage build until the last step. | |
717 windows_coverage_env['SIGNTOOL_ORIG'] = windows_coverage_env['SIGNTOOL'] | |
718 windows_coverage_env['SIGNTOOL'] = '@echo Signing deferred: ' | |
719 | |
720 def SigningCommand(env, filename): | |
721 # Only do signing if there is a certificate file or certificate name. | |
722 if env.subst('$CERTIFICATE_PATH') or env.subst('$CERTIFICATE_NAME'): | |
723 # The command used to do signing (target added on below). | |
724 signing_cmd = '$SIGNTOOL_ORIG sign ' | |
725 # Add in certificate file if any. | |
726 if env.subst('$CERTIFICATE_PATH'): | |
727 signing_cmd += ' /f "$CERTIFICATE_PATH"' | |
728 # Add certificate password if any. | |
729 if env.subst('$CERTIFICATE_PASSWORD'): | |
730 signing_cmd += ' /p "$CERTIFICATE_PASSWORD"' | |
731 # Add certificate store if any. | |
732 if env.subst('$CERTIFICATE_NAME'): | |
733 # The command used to do signing (target added on below). | |
734 signing_cmd += ' /s "$CERTIFICATE_STORE" /n "$CERTIFICATE_NAME"' | |
735 # Add timestamp server if any. | |
736 if env.subst('$TIMESTAMP_SERVER'): | |
737 signing_cmd += ' /t "$TIMESTAMP_SERVER"' | |
738 # Add in target name | |
739 signing_cmd += ' "%s"' % filename | |
740 return signing_cmd | |
741 else: | |
742 return 'echo no signing needed' | |
743 | |
744 def _IsInstrumentableFileType(file): | |
745 if (file.endswith('.exe') or | |
746 file.endswith('.dll')): | |
747 return True | |
748 return False | |
749 | |
750 def _IsSignableFileType(file): | |
751 if (file.endswith('.exe') or | |
752 file.endswith('.dll') or | |
753 file.endswith('.msi') or | |
754 file.endswith('.msp')): | |
755 return True | |
756 return False | |
757 | |
758 # Sign files during the install stage, since instrumentation invalidates the | |
759 # signature. Signing within the individual build files was disabled above. | |
760 # Do not sign intermediate "_unsigned" or "_unittest" files. | |
761 # Instrumented files must be signed after installing becuase install is what | |
762 # does the instrumentation. This also seems to be required to avoid | |
763 # unnecessarily rebuilding non-instrumentable files. | |
764 def _PostCoverageSigningInstall(dest, source, env): | |
765 if _IsInstrumentableFileType(dest) or not _IsSignableFileType(dest): | |
766 # Install the file to staging. Includes instrumentation if appropriate. | |
767 env['PRECOVERAGE_SIGN_INSTALL'](dest, source, env) | |
768 else: | |
769 # For signable but not instrumentable files, copy the files rather than | |
770 # using PRECOVERAGE_SIGN_INSTALL as this works around unnecessary rebuilds | |
771 # caused by http://code.google.com/p/swtoolkit/issues/detail?id=13. | |
772 env.Execute('copy "%s" "%s"' % (source, dest)) | |
773 | |
774 if (_IsSignableFileType(dest) and | |
775 (-1 == dest.find('_unsigned')) and | |
776 (-1 == dest.find('_unittest')) and | |
777 os.path.split(os.path.split(dest)[0])[1] == 'staging'): | |
778 env.Execute(SigningCommand(env, dest)) | |
779 | |
780 windows_coverage_env['PRECOVERAGE_SIGN_INSTALL'] = ( | |
781 windows_coverage_env['INSTALL']) | |
782 windows_coverage_env['INSTALL'] = _PostCoverageSigningInstall | |
783 | |
784 | |
785 # Make debug the default build after any copies of it have been made. | |
786 windows_debug_env.Append(BUILD_GROUPS = ['default']) | |
787 | |
788 # ---------------------------------------------------------- | |
789 | |
790 # Build the variants listed above. | |
791 # This step will call each of the SConscripts (build.scons) listed, | |
792 # once for each variant currently being built. | |
793 BuildEnvironments( | |
794 [ windows_debug_env, | |
795 windows_optimized_env, | |
796 windows_coverage_env, | |
797 ] | |
798 ) | |
799 | |
800 if 'HAMMER_RUNS_TESTS' in os.environ.keys(): | |
801 # Hammer sets the default target to 'scons-out'. This causes run_* aliases | |
802 # to also be built, which means the tests run by default. To avoid this, clear | |
803 # Default and set the default to just build the programs. | |
804 Default(None) | |
805 # TODO(omaha): Not all of our core binaries are included in these three | |
806 # aliases. This is because SignedBinary() and Command() do not add the outputs | |
807 # to a group. Fix this. | |
808 Default(['all_programs', 'all_libraries', 'all_test_programs']) | |
809 | |
810 if win_env.Bit('msvs'): | |
811 source_project = win_env.ComponentVSDirProject('all_source', ['$MAIN_DIR']) | |
812 | |
813 # 'all_*' values do not appear to be populated until after BuildEnvironments | |
814 # is called. Thus, the solution will be specific to either debug or optimized. | |
815 # ComponentVSSourceProject() might be more desirable, but it does not appear | |
816 # to work. | |
817 windows_debug_env.ComponentVSSolution('omaha_dbg', | |
818 ['all_programs', 'all_libraries'], | |
819 projects=[source_project]) | |
OLD | NEW |