Added option to use binaries instead of source when installing
the toolchain in a chroot.
Tested with and without the -B option.
PRESUBMIT=passed
R=raymes,bjanakiraman
DELTA=35 (26 added, 0 deleted, 9 changed)
RCL=45025-p2
RDATE=2010/11/04 16:54:57
P4 change: 42605578
diff --git a/v14/build_tc.py b/v14/build_tc.py
index 9d491f6..9777081 100755
--- a/v14/build_tc.py
+++ b/v14/build_tc.py
@@ -29,12 +29,18 @@
parser.add_option("-b", "--board", dest="board",
help="board is the argument to the setup_board command.")
parser.add_option("-C", "--clean", dest="clean",
- action="store_true", help="Uninstall the toolchain.")
+ action="store_true", default=False,
+ help="Uninstall the toolchain.")
parser.add_option("-f", "--force", dest="force",
- action="store_true", help="Do an uninstall/install cycle.")
+ action="store_true", default=False,
+ help="Do an uninstall/install cycle.")
parser.add_option("-i", "--incremental", dest="incremental",
help="The toolchain component that should be "
"incrementally compiled.")
+ parser.add_option("-B", "--binary", dest="binary",
+ action="store_true", default=False,
+ help="The toolchain should use binaries stored in "
+ "the install/ directory.")
options = parser.parse_args()[0]
@@ -45,6 +51,11 @@
if options.chromeos_root is None:
options.chromeos_root = "../.."
+ portage_flags = ""
+ if options.binary == True:
+ # FIXME(asharif): This should be using --usepkg but that was not working.
+ portage_flags = "--usepkgonly"
+
f = open(options.chromeos_root + "/src/overlays/overlay-" +
options.board + "/toolchain.conf", "r")
target = f.read()
@@ -57,12 +68,22 @@
version_dir = "/home/${USER}/toolchain_root/" + version_number
env += CreateEnvVarString(" PORT_LOGDIR", version_dir + "/logs")
env += CreateEnvVarString(" PKGDIR", version_dir + "/install")
+ env += CreateEnvVarString(" PORTAGE_BINHOST", version_dir +
+ "/cross/" + target)
env += CreateEnvVarString(" PORTAGE_TMPDIR", version_dir + "/objects")
if options.force == True:
BuildTC(options.chromeos_root, options.toolchain_root, env, target,
- True, options.incremental)
+ True, options.incremental, portage_flags)
BuildTC(options.chromeos_root, options.toolchain_root, env, target,
- options.clean, options.incremental)
+ options.clean, options.incremental, portage_flags)
+
+
+def CreateCrossdevPortageFlags(portage_flags):
+ if not portage_flags:
+ return ""
+ crossdev_flags = " --portage "
+ crossdev_flags += " --portage ".join(portage_flags.split(" "))
+ return crossdev_flags
def CreateEnvVarString(variable, value):
@@ -74,14 +95,14 @@
def BuildTC(chromeos_root, toolchain_root, env, target, uninstall,
- incremental_component):
+ incremental_component, portage_flags):
"""Build the toolchain."""
binutils_version = "2.20.1-r1"
gcc_version = "9999"
libc_version = "2.10.1-r1"
kernel_version = "2.6.30-r1"
if incremental_component is not None and incremental_component:
- env += "FEATURES+=" + EscapeQuoteString("keepwork")
+ env += " FEATURES+=" + EscapeQuoteString("keepwork")
if uninstall == True:
tflag = " -C "
@@ -96,11 +117,14 @@
command += " -- sudo " + env
if incremental_component == "binutils":
- command += " emerge =cross-" + target + "/binutils-" + binutils_version
+ command += (" emerge =cross-" + target + "/binutils-" + binutils_version +
+ portage_flags)
elif incremental_component == "gcc":
- command += " emerge =cross-" + target + "/gcc-" + gcc_version
+ command += (" emerge =cross-" + target + "/gcc-" + gcc_version +
+ portage_flags)
elif incremental_component == "libc" or incremental_component == "glibc":
- command += " emerge =cross-" + target + "/glibc-" + libc_version
+ command += (" emerge =cross-" + target + "/glibc-" + libc_version +
+ portage_flags)
else:
command += (" crossdev -v " + tflag + target +
" --binutils " + binutils_version +
@@ -108,6 +132,8 @@
" --gcc " + gcc_version +
" --kernel " + kernel_version +
" --portage -b --portage --newuse")
+ crossdev_flags = CreateCrossdevPortageFlags(portage_flags)
+ command += crossdev_flags
retval = utils.RunCommand(command)
return retval