diff options
author | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-12 03:02:38 +0000 |
---|---|---|
committer | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-12 03:02:38 +0000 |
commit | 2a5390f39d470f65fafd225041602c302985d156 (patch) | |
tree | e7abac1f128be5c4583d8fa2dc93584a03cdfcb7 | |
parent | b75d4a04a5c16e876268c8ec24daa8eb05f37ec0 (diff) | |
download | chromium_src-2a5390f39d470f65fafd225041602c302985d156.zip chromium_src-2a5390f39d470f65fafd225041602c302985d156.tar.gz chromium_src-2a5390f39d470f65fafd225041602c302985d156.tar.bz2 |
Fix size regression due to missing strip.
Add a strip script based on the old build_nacl_irt.py (just keep strip piece)
Rename nacl_irt target to nacl_irt_unstripped and add a new target called
nacl_irt which strips the previous target.
Review URL: http://codereview.chromium.org/8539039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109764 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/strip_nacl_irt.py | 77 | ||||
-rw-r--r-- | ppapi/native_client/native_client.gyp | 67 |
2 files changed, 141 insertions, 3 deletions
diff --git a/chrome/strip_nacl_irt.py b/chrome/strip_nacl_irt.py new file mode 100755 index 0000000..ac2a3d3 --- /dev/null +++ b/chrome/strip_nacl_irt.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# Copyright (c) 2011 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. + +import optparse +import os +import re +import shutil +import subprocess +import sys + + +# Where things are in relation to this script. +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +SRC_DIR = os.path.dirname(SCRIPT_DIR) +NACL_DIR = os.path.join(SRC_DIR, 'native_client') + + +def StripIRT(platform, src, dst): + """Build the IRT for several platforms. + + Arguments: + platform: is the name of the platform to build for. + src: path to the input NEXE. + dst: path to the output NEXE. + """ + uplatform = platform.replace('-', '_') + # NaCl Trusted code is in thumb2 mode in CrOS, but as yet, + # untrusted code is still in classic ARM mode + # arm-thumb2 is for the future when untrusted code is in thumb2 as well + platform2 = {'arm': 'pnacl', + 'arm-thumb2' : 'pnacl', + 'x86-32': 'i686', + 'x86-64': 'x86_64'}.get(platform, uplatform) + cplatform = { + 'win32': 'win', + 'cygwin': 'win', + 'darwin': 'mac', + }.get(sys.platform, 'linux') + if platform in ['arm', 'arm-thumb2']: + cmd = [ + '../native_client/toolchain/pnacl_linux_x86_64_newlib/bin/' + + platform2 + '-strip', + '--strip-debug', src, '-o', dst + ] + else: + cmd = [ + '../native_client/toolchain/' + cplatform + '_x86_newlib/bin/' + + platform2 + '-nacl-strip', + '--strip-debug', src, '-o', dst + ] + print 'Running: ' + ' '.join(cmd) + p = subprocess.Popen(cmd, cwd=SCRIPT_DIR) + p.wait() + if p.returncode != 0: + sys.exit(4) + + +def Main(argv): + parser = optparse.OptionParser() + parser.add_option('--platform', dest='platforms', + help='select a platform to strip') + parser.add_option('--src', dest='src', + help='source IRT file') + parser.add_option('--dst', dest='dst', + help='destination IRT file') + (options, args) = parser.parse_args(argv[1:]) + if args or not options.platforms: + parser.print_help() + sys.exit(1) + + StripIRT(options.platforms, options.src, options.dst) + + +if __name__ == '__main__': + Main(sys.argv) diff --git a/ppapi/native_client/native_client.gyp b/ppapi/native_client/native_client.gyp index ab31742..f5dad13 100644 --- a/ppapi/native_client/native_client.gyp +++ b/ppapi/native_client/native_client.gyp @@ -32,12 +32,12 @@ ], }, { - 'target_name': 'nacl_irt', + 'target_name': 'nacl_irt_unstripped', 'type': 'none', 'variables': { 'nexe_target': 'nacl_irt', - 'out64': '<(PRODUCT_DIR)/nacl_irt_x86_64.nexe', - 'out32': '<(PRODUCT_DIR)/nacl_irt_x86_32.nexe', + 'out64': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/nacl_irt_x86_64.nexe', + 'out32': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/nacl_irt_x86_32.nexe', 'build_glibc': 0, 'build_newlib': 1, 'include_dirs': [ @@ -84,6 +84,67 @@ '../../native_client/src/shared/gio/gio.gyp:gio_lib', ], }, + { + 'target_name': 'nacl_irt', + 'type': 'none', + 'dependencies': [ + 'nacl_irt_unstripped', + ], + 'conditions': [ + ['target_arch=="ia32"', { + 'actions': [ + { + 'action_name': 'strip x86-32 irt', + 'msvs_cygwin_shell': 0, + 'description': 'Strip x86-32 nacl_irt)', + 'inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/nacl_irt_x86_32.nexe', + '../../chrome/strip_nacl_irt.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/nacl_irt_x86_32.nexe', + ], + 'action': [ + '>(python_exe)', + '../../chrome/strip_nacl_irt.py', + '--platform', + 'x86-32' + '--src', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/nacl_irt_x86_32.nexe', + '--dst', + '<(PRODUCT_DIR)/nacl_irt_x86_32.nexe' + ], + }, + ], + }], + ['target_arch=="x64" or OS=="win"', { + 'actions': [ + { + 'action_name': 'strip x86-64 irt', + 'msvs_cygwin_shell': 0, + 'description': 'Strip x86-64 nacl_irt)', + 'inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/nacl_irt_x86_64.nexe', + '../../chrome/strip_nacl_irt.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/nacl_irt_x86_64.nexe', + ], + 'action': [ + '>(python_exe)', + '../../chrome/strip_nacl_irt.py', + '--platform', + 'x86-64', + '--src', + '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/nacl_irt_x86_64.nexe', + '--dst', + '<(PRODUCT_DIR)/nacl_irt_x86_64.nexe' + ], + }, + ], + }], + ], + }, ], }], ], |