| 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 import omaha_version_utils | |
| 20 | |
| 21 Import('env') | |
| 22 | |
| 23 def BuildCOMForwarder(cmd_line_switch, | |
| 24 signed_exe_name): | |
| 25 com_forwarder_env = env.Clone() | |
| 26 | |
| 27 com_forwarder_env.FilterOut(CCFLAGS=['/GL', '/RTC1', '/GS']) | |
| 28 com_forwarder_env.FilterOut(LINKFLAGS=['/LTCG']) | |
| 29 | |
| 30 com_forwarder_env.Append( | |
| 31 CCFLAGS=[ | |
| 32 '/GS-', | |
| 33 '/Zl', | |
| 34 ], | |
| 35 CPPDEFINES = [ | |
| 36 'CMD_LINE_SWITCH=_T(\\"%s\\")' % cmd_line_switch, | |
| 37 ], | |
| 38 LINKFLAGS=[ | |
| 39 '/ENTRY:WinMainCRTStartup', | |
| 40 ], | |
| 41 LIBS=[ | |
| 42 'libcmt.lib', | |
| 43 'shlwapi.lib', | |
| 44 ], | |
| 45 ) | |
| 46 # The resource file used is the same as the one for GoogleUpdate.exe. | |
| 47 # The version resource used is the same as the one for goopdate.dll. | |
| 48 com_forwarder_inputs = [ | |
| 49 com_forwarder_env.ComponentObject('%s.obj' % signed_exe_name, | |
| 50 'com_forwarder.cc'), | |
| 51 com_forwarder_env.RES('%s.res' % signed_exe_name, | |
| 52 '../google_update/resource.rc'), | |
| 53 '$OBJ_ROOT/goopdate/goopdate_version.res', | |
| 54 ] | |
| 55 | |
| 56 unsigned_broker = com_forwarder_env.ComponentProgram( | |
| 57 prog_name='%s_unsigned' % signed_exe_name, | |
| 58 source=com_forwarder_inputs, | |
| 59 ) | |
| 60 signed_broker = com_forwarder_env.SignedBinary( | |
| 61 target='%s.exe' % signed_exe_name, | |
| 62 source=unsigned_broker, | |
| 63 ) | |
| 64 env.Replicate('$STAGING_DIR', signed_broker) | |
| 65 | |
| 66 | |
| 67 # Build the broker forwarder and legacy on-demand. | |
| 68 BuildCOMForwarder('/broker', 'GoogleUpdateBroker') | |
| 69 BuildCOMForwarder('/ondemand', 'GoogleUpdateOnDemand') | |
| 70 | |
| 71 # | |
| 72 # Build COM libraries and headers. | |
| 73 # | |
| 74 midl_env = env.Clone() | |
| 75 midl_env.Tool('midl') | |
| 76 midl_env['MIDLFLAGS'] += [ | |
| 77 '/Oicf', # generate optimized stubless proxy/stub code | |
| 78 ] | |
| 79 | |
| 80 # | |
| 81 # Generate omaha3_idl.idl. The output is an IDL file with a variant CLSID | |
| 82 # for coclass GoogleComProxyMachineClass and GoogleComProxyUserClass. | |
| 83 # | |
| 84 generated_idl = env.Command( | |
| 85 target='omaha3_idl.idl', | |
| 86 source='$MAIN_DIR/goopdate/omaha3_idl.idl', | |
| 87 action=('python %s/tools/generate_omaha3_idl.py --idl_template_file ' | |
| 88 '$SOURCE --idl_output_file $TARGET' % env['MAIN_DIR']) | |
| 89 ) | |
| 90 | |
| 91 # Compile the .idl file into .tlb, .c & .h files | |
| 92 midl_input = 'omaha3_idl.idl' | |
| 93 midl_outputs = midl_env.TypeLibrary(generated_idl) | |
| 94 | |
| 95 # Save the .idl and the produced .tlb and .h files so we can provide | |
| 96 # them to clients. | |
| 97 env.Replicate('$STAGING_DIR/idls', midl_input) | |
| 98 for node in midl_outputs: | |
| 99 if not str(node).endswith('.c'): | |
| 100 env.Replicate('$STAGING_DIR/idls', node) | |
| 101 | |
| 102 midl_env.ComponentLibrary( | |
| 103 lib_name='omaha3_idl', | |
| 104 source='omaha3_idl_i.c', | |
| 105 ) | |
| 106 | |
| 107 handler_common_env = env.Clone() | |
| 108 handler_common_env.Append( | |
| 109 CPPDEFINES = [ | |
| 110 '_ATL_FREE_THREADED', | |
| 111 ], | |
| 112 CPPPATH = [ | |
| 113 '$OBJ_ROOT', # Needed for generated files. | |
| 114 ], | |
| 115 LIBS = [ | |
| 116 '$LIB_DIR/base.lib', | |
| 117 '$LIB_DIR/goopdate_lib.lib', | |
| 118 ('atls.lib', 'atlsd.lib')[env.Bit('debug')], | |
| 119 ('libcmt.lib', 'libcmtd.lib')[env.Bit('debug')], | |
| 120 ('libcpmt.lib', 'libcpmtd.lib')[env.Bit('debug')], | |
| 121 'psapi.lib', | |
| 122 'netapi32.lib', | |
| 123 'rasapi32.lib', | |
| 124 'shlwapi.lib', | |
| 125 'userenv.lib', | |
| 126 'version.lib', | |
| 127 'wtsapi32.lib', | |
| 128 ], | |
| 129 ) | |
| 130 | |
| 131 def BuildGoogleUpdateHandlerDll(omaha_version_info, is_machine_handler, psname): | |
| 132 version_string = omaha_version_info.GetVersionString() | |
| 133 prefix = omaha_version_info.filename_prefix | |
| 134 handler_env = handler_common_env.Clone(COMPONENT_STATIC = False) | |
| 135 | |
| 136 if prefix == 'TEST_': | |
| 137 handler_env['OBJPREFIX'] = handler_env.subst('test/$OBJPREFIX') | |
| 138 elif prefix: | |
| 139 raise Exception('ERROR: Unrecognized prefix "%s"' % prefix) | |
| 140 | |
| 141 handler_env.Append( | |
| 142 CPPDEFINES = [ | |
| 143 'IS_MACHINE_HANDLER=%d' % is_machine_handler, | |
| 144 ], | |
| 145 LIBS = [ | |
| 146 '$LIB_DIR/common.lib', | |
| 147 'wininet.lib', | |
| 148 'rpcrt4.lib', | |
| 149 ], | |
| 150 RCFLAGS = [ | |
| 151 '/DVERSION_MAJOR=%d' % omaha_version_info.version_major, | |
| 152 '/DVERSION_MINOR=%d' % omaha_version_info.version_minor, | |
| 153 '/DVERSION_BUILD=%d' % omaha_version_info.version_build, | |
| 154 '/DVERSION_PATCH=%d' % omaha_version_info.version_patch, | |
| 155 '/DVERSION_NUMBER_STRING=\\"%s\\"' % version_string, | |
| 156 ], | |
| 157 ) | |
| 158 | |
| 159 resource = handler_env.RES(target='%s%s_resource.res' % (prefix, psname), | |
| 160 source='google_update_ps_resource.rc') | |
| 161 | |
| 162 handler_env.Depends( | |
| 163 resource, | |
| 164 ['$MAIN_DIR/VERSION', | |
| 165 '$MAIN_DIR/base/generic_reg_file_dll_handler.rgs']) | |
| 166 | |
| 167 target_name = '%s%s_unsigned' % (prefix, psname) | |
| 168 | |
| 169 inputs = [ | |
| 170 'google_update_ps.def', | |
| 171 resource, | |
| 172 prefix + 'goopdate_version.res', | |
| 173 ] | |
| 174 inputs += handler_env.Object('google_update_ps_%s.obj' % psname, | |
| 175 '$OBJ_ROOT/goopdate/google_update_ps.cc') | |
| 176 inputs += handler_env.Object('omaha3_idl_datax_%s.obj' % psname, | |
| 177 '$OBJ_ROOT/goopdate/omaha3_idl_datax.c') | |
| 178 | |
| 179 unsigned_dll = handler_env.ComponentLibrary( | |
| 180 lib_name=target_name, | |
| 181 source=inputs, | |
| 182 ) | |
| 183 | |
| 184 signed_dll = handler_env.SignedBinary( | |
| 185 target='%s%s.dll' % (prefix, psname), | |
| 186 source=unsigned_dll, | |
| 187 ) | |
| 188 | |
| 189 env.Replicate('$STAGING_DIR', signed_dll) | |
| 190 env.Replicate('$STAGING_DIR', [f for f in unsigned_dll if f.suffix == '.pdb']) | |
| 191 | |
| 192 | |
| 193 for omaha_version_info in env['omaha_versions_info']: | |
| 194 BuildGoogleUpdateHandlerDll(omaha_version_info, 1, 'psmachine') | |
| 195 BuildGoogleUpdateHandlerDll(omaha_version_info, 0, 'psuser') | |
| 196 | |
| 197 gd_env = env.Clone() | |
| 198 | |
| 199 # TODO(omaha3): Is it okay that other libs, such as common, do not define this. | |
| 200 gd_env['CPPDEFINES'] += [ | |
| 201 '_ATL_FREE_THREADED', | |
| 202 ] | |
| 203 | |
| 204 # Need to look in output dir to find .h files generated by midl compiler. | |
| 205 gd_env['CPPPATH'] += [ | |
| 206 '$OBJ_ROOT', # Needed for generated files. | |
| 207 '$MAIN_DIR/third_party/breakpad/src/', | |
| 208 ] | |
| 209 | |
| 210 target_name = 'goopdate_lib' | |
| 211 | |
| 212 gd_inputs = [ | |
| 213 'app.cc', | |
| 214 'app_bundle.cc', | |
| 215 'app_bundle_state.cc', | |
| 216 'app_bundle_state_busy.cc', | |
| 217 'app_bundle_state_init.cc', | |
| 218 'app_bundle_state_initialized.cc', | |
| 219 'app_bundle_state_paused.cc', | |
| 220 'app_bundle_state_ready.cc', | |
| 221 'app_bundle_state_stopped.cc', | |
| 222 'app_command.cc', | |
| 223 'app_manager.cc', | |
| 224 'app_state.cc', | |
| 225 'app_state_error.cc', | |
| 226 'app_state_init.cc', | |
| 227 'app_state_checking_for_update.cc', | |
| 228 'app_state_download_complete.cc', | |
| 229 'app_state_downloading.cc', | |
| 230 'app_state_install_complete.cc', | |
| 231 'app_state_installing.cc', | |
| 232 'app_state_no_update.cc', | |
| 233 'app_state_ready_to_install.cc', | |
| 234 'app_state_update_available.cc', | |
| 235 'app_state_waiting_to_check_for_update.cc', | |
| 236 'app_state_waiting_to_download.cc', | |
| 237 'app_state_waiting_to_install.cc', | |
| 238 'app_version.cc', | |
| 239 'application_usage_data.cc', | |
| 240 'code_red_check.cc', | |
| 241 'crash.cc', | |
| 242 'cocreate_async.cc', | |
| 243 'cred_dialog.cc', | |
| 244 'current_state.cc', | |
| 245 'download_complete_ping_event.cc', | |
| 246 'download_manager.cc', | |
| 247 'google_update.cc', | |
| 248 'goopdate.cc', | |
| 249 'goopdate_metrics.cc', | |
| 250 'install_manager.cc', | |
| 251 'installer_wrapper.cc', | |
| 252 'job_observer.cc', | |
| 253 'model.cc', | |
| 254 'model_object.cc', | |
| 255 'ondemand.cc', | |
| 256 'oneclick_process_launcher.cc', | |
| 257 'offline_utils.cc', | |
| 258 'string_formatter.cc', | |
| 259 'package.cc', | |
| 260 'package_cache.cc', | |
| 261 'process_launcher.cc', | |
| 262 'resource_manager.cc', | |
| 263 'update3web.cc', | |
| 264 'update_request_utils.cc', | |
| 265 'update_response_utils.cc', | |
| 266 'worker.cc', | |
| 267 'worker_utils.cc', | |
| 268 'worker_metrics.cc', | |
| 269 ] | |
| 270 if env.Bit('use_precompiled_headers'): | |
| 271 gd_inputs += gd_env.EnablePrecompile(target_name) | |
| 272 | |
| 273 # Compile the library. | |
| 274 gd_env.ComponentLibrary(target_name, gd_inputs) | |
| 275 | |
| 276 | |
| 277 # | |
| 278 # Build Goopdate DLL | |
| 279 # | |
| 280 for omaha_version_info in env['omaha_versions_info']: | |
| 281 prefix = omaha_version_info.filename_prefix | |
| 282 | |
| 283 temp_env = env.Clone(COMPONENT_STATIC=False) | |
| 284 | |
| 285 if prefix == 'TEST_': | |
| 286 temp_env['OBJPREFIX'] = temp_env.subst('test/$OBJPREFIX') | |
| 287 elif prefix: | |
| 288 raise Exception('ERROR: Unrecognized prefix "%s"' % prefix) | |
| 289 | |
| 290 # Add languages that have version resources but are not fully supported. | |
| 291 translated_languages = omaha_version_utils.GetShellLanguagesForVersion( | |
| 292 omaha_version_info.GetVersion()) | |
| 293 | |
| 294 temp_env.Append( | |
| 295 CPPPATH = [ | |
| 296 '$MAIN_DIR/third_party/breakpad/src/', | |
| 297 '$OBJ_ROOT', | |
| 298 ], | |
| 299 | |
| 300 # Do not add static dependencies on system import libraries. Prefer delay | |
| 301 # loading when possible. Only what is necessary must be loaded in the | |
| 302 # memory space when long-running. | |
| 303 LIBS = [ | |
| 304 '$LIB_DIR/base.lib', | |
| 305 '$LIB_DIR/breakpad.lib', | |
| 306 '$LIB_DIR/client.lib', | |
| 307 '$LIB_DIR/common.lib', | |
| 308 '$LIB_DIR/core.lib', | |
| 309 '$LIB_DIR/google_update_recovery.lib', | |
| 310 '$LIB_DIR/goopdate_lib.lib', | |
| 311 '$LIB_DIR/logging.lib', | |
| 312 '$LIB_DIR/net.lib', | |
| 313 '$LIB_DIR/omaha3_idl.lib', | |
| 314 '$LIB_DIR/security.lib', | |
| 315 '$LIB_DIR/service.lib', | |
| 316 '$LIB_DIR/setup.lib', | |
| 317 '$LIB_DIR/statsreport.lib', | |
| 318 '$LIB_DIR/ui.lib', | |
| 319 ('atls.lib', 'atlsd.lib')[temp_env.Bit('debug')], | |
| 320 ('libcmt.lib', 'libcmtd.lib')[temp_env.Bit('debug')], | |
| 321 ('libcpmt.lib', 'libcpmtd.lib')[temp_env.Bit('debug')], | |
| 322 # TODO(omaha3): This must be linked in because we have UI in the DLL. | |
| 323 'bits.lib', | |
| 324 'comctl32.lib', | |
| 325 'crypt32.lib', | |
| 326 'delayimp.lib', | |
| 327 'iphlpapi.lib', | |
| 328 'msi.lib', | |
| 329 'msimg32.lib', | |
| 330 'mstask.lib', | |
| 331 'netapi32.lib', | |
| 332 'psapi.lib', | |
| 333 'rasapi32.lib', | |
| 334 'rpcns4.lib', | |
| 335 'rpcrt4.lib', | |
| 336 'shlwapi.lib', | |
| 337 'taskschd.lib', | |
| 338 'version.lib', | |
| 339 'userenv.lib', | |
| 340 'wininet.lib', | |
| 341 'wintrust.lib', | |
| 342 'ws2_32.lib', | |
| 343 'wtsapi32.lib', | |
| 344 ], | |
| 345 LINKFLAGS = [ | |
| 346 '/DELAYLOAD:oleaut32.dll', | |
| 347 '/DELAYLOAD:psapi.dll', | |
| 348 '/DELAYLOAD:rasapi32.dll', | |
| 349 '/DELAYLOAD:shell32.dll', | |
| 350 '/DELAYLOAD:shlwapi.dll', | |
| 351 '/DELAYLOAD:userenv.dll', | |
| 352 '/DELAYLOAD:version.dll', | |
| 353 '/DELAYLOAD:wtsapi32.dll', | |
| 354 | |
| 355 # Forces the dependency on ws2_32.lib. | |
| 356 '/INCLUDE:_WSAStartup@8', | |
| 357 | |
| 358 # TODO(Omaha) - Choose a rebase address which does not conflict | |
| 359 # with other DLLs loaded in our process. For now, we just picked | |
| 360 # an arbitrary address. | |
| 361 '/BASE:0x18000000', | |
| 362 ], | |
| 363 RCFLAGS = [ | |
| 364 '/DVERSION_MAJOR=%d' % omaha_version_info.version_major, | |
| 365 '/DVERSION_MINOR=%d' % omaha_version_info.version_minor, | |
| 366 '/DVERSION_BUILD=%d' % omaha_version_info.version_build, | |
| 367 '/DVERSION_PATCH=%d' % omaha_version_info.version_patch, | |
| 368 '/DVERSION_NUMBER_STRING=\\"%s\\"' % ( | |
| 369 omaha_version_info.GetVersionString()), | |
| 370 | |
| 371 # goopdate.dll is resource neutral. | |
| 372 '/DLANGUAGE_STRING=\\"en\\"', | |
| 373 ], | |
| 374 ) | |
| 375 | |
| 376 resource_res = temp_env.RES( | |
| 377 target=prefix + 'goopdate.res', | |
| 378 source='goopdate.rc', | |
| 379 ) | |
| 380 | |
| 381 # Force a rebuild when the .tlb changes. | |
| 382 temp_env.Depends(resource_res, '$OBJ_ROOT/goopdate/omaha3_idl.tlb') | |
| 383 | |
| 384 version_res = temp_env.RES( | |
| 385 target=prefix + 'goopdate_version.res', | |
| 386 source='goopdate_version.rc' | |
| 387 ) | |
| 388 | |
| 389 # Force a rebuild when the version changes. | |
| 390 env.Depends(version_res, '$MAIN_DIR/VERSION') | |
| 391 | |
| 392 target_name = prefix + 'goopdate_unsigned' | |
| 393 | |
| 394 # main.cc is included here because the linker gets confused if we try to | |
| 395 # create a DLL without an entry point. There's probably a more accurate | |
| 396 # description of the problem and thus a different solution, but this worked. | |
| 397 inputs = [ | |
| 398 'goopdate.def', | |
| 399 'main.cc', | |
| 400 resource_res, | |
| 401 version_res, | |
| 402 ] | |
| 403 if env.Bit('use_precompiled_headers'): | |
| 404 inputs += temp_env.EnablePrecompile(target_name) | |
| 405 | |
| 406 for language in translated_languages: | |
| 407 lang_base_name = 'goopdate_dll/generated_resources_' + language | |
| 408 inputs += temp_env.RES( | |
| 409 target='resources/%s.res' % (prefix + lang_base_name), | |
| 410 source='resources/%s.rc' % lang_base_name, | |
| 411 ) | |
| 412 | |
| 413 unsigned_dll = temp_env.ComponentLibrary( | |
| 414 lib_name=target_name, | |
| 415 source=inputs, | |
| 416 ) | |
| 417 | |
| 418 signed_dll = temp_env.SignedBinary( | |
| 419 target=prefix + 'goopdate.dll', | |
| 420 source=unsigned_dll, | |
| 421 ) | |
| 422 | |
| 423 env.Replicate('$STAGING_DIR', signed_dll) | |
| 424 env.Replicate('$STAGING_DIR', [f for f in unsigned_dll if f.suffix == '.pdb']) | |
| 425 | |
| 426 | |
| 427 customization_test_env = env.Clone() | |
| 428 | |
| 429 customization_test_env.Append( | |
| 430 LIBS = [ | |
| 431 '$LIB_DIR/common.lib', | |
| 432 ], | |
| 433 ) | |
| 434 | |
| 435 customization_test_env['CPPPATH'] += [ | |
| 436 '$OBJ_ROOT', # Needed for generated files. | |
| 437 ] | |
| 438 customization_test = customization_test_env.OmahaUnittest( | |
| 439 name='omaha_customization_goopdate_apis_unittest', | |
| 440 source=[ | |
| 441 'omaha_customization_goopdate_apis_unittest.cc', | |
| 442 'omaha3_idl_i.obj', # Needed for LIBID_*. | |
| 443 ], | |
| 444 all_in_one=False, | |
| 445 COMPONENT_TEST_SIZE='small', | |
| 446 ) | |
| 447 | |
| 448 # The test uses the DLL for its TypeLib. | |
| 449 customization_test_env.Depends(customization_test, '$STAGING_DIR/goopdate.dll') | |
| 450 | |
| 451 | |
| 452 # Build all the resource dlls. | |
| 453 env.BuildSConscript('resources') | |
| OLD | NEW |