Skip to content

Commit

Permalink
Remove GYP_DEFINES reference from cygprofile
Browse files Browse the repository at this point in the history
Removes the references to GYP_DEFINES in //tools/cygprofile.
Default to just 'arm' for the architecture. The scripts in here
allow for this to be customized.

Bug: 873373, 718157
Change-Id: Ic3dd78e47b7ceebd7d1228d2432c7b41c16556e6
Reviewed-on: https://chromium-review.googlesource.com/c/1359136
Reviewed-by: Egor Pasko <pasko@chromium.org>
Commit-Queue: Egor Pasko <pasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613552}
  • Loading branch information
martiniss authored and Commit Bot committed Dec 4, 2018
1 parent d992316 commit 71b391b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 22 deletions.
4 changes: 1 addition & 3 deletions tools/cygprofile/check_orderfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ def _VerifySymbolOrder(orderfile_symbols, symbol_infos, threshold):
def main():
parser = optparse.OptionParser(usage=
'usage: %prog [options] <binary> <orderfile>')
parser.add_option('--target-arch', action='store', dest='arch',
parser.add_option('--target-arch', action='store', dest='arch', default='arm',
choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'],
help='The target architecture for the binary.')
parser.add_option('--threshold', action='store', dest='threshold',
default=20, type=int,
help='The maximum allowed number of out-of-order symbols.')
options, argv = parser.parse_args(sys.argv)
if not options.arch:
options.arch = cygprofile_utils.DetectArchitecture()
if len(argv) != 3:
parser.print_help()
return 1
Expand Down
4 changes: 1 addition & 3 deletions tools/cygprofile/cyglog_to_orderfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _ReadReachedOffsets(filename):
def _CreateArgumentParser():
parser = argparse.ArgumentParser(
description='Creates an orderfile from profiles.')
parser.add_argument('--target-arch', required=False,
parser.add_argument('--target-arch', required=False, default='arm',
choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'],
help='The target architecture for libchrome.so')
parser.add_argument('--reached-offsets', type=str, required=True,
Expand All @@ -252,8 +252,6 @@ def main():
parser = _CreateArgumentParser()
args = parser.parse_args()

if not args.target_arch:
args.arch = cygprofile_utils.DetectArchitecture()
symbol_extractor.SetArchitecture(args.target_arch)

offsets = _ReadReachedOffsets(args.reached_offsets)
Expand Down
12 changes: 0 additions & 12 deletions tools/cygprofile/cygprofile_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ def WriteEnd(self, message):
self._warnings - self._max_warnings, message))


def DetectArchitecture(default='arm'):
"""Detects the architecture by looking for target_arch in GYP_DEFINES.
If not not found, returns default.
"""
gyp_defines = os.environ.get('GYP_DEFINES', '')
match = re.match('target_arch=(\S+)', gyp_defines)
if match and len(match.groups()) == 1:
return match.group(1)
else:
return default


def InvertMapping(x_to_ys):
"""Given a map x -> [y1, y2...] returns inverse mapping y->[x1, x2...]."""
y_to_xs = {}
Expand Down
2 changes: 1 addition & 1 deletion tools/cygprofile/orderfile_generator_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def CreateArgumentParser():
'--verify', action='store_true',
help='If true, the script only verifies the current orderfile')
parser.add_argument('--target-arch', action='store', dest='arch',
default=cygprofile_utils.DetectArchitecture(),
default='arm',
choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'],
help='The target architecture for which to build')
parser.add_argument('--output-json', action='store', dest='json_file',
Expand Down
4 changes: 1 addition & 3 deletions tools/cygprofile/patch_orderfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def GeneratePatchedOrderfile(unpatched_orderfile, native_lib_filename,
def _CreateArgumentParser():
"""Creates and returns the argument parser."""
parser = argparse.ArgumentParser()
parser.add_argument('--target-arch', action='store',
parser.add_argument('--target-arch', action='store', default='arm',
choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'],
help='The target architecture for the library.')
parser.add_argument('--unpatched-orderfile', required=True,
Expand All @@ -180,8 +180,6 @@ def _CreateArgumentParser():
def main():
parser = _CreateArgumentParser()
options = parser.parse_args()
if not options.target_arch:
options.arch = cygprofile_utils.DetectArchitecture()
symbol_extractor.SetArchitecture(options.target_arch)
GeneratePatchedOrderfile(options.unpatched_orderfile, options.native_library,
options.output_file)
Expand Down

0 comments on commit 71b391b

Please sign in to comment.