diff options
author | iancottrell@chromium.org <iancottrell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 16:38:27 +0000 |
---|---|---|
committer | iancottrell@chromium.org <iancottrell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 16:38:27 +0000 |
commit | 8fec4b6eef7f1f4ef5840504f6abcdf0d2f9f80d (patch) | |
tree | e6b4d0ff3ecc43b75382e54fb8571606027f0e8f /tools/cr | |
parent | 84145539b09c35eb92f28b98e0b35e3a738e68e3 (diff) | |
download | chromium_src-8fec4b6eef7f1f4ef5840504f6abcdf0d2f9f80d.zip chromium_src-8fec4b6eef7f1f4ef5840504f6abcdf0d2f9f80d.tar.gz chromium_src-8fec4b6eef7f1f4ef5840504f6abcdf0d2f9f80d.tar.bz2 |
Adding the concept of a target platform.
BUG=316397
Review URL: https://codereview.chromium.org/72733002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/cr')
-rw-r--r-- | tools/cr/cr/base/platform.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tools/cr/cr/base/platform.py b/tools/cr/cr/base/platform.py new file mode 100644 index 0000000..db6f66d --- /dev/null +++ b/tools/cr/cr/base/platform.py @@ -0,0 +1,70 @@ +# Copyright 2013 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. + +"""Module for the target platform support.""" + +from importlib import import_module +import os + +import cr + +DEFAULT = cr.Config.From( + DEPOT_TOOLS=os.path.join('{GOOGLE_CODE}', 'depot_tools'), +) + + +class Platform(cr.Plugin, cr.Plugin.Type): + """Base class for implementing cr platforms. + + A platform is the target operating system being compiled for (linux android). + """ + + _platform_module = import_module('platform', None) + SELECTOR = 'CR_PLATFORM' + + @classmethod + def AddArguments(cls, parser): + parser.add_argument( + '--platform', dest=cls.SELECTOR, + choices=cls.Choices(), + default=None, + help='Sets the target platform to use. Overrides ' + cls.SELECTOR + ) + + @classmethod + def System(cls): + return cls._platform_module.system() + + def __init__(self): + super(Platform, self).__init__() + + def Activate(self, context): + super(Platform, self).Activate(context) + if _PathFixup not in context.fixup_hooks: + context.fixup_hooks.append(_PathFixup) + + @cr.Plugin.activemethod + def Prepare(self, context): + pass + + @property + def paths(self): + return [] + + +def _PathFixup(context, key, value): + """A context fixup that does platform specific modifications to the PATH.""" + if key == 'PATH': + paths = [] + for entry in Platform.GetActivePlugin(context).paths: + entry = context.Substitute(entry) + if entry not in paths: + paths.append(entry) + for entry in value.split(os.path.pathsep): + if entry.endswith(os.path.sep + 'goma'): + pass + elif entry not in paths: + paths.append(entry) + value = os.path.pathsep.join(paths) + return value |