예제 #1
0
def set_toolchain(
    ma: linux.LinuxShell,
    arch = "armv7-eabihf",
    libc = "glibc",
    typ = "stable",
    date = "2018.11-1",
) -> None:
    """
    download and set a toolchain from:

    https://toolchains.bootlin.com/downloads/releases/toolchains/

    !! Bootlin toolchain does not work for U-Boot as there are
       problems with relocate-sdk.sh script !!

    Also, this part is integrated into tbot now:
    tbot/machine/linux/build/toolchain.py
    search for EnvSetBootlinToolchain

    :param LinuxMachine: Linux machine:
    :param str arch: architecture, default "armv7-eabihf"
    :param str libc: used libc. default "glibc"
    :param str typ: "stable" or "bleeding-edge", defaule "stable"
    :param str date: "2018.11-1"
    """
    log_event.doc_tag("set_bootlin_toolchain_arch_fixlen", arch)
    log_event.doc_tag("set_bootlin_toolchain_libc_fixlen", libc)
    log_event.doc_tag("set_bootlin_toolchain_typ_fixlen", typ)
    log_event.doc_tag("set_bootlin_toolchain_date_fixlen", date)
    log_event.doc_begin("set_toolchain_check_installed")
    td = get_toolchain_dir(ma)
    ma.exec0("cd", td)
    fn = arch + "--" + libc + "--" + typ + "-" + date
    fn2 = arch + "/tarballs/" + fn
    ending = ".tar.bz2"
    tooldir = td / fn / "bin"
    ret = ma.exec("test", "-d", tooldir)
    log_event.doc_end("set_toolchain_check_installed")
    if ret[0] == 1:
        log_event.doc_begin("set_toolchain_install")
        msg = "Get toolchain " + fn
        tbot.log.message(msg)
        ma.exec0("wget", "https://toolchains.bootlin.com/downloads/releases/toolchains/" + fn2 + ending)
        ma.exec0("tar", "xfj", fn + ending)
        ma.exec0("cd", fn)
        ma.exec0("./relocate-sdk.sh")
        log_event.doc_end("set_toolchain_install")
    ret = ma.exec("printenv", "PATH", tbot.machine.linux.Pipe, "grep", "--color=never", tooldir)
    if ret[0] == 1:
        log_event.doc_begin("set_toolchain_add")
        tbot.log.message(f"Add toolchain to PATH ({tooldir})")
        old_path = ma.env("PATH")
        ma.env("PATH", linux.F("{}:{}", tooldir, old_path))
        log_event.doc_end("set_toolchain_add")
    ma.exec0("printenv", "PATH")
    if "arm" in arch:
        log_event.doc_begin("set_toolchain_set_shell_vars")
        ma.exec0("export", "ARCH=arm" )
        ma.exec0("CROSS_COMPILE=arm-linux-")
        log_event.doc_end("set_toolchain_set_shell_vars")
예제 #2
0
def _uboot_prepare(h: linux.LinuxShell) -> uboot.UBootBuilder:
    remote = h.workdir / "selftest-ub-remote"

    # Git committer and author information in case the user's git
    # environment is not set up yet
    h.env("GIT_AUTHOR_NAME", "tbot selftest")
    h.env("GIT_AUTHOR_EMAIL", "*****@*****.**")
    h.env("GIT_COMMITTER_NAME", "tbot selftest")
    h.env("GIT_COMMITTER_EMAIL", "*****@*****.**")

    if remote.exists():
        h.exec0("rm", "-rf", remote)

    h.exec0("mkdir", remote)
    h.exec0("git", "-C", remote, "init")
    repo = git.GitRepository(target=remote, clean=False)

    makefile = """\
all:
\t@echo "Making all ..."
\ttest ${CC} = "dummy-none-gcc"
\texit 1

defconfig:
\t@echo "Configuring ..."
\ttouch .config

mrproper:
\t@echo "Cleaning ..."
\trm -f .config
\ttouch .cleaned

olddefconfig:

.PHONY: all defconfig mrproper olddefconfig
"""

    (repo / "Makefile").write_text(makefile)

    repo.add(repo / "Makefile")
    repo.commit("U-Boot Dummy", author="tbot selftest <tbot@tbot>")

    # Create Patch
    patch = """\
From 1d78601502661ae531b00540bf86e145a317f23f Mon Sep 17 00:00:00 2001
From: tbot Selftest <none@none>
Date: Wed, 30 Jan 2019 13:31:12 +0100
Subject: [PATCH] Fix Makefile

---
 Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile b/Makefile
index e76351696ad0..fe143c6d4054 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,6 @@
 all:
 \t@echo "Making all ..."
 \ttest ${CC} = "dummy-none-gcc"
-\texit 1
 \n defconfig:
 \t@echo "Configuring ..."
-- \n2.20.1
"""

    patchfile = h.workdir / "uboot-selftest.patch"
    patchfile.write_text(patch)

    class UBootBuilder(uboot.UBootBuilder):
        name = "tbot-selftest"
        remote = repo.at_host(h)
        defconfig = "defconfig"
        toolchain = "selftest-toolchain"

        def do_patch(self, repo: git.GitRepository) -> None:
            patch = repo.host.workdir / "uboot-selftest.patch"

            # Git committer and author information in case the user's git
            # environment is not set up yet
            repo.host.env("GIT_AUTHOR_NAME", "tbot selftest")
            repo.host.env("GIT_AUTHOR_EMAIL", "*****@*****.**")
            repo.host.env("GIT_COMMITTER_NAME", "tbot selftest")
            repo.host.env("GIT_COMMITTER_EMAIL", "*****@*****.**")

            repo.am(patch)

    return UBootBuilder()