1 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 """A module for the basic build type support in cr.""" 6 7 import cr 8 9 10 class BuildType(cr.Plugin, cr.Plugin.Type): 11 """Base class for implementing cr build types. 12 13 A build type corresponds to the second directory level in the standard output 14 directory format, and the BUILDTYPE environment variable used by chromium 15 tools. 16 """ 17 18 SELECTOR = 'CR_BUILDTYPE' 19 20 DEFAULT = cr.Config.From( 21 BUILDTYPE='{CR_BUILDTYPE}', 22 ) 23 24 def __init__(self): 25 super(BuildType, self).__init__() 26 self.active_config.Set( 27 CR_TEST_MODE=self.name, 28 ) 29 30 @classmethod 31 def AddArguments(cls, parser): 32 parser.add_argument( 33 '--type', dest=cls.SELECTOR, 34 choices=cls.Choices(), 35 default=None, 36 help='Sets the build type to use. Overrides ' + cls.SELECTOR 37 ) 38 39 40 class DebugBuildType(BuildType): 41 """A concrete implementation of BuildType for Debug builds.""" 42 43 def __init__(self): 44 super(DebugBuildType, self).__init__() 45 self._name = 'Debug' 46 47 48 class ReleaseBuildType(BuildType): 49 """A concrete implementation of BuildType for Release builds.""" 50 51 def __init__(self): 52 super(ReleaseBuildType, self).__init__() 53 self._name = 'Release' 54 55 @property 56 def priority(self): 57 return BuildType.GetPlugin('Debug').priority + 1 58 59