summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-17 20:30:06 +0000
committerrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-17 20:30:06 +0000
commite06b745eb745c7e3bd177f76869c04dfc1efaa94 (patch)
tree67873f2afcd893c058414180a06df5929072d2a8 /chrome
parent4a9717e2030aadf15cb62275ed0f4ff1a37e869f (diff)
downloadchromium_src-e06b745eb745c7e3bd177f76869c04dfc1efaa94.zip
chromium_src-e06b745eb745c7e3bd177f76869c04dfc1efaa94.tar.gz
chromium_src-e06b745eb745c7e3bd177f76869c04dfc1efaa94.tar.bz2
Second stab at applying http://codereview.chromium.org/43138/show.
Removing the (not really needed) dependency on chrome\VERSION which works on the try server but breaks on buildbot. Review URL: http://codereview.chromium.org/42289 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/installer/mini_installer/chrome.release1
-rw-r--r--chrome/installer/setup/install.cc35
-rw-r--r--chrome/installer/setup/setup.vcproj7
-rw-r--r--chrome/installer/setup/uninstall.cc15
-rw-r--r--chrome/installer/util/install_util.cc23
-rw-r--r--chrome/installer/util/install_util.h21
-rw-r--r--chrome/installer/util/self_reg_work_item.cc51
-rw-r--r--chrome/installer/util/self_reg_work_item.h40
-rw-r--r--chrome/installer/util/util.gyp2
-rw-r--r--chrome/installer/util/util.vcproj12
-rw-r--r--chrome/installer/util/work_item.cc6
-rw-r--r--chrome/installer/util/work_item.h8
-rw-r--r--chrome/installer/util/work_item_list.cc7
-rw-r--r--chrome/installer/util/work_item_list.h8
-rw-r--r--chrome/tools/build/win/scan_server_dlls.py141
-rw-r--r--chrome/tools/build/win/server.rules21
16 files changed, 387 insertions, 11 deletions
diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release
index f6b2cbd..6092c58 100644
--- a/chrome/installer/mini_installer/chrome.release
+++ b/chrome/installer/mini_installer/chrome.release
@@ -38,6 +38,7 @@ Themes\default.dll: %(VersionDir)s\Themes
locales\*.dll: %(VersionDir)s\Locales
Resources\Inspector\*.*: %(VersionDir)s\Resources\Inspector
Resources\Inspector\Images\*.*: %(VersionDir)s\Resources\Inspector\Images
+servers\*.dll: %(VersionDir)s\
[GOOGLE_CHROME]
rlz.dll: %(VersionDir)s\
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index e6c51dd..d872335 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -12,10 +12,14 @@
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/work_item.h"
+// Build-time generated include file.
+#include "registered_dlls.h"
+
namespace {
std::wstring AppendPath(const std::wstring parent_path,
const std::wstring path) {
@@ -111,7 +115,6 @@ void AddInstallerCopyTasks(const std::wstring& exe_path,
install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path);
}
-
// This method tells if we are running on 64 bit platform so that we can copy
// one extra exe. If the API call to determine 64 bit fails, we play it safe
// and return true anyway so that the executable can be copied.
@@ -130,7 +133,7 @@ bool Is64bit() {
return false;
}
-}
+} // namespace
bool installer::InstallNewVersion(const std::wstring& exe_path,
const std::wstring& archive_path,
@@ -139,7 +142,6 @@ bool installer::InstallNewVersion(const std::wstring& exe_path,
const std::wstring& temp_dir,
const HKEY reg_root,
const Version& new_version) {
-
if (reg_root != HKEY_LOCAL_MACHINE && reg_root != HKEY_CURRENT_USER)
return false;
@@ -268,6 +270,33 @@ bool installer::InstallNewVersion(const std::wstring& exe_path,
}
}
+ // Now we need to register any self registering components and unregister
+ // any that were left from the old version that is being upgraded:
+ if (!current_version.empty()) {
+ std::wstring old_dll_path(install_path);
+ file_util::AppendToPath(&old_dll_path, current_version);
+ scoped_ptr<WorkItemList> old_dll_list(WorkItem::CreateWorkItemList());
+ if (InstallUtil::BuildDLLRegistrationList(old_dll_path, kDllsToRegister,
+ kNumDllsToRegister, false,
+ old_dll_list.get())) {
+ // Don't abort the install as a result of a failure to unregister old
+ // DLLs.
+ old_dll_list->Do();
+ }
+ }
+
+ std::wstring dll_path(install_path);
+ file_util::AppendToPath(&dll_path, new_version.GetString());
+ scoped_ptr<WorkItemList> dll_list(WorkItem::CreateWorkItemList());
+ if (InstallUtil::BuildDLLRegistrationList(dll_path, kDllsToRegister,
+ kNumDllsToRegister, true,
+ dll_list.get())) {
+ success = dll_list->Do();
+ if (!success) {
+ dll_list->Rollback();
+ }
+ }
+
if (!success) {
LOG(ERROR) << "Install failed, rolling back... ";
install_list->Rollback();
diff --git a/chrome/installer/setup/setup.vcproj b/chrome/installer/setup/setup.vcproj
index 72cdcad..4afb42f 100644
--- a/chrome/installer/setup/setup.vcproj
+++ b/chrome/installer/setup/setup.vcproj
@@ -16,6 +16,9 @@
<ToolFile
RelativePath="..\..\tools\build\win\version.rules"
/>
+ <ToolFile
+ RelativePath="..\..\tools\build\win\server.rules"
+ />
</ToolFiles>
<Configurations>
<Configuration
@@ -85,6 +88,10 @@
</File>
</Filter>
<File
+ RelativePath="..\mini_installer\chrome.release"
+ >
+ </File>
+ <File
RelativePath=".\install.cc"
>
</File>
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 2fb0815..e2ec9d18 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -17,11 +17,15 @@
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/helper.h"
+#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/logging_installer.h"
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/version.h"
+// Build-time generated include file.
+#include "registered_dlls.h"
+
namespace {
// This functions checks for any Chrome instances that are
@@ -281,6 +285,17 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
file_util::AppendToPath(&reg_path, installer_util::kChromeExe);
DeleteRegistryKey(hklm_key, reg_path);
hklm_key.Close();
+
+ // Unregister any dll servers that we may have registered.
+ std::wstring dll_path(installer::GetChromeInstallPath(system_uninstall));
+ file_util::AppendToPath(&dll_path, installed_version.GetString());
+
+ scoped_ptr<WorkItemList> dll_list(WorkItem::CreateWorkItemList());
+ if (InstallUtil::BuildDLLRegistrationList(dll_path, kDllsToRegister,
+ kNumDllsToRegister, false,
+ dll_list.get())) {
+ dll_list->Do();
+ }
}
// Finally delete all the files from Chrome folder after moving setup.exe
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 6fc0328..86f0847 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -5,12 +5,14 @@
// See the corresponding header file for description of the functions in this
// file.
-#include "install_util.h"
+#include "chrome/installer/util/install_util.h"
-#include <algorithm>
#include <shellapi.h>
#include <shlobj.h>
+#include <algorithm>
+
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/registry.h"
#include "base/scoped_ptr.h"
@@ -115,7 +117,6 @@ void InstallUtil::WriteInstallerResult(bool system_install,
}
bool InstallUtil::IsPerUserInstall(const wchar_t* const exe_path) {
-
wchar_t program_files_path[MAX_PATH] = {0};
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
SHGFP_TYPE_CURRENT, program_files_path))) {
@@ -125,3 +126,19 @@ bool InstallUtil::IsPerUserInstall(const wchar_t* const exe_path) {
}
return true;
}
+
+bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path,
+ const wchar_t** const dll_names,
+ int dll_names_count,
+ bool do_register,
+ WorkItemList* registration_list) {
+ DCHECK(NULL != registration_list);
+ bool success = true;
+ for (int i = 0; i < dll_names_count; i++) {
+ std::wstring dll_file_path(install_path);
+ file_util::AppendToPath(&dll_file_path, dll_names[i]);
+ success = registration_list->AddSelfRegWorkItem(dll_file_path,
+ do_register) && success;
+ }
+ return (dll_names_count > 0) && success;
+}
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h
index 68b0538..2bc5117 100644
--- a/chrome/installer/util/install_util.h
+++ b/chrome/installer/util/install_util.h
@@ -9,14 +9,16 @@
#ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
#define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
-#include <string>
#include <tchar.h>
#include <windows.h>
+#include <string>
#include "base/basictypes.h"
#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/version.h"
+class WorkItemList;
+
// This is a utility class that provides common installation related
// utility methods that can be used by installer and also unit tested
// independently.
@@ -53,6 +55,23 @@ class InstallUtil {
// Program Files).
static bool IsPerUserInstall(const wchar_t* const exe_path);
+ // Adds all DLLs in install_path whose names are given by dll_names to a
+ // work item list containing registration or unregistration actions.
+ //
+ // install_path: Install path containing the registrable DLLs.
+ // dll_names: the array of strings containing dll_names
+ // dll_names_count: the number of DLL names in dll_names
+ // do_register: whether to register or unregister the DLLs
+ // registration_list: the WorkItemList that this method populates
+ //
+ // Returns true if at least one DLL was successfully added to
+ // registration_list.
+ static bool BuildDLLRegistrationList(const std::wstring& install_path,
+ const wchar_t** const dll_names,
+ int dll_names_count,
+ bool do_register,
+ WorkItemList* registration_list);
+
private:
DISALLOW_EVIL_CONSTRUCTORS(InstallUtil);
};
diff --git a/chrome/installer/util/self_reg_work_item.cc b/chrome/installer/util/self_reg_work_item.cc
new file mode 100644
index 0000000..e413025
--- /dev/null
+++ b/chrome/installer/util/self_reg_work_item.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/installer/util/self_reg_work_item.h"
+
+#include "chrome/installer/util/logging_installer.h"
+
+SelfRegWorkItem::SelfRegWorkItem(const std::wstring& dll_path,
+ bool do_register)
+ : do_register_(do_register), dll_path_(dll_path) {
+}
+
+SelfRegWorkItem::~SelfRegWorkItem() {
+}
+
+typedef HRESULT (STDAPICALLTYPE *DllRegisterServerFunc)();
+
+bool SelfRegWorkItem::RegisterDll(bool do_register) {
+ HMODULE dll_module = ::LoadLibraryEx(dll_path_.c_str(), NULL,
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+ bool success = false;
+ if (NULL != dll_module) {
+ DllRegisterServerFunc register_server_func = NULL;
+ if (do_register) {
+ register_server_func = reinterpret_cast<DllRegisterServerFunc>(
+ ::GetProcAddress(dll_module, "DllRegisterServer"));
+ } else {
+ register_server_func = reinterpret_cast<DllRegisterServerFunc>(
+ ::GetProcAddress(dll_module, "DllUnregisterServer"));
+ }
+
+ if (NULL != register_server_func) {
+ success = SUCCEEDED(register_server_func());
+ if (!success) {
+ LOG(ERROR) << "Failed to " << (do_register ? "register" : "unregister")
+ << " DLL at " << dll_path_.c_str();
+ }
+ }
+ ::FreeLibrary(dll_module);
+ }
+ return success;
+}
+
+bool SelfRegWorkItem::Do() {
+ return RegisterDll(do_register_);
+}
+
+void SelfRegWorkItem::Rollback() {
+ RegisterDll(!do_register_);
+}
diff --git a/chrome/installer/util/self_reg_work_item.h b/chrome/installer/util/self_reg_work_item.h
new file mode 100644
index 0000000..ae2041b
--- /dev/null
+++ b/chrome/installer/util/self_reg_work_item.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__
+#define CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__
+
+#include <windows.h>
+#include <string>
+
+#include "chrome/installer/util/work_item.h"
+
+// Registers or unregisters the DLL at the given path.
+class SelfRegWorkItem : public WorkItem {
+ public:
+ virtual ~SelfRegWorkItem();
+
+ virtual bool Do();
+ virtual void Rollback();
+
+ private:
+ friend class WorkItem;
+
+ SelfRegWorkItem(const std::wstring& dll_path, bool do_register);
+
+ // Examines the DLL at dll_path looking for either DllRegisterServer (if
+ // do_register is true) or DllUnregisterServer (if do_register is false).
+ // Returns true if the DLL exports the function and it a call to it
+ // succeeds, false otherwise.
+ bool RegisterDll(bool do_register);
+
+ // The path to the dll to be registered.
+ std::wstring dll_path_;
+
+ // Whether this work item will register or unregister the dll. The rollback
+ // action just inverts this parameter.
+ bool do_register_;
+};
+
+#endif // CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__
diff --git a/chrome/installer/util/util.gyp b/chrome/installer/util/util.gyp
index ad5638e..26b1418 100644
--- a/chrome/installer/util/util.gyp
+++ b/chrome/installer/util/util.gyp
@@ -67,6 +67,8 @@
'master_preferences.h',
'move_tree_work_item.cc',
'move_tree_work_item.h',
+ 'self_reg_work_item.cc',
+ 'self_reg_work_item.h',
'set_reg_value_work_item.cc',
'set_reg_value_work_item.h',
'shell_util.cc',
diff --git a/chrome/installer/util/util.vcproj b/chrome/installer/util/util.vcproj
index 59f72da..33e6666 100644
--- a/chrome/installer/util/util.vcproj
+++ b/chrome/installer/util/util.vcproj
@@ -261,15 +261,23 @@
>
</File>
<File
+ RelativePath=".\move_tree_work_item.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\move_tree_work_item.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\pref_names.cc"
>
</File>
<File
- RelativePath=".\move_tree_work_item.cc"
+ RelativePath=".\self_reg_work_item.cc"
>
</File>
<File
- RelativePath=".\move_tree_work_item.h"
+ RelativePath=".\self_reg_work_item.h"
>
</File>
<File
diff --git a/chrome/installer/util/work_item.cc b/chrome/installer/util/work_item.cc
index 6c56fa7..dcb4293 100644
--- a/chrome/installer/util/work_item.cc
+++ b/chrome/installer/util/work_item.cc
@@ -10,6 +10,7 @@
#include "chrome/installer/util/delete_tree_work_item.h"
#include "chrome/installer/util/delete_reg_value_work_item.h"
#include "chrome/installer/util/move_tree_work_item.h"
+#include "chrome/installer/util/self_reg_work_item.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/work_item_list.h"
@@ -67,6 +68,11 @@ SetRegValueWorkItem* WorkItem::CreateSetRegValueWorkItem(
value_name, value_data, overwrite);
}
+SelfRegWorkItem* WorkItem::CreateSelfRegWorkItem(const std::wstring& dll_path,
+ bool do_register) {
+ return new SelfRegWorkItem(dll_path, do_register);
+}
+
WorkItemList* WorkItem::CreateWorkItemList() {
return new WorkItemList();
}
diff --git a/chrome/installer/util/work_item.h b/chrome/installer/util/work_item.h
index 86f4834..1a29c2f0 100644
--- a/chrome/installer/util/work_item.h
+++ b/chrome/installer/util/work_item.h
@@ -9,8 +9,8 @@
#ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_H_
#define CHROME_INSTALLER_UTIL_WORK_ITEM_H_
-#include <string>
#include <windows.h>
+#include <string>
class CopyTreeWorkItem;
class CreateDirWorkItem;
@@ -18,6 +18,7 @@ class CreateRegKeyWorkItem;
class DeleteTreeWorkItem;
class DeleteRegValueWorkItem;
class MoveTreeWorkItem;
+class SelfRegWorkItem;
class SetRegValueWorkItem;
class WorkItemList;
@@ -83,6 +84,11 @@ class WorkItem {
HKEY predefined_root, std::wstring key_path,
std::wstring value_name, DWORD value_data, bool overwrite);
+ // Add a SelfRegWorkItem that registers or unregisters a DLL at the
+ // specified path.
+ static SelfRegWorkItem* CreateSelfRegWorkItem(const std::wstring& dll_path,
+ bool do_register);
+
// Create an empty WorkItemList. A WorkItemList can recursively contains
// a list of WorkItems.
static WorkItemList* CreateWorkItemList();
diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc
index 7913b8c..e5aa3bc 100644
--- a/chrome/installer/util/work_item_list.cc
+++ b/chrome/installer/util/work_item_list.cc
@@ -133,3 +133,10 @@ bool WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root,
value_data, overwrite));
return AddWorkItem(item);
}
+
+bool WorkItemList::AddSelfRegWorkItem(const std::wstring& dll_path,
+ bool do_register) {
+ WorkItem* item = reinterpret_cast<WorkItem*>(
+ WorkItem::CreateSelfRegWorkItem(dll_path, do_register));
+ return AddWorkItem(item);
+}
diff --git a/chrome/installer/util/work_item_list.h b/chrome/installer/util/work_item_list.h
index a8e3bbb..b7b4fc3 100644
--- a/chrome/installer/util/work_item_list.h
+++ b/chrome/installer/util/work_item_list.h
@@ -5,9 +5,11 @@
#ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H__
#define CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H__
+#include <windows.h>
+
#include <list>
#include <string>
-#include <windows.h>
+
#include "chrome/installer/util/work_item.h"
// A WorkItem subclass that recursively contains a list of WorkItems. Thus it
@@ -70,6 +72,10 @@ class WorkItemList : public WorkItem {
std::wstring value_name, DWORD value_data,
bool overwrite);
+ // Add a SelfRegWorkItem that registers or unregisters a DLL at the
+ // specified path.
+ bool AddSelfRegWorkItem(const std::wstring& dll_path, bool do_register);
+
private:
friend class WorkItem;
diff --git a/chrome/tools/build/win/scan_server_dlls.py b/chrome/tools/build/win/scan_server_dlls.py
new file mode 100644
index 0000000..084728d
--- /dev/null
+++ b/chrome/tools/build/win/scan_server_dlls.py
@@ -0,0 +1,141 @@
+#!/usr/bin/python
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Script used to scan for server DLLs at build time and build a header
+ included by setup.exe. This header contains an array of the names of
+ the DLLs that need registering at install time.
+
+"""
+
+import ConfigParser
+import glob
+import optparse
+import os
+import sys
+
+CHROME_DIR = "Chrome-bin"
+SERVERS_DIR = "servers"
+GENERATED_DLL_INCLUDE_FILE_NAME = "registered_dlls.h"
+GENERATED_DLL_INCLUDE_FILE_CONTENTS = """
+// This file is automatically generated by scan_server_dlls.py.
+// It contains the list of COM server dlls that need registering at
+// install time.
+#include "base/basictypes.h"
+
+namespace {
+const wchar_t* kDllsToRegister[] = { %s };
+const int kNumDllsToRegister = %d;
+}
+"""
+
+
+def Readconfig(output_dir, input_file):
+ """Reads config information from input file after setting default value of
+ global variabes.
+ """
+ variables = {}
+ variables['ChromeDir'] = CHROME_DIR
+ # Use a bogus version number, we don't really care what it is, we just
+ # want to find the files that would get picked up from chrome.release,
+ # and don't care where the installer archive task ends up putting them.
+ variables['VersionDir'] = os.path.join(variables['ChromeDir'],
+ '0.0.0.0')
+ config = ConfigParser.SafeConfigParser(variables)
+
+ print "Reading input_file: " + input_file
+
+ config.read(input_file)
+ return config
+
+
+def CreateRegisteredDllIncludeFile(registered_dll_list, header_output_dir):
+ """ Outputs the header file included by the setup project that
+ contains the names of the DLLs to be registered at installation
+ time.
+ """
+ output_file = os.path.join(header_output_dir, GENERATED_DLL_INCLUDE_FILE_NAME)
+
+ dll_array_string = ""
+ for dll in registered_dll_list:
+ dll.replace("\\", "\\\\")
+ if dll_array_string:
+ dll_array_string += ', '
+ dll_array_string += "L\"%s\"" % dll
+
+ f = open(output_file, 'w')
+ try:
+ if len(registered_dll_list) == 0:
+ f.write(GENERATED_DLL_INCLUDE_FILE_CONTENTS % ("L\"\"", 0))
+ else:
+ f.write(GENERATED_DLL_INCLUDE_FILE_CONTENTS % (dll_array_string,
+ len(registered_dll_list)))
+ finally:
+ f.close()
+
+
+def ScanServerDlls(config, distribution, output_dir):
+ """Scans for DLLs in the specified section of config that are in the
+ subdirectory of output_dir named SERVERS_DIR. Returns a list of only the
+ filename components of the paths to all matching DLLs.
+ """
+
+ registered_dll_list = []
+ ScanDllsInSection(config, 'GENERAL', output_dir, registered_dll_list)
+ if distribution:
+ if len(distribution) > 1 and distribution[0] == '_':
+ distribution = distribution[1:]
+ ScanDllsInSection(config, distribution.upper(), output_dir,
+ registered_dll_list)
+
+ return registered_dll_list
+
+
+def ScanDllsInSection(config, section, output_dir, registered_dll_list):
+ """Scans for DLLs in the specified section of config that are in the
+ subdirectory of output_dir named SERVERS_DIR. Appends the file name of all
+ matching dlls to registered_dll_list.
+ """
+ for option in config.options(section):
+ if option.endswith('dir'):
+ continue
+
+ dst = config.get(section, option)
+ (x, src_folder) = os.path.split(dst)
+
+ for file in glob.glob(os.path.join(output_dir, option)):
+ if option.startswith(SERVERS_DIR):
+ (x, file_name) = os.path.split(file)
+ print "Found server DLL file: " + file_name
+ registered_dll_list.append(file_name)
+
+
+def RunSystemCommand(cmd):
+ if (os.system(cmd) != 0):
+ raise "Error while running cmd: %s" % cmd
+
+
+def main(options):
+ """Main method that reads input file, scans <build_output>\servers for
+ matches to files described in the input file. A header file for the
+ setup project is then generated.
+ """
+ config = Readconfig(options.output_dir, options.input_file)
+ registered_dll_list = ScanServerDlls(config, options.distribution,
+ options.output_dir)
+ CreateRegisteredDllIncludeFile(registered_dll_list,
+ options.header_output_dir)
+
+
+if '__main__' == __name__:
+ option_parser = optparse.OptionParser()
+ option_parser.add_option('-o', '--output_dir', help='Build Output directory')
+ option_parser.add_option('-x', '--header_output_dir',
+ help='Location where the generated header file will be placed.')
+ option_parser.add_option('-i', '--input_file', help='Input file')
+ option_parser.add_option('-d', '--distribution',
+ help='Name of Chromium Distribution. Optional.')
+
+ options, args = option_parser.parse_args()
+ sys.exit(main(options))
diff --git a/chrome/tools/build/win/server.rules b/chrome/tools/build/win/server.rules
new file mode 100644
index 0000000..b9ba301
--- /dev/null
+++ b/chrome/tools/build/win/server.rules
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<VisualStudioToolFile
+ Name="DLL Registration Rules"
+ Version="8.00"
+ >
+ <Rules>
+ <CustomBuildRule
+ Name="Scan Server DLLs"
+ DisplayName="Scan Server DLLs"
+ CommandLine="$(SolutionDir)..\third_party\python_24\python.exe $(SolutionDir)tools\build\win\scan_server_dlls.py --output_dir=&quot;$(OutDir)&quot; --input_file=&quot;$(InputPath)&quot; --header_output_dir=&quot;$(IntDir)&quot; --distribution=$(CHROMIUM_BUILD)"
+ Outputs="$(OutDir)/registered_dlls.h;"
+ AdditionalDependencies="$(SolutionDir)\tools\build\win\scan_server_dlls.py;$(OutDir)\chrome.exe;$(OutDir)\crash_reporter.exe;$(OutDir)\chrome.dll;$(OutDir)\locales\en-US.dll;$(OutDir)\icudt38.dll"
+ FileExtensions="*.release"
+ ExecutionDescription="Scanning for COM Server DLLs..."
+ ShowOnlyRuleProperties="false"
+ >
+ <Properties>
+ </Properties>
+ </CustomBuildRule>
+ </Rules>
+</VisualStudioToolFile>