summaryrefslogtreecommitdiffstats
path: root/tools/cr
diff options
context:
space:
mode:
authorssid <ssid@chromium.org>2016-01-07 10:59:05 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-07 18:59:57 +0000
commit6dd04c213d6c79b2bc0cd54078e548cc64611dd7 (patch)
tree5d3c1bd2170d85d41d824d269adced7d6cb035f2 /tools/cr
parentd9d1d001ad9fa0ff034a9a9eab183a8de1c23724 (diff)
downloadchromium_src-6dd04c213d6c79b2bc0cd54078e548cc64611dd7.zip
chromium_src-6dd04c213d6c79b2bc0cd54078e548cc64611dd7.tar.gz
chromium_src-6dd04c213d6c79b2bc0cd54078e548cc64611dd7.tar.bz2
Fix recognition of "linuxchromeos" directory in cr
Since the strings "linuxchromeos" and "linux" both match the directory name, cr throws an error for not being able to find the platform. This CL fixes this issue to match substrings better. Review URL: https://codereview.chromium.org/1562083002 Cr-Commit-Position: refs/heads/master@{#368115}
Diffstat (limited to 'tools/cr')
-rw-r--r--tools/cr/cr/commands/init.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/cr/cr/commands/init.py b/tools/cr/cr/commands/init.py
index 647176a..7b09330 100644
--- a/tools/cr/cr/commands/init.py
+++ b/tools/cr/cr/commands/init.py
@@ -83,13 +83,16 @@ class InitCommand(cr.Command):
# Try to guess platform based on output name
platforms = [p.name for p in cr.Platform.AllPlugins()]
matches = [p for p in platforms if p in base]
- if len(matches) != 1:
+ # Get the longest matching string and check if the others are
+ # substrings. This is done to support "linuxchromeos" and "linux".
+ platform = max(matches, key=len)
+ all_matches_are_substrings = all(p in platform for p in matches)
+ if all_matches_are_substrings or not matches:
print 'Platform is not set, and could not be guessed from', base
print 'Should be one of', ','.join(platforms)
if len(matches) > 1:
print 'Matched all of', ','.join(matches)
exit(1)
- platform = matches[0]
generator = cr.context.args.CR_GENERATOR
if not generator:
generator = 'gyp'