chrome_set_ver - create chromium/src/third_party/cros symlink
Chromium needs this to build. Symlink points to src/platform/cros.
BUG=chromium-os:18386
TEST=Unit tests.
Change-Id: Ie114104e8c209b5461134fc98ee5f7a6f8c46531
Reviewed-on: http://gerrit.chromium.org/gerrit/5692
Reviewed-by: Anush Elangovan <anush@chromium.org>
Tested-by: Ryan Cui <rcui@chromium.org>
diff --git a/bin/chrome_set_ver.py b/bin/chrome_set_ver.py
index 90fa67e..e6be4a8 100755
--- a/bin/chrome_set_ver.py
+++ b/bin/chrome_set_ver.py
@@ -13,6 +13,9 @@
_CHROMIUM_SRC_ROOT = 'chromium/src'
+_CHROMIUM_CROS_DIR = 'chromium/src/third_party/cros'
+_PLATFORM_CROS_DIR = 'src/platform/cros'
+_PLATFORM_CROS_NAME = 'chromiumos/platform/cros'
def _LoadDEPS(deps_content):
@@ -52,12 +55,27 @@
def _ResetProject(project_path, commit_hash):
- """Reset a git repo to the specified commit hash"""
+ """Reset a git repo to the specified commit hash."""
cros_lib.RunCommand(['git', 'checkout', commit_hash], print_cmd=False,
redirect_stdout=True, redirect_stderr=True,
cwd=project_path)
+def _CreateCrosSymlink(repo_root):
+ """Create the src/third_party/cros symlink that chromium needs to build."""
+ platform_cros_dir = os.path.join(repo_root, _PLATFORM_CROS_DIR)
+ if not os.path.isdir(platform_cros_dir):
+ cros_lib.Die('Repository %s not found! Please add project %s to your'
+ 'manifest' % (platform_cros_dir, _PLATFORM_CROS_NAME))
+
+ chromium_cros_dir = os.path.join(os.path.join(repo_root, _CHROMIUM_CROS_DIR))
+ rel_link_source = os.path.relpath(platform_cros_dir,
+ os.path.dirname(chromium_cros_dir))
+ if not os.path.exists(chromium_cros_dir):
+ print rel_link_source
+ os.symlink(rel_link_source, chromium_cros_dir)
+
+
def _ResetGitCheckout(chromium_root, deps):
"""Reset chrome repos to hashes specified in the DEPS file.
@@ -97,8 +115,8 @@
default=True, help='Allow chrome-internal URLs')
(options, inputs) = parser.parse_args(argv)
- chromium_src_root = os.path.join(os.path.dirname(cros_lib.FindRepoDir()),
- _CHROMIUM_SRC_ROOT)
+ repo_root = cros_lib.FindRepoCheckoutRoot()
+ chromium_src_root = os.path.join(repo_root, _CHROMIUM_SRC_ROOT)
if not os.path.isdir(chromium_src_root):
sys.exit('chromium src/ dir not found')
@@ -114,6 +132,7 @@
merged_deps.update(unix_deps)
chromium_root = os.path.dirname(chromium_src_root)
+ _CreateCrosSymlink(repo_root)
_ResetGitCheckout(chromium_root, merged_deps)
_RunHooks(chromium_root, deps['hooks'])
diff --git a/bin/chrome_set_ver_unittest.py b/bin/chrome_set_ver_unittest.py
index 0edce35..3c94e5e 100755
--- a/bin/chrome_set_ver_unittest.py
+++ b/bin/chrome_set_ver_unittest.py
@@ -40,7 +40,7 @@
repo_root = cros_lib.FindRepoDir()
assert(os.path.realpath(os.path.dirname(repo_root)) == self.repo_root)
- def testParseAndRunDEPSFile(self):
+ def testParseAndRunDEPSFileAndGenerateSymlink(self):
"""Test resetting of repos, usage of Var's and running of hooks."""
chrome_set_ver.main(['-d',
os.path.join(self.test_base, 'test_1/DEPS.git')])
@@ -61,6 +61,10 @@
self.assertTrue(os.path.exists(hook1_output))
self.assertTrue(os.path.exists(hook2_output))
+ # Verify symlink was generated
+ test_file = 'chromium/src/third_party/cros/TEST'
+ self.assertTrue(os.path.exists(os.path.join(self.repo_root, test_file)))
+
def testErrorOnOverlap(self):
"""Test that an overlapping entry in unix deps causes error."""
self.assertRaises(AssertionError, chrome_set_ver.main,
diff --git a/bin/testdata/chrome_set_ver_unittest/repo_root.tar.gz b/bin/testdata/chrome_set_ver_unittest/repo_root.tar.gz
index 554fcf2..ca22669 100644
--- a/bin/testdata/chrome_set_ver_unittest/repo_root.tar.gz
+++ b/bin/testdata/chrome_set_ver_unittest/repo_root.tar.gz
Binary files differ
diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py
index 22c58ca..ae45cbf 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -322,6 +322,15 @@
return None
+def FindRepoCheckoutRoot(path=None):
+ """Get the root of your repo managed checkout."""
+ repo_dir = FindRepoDir(path)
+ if repo_dir:
+ return os.path.dirname(repo_dir)
+ else:
+ return None
+
+
def GetProjectDir(cwd, project):
"""Returns the absolute path to a project.