blob: 803e07180bc991b82a362d7bf2e3d724a9dbe66d [file] [log] [blame]
#!/usr/bin/python2.4
#
# Copyright 2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========================================================================
import omaha_version_utils
Import('env')
#
# Build Goopdate library
#
midl_env = env.Clone()
midl_env.Tool('midl')
midl_env['MIDLFLAGS'] += [
'/Oicf', # generate optimized stubless proxy/stub code
]
# Compile the .idl file into .c & .h files
midl_env.TypeLibrary('google_update_idl.idl')
gd_env = env.Clone()
# Need to look in output dir to find .h files generated by midl compiler.
gd_env['CPPPATH'] += [
'$OBJ_ROOT',
'$MAIN_DIR/third_party/breakpad/src/',
]
target_name = 'goopdate_dll.lib'
gd_inputs = [
#'browser_ping.cc',
'browser_launcher.cc',
'command_line.cc',
'command_line_builder.cc',
'command_line_parser.cc',
'command_line_validator.cc',
'config_manager.cc',
'crash.cc',
'extra_args_parser.cc',
'event_logger.cc',
'google_update.cc',
'goopdate.cc',
'goopdate_command_line_validator.cc',
'goopdate_helper.cc',
'goopdate_metrics.cc',
'goopdate_utils.cc',
'goopdate_xml_parser.cc',
'program_instance.cc',
'request.cc',
'stats_uploader.cc',
'resource_manager.cc',
'ui_displayed_event.cc',
'webplugin_utils.cc',
]
if env.Bit('use_precompiled_headers'):
gd_inputs += gd_env.EnablePrecompile(target_name)
# Compile the library.
gd_env.ComponentLibrary(target_name, gd_inputs)
#
# Build Goopdate proxy/stub library separately, because it is not compatible
# with precompiled headers.
#
no_precomp_env = env.Clone()
no_precomp_env['CPPPATH'] += ['$OBJ_ROOT']
no_precomp_env.ComponentLibrary('google_update_ps', 'google_update_idl_datax.c')
#
# Build Goopdate DLL
#
for omaha_version_info in env['omaha_versions_info']:
prefix = omaha_version_info.filename_prefix
temp_env = env.Clone(COMPONENT_STATIC=False)
if prefix == 'TEST_':
temp_env['OBJPREFIX'] = temp_env.subst('test/$OBJPREFIX')
elif prefix:
raise Exception('ERROR: Unrecognized prefix "%s"' % prefix)
# Add languages that have version resources but are not fully supported.
translated_languages = omaha_version_utils.GetShellLanguagesForVersion(
omaha_version_info.GetVersion())
temp_env.Append(
CPPPATH = [
'$MAIN_DIR/third_party/breakpad/src/',
],
# Do not add static dependencies on system import libraries. Prefer delay
# loading when possible. When running as 'core', only what is necessary
# must be loaded in the memory space.
LIBS = [
'$LIB_DIR/breakpad.lib',
'$LIB_DIR/common.lib',
'$LIB_DIR/core.lib',
'$LIB_DIR/goopdate_dll.lib',
'$LIB_DIR/google_update_ps.lib',
'$LIB_DIR/google_update_recovery.lib',
'$LIB_DIR/logging.lib',
'$LIB_DIR/net.lib',
'$LIB_DIR/repair_goopdate.lib',
'$LIB_DIR/security.lib',
'$LIB_DIR/service.lib',
'$LIB_DIR/setup.lib',
'$LIB_DIR/statsreport.lib',
'$LIB_DIR/worker.lib',
('atls.lib', 'atlsd.lib')[temp_env.Bit('debug')],
('libcmt.lib', 'libcmtd.lib')[temp_env.Bit('debug')],
('libcpmt.lib', 'libcpmtd.lib')[temp_env.Bit('debug')],
'comctl32.lib',
'crypt32.lib',
'delayimp.lib',
'iphlpapi.lib',
'netapi32.lib',
'msi.lib',
'mstask.lib',
'psapi.lib',
'rasapi32.lib',
'rpcns4.lib',
'rpcrt4.lib',
'shlwapi.lib',
'version.lib',
'urlmon.lib',
'userenv.lib',
'wininet.lib',
'wintrust.lib',
'ws2_32.lib',
'wtsapi32.lib',
],
LINKFLAGS = [
'/DELAYLOAD:comctl32.dll',
'/DELAYLOAD:crypt32.dll',
'/DELAYLOAD:iphlpapi.dll',
'/DELAYLOAD:msi.dll',
'/DELAYLOAD:oleaut32.dll',
'/DELAYLOAD:psapi.dll',
'/DELAYLOAD:rasapi32.dll',
'/DELAYLOAD:shell32.dll',
'/DELAYLOAD:shlwapi.dll',
'/DELAYLOAD:urlmon.dll',
'/DELAYLOAD:userenv.dll',
'/DELAYLOAD:version.dll',
'/DELAYLOAD:wininet.dll',
'/DELAYLOAD:wintrust.dll',
'/DELAYLOAD:wtsapi32.dll',
# Forces the dependency on ws2_32.lib.
'/INCLUDE:_WSAStartup@8',
# TODO(Omaha) - Choose a rebase address which does not conflict
# with other DLLs loaded in our process. For now, we just picked
# an arbitrary address.
'/BASE:0x18000000',
],
RCFLAGS = [
'/DVERSION_MAJOR=%d' % omaha_version_info.version_major,
'/DVERSION_MINOR=%d' % omaha_version_info.version_minor,
'/DVERSION_BUILD=%d' % omaha_version_info.version_build,
'/DVERSION_PATCH=%d' % omaha_version_info.version_patch,
'/DVERSION_NUMBER_STRING=\\"%s\\"' % (
omaha_version_info.GetVersionString()),
# goopdate.dll is resource neutral.
'/DLANGAUGE_STRING=\\"en\\"',
],
)
version_res = temp_env.RES(
target=prefix + 'goopdate_version.res',
source='goopdate_version.rc'
)
# Force a rebuild when the version changes.
env.Depends(version_res, '$MAIN_DIR/VERSION')
target_name = prefix + 'goopdate_unsigned.dll'
# main.cc is included here because the linker gets confused if we try to
# create a DLL without an entry point. There's probably a more accurate
# description of the problem and thus a different solution, but this worked.
inputs = [
'goopdate.def',
'main.cc',
temp_env.RES(prefix + 'goopdate.res', 'goopdate.rc'),
version_res,
]
if env.Bit('use_precompiled_headers'):
inputs += temp_env.EnablePrecompile(target_name)
for language in translated_languages:
lang_base_name = 'goopdate_dll/generated_resources_' + language
inputs += temp_env.RES(
target='resources/%s.res' % (prefix + lang_base_name),
source='resources/%s.rc' % lang_base_name,
)
unsigned_dll = temp_env.ComponentLibrary(
lib_name=target_name,
source=inputs,
)
signed_dll = temp_env.SignedBinary(
target=prefix + 'goopdate.dll',
source=unsigned_dll,
)
env.Replicate('$STAGING_DIR', signed_dll)
env.Replicate('$STAGING_DIR', [f for f in unsigned_dll if f.suffix == '.pdb'])
# Build all the resource dlls.
env.BuildSConscript('resources')