summaryrefslogtreecommitdiffstats
path: root/chrome/tools/build/win
diff options
context:
space:
mode:
authorrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-17 15:34:43 +0000
committerrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-17 15:34:43 +0000
commit0fb1960ad3ffa0df4e5c2ac46d0e240aa4e55108 (patch)
treed30839c2ad94dd622883c0be5237fd6ba7c1a564 /chrome/tools/build/win
parente4ac5dff67e3f5ea9b3d7c4adad2aade7a21bbe7 (diff)
downloadchromium_src-0fb1960ad3ffa0df4e5c2ac46d0e240aa4e55108.zip
chromium_src-0fb1960ad3ffa0df4e5c2ac46d0e240aa4e55108.tar.gz
chromium_src-0fb1960ad3ffa0df4e5c2ac46d0e240aa4e55108.tar.bz2
Change mini_installer's chrome.release specification to include wildcards.
Add the ability to register / unregister dlls at installation / uninstallation time. Review URL: http://codereview.chromium.org/43138 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11864 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools/build/win')
-rw-r--r--chrome/tools/build/win/scan_server_dlls.py161
-rw-r--r--chrome/tools/build/win/server.rules21
2 files changed, 182 insertions, 0 deletions
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..f1b8a52
--- /dev/null
+++ b/chrome/tools/build/win/scan_server_dlls.py
@@ -0,0 +1,161 @@
+#!/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"
+VERSION_FILE = "VERSION"
+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 BuildVersion(output_dir):
+ """Returns the full build version string constructed from information in
+ VERSION_FILE. Any segment not found in that file will default to '0'.
+ """
+ major = 0
+ minor = 0
+ build = 0
+ patch = 0
+ for line in open(os.path.join(output_dir, "..", VERSION_FILE), 'r'):
+ line = line.rstrip()
+ if line.startswith('MAJOR='):
+ major = line[6:]
+ elif line.startswith('MINOR='):
+ minor = line[6:]
+ elif line.startswith('BUILD='):
+ build = line[6:]
+ elif line.startswith('PATCH='):
+ patch = line[6:]
+ return '%s.%s.%s.%s' % (major, minor, build, patch)
+
+
+def Readconfig(output_dir, input_file, current_version):
+ """Reads config information from input file after setting default value of
+ global variabes.
+ """
+ variables = {}
+ variables['ChromeDir'] = CHROME_DIR
+ variables['VersionDir'] = os.path.join(variables['ChromeDir'],
+ current_version)
+ config = ConfigParser.SafeConfigParser(variables)
+
+ print "We are attempting to read 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.
+ """
+ current_version = BuildVersion(options.output_dir)
+ config = Readconfig(options.output_dir, options.input_file, current_version)
+ 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..a65fe22
--- /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=&amp;quot;$(OutDir)&amp;quot; --input_file=&amp;quot;$(InputPath)&amp;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>