Copy the gcc libs to the appropriate destination directory for the board.
Use get_board_arch defined in toolchain_utils to get the right destination
directory for gcc libs.
BUG=chromium:429775
TEST=Ran build_tc.py for panther board.
Change-Id: I1eff4ac788dd61338037838f7d3f688163a6c2bc
Reviewed-on: https://chrome-internal-review.googlesource.com/182626
Reviewed-by: Luis Lozano <llozano@chromium.org>
Commit-Queue: Rahul Chaudhry <rahulchaudhry@google.com>
Tested-by: Rahul Chaudhry <rahulchaudhry@google.com>
diff --git a/build_tc.py b/build_tc.py
index ad092aa..34cba54 100755
--- a/build_tc.py
+++ b/build_tc.py
@@ -32,6 +32,8 @@
self._board = board
self._ctarget = misc.GetCtargetFromBoard(self._board,
self._chromeos_root)
+ self._gcc_libs_dest = misc.GetGccLibsDestForBoard(self._board,
+ self._chromeos_root)
self.tag = "%s-%s" % (name, self._ctarget)
self._ce = command_executer.GetCommandExecuter()
self._mask_file = os.path.join(
@@ -158,8 +160,8 @@
if rv != 0:
return rv
if self._name == "gcc":
- command = ("sudo cp -r /usr/lib/gcc/%s /build/%s/usr/lib/gcc/." %
- (self._ctarget, self._board))
+ command = ("sudo cp -r /usr/lib/gcc/%s %s" %
+ (self._ctarget, self._gcc_libs_dest))
rv = self._ce.ChrootRunCommand(self._chromeos_root, command)
return rv
diff --git a/utils/misc.py b/utils/misc.py
index 9e7a4ca..064d7b2 100644
--- a/utils/misc.py
+++ b/utils/misc.py
@@ -231,6 +231,34 @@
return out.strip()
+def GetArchFromBoard(board, chromeos_root):
+ """Get Arch from board."""
+ base_board = board.split("_")[0]
+ command = ("source %s; get_board_arch %s" %
+ (TOOLCHAIN_UTILS_PATH, base_board))
+ ce = command_executer.GetCommandExecuter()
+ ret, out, _ = ce.ChrootRunCommand(chromeos_root,
+ command,
+ return_output=True)
+ if ret != 0:
+ raise ValueError("Board %s is invalid!" % board)
+ # Remove ANSI escape sequences.
+ out = StripANSIEscapeSequences(out)
+ return out.strip()
+
+
+def GetGccLibsDestForBoard(board, chromeos_root):
+ """Get gcc libs destination from board."""
+ arch = GetArchFromBoard(board, chromeos_root)
+ if arch == "x86":
+ return "/build/%s/usr/lib/gcc/" % board
+ if arch == "amd64":
+ return "/build/%s/usr/lib64/gcc/" % board
+ if arch == "arm":
+ return "/build/%s/usr/lib/gcc/" % board
+ raise ValueError("Arch %s is invalid!" % arch)
+
+
def StripANSIEscapeSequences(string):
string = re.sub(r"\x1b\[[0-9]*[a-zA-Z]", "", string)
return string