Copy gcc libs directory to sysroot after build.

Tools like crosperf look for the gcc libraries under the sysroot.
Also fixed a mino issue when using --gcc_dir and other *_dir options
when the directory given does not exist.

BUG=None
TEST=Build toolchain and verified the libraries are copied to the
     correct place.
     Verified that the *_dir options check for existance of dir given

Change-Id: I61599db2843d5bdbbc479164a8f05c722f9f7e75
Reviewed-on: https://gerrit-int.chromium.org/34153
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Reviewed-by: Caroline  Tice <cmtice@google.com>
Commit-Queue: Luis Lozano <llozano@chromium.org>
Tested-by: Luis Lozano <llozano@chromium.org>
diff --git a/build_tc.py b/build_tc.py
index 0c009b3..02918b6 100755
--- a/build_tc.py
+++ b/build_tc.py
@@ -151,7 +151,14 @@
     env_string = " ".join(["%s=\"%s\"" % var for var in env.items()])
     command = "emerge =cross-%s/%s-9999" % (self._ctarget, self._name)
     full_command = "sudo %s %s" % (env_string, command)
-    return self._ce.ChrootRunCommand(self._chromeos_root, full_command)
+    rv = self._ce.ChrootRunCommand(self._chromeos_root, full_command)
+    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))
+      rv = self._ce.ChrootRunCommand(self._chromeos_root, command)
+    return rv
 
   def MoveMaskFile(self):
     self._new_mask_file = None
@@ -253,10 +260,13 @@
   chromeos_root = misc.CanonicalizePath(options.chromeos_root)
   if options.gcc_dir:
     gcc_dir = misc.CanonicalizePath(options.gcc_dir)
+    assert gcc_dir and os.path.isdir(gcc_dir), "gcc_dir does not exist!"
   if options.binutils_dir:
     binutils_dir = misc.CanonicalizePath(options.binutils_dir)
+    assert os.path.isdir(binutils_dir), "binutils_dir does not exist!"
   if options.gdb_dir:
     gdb_dir = misc.CanonicalizePath(options.gdb_dir)
+    assert os.path.isdir(gdb_dir), "gdb_dir does not exist!"
   if options.unmount_only:
     options.mount_only = False
   elif options.mount_only: