diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 14:46:11 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 14:46:11 +0000 |
commit | 07baa184e1f05751a1fcaf77225c6710a3dd77d2 (patch) | |
tree | f79b68805475326ed88be9281b626b13e6a68579 /tools/win | |
parent | 7e6bb50bcaadb40538866614971de8a29b3b29eb (diff) | |
download | chromium_src-07baa184e1f05751a1fcaf77225c6710a3dd77d2.zip chromium_src-07baa184e1f05751a1fcaf77225c6710a3dd77d2.tar.gz chromium_src-07baa184e1f05751a1fcaf77225c6710a3dd77d2.tar.bz2 |
Generate, merge, and embed manifest when doing split_link
(Requires re-running tools\win\split_link\install_split_link.py)
R=cpu@chromium.org
BUG=237249
Review URL: https://codereview.chromium.org/14850021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/win')
-rw-r--r-- | tools/win/split_link/install_split_link.py | 11 | ||||
-rw-r--r-- | tools/win/split_link/split_link.py | 37 |
2 files changed, 40 insertions, 8 deletions
diff --git a/tools/win/split_link/install_split_link.py b/tools/win/split_link/install_split_link.py index 13ae448..309b511 100644 --- a/tools/win/split_link/install_split_link.py +++ b/tools/win/split_link/install_split_link.py @@ -44,9 +44,10 @@ def main(): os.chdir(BASE_DIR) link = FindInPath('link.exe') - if not link: - print("Couldn't find link.exe in PATH. Must run from Administrator " - "Visual Studio Command Prompt.") + mt = FindInPath('mt.exe') + if not link or not mt: + print("Couldn't find link.exe or mt.exe in PATH. " + "Must run from Administrator Visual Studio Command Prompt.") return 1 link_backup = os.path.join(os.path.split(link)[0], 'link.exe.split_link.exe') @@ -83,6 +84,10 @@ def main(): 'Software\\Chromium\\split_link_installed', _winreg.REG_SZ, link_backup) + _winreg.SetValue(_winreg.HKEY_CURRENT_USER, + 'Software\\Chromium\\split_link_mt_path', + _winreg.REG_SZ, + mt) except IOError: print("Wasn't able to copy split_link.exe over %s. " "Not running with Administrator privileges?" % link) diff --git a/tools/win/split_link/split_link.py b/tools/win/split_link/split_link.py index 4519155..344b349 100644 --- a/tools/win/split_link/split_link.py +++ b/tools/win/split_link/split_link.py @@ -49,9 +49,11 @@ def GetFlagsAndInputs(argv): flags = [] for arg in args: lower_arg = arg.lower() - # We'll be replacing this ourselves. + # We'll be replacing these ourselves. if lower_arg.startswith('/out:'): continue + if lower_arg.startswith('/manifestfile:'): + continue if (not lower_arg.startswith('/') and lower_arg.endswith(('.obj', '.lib', '.res'))): inputs.append(arg) @@ -61,16 +63,24 @@ def GetFlagsAndInputs(argv): return flags, inputs -def GetOriginalLinkerPath(): +def GetRegistryValue(subkey): try: val = _winreg.QueryValue(_winreg.HKEY_CURRENT_USER, - 'Software\\Chromium\\split_link_installed') + 'Software\\Chromium\\' + subkey) if os.path.exists(val): return val except WindowsError: pass - raise SystemExit("Couldn't read linker location from registry") + raise SystemExit("Couldn't read from registry") + + +def GetOriginalLinkerPath(): + return GetRegistryValue('split_link_installed') + + +def GetMtPath(): + return GetRegistryValue('split_link_mt_path') def PartFor(input_file, description_parts, description_all): @@ -118,7 +128,8 @@ def ParseOutExternals(output): mo = re.search(r'fatal error LNK1120: (\d+) unresolved externals', output) # Make sure we have the same number that the linker thinks we have. - assert mo or not result + if mo is None and result: + raise SystemExit(output) if len(result) != int(mo.group(1)): print output print 'Expecting %d, got %d' % (int(mo.group(1)), len(result)) @@ -139,6 +150,10 @@ def OutputNameForIndex(index): return 'chrome%d.dll' % index +def ManifestNameForIndex(index): + return OutputNameForIndex(index) + '.intermediate.manifest' + + def RunLinker(flags, index, inputs, phase): """Invokes the linker and returns the stdout, returncode and target name.""" rspfile = 'part%d_%s.rsp' % (index, phase) @@ -146,8 +161,10 @@ def RunLinker(flags, index, inputs, phase): print >> f, AsCommandLineArgs(inputs) print >> f, AsCommandLineArgs(flags) output_name = OutputNameForIndex(index) + manifest_name = ManifestNameForIndex(index) print >> f, '/ENTRY:ChromeEmptyEntry@12' print >> f, '/OUT:' + output_name + print >> f, '/MANIFESTFILE:' + manifest_name # Log('[[[\n' + open(rspfile).read() + '\n]]]') link_exe = GetOriginalLinkerPath() popen = subprocess.Popen([link_exe, '@' + rspfile], stdout=subprocess.PIPE) @@ -253,6 +270,16 @@ def main(): import_libs = BuildImportLibs(flags, inputs_by_part, deffiles) else: return 1 + + mt_exe = GetMtPath() + for i, dll in enumerate(dlls): + Log('embedding manifest in %s' % dll) + args = [mt_exe, '-nologo', '-manifest'] + args.append(ManifestNameForIndex(i)) + args.append(description['manifest']) + args.append('-outputresource:%s;2' % dll) + subprocess.check_call(args) + Log('built %r' % dlls) return 0 |