OLD | NEW |
| (Empty) |
1 #!/usr/bin/python2.4 | |
2 # Copyright 2009 Google Inc. | |
3 # | |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | |
5 # you may not use this file except in compliance with the License. | |
6 # You may obtain a copy of the License at | |
7 # | |
8 # http://www.apache.org/licenses/LICENSE-2.0 | |
9 # | |
10 # Unless required by applicable law or agreed to in writing, software | |
11 # distributed under the License is distributed on an "AS IS" BASIS, | |
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 # See the License for the specific language governing permissions and | |
14 # limitations under the License. | |
15 # ======================================================================== | |
16 | |
17 # We always build the shell as GoogleUpdate_signed.exe. | |
18 # For official builds, we copy the saved constant shell to the output directory. | |
19 # For unofficial builds, we copy the built shell. | |
20 # Otherwise, the goopdate.dll certificate check fails. | |
21 # | |
22 # Changes to this executable will not appear in offical builds until they are | |
23 # included in an offical build and the resulting file is checked in to the | |
24 # saved constant shell location. | |
25 | |
26 | |
27 import omaha_version_utils | |
28 | |
29 Import('env') | |
30 | |
31 exe_env = env.Clone() | |
32 | |
33 # Only build the first version. We don't need a test version. | |
34 omaha_version_info = exe_env['omaha_versions_info'][0] | |
35 | |
36 # The shell contains languages not supported by the rest of Omaha. | |
37 # This is intended to allow us to add languages in the future without releasing | |
38 # a new shell. | |
39 shell_languages = omaha_version_utils.GetShellLanguagesForVersion( | |
40 omaha_version_info.GetVersion()) | |
41 | |
42 # TODO(omaha): While there is a precompile.h, it does not actually use PCH. | |
43 exe_env.Append( | |
44 CCFLAGS = [ | |
45 '/wd4548', | |
46 '/wd4917', | |
47 '/wd4265', | |
48 '/FIgoogle_update/precompile.h', | |
49 ], | |
50 LIBS = [ | |
51 'delayimp.lib', | |
52 'advapi32.lib', | |
53 'crypt32.lib', | |
54 'kernel32.lib', | |
55 'ole32.lib', | |
56 'shell32.lib', | |
57 'shlwapi.lib', | |
58 'user32.lib', | |
59 'wintrust.lib', | |
60 ('atls.lib', 'atlsd.lib')[exe_env.Bit('debug')], | |
61 ('libcmt.lib', 'libcmtd.lib')[exe_env.Bit('debug')], | |
62 ('libcpmt.lib', 'libcpmtd.lib')[exe_env.Bit('debug')], | |
63 ], | |
64 LINKFLAGS = [ | |
65 '/NODEFAULTLIB', | |
66 '/MERGE:.rdata=.text' | |
67 '/DELAYLOAD:advapi32.dll', | |
68 '/DELAYLOAD:crypt32.dll', | |
69 '/DELAYLOAD:shell32.dll', | |
70 '/DELAYLOAD:shlwapi.dll', | |
71 '/DELAYLOAD:user32.dll', | |
72 '/DELAYLOAD:wintrust.dll', | |
73 | |
74 # Forces the dependency on ole32.lib. | |
75 '/INCLUDE:_CoCreateGuid@4', | |
76 ], | |
77 RCFLAGS = [ | |
78 '/DVERSION_MAJOR=%d' % omaha_version_info.version_major, | |
79 '/DVERSION_MINOR=%d' % omaha_version_info.version_minor, | |
80 '/DVERSION_BUILD=%d' % omaha_version_info.version_build, | |
81 '/DVERSION_PATCH=%d' % omaha_version_info.version_patch, | |
82 '/DVERSION_NUMBER_STRING=\\"%s\\"' % ( | |
83 omaha_version_info.GetVersionString()), | |
84 ], | |
85 ) | |
86 | |
87 | |
88 exe_inputs = [ | |
89 'winmain.cc', | |
90 '../base/signaturevalidator.cc', | |
91 exe_env.RES('resource.rc'), | |
92 ] | |
93 | |
94 # Compile .rc files, then add the resulting .res files to the exe inputs. | |
95 for language in shell_languages: | |
96 exe_inputs += exe_env.RES('generated_resources_%s.rc' % language) | |
97 | |
98 # Force a rebuild when the version changes. The en file should be enough to | |
99 # rebuild all languages. | |
100 Depends(exe_env['OBJ_ROOT'] + '/google_update/generated_resources_en.res', | |
101 exe_env['MAIN_DIR'] + '/VERSION') | |
102 | |
103 # Need to add custom suffix to avoid target conflict with | |
104 # common/signaturevalidator.obj | |
105 exe_env['OBJSUFFIX'] = '_gu' + exe_env['OBJSUFFIX'] | |
106 | |
107 | |
108 # We disable runtime stack check to avoid increasing the code size. | |
109 # There is a compiler pragma to programmatically disable the stack checks | |
110 # but for some reason it did not work. | |
111 exe_env.FilterOut(CPPFLAGS = ['/GS']) | |
112 | |
113 # Disable stack checks for VC80. Stack checks are on by default. | |
114 if exe_env['msc_ver'] >= 1400: | |
115 exe_env['CCFLAGS'] += ['/GS-'] | |
116 | |
117 unsigned_exe_output = exe_env.ComponentProgram( | |
118 prog_name='GoogleUpdate_unsigned', | |
119 source=exe_inputs, | |
120 ) | |
121 | |
122 sign_output = env.SignedBinary( | |
123 target='GoogleUpdate_signed.exe', | |
124 source=unsigned_exe_output, | |
125 ) | |
126 | |
127 env.Replicate('$STAGING_DIR', sign_output) | |
128 | |
129 # Official builds should always use the checked in constant shell unless they | |
130 # are being built with the test certificate, in which case the saved constant | |
131 # shell would fail to validate the certificates in the build. | |
132 if env.Bit('build_server') and not env.Bit('test_certificate'): | |
133 # Copy the constant shell from its checked in location. | |
134 source_shell = ('$MAIN_DIR/google_update/bin/%s/GoogleUpdate.exe' % | |
135 ('opt', 'dbg')[env.Bit('debug')]) | |
136 else: | |
137 # Use the version we just built. | |
138 source_shell = sign_output[0] | |
139 | |
140 env.Replicate('$STAGING_DIR', source_shell, REPLICATE_REPLACE=[('_signed', '')]) | |
141 env.Replicate(target='$STAGING_DIR', | |
142 source=sign_output[0], | |
143 REPLICATE_REPLACE=[('GoogleUpdate_signed', env['omaha_versions_inf
o'][0].crash_handler_filename)] | |
144 ) | |
OLD | NEW |