summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/command.py3
-rw-r--r--cli/cros/cros_build.py9
-rw-r--r--lib/brick_lib.py273
l---------lib/brick_lib_unittest1
-rw-r--r--lib/brick_lib_unittest.py217
-rw-r--r--lib/chroot_util.py1
-rw-r--r--lib/commandline.py17
-rw-r--r--lib/commandline_unittest.py8
-rw-r--r--lib/cros_test_lib.py21
-rw-r--r--lib/sysroot_lib.py25
-rw-r--r--lib/toolchain.py15
-rw-r--r--lib/toolchain_list.py31
-rw-r--r--lib/toolchain_unittest.py67
-rw-r--r--scripts/cros_brick_utils.py40
-rw-r--r--scripts/cros_list_modified_packages.py20
-rw-r--r--scripts/cros_list_overlays.py33
-rw-r--r--scripts/cros_setup_toolchains.py30
-rw-r--r--scripts/cros_sysroot_utils.py8
-rw-r--r--scripts/cros_workon.py11
19 files changed, 31 insertions, 799 deletions
diff --git a/cli/command.py b/cli/command.py
index 360a6ec10..7743ae2cb 100644
--- a/cli/command.py
+++ b/cli/command.py
@@ -19,7 +19,6 @@ import glob
import os
from chromite.cbuildbot import constants
-from chromite.lib import brick_lib
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import cros_import
@@ -158,8 +157,6 @@ class CliCommand(object):
def __init__(self, options):
self.options = options
- brick = brick_lib.FindBrickInPath()
- self.curr_brick_locator = brick.brick_locator if brick else None
@classmethod
def AddParser(cls, parser):
diff --git a/cli/cros/cros_build.py b/cli/cros/cros_build.py
index badfb69f4..0709288f5 100644
--- a/cli/cros/cros_build.py
+++ b/cli/cros/cros_build.py
@@ -7,7 +7,6 @@
from __future__ import print_function
from chromite.cli import command
-from chromite.lib import brick_lib
from chromite.lib import chroot_util
from chromite.lib import commandline
from chromite.lib import cros_build_lib
@@ -54,12 +53,6 @@ To just build a single package:
self.host = True
elif self.options.board:
self.board = self.options.board
- elif self.options.brick or self.curr_brick_locator:
- self.brick = brick_lib.Brick(self.options.brick
- or self.curr_brick_locator)
- self.board = self.brick.FriendlyName()
- if not self.build_pkgs:
- self.build_pkgs = self.brick.MainPackages()
else:
# If nothing is explicitly set, use the default board.
self.board = cros_build_lib.GetDefaultBoard()
@@ -72,8 +65,6 @@ To just build a single package:
super(cls, BuildCommand).AddParser(parser)
target = parser.add_mutually_exclusive_group()
target.add_argument('--board', help='The board to build packages for.')
- target.add_argument('--brick', type='brick_path',
- help='The brick to build packages for.')
target.add_argument('--host', help='Build packages for the chroot itself.',
default=False, action='store_true')
parser.add_argument('--no-binary', help="Don't use binary packages.",
diff --git a/lib/brick_lib.py b/lib/brick_lib.py
deleted file mode 100644
index 092568816..000000000
--- a/lib/brick_lib.py
+++ /dev/null
@@ -1,273 +0,0 @@
-# Copyright 2015 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Common brick related utilities."""
-
-from __future__ import print_function
-
-import os
-
-from chromite.lib import osutils
-from chromite.lib import workspace_lib
-
-_DEFAULT_LAYOUT_CONF = {'profile_eapi_when_unspecified': '5-progress',
- 'profile-formats': 'portage-2 profile-default-eapi',
- 'thin-manifests': 'true',
- 'use-manifests': 'true'}
-
-_CONFIG_FILE = 'config.json'
-
-_IGNORED_OVERLAYS = ('portage-stable', 'chromiumos', 'eclass-overlay')
-
-
-class BrickCreationFailed(Exception):
- """The brick creation failed."""
-
-
-class BrickNotFound(Exception):
- """The brick does not exist."""
-
-
-class BrickFeatureNotSupported(Exception):
- """Attempted feature not supported for this brick."""
-
-
-class Brick(object):
- """Encapsulates the interaction with a brick."""
-
- def __init__(self, brick_loc, initial_config=None, allow_legacy=True):
- """Instantiates a brick object.
-
- Args:
- brick_loc: brick locator. This can be a relative path to CWD, an absolute
- path, a public board name prefix with 'board:' or a relative path to the
- root of the workspace, prefixed with '//').
- initial_config: The initial configuration as a python dictionary.
- If not None, creates a brick with this configuration.
- allow_legacy: Allow board overlays, simulating a basic read-only config.
- Ignored if |initial_config| is not None.
-
- Raises:
- ValueError: If |brick_loc| is invalid.
- LocatorNotResolved: |brick_loc| is valid but could not be resolved.
- BrickNotFound: If |brick_loc| does not point to a brick and no initial
- config was provided.
- BrickCreationFailed: when the brick could not be created successfully.
- """
- if workspace_lib.IsLocator(brick_loc):
- self.brick_dir = workspace_lib.LocatorToPath(brick_loc)
- self.brick_locator = brick_loc
- else:
- self.brick_dir = brick_loc
- self.brick_locator = workspace_lib.PathToLocator(brick_loc)
-
- self.config = None
- self.legacy = False
- config_json = os.path.join(self.brick_dir, _CONFIG_FILE)
-
- if not os.path.exists(config_json):
- if initial_config:
- if os.path.exists(self.brick_dir):
- raise BrickCreationFailed('directory %s already exists.'
- % self.brick_dir)
- success = False
- try:
- self.UpdateConfig(initial_config)
- osutils.SafeMakedirs(self.OverlayDir())
- osutils.SafeMakedirs(self.SourceDir())
- success = True
- except BrickNotFound as e:
- # If BrickNotFound was raised, the dependencies contain a missing
- # brick.
- raise BrickCreationFailed('dependency not found %s' % e)
- finally:
- if not success:
- # If the brick creation failed for any reason, cleanup the partially
- # created brick.
- osutils.RmDir(self.brick_dir, ignore_missing=True)
-
- elif allow_legacy:
- self.legacy = True
- try:
- masters = self._ReadLayoutConf().get('masters')
- masters_list = masters.split() if masters else []
-
- # Keep general Chromium OS overlays out of this list as they are
- # handled separately by the build system.
- deps = ['board:' + d for d in masters_list
- if d not in _IGNORED_OVERLAYS]
- self.config = {'name': self._ReadLayoutConf()['repo-name'],
- 'dependencies': deps}
- except (IOError, KeyError):
- pass
-
- if self.config is None:
- raise BrickNotFound('Brick not found at %s' % self.brick_dir)
- elif initial_config is None:
- self.config = workspace_lib.ReadConfigFile(config_json)
- else:
- raise BrickCreationFailed('brick %s already exists.' % self.brick_dir)
-
- self.friendly_name = None
- if not self.legacy:
- self.friendly_name = workspace_lib.LocatorToFriendlyName(
- self.brick_locator)
-
- def _LayoutConfPath(self):
- """Returns the path to the layout.conf file."""
- return os.path.join(self.OverlayDir(), 'metadata', 'layout.conf')
-
- def _WriteLayoutConf(self, content):
- """Writes layout.conf.
-
- Sets unset fields to a sensible default and write |content| in layout.conf
- in the right format.
-
- Args:
- content: dictionary containing the set fields in layout.conf.
- """
- for k, v in _DEFAULT_LAYOUT_CONF.iteritems():
- content.setdefault(k, v)
-
- content_str = ''.join(['%s = %s\n' % (k, v)
- for k, v in content.iteritems()])
- osutils.WriteFile(self._LayoutConfPath(), content_str, makedirs=True)
-
- def _ReadLayoutConf(self):
- """Returns the content of layout.conf as a Python dictionary."""
- def ParseConfLine(line):
- k, _, v = line.partition('=')
- return k.strip(), v.strip() or None
-
- content_str = osutils.ReadFile(self._LayoutConfPath())
- return dict(ParseConfLine(line) for line in content_str.splitlines())
-
- def UpdateConfig(self, config, regenerate=True):
- """Updates the brick's configuration.
-
- Writes |config| to the configuration file.
- If |regenerate| is true, regenerate the portage configuration files in
- this brick to match the new configuration.
-
- Args:
- config: brick configuration as a python dict.
- regenerate: if True, regenerate autogenerated brick files.
- """
- if self.legacy:
- raise BrickFeatureNotSupported(
- 'Cannot update configuration of legacy brick %s' % self.brick_dir)
-
- self.config = config
- # All objects must be unambiguously referenced. Normalize all the
- # dependencies according to the workspace.
- self.config['dependencies'] = [d if workspace_lib.IsLocator(d)
- else workspace_lib.PathToLocator(d)
- for d in self.config.get('dependencies', [])]
-
- workspace_lib.WriteConfigFile(os.path.join(self.brick_dir, _CONFIG_FILE),
- config)
-
- if regenerate:
- self.GeneratePortageConfig()
-
- def GeneratePortageConfig(self):
- """Generates all autogenerated brick files."""
- # We don't generate anything in legacy brick so everything is up-to-date.
- if self.legacy:
- return
-
- deps = [b.config['name'] for b in self.Dependencies()]
-
- self._WriteLayoutConf(
- {'masters': ' '.join(
- ['eclass-overlay', 'portage-stable', 'chromiumos'] + deps),
- 'repo-name': self.config['name']})
-
- def Dependencies(self):
- """Returns the dependent bricks."""
- return [Brick(d) for d in self.config.get('dependencies', [])]
-
- def Inherits(self, brick_name):
- """Checks whether this brick contains |brick_name|.
-
- Args:
- brick_name: The name of the brick to check containment.
-
- Returns:
- Whether |brick_name| is contained in this brick.
- """
- return brick_name in [b.config['name'] for b in self.BrickStack()]
-
- def MainPackages(self):
- """Returns the brick's main package(s).
-
- This finds the 'main_package' property. It nevertheless returns a (single
- element) list as it is easier to work with.
-
- Returns:
- A list of main packages; empty if no main package configured.
- """
- main_package = self.config.get('main_package')
- return [main_package] if main_package else []
-
- def OverlayDir(self):
- """Returns the brick's overlay directory."""
- if self.legacy:
- return self.brick_dir
-
- return os.path.join(self.brick_dir, 'packages')
-
- def SourceDir(self):
- """Returns the project's source directory."""
- return os.path.join(self.brick_dir, 'src')
-
- def FriendlyName(self):
- """Return the friendly name for this brick.
-
- This name is used as the board name for legacy commands (--board).
- """
- if self.friendly_name is None:
- raise BrickFeatureNotSupported()
- return self.friendly_name
-
- def BrickStack(self):
- """Returns the brick stack for this brick.
-
- Returns:
- A list of bricks, respecting the partial ordering of bricks as defined by
- dependencies, ordered from the lowest priority to the highest priority.
- """
- seen = set()
- def _stack(brick):
- seen.add(brick.brick_dir)
- l = []
- for dep in brick.Dependencies():
- if dep.brick_dir not in seen:
- l.extend(_stack(dep))
- l.append(brick)
- return l
-
- return _stack(self)
-
-
-def FindBrickInPath(path=None):
- """Returns the root directory of the brick containing a path.
-
- Return the first parent directory of |path| that is the root of a brick.
- This method is used for brick auto-detection and does not consider legacy.
-
- Args:
- path: path to a directory. If |path| is None, |path| will be set to CWD.
-
- Returns:
- The path to the first parent that is a brick directory if one exist.
- Otherwise return None.
- """
- for p in osutils.IteratePathParents(path or os.getcwd()):
- try:
- return Brick(p, allow_legacy=False)
- except BrickNotFound:
- pass
-
- return None
diff --git a/lib/brick_lib_unittest b/lib/brick_lib_unittest
deleted file mode 120000
index 72196ceea..000000000
--- a/lib/brick_lib_unittest
+++ /dev/null
@@ -1 +0,0 @@
-../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/brick_lib_unittest.py b/lib/brick_lib_unittest.py
deleted file mode 100644
index 9eff5b2b3..000000000
--- a/lib/brick_lib_unittest.py
+++ /dev/null
@@ -1,217 +0,0 @@
-# Copyright 2015 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Tests for the brick library."""
-
-from __future__ import print_function
-
-import os
-
-from chromite.cbuildbot import constants
-from chromite.lib import brick_lib
-from chromite.lib import cros_test_lib
-from chromite.lib import osutils
-from chromite.lib import workspace_lib
-
-
-class BrickLibTest(cros_test_lib.WorkspaceTestCase):
- """Unittest for brick.py"""
-
- # pylint: disable=protected-access
-
- def setUp(self):
- self.CreateWorkspace()
-
- def SetupLegacyBrick(self, brick_dir=None, brick_name='foo'):
- """Sets up a legacy brick layout."""
- if brick_dir is None:
- brick_dir = self.workspace_path
- layout_conf = 'repo-name = %s\n' % brick_name
- osutils.WriteFile(os.path.join(brick_dir, 'metadata', 'layout.conf'),
- layout_conf, makedirs=True)
-
- def testLayoutFormat(self):
- """Test that layout.conf is correctly formatted."""
- brick = self.CreateBrick()
- content = {'repo-name': 'hello',
- 'bar': 'foo'}
- brick._WriteLayoutConf(content)
-
- path = os.path.join(brick.OverlayDir(), 'metadata', 'layout.conf')
- layout_conf = osutils.ReadFile(path).split('\n')
-
- expected_lines = ['repo-name = hello',
- 'bar = foo',
- 'profile-formats = portage-2 profile-default-eapi']
- for line in expected_lines:
- self.assertTrue(line in layout_conf)
-
- def testConfigurationGenerated(self):
- """Test that portage's files are generated when the config file changes."""
- brick = self.CreateBrick()
- sample_config = {'name': 'hello',
- 'dependencies': []}
-
- brick.UpdateConfig(sample_config)
-
- self.assertExists(brick._LayoutConfPath())
-
- def testFindBrickInPath(self):
- """Test that we can infer the current brick from the current directory."""
- brick = self.CreateBrick()
- os.remove(os.path.join(brick.brick_dir, brick_lib._CONFIG_FILE))
- brick_dir = os.path.join(self.workspace_path, 'foo', 'bar', 'project')
- expected_name = 'hello'
- brick_lib.Brick(brick_dir, initial_config={'name': 'hello'})
-
- with osutils.ChdirContext(self.workspace_path):
- self.assertEqual(None, brick_lib.FindBrickInPath())
-
- with osutils.ChdirContext(brick_dir):
- self.assertEqual(expected_name,
- brick_lib.FindBrickInPath().config['name'])
-
- subdir = os.path.join(brick_dir, 'sub', 'directory')
- osutils.SafeMakedirs(subdir)
- with osutils.ChdirContext(subdir):
- self.assertEqual(expected_name,
- brick_lib.FindBrickInPath().config['name'])
-
- def testBrickCreation(self):
- """Test that brick initialization throws the right errors."""
- brick = self.CreateBrick()
- with self.assertRaises(brick_lib.BrickCreationFailed):
- brick_lib.Brick(brick.brick_dir, initial_config={})
-
- nonexistingbrick = os.path.join(self.workspace_path, 'foo')
- with self.assertRaises(brick_lib.BrickNotFound):
- brick_lib.Brick(nonexistingbrick)
-
- def testLoadNonExistingBrickFails(self):
- """Tests that trying to load a non-existing brick fails."""
- self.assertRaises(brick_lib.BrickNotFound, brick_lib.Brick,
- self.workspace_path)
-
- def testLoadExistingNormalBrickSucceeds(self):
- """Tests that loading an existing brick works."""
- brick = self.CreateBrick(name='my_brick')
- brick = brick_lib.Brick(brick.brick_dir, allow_legacy=False)
- self.assertEquals('my_brick', brick.config.get('name'))
-
- def testLoadExistingLegacyBrickFailsIfNotAllowed(self):
- """Tests that loading a legacy brick fails when not allowed."""
- self.SetupLegacyBrick()
- with self.assertRaises(brick_lib.BrickNotFound):
- brick_lib.Brick(self.workspace_path, allow_legacy=False)
-
- def testLoadExistingLegacyBrickSucceeds(self):
- """Tests that loading a legacy brick fails when not allowed."""
- self.SetupLegacyBrick()
- brick = brick_lib.Brick(self.workspace_path)
- self.assertEquals('foo', brick.config.get('name'))
-
- def testLegacyBrickUpdateConfigFails(self):
- """Tests that a legacy brick config cannot be updated."""
- self.SetupLegacyBrick()
- brick = brick_lib.Brick(self.workspace_path)
- with self.assertRaises(brick_lib.BrickFeatureNotSupported):
- brick.UpdateConfig({'name': 'bar'})
-
- def testInherits(self):
- """Tests the containment checking works as intended."""
- saved_root = constants.SOURCE_ROOT
-
- try:
- # Mock the source root so that we can create fake legacy overlay.
- constants.SOURCE_ROOT = self.workspace_path
- legacy = os.path.join(self.workspace_path, 'src', 'overlays',
- 'overlay-foobar')
- self.SetupLegacyBrick(brick_dir=legacy, brick_name='foobar')
-
- bar_brick = brick_lib.Brick('//bar', initial_config={'name': 'bar'})
- foo_brick = brick_lib.Brick(
- '//foo', initial_config={'name': 'foo',
- 'dependencies': ['//bar', 'board:foobar']})
-
- self.assertTrue(bar_brick.Inherits('bar'))
- self.assertTrue(foo_brick.Inherits('bar'))
- self.assertFalse(bar_brick.Inherits('foo'))
- self.assertTrue(foo_brick.Inherits('foobar'))
- self.assertFalse(foo_brick.Inherits('dontexist'))
-
- finally:
- constants.SOURCE_ROOT = saved_root
-
- def testOverlayDir(self):
- """Tests that overlay directory is returned correctly."""
- self.assertExists(self.CreateBrick().OverlayDir())
-
- def testOpenUsingLocator(self):
- """Tests that we can open a brick given a locator."""
- brick_lib.Brick(os.path.join(self.workspace_path, 'foo'),
- initial_config={'name': 'foo'})
-
- brick_lib.Brick('//foo')
-
- with self.assertRaises(brick_lib.BrickNotFound):
- brick_lib.Brick('//doesnotexist')
-
- def testCreateUsingLocator(self):
- """Tests that we can create a brick using a locator."""
- brick_lib.Brick('//foobar', initial_config={'name': 'foobar'})
- brick_lib.Brick('//bricks/some/path', initial_config={'name': 'path'})
-
- brick_lib.Brick('//foobar')
- brick_lib.Brick('//bricks/some/path')
-
- brick_lib.Brick(os.path.join(self.workspace_path, 'foobar'))
- brick_lib.Brick(os.path.join(self.workspace_path, 'bricks', 'some', 'path'))
-
- def testFriendlyName(self):
- """Tests that the friendly name generation works."""
- first = brick_lib.Brick('//foo/bar/test', initial_config={'name': 'test'})
- self.assertEqual('foo.bar.test', first.FriendlyName())
-
- second = brick_lib.Brick(os.path.join(self.workspace_path, 'test', 'foo'),
- initial_config={'name': 'foo'})
- self.assertEqual('test.foo', second.FriendlyName())
-
- def testMissingDependency(self):
- """Tests that the brick creation fails when a dependency is missing."""
- with self.assertRaises(brick_lib.BrickCreationFailed):
- brick_lib.Brick('//bar',
- initial_config={'name':'bar',
- 'dependencies':['//dont/exist']})
-
- # If the creation failed, the directory is removed cleanly.
- self.assertFalse(os.path.exists(workspace_lib.LocatorToPath('//bar')))
-
- def testNormalizedDependencies(self):
- """Tests that dependencies are normalized during brick creation."""
- brick_lib.Brick('//foo/bar', initial_config={'name': 'bar'})
- with osutils.ChdirContext(os.path.join(self.workspace_path, 'foo')):
- brick_lib.Brick('//baz', initial_config={'name': 'baz',
- 'dependencies': ['bar']})
-
- deps = brick_lib.Brick('//baz').config['dependencies']
- self.assertEqual(1, len(deps))
- self.assertEqual('//foo/bar', deps[0])
-
- def testBrickStack(self):
- """Tests that the brick stacking is correct."""
- def brick_dep(name, deps):
- config = {'name': os.path.basename(name),
- 'dependencies': deps}
- return brick_lib.Brick(name, initial_config=config)
-
- brick_dep('//first', [])
- brick_dep('//second', ['//first'])
- third = brick_dep('//third', ['//first', '//second'])
- fourth = brick_dep('//fourth', ['//second', '//first'])
-
- self.assertEqual(['//first', '//second', '//third'],
- [b.brick_locator for b in third.BrickStack()])
-
- self.assertEqual(['//first', '//second', '//fourth'],
- [b.brick_locator for b in fourth.BrickStack()])
diff --git a/lib/chroot_util.py b/lib/chroot_util.py
index ad1ae185b..603cc3df0 100644
--- a/lib/chroot_util.py
+++ b/lib/chroot_util.py
@@ -9,7 +9,6 @@ from __future__ import print_function
import os
from chromite.cbuildbot import constants
-from chromite.lib import brick_lib
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import sysroot_lib
diff --git a/lib/commandline.py b/lib/commandline.py
index 1a3392f48..4416047ed 100644
--- a/lib/commandline.py
+++ b/lib/commandline.py
@@ -357,22 +357,6 @@ def NormalizeWorkspacePath(path, default_dir=None, extension=None):
return locator
-def NormalizeBrickPath(path):
- """Normalize a brick path using some common assumptions.
-
- Makes the following changes to |path|:
- 1. Put non-paths in //bricks (e.g. foo -> //bricks/foo).
- 2. Convert to a workspace locator.
-
- Args:
- path: brick path.
-
- Returns:
- Locator to the brick.
- """
- return NormalizeWorkspacePath(path, default_dir='//bricks')
-
-
VALID_TYPES = {
'bool': ParseBool,
'date': ParseDate,
@@ -380,7 +364,6 @@ VALID_TYPES = {
'gs_path': NormalizeGSPath,
'local_or_gs_path': NormalizeLocalOrGSPath,
'path_or_uri': NormalizeUri,
- 'brick_path': NormalizeBrickPath,
'workspace_path': NormalizeWorkspacePath,
}
diff --git a/lib/commandline_unittest.py b/lib/commandline_unittest.py
index dec0e828a..d13c51933 100644
--- a/lib/commandline_unittest.py
+++ b/lib/commandline_unittest.py
@@ -292,19 +292,13 @@ class NormalizeWorkspacePathTest(cros_test_lib.WorkspaceTestCase):
self._VerifyNormalized('a.bin', '//a.bin.txt', extension='txt')
self._VerifyNormalized('a.txt', '//a.txt', extension='txt')
- def testSpecificPaths(self):
- """Tests normalizing brick/BSP/blueprint paths."""
- self.assertEqual('//bricks/a', commandline.NormalizeBrickPath('a'))
-
def testParser(self):
"""Tests adding these types to a parser."""
parser = commandline.ArgumentParser()
parser.add_argument('path', type='workspace_path')
- parser.add_argument('brick', type='brick_path')
- options = parser.parse_args(['my_path', 'my_brick'])
+ options = parser.parse_args(['my_path'])
self.assertEqual('//my_path', options.path)
- self.assertEqual('//bricks/my_brick', options.brick)
class CacheTest(cros_test_lib.MockTempDirTestCase):
diff --git a/lib/cros_test_lib.py b/lib/cros_test_lib.py
index 0ccddbb40..20b3eb50f 100644
--- a/lib/cros_test_lib.py
+++ b/lib/cros_test_lib.py
@@ -29,7 +29,6 @@ import urllib
from chromite.cbuildbot import config_lib
from chromite.cbuildbot import constants
-from chromite.lib import brick_lib
from chromite.lib import cidb
from chromite.lib import commandline
from chromite.lib import cros_build_lib
@@ -1602,26 +1601,6 @@ class WorkspaceTestCase(MockTempDirTestCase):
self.mock_workspace_path = self.PatchObject(
workspace_lib, 'WorkspacePath', return_value=self.workspace_path)
- def CreateBrick(self, name='thebrickfoo', main_package='category/bar',
- dependencies=None):
- """Creates a new brick.
-
- Args:
- name: Brick name/path relative to the workspace root.
- main_package: Main package to assign.
- dependencies: List of bricks to depend on.
-
- Returns:
- The created Brick object.
- """
- brick_path = os.path.join(self.workspace_path, name)
- config = {'name': name, 'main_package': main_package}
- if dependencies:
- config['dependencies'] = dependencies
-
- return brick_lib.Brick(brick_path, initial_config=config)
-
-
@contextlib.contextmanager
def SetTimeZone(tz):
"""Temporarily set the timezone to the specified value.
diff --git a/lib/sysroot_lib.py b/lib/sysroot_lib.py
index b04d4bf24..74fe4e94b 100644
--- a/lib/sysroot_lib.py
+++ b/lib/sysroot_lib.py
@@ -316,31 +316,6 @@ class Sysroot(object):
return self._GenerateConfig(toolchains, board_overlays, portdir_overlays,
header, BOARD_USE=board)
- def GenerateBrickConfig(self, bricks, bsp=None):
- """Generates the configuration for a given brick stack and bsp.
-
- Args:
- bricks: The brick stack, expanded, excluding the bsp.
- bsp: BSP to use.
- """
- brick_list = bricks
- if bsp:
- brick_list = bsp.BrickStack() + brick_list
-
- board_overlays = [b.OverlayDir() for b in brick_list]
- portdir_overlays = [_CHROMIUMOS_OVERLAY, _ECLASS_OVERLAY] + board_overlays
-
- # If the bsp is not set use the highest priority brick. This is meant to
- # preserve support for building with --brick.
- # TODO(bsimonnet): remove this once we remove support for --brick
- # (brbug.com/916).
- bsp = bsp or bricks[-1]
- toolchains = toolchain.GetToolchainsForBrick(bsp.brick_locator)
-
- header = '# Autogenerated by chromite.lib.sysroot_lib.'
- return self._GenerateConfig(toolchains, board_overlays, portdir_overlays,
- header)
-
def WriteConfig(self, config):
"""Writes the configuration.
diff --git a/lib/toolchain.py b/lib/toolchain.py
index cedc9a0f4..d20ed4197 100644
--- a/lib/toolchain.py
+++ b/lib/toolchain.py
@@ -9,7 +9,6 @@ from __future__ import print_function
import cStringIO
from chromite.cbuildbot import constants
-from chromite.lib import brick_lib
from chromite.lib import cros_build_lib
from chromite.lib import gs
from chromite.lib import portage_util
@@ -65,20 +64,6 @@ def GetToolchainsForBoard(board, buildroot=constants.SOURCE_ROOT):
return targets
-def GetToolchainsForBrick(brick_locator):
- """Get a dictionary mapping toolchain targets to their options for a brick.
-
- Args:
- brick_locator: locator for the brick.
-
- Returns:
- The list of toolchain tuples for the given brick.
- """
- toolchains = toolchain_list.ToolchainList(
- brick=brick_lib.Brick(brick_locator))
- return toolchains.GetMergedToolchainSettings()
-
-
def FilterToolchains(targets, key, value):
"""Filter out targets based on their attributes.
diff --git a/lib/toolchain_list.py b/lib/toolchain_list.py
index 432436be4..261e36e9f 100644
--- a/lib/toolchain_list.py
+++ b/lib/toolchain_list.py
@@ -22,7 +22,7 @@ _DEFAULT_TOOLCHAIN_KEY = 'default'
class NoDefaultToolchainDefinedError(Exception):
- """Brillo brick stacks are required to define a default toolchain."""
+ """Overlays are required to define a default toolchain."""
class MismatchedToolchainConfigsError(Exception):
@@ -32,28 +32,20 @@ class MismatchedToolchainConfigsError(Exception):
class ToolchainList(object):
"""Represents a list of toolchains."""
- def __init__(self, brick=None, overlays=None):
+ def __init__(self, overlays):
"""Construct an instance.
Args:
- brick: brick_lib.Brick object. We'll add the toolchains used by the brick
- and its dependencies to |self|.
overlays: list of overlay directories to add toolchains from.
"""
- if brick is None and overlays is None:
- raise ValueError('Must specify either brick or overlays.')
- if brick is not None and overlays is not None:
- raise ValueError('Must specify one of brick or overlays.')
+ if overlays is None:
+ raise ValueError('Must specify overlays.')
self._toolchains = []
self._require_explicit_default_toolchain = True
- if brick:
- for each_brick in brick.BrickStack():
- self._AddToolchainsFromBrick(each_brick)
- else:
- self._require_explicit_default_toolchain = False
- for overlay_path in overlays:
- self._AddToolchainsFromOverlayDir(overlay_path)
+ self._require_explicit_default_toolchain = False
+ for overlay_path in overlays:
+ self._AddToolchainsFromOverlayDir(overlay_path)
def _AddToolchainsFromOverlayDir(self, overlay_dir):
"""Add toolchains to |self| from the given overlay.
@@ -79,15 +71,6 @@ class ToolchainList(object):
settings = json.loads(line_pieces[1]) if len(line_pieces) > 1 else {}
self._AddToolchain(target, setting_overrides=settings)
- def _AddToolchainsFromBrick(self, brick):
- """Add toolchains to |self| defined by the given brick.
-
- Args:
- brick: brick_lib.Brick object.
- """
- for target, settings in brick.config.get('toolchains', {}):
- self._AddToolchain(target, setting_overrides=settings)
-
def _AddToolchain(self, target, setting_overrides=None):
"""Add a toolchain to |self|.
diff --git a/lib/toolchain_unittest.py b/lib/toolchain_unittest.py
index 1e4421443..45a0658e7 100644
--- a/lib/toolchain_unittest.py
+++ b/lib/toolchain_unittest.py
@@ -9,12 +9,10 @@ from __future__ import print_function
import mock
import os
-from chromite.lib import brick_lib
from chromite.lib import cros_build_lib_unittest
from chromite.lib import cros_test_lib
from chromite.lib import osutils
from chromite.lib import toolchain
-from chromite.lib import toolchain_list
from chromite.lib import workspace_lib
@@ -32,24 +30,6 @@ extra-toolchain # Unlikely to win any performance tests.
bonus-toolchain {"stable": true}
"""
-MODERN_BSP_BRICK_CONFIG = {
- 'name': 'bsp-brick',
- 'toolchains': [('base-target-name', {'default': True}),
- ('bonus-toolchain', {'a setting': 'bonus value'})
- ],
- 'dependencies': ['//custom-firmware-brick'],
-}
-
-MODERN_FIRMWARE_BRICK_CONFIG = {
- 'name': 'custom-firmware-brick',
- 'toolchains': [('bonus-toolchain', {'stable': True}),
- ('extra-toolchain', {})],
-}
-
-TYPICAL_BRICK_WITHOUT_TOOLCHAINS = {
- 'name': 'custom-firmware-brick',
-}
-
EXPECTED_TOOLCHAINS = {
'bonus-toolchain': {
'sdk': True,
@@ -66,10 +46,6 @@ EXPECTED_TOOLCHAINS = {
class ToolchainTest(cros_test_lib.MockTempDirTestCase):
"""Tests for lib.toolchain."""
- def _MakeBrick(self, config):
- return brick_lib.Brick(os.path.join(self.tempdir, config['name']),
- initial_config=config)
-
def setUp(self):
self.PatchObject(workspace_lib, 'WorkspacePath', return_value=self.tempdir)
@@ -104,46 +80,3 @@ target=foo
find_overlays_mock.return_value = overlays
actual_targets = toolchain.GetToolchainsForBoard('board_value')
self.assertEqual(EXPECTED_TOOLCHAINS, actual_targets)
-
- def testReadsBrickToolchains(self):
- """Tests that we can read the toolchain for a brick stack."""
- # Creates the brick in a subdirectory of tempdir so that we can create other
- # bricks without interfering with it.
- self._MakeBrick(MODERN_FIRMWARE_BRICK_CONFIG)
- top_brick = self._MakeBrick(MODERN_BSP_BRICK_CONFIG)
- self.assertEqual(EXPECTED_TOOLCHAINS,
- toolchain.GetToolchainsForBrick(top_brick.brick_locator))
-
- def testShouldDetectMissingDefaultsInBricks(self):
- """Tests that we check for a default toolchain in bricks."""
- brick = self._MakeBrick(
- {'name': 'brick-name', 'toolchains': [('base-toolchain', {})]})
- self.assertRaises(toolchain_list.NoDefaultToolchainDefinedError,
- toolchain.GetToolchainsForBrick,
- brick.brick_locator)
-
- def testShouldDetectConflictingOverrides(self):
- """Tests that we disallow toolchains with obvious conflicting settings."""
- conflicting_brick = self._MakeBrick(
- {'name': 'conflicting-brick',
- 'toolchains': [
- ('base-toolchain', {'default': True,
- 'setting': 'conflicting value'}),
- ],
- })
- brick = self._MakeBrick(
- {'name': 'bsp-brick',
- 'toolchains': [
- ('base-toolchain', {'default': True,
- 'setting': 'bsp value'}),
- ],
- 'dependencies': [conflicting_brick.brick_locator],
- })
- self.assertRaises(toolchain_list.MismatchedToolchainConfigsError,
- toolchain.GetToolchainsForBrick,
- brick.brick_locator)
-
- def testToleratesBricksWithoutToolchains(self):
- """Tests that we correctly handle bricks that are toolchain agnostic."""
- simple_brick = self._MakeBrick(TYPICAL_BRICK_WITHOUT_TOOLCHAINS)
- toolchain.GetToolchainsForBrick(simple_brick.brick_locator)
diff --git a/scripts/cros_brick_utils.py b/scripts/cros_brick_utils.py
deleted file mode 100644
index 102d7a75a..000000000
--- a/scripts/cros_brick_utils.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2015 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Collection of tools used in scripts while we migrate to bricks."""
-
-from __future__ import print_function
-
-from chromite.lib import brick_lib
-from chromite.lib import commandline
-from chromite.lib import cros_build_lib
-
-
-def ParseArgs(argv):
- """Parse arguments.
-
- Args:
- argv: array of arguments passed to the script.
- """
- parser = commandline.ArgumentParser(description=__doc__)
- parser.add_argument('brick')
- parser.add_argument(
- '--friendly-name', action='store_true', dest='friendlyname',
- help='Returns the friendly name for a given brick. This name is used in '
- 'the sysroot path and as "board name" in our legacy tools.')
- options = parser.parse_args(argv)
- options.Freeze()
- return options
-
-
-def main(argv):
- opts = ParseArgs(argv)
-
- try:
- brick = brick_lib.Brick(opts.brick, allow_legacy=False)
- except brick_lib.BrickNotFound:
- cros_build_lib.Die('Brick %s not found.' % opts.brick)
-
- if opts.friendlyname:
- print(brick.FriendlyName())
diff --git a/scripts/cros_list_modified_packages.py b/scripts/cros_list_modified_packages.py
index b5327e927..7b9dfd139 100644
--- a/scripts/cros_list_modified_packages.py
+++ b/scripts/cros_list_modified_packages.py
@@ -34,7 +34,6 @@ except ImportError:
import queue as Queue
from chromite.cbuildbot import constants
-from chromite.lib import brick_lib
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
@@ -142,12 +141,6 @@ def ListWorkonPackagesInfo(sysroot):
vdb_path = os.path.join(sysroot.path, portage.const.VDB_PATH)
for overlay in overlays:
- # Is this a brick overlay? Get its source base directory.
- brick_srcbase = ''
- brick = brick_lib.FindBrickInPath(overlay)
- if brick and brick.OverlayDir() == overlay.rstrip(os.path.sep):
- brick_srcbase = brick.SourceDir()
-
for filename, projects, srcpaths in portage_util.GetWorkonProjectMap(
overlay, packages):
# chromeos-base/power_manager/power_manager-9999
@@ -170,12 +163,9 @@ def ListWorkonPackagesInfo(sysroot):
# Get the modificaton time of the ebuild in the overlay.
src_ebuild_mtime = os.lstat(os.path.join(overlay, filename)).st_mtime
- # Translate relative srcpath values into their absolute counterparts.
- full_srcpaths = [os.path.join(brick_srcbase, s) for s in srcpaths]
-
# Write info into the results dictionary, overwriting any previous
# values. This ensures that overlays override appropriately.
- results[cp] = WorkonPackageInfo(cp, pkg_mtime, projects, full_srcpaths,
+ results[cp] = WorkonPackageInfo(cp, pkg_mtime, projects, srcpaths,
src_ebuild_mtime)
return results.values()
@@ -231,7 +221,6 @@ def _ParseArguments(argv):
target = parser.add_mutually_exclusive_group(required=True)
target.add_argument('--board', help='Board name')
- target.add_argument('--brick', help='Brick locator')
target.add_argument('--host', default=False, action='store_true',
help='Look at host packages instead of board packages')
target.add_argument('--sysroot', help='Sysroot path.')
@@ -245,12 +234,7 @@ def main(argv):
logging.getLogger().setLevel(logging.INFO)
flags = _ParseArguments(argv)
sysroot = None
- if flags.brick:
- try:
- sysroot = cros_build_lib.GetSysroot(brick_lib.Brick(flags.brick))
- except brick_lib.BrickNotFound:
- cros_build_lib.Die('Could not load brick %s.' % flags.brick)
- elif flags.board:
+ if flags.board:
sysroot = cros_build_lib.GetSysroot(flags.board)
elif flags.host:
sysroot = '/'
diff --git a/scripts/cros_list_overlays.py b/scripts/cros_list_overlays.py
index 2cead1b9b..754a041d8 100644
--- a/scripts/cros_list_overlays.py
+++ b/scripts/cros_list_overlays.py
@@ -9,7 +9,6 @@ from __future__ import print_function
import os
from chromite.cbuildbot import constants
-from chromite.lib import brick_lib
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import portage_util
@@ -28,7 +27,6 @@ def _ParseArguments(argv):
'only makes sense when --board is specified.')
parser.add_argument('-a', '--all', default=False, action='store_true',
help='Show all overlays (even common ones).')
- parser.add_argument('--brick', help='Main brick to use')
opts = parser.parse_args(argv)
opts.Freeze()
@@ -36,13 +34,6 @@ def _ParseArguments(argv):
if opts.primary_only and opts.board is None:
parser.error('--board is required when --primary_only is supplied.')
- if opts.brick:
- if opts.board:
- parser.error('--board and --brick are incompatible.')
-
- if opts.all:
- parser.error('Cannot list all overlays with --brick')
-
return opts
@@ -50,21 +41,17 @@ def main(argv):
opts = _ParseArguments(argv)
args = (constants.BOTH_OVERLAYS, opts.board)
- if opts.brick:
- main_brick = brick_lib.Brick(opts.brick)
- overlays = [b.OverlayDir() for b in main_brick.BrickStack()]
+ # Verify that a primary overlay exists.
+ try:
+ primary_overlay = portage_util.FindPrimaryOverlay(*args)
+ except portage_util.MissingOverlayException as ex:
+ cros_build_lib.Die(str(ex))
+
+ # Get the overlays to print.
+ if opts.primary_only:
+ overlays = [primary_overlay]
else:
- # Verify that a primary overlay exists.
- try:
- primary_overlay = portage_util.FindPrimaryOverlay(*args)
- except portage_util.MissingOverlayException as ex:
- cros_build_lib.Die(str(ex))
-
- # Get the overlays to print.
- if opts.primary_only:
- overlays = [primary_overlay]
- else:
- overlays = portage_util.FindOverlays(*args)
+ overlays = portage_util.FindOverlays(*args)
# Exclude any overlays in src/third_party, for backwards compatibility with
# scripts that expected these to not be listed.
diff --git a/scripts/cros_setup_toolchains.py b/scripts/cros_setup_toolchains.py
index 6cda17077..ca6d311c8 100644
--- a/scripts/cros_setup_toolchains.py
+++ b/scripts/cros_setup_toolchains.py
@@ -18,7 +18,6 @@ from chromite.lib import cros_logging as logging
from chromite.lib import osutils
from chromite.lib import parallel
from chromite.lib import toolchain
-from chromite.lib import workspace_lib
# Needs to be after chromite imports.
import lddtree
@@ -569,8 +568,8 @@ def ExpandTargets(targets_wanted):
Dictionary of concrete targets and their toolchain tuples.
"""
targets_wanted = set(targets_wanted)
- if targets_wanted in (set(['boards']), set(['bricks'])):
- # Only pull targets from the included boards/bricks.
+ if targets_wanted == set(['boards']):
+ # Only pull targets from the included boards.
return {}
all_targets = toolchain.GetAllTargets()
@@ -589,7 +588,7 @@ def ExpandTargets(targets_wanted):
def UpdateToolchains(usepkg, deleteold, hostonly, reconfig,
- targets_wanted, boards_wanted, bricks_wanted, root='/'):
+ targets_wanted, boards_wanted, root='/'):
"""Performs all steps to create a synchronized toolchain enviroment.
Args:
@@ -599,7 +598,6 @@ def UpdateToolchains(usepkg, deleteold, hostonly, reconfig,
reconfig: Reload crossdev config and reselect toolchains
targets_wanted: All the targets to update
boards_wanted: Load targets from these boards
- bricks_wanted: Load targets from these bricks
root: The root in which to install the toolchains.
"""
targets, crossdev_targets, reconfig_targets = {}, {}, {}
@@ -608,12 +606,10 @@ def UpdateToolchains(usepkg, deleteold, hostonly, reconfig,
# work on bare systems where this is useful.
targets = ExpandTargets(targets_wanted)
- # Now re-add any targets that might be from this board/brick. This is to
+ # Now re-add any targets that might be from this board. This is to
# allow unofficial boards to declare their own toolchains.
for board in boards_wanted:
targets.update(toolchain.GetToolchainsForBoard(board))
- for brick in bricks_wanted:
- targets.update(toolchain.GetToolchainsForBrick(brick))
# First check and initialize all cross targets that need to be.
for target in targets:
@@ -647,12 +643,9 @@ def ShowConfig(name):
"""Show the toolchain tuples used by |name|
Args:
- name: The board name or brick locator to query.
+ name: The board name to query.
"""
- if workspace_lib.IsLocator(name):
- toolchains = toolchain.GetToolchainsForBrick(name)
- else:
- toolchains = toolchain.GetToolchainsForBoard(name)
+ toolchains = toolchain.GetToolchainsForBoard(name)
# Make sure we display the default toolchain first.
print(','.join(
toolchain.FilterToolchains(toolchains, 'default', True).keys() +
@@ -1075,21 +1068,18 @@ def main(argv):
parser.add_argument('-t', '--targets',
dest='targets', default='sdk',
help="Comma separated list of tuples. Special keywords "
- "'host', 'sdk', 'boards', 'bricks' and 'all' are "
+ "'host', 'sdk', 'boards', and 'all' are "
"allowed. Defaults to 'sdk'.")
parser.add_argument('--include-boards', default='', metavar='BOARDS',
help='Comma separated list of boards whose toolchains we '
'will always include. Default: none')
- parser.add_argument('--include-bricks', default='', metavar='BRICKS',
- help='Comma separated list of bricks whose toolchains we '
- 'will always include. Default: none')
parser.add_argument('--hostonly',
dest='hostonly', default=False, action='store_true',
help='Only setup the host toolchain. '
'Useful for bootstrapping chroot')
parser.add_argument('--show-board-cfg', '--show-cfg',
dest='cfg_name', default=None,
- help='Board or brick to list toolchains tuples for')
+ help='Board to list toolchains tuples for')
parser.add_argument('--create-packages',
action='store_true', default=False,
help='Build redistributable packages')
@@ -1110,8 +1100,6 @@ def main(argv):
targets_wanted = set(options.targets.split(','))
boards_wanted = (set(options.include_boards.split(','))
if options.include_boards else set())
- bricks_wanted = (set(options.include_bricks.split(','))
- if options.include_bricks else set())
if options.cfg_name:
ShowConfig(options.cfg_name)
@@ -1129,7 +1117,7 @@ def main(argv):
root = options.sysroot or '/'
UpdateToolchains(options.usepkg, options.deleteold, options.hostonly,
options.reconfig, targets_wanted, boards_wanted,
- bricks_wanted, root=root)
+ root=root)
Crossdev.Save()
return 0
diff --git a/scripts/cros_sysroot_utils.py b/scripts/cros_sysroot_utils.py
index a4d3fbf95..614153e9f 100644
--- a/scripts/cros_sysroot_utils.py
+++ b/scripts/cros_sysroot_utils.py
@@ -10,7 +10,6 @@ from __future__ import print_function
import os
import sys
-from chromite.lib import brick_lib
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import sysroot_lib
@@ -33,7 +32,6 @@ def ParseArgs(argv):
config = subparser.add_parser('generate-config')
target = config.add_mutually_exclusive_group(required=True)
target.add_argument('--board', help='Board to generate the config for.')
- target.add_argument('--brick', help='Brick to generate the config for.')
config.add_argument('--out-file', dest='out_file',
help='File to write into. If not specified, the '
'configuration will be printed to stdout.')
@@ -84,11 +82,7 @@ def main(argv):
if opts.command == 'create-wrappers':
sysroot.CreateAllWrappers(opts.friendlyname)
elif opts.command == 'generate-config':
- if opts.brick:
- config = sysroot.GenerateBrickConfig(
- brick_lib.Brick(opts.brick).BrickStack())
- else:
- config = sysroot.GenerateBoardConfig(opts.board)
+ config = sysroot.GenerateBoardConfig(opts.board)
output.write('\n' + config)
elif opts.command == 'generate-make-conf':
diff --git a/scripts/cros_workon.py b/scripts/cros_workon.py
index 087c0a828..252ebc3be 100644
--- a/scripts/cros_workon.py
+++ b/scripts/cros_workon.py
@@ -12,7 +12,6 @@ source modified and built using the unstable 'live' (9999) ebuild.
from __future__ import print_function
-from chromite.lib import brick_lib
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import terminal
@@ -23,7 +22,6 @@ def main(argv):
shared = commandline.SharedParser()
shared.add_argument('--board', default=cros_build_lib.GetDefaultBoard(),
help='The board to set package keywords for.')
- shared.add_argument('--brick', help='The brick to set package keywords for.')
shared.add_argument('--host', default=False, action='store_true',
help='Uses the host instead of board')
shared.add_argument('--remote', default='',
@@ -81,15 +79,8 @@ def main(argv):
elif options.board:
friendly_name = options.board
sysroot = cros_build_lib.GetSysroot(board=options.board)
- elif options.brick:
- brick = brick_lib.Brick(options.brick)
- friendly_name = brick.FriendlyName()
- # TODO(wiley) This is a hack. It doesn't really make sense to calculate
- # the sysroot from a brick alone, since bricks are installed
- # into sysroots. Revisit this when blueprints are working.
- sysroot = cros_build_lib.GetSysroot(friendly_name)
else:
- cros_build_lib.Die('You must specify either --host, --board or --brick')
+ cros_build_lib.Die('You must specify either --host, --board')
helper = workon_helper.WorkonHelper(sysroot, friendly_name)
try: