Esempio n. 1
0
 def fetch_repo(self, url, branch):
     if os.path.exists(".git"):
         gc.collect()
         repo = git.Repo(getcwd())
         repo.git.clear_cache()
         rmtree(repo.git_dir)
     self.repo = git.Repo.init(getcwd())
     r = Remote(self.repo, name="origin")
     if r in Remote.list_items(self.repo):
         self.repo.delete_remote(r)
     self.repo.git.remote("add", "origin", url)
     self.repo.git.fetch("origin", "-t")
     remote_branch = self.check_remote_branch()
     if not remote_branch:
         print("Fetch tag failed, just fetch all the source code")
         self.repo.git.fetch("origin")
         remote_branch = self.check_remote_branch()
         if not remote_branch:
             print("No branch found in the remote repo, patch failed")
             shutil.rmtree(".git")
             return False
     self.repo.git.checkout(remote_branch, "--force", b="master")
     print(
         "Branch 'master' set up to track remote branch '{}' from 'origin'".
         format(remote_branch))
     self.check_commit()
     self.repo.git.checkout(self.commit, "--force", b=branch)
     print("Switched to a new branch '{}'".format(branch))
Esempio n. 2
0
def test_appconfig_commands(tmpdir, get_osp):
    testdir = tmpdir.mkdir("test")
    with cd(testdir.strpath):
        runcmd(["new", "--quick"])
        app_path = os.path.join(getcwd(), "helloworld")
        runcmd(["appconfig", "--path", app_path])
        runcmd(["appconfig", "--path", app_path, "--toolchain", "gnu"])
Esempio n. 3
0
def test_build_commands(tmpdir, get_osp):
    testdir = tmpdir.mkdir("test")
    with cd(testdir.strpath):
        runcmd(["new", "--quick"])
        app_path = os.path.join(getcwd(), "helloworld")
        runcmd(["build", "--path", app_path, "--toolchain", "gnu"])
        runcmd([
            "build", "--path", app_path, "--board", "emsk", "--bd_ver", "22",
            "--core", "arcem7d", "--toolchain", "gnu"
        ])
        runcmd([
            "build", "--path", app_path, "BOARD=emsk", "BD_VER=23",
            "CUR_CORE=arcem9d", "TOOLCHAIN=gnu", "elf"
        ])
        runcmd([
            "build", "--path", app_path, "-j", "4", "BOARD=emsk", "BD_VER=23",
            "CUR_CORE=arcem9d", "TOOLCHAIN=gnu", "elf"
        ])
    app_path = "example/baremetal/secureshield/secret_normal"
    osp_class = osp.OSP()
    embarc_root = osp_class.get_path("new_osp")
    app_path = os.path.join(embarc_root,
                            "example/baremetal/secureshield/secret_normal")
    runcmd([
        "build", "--path", app_path, "--board", "iotdk", "--bd_ver", "10",
        "--core", "arcem9d", "--toolchain", "gnu"
    ])
Esempio n. 4
0
    def patch(self, branch="embARC"):
        """Apply patch to a repo
        When get repo url and repo commit from .patch file, it will fetch
        tags from one repositories according to url, and create a new 
        branch to apply patch. Or it will apply patch to current branch.
        @param branch A new branch to apply patches.

        """
        if self.need_patch():
            if self.url and self.commit:
                self.fetch_repo(self.url, branch)
            for file in os.listdir(getcwd()):
                if os.path.splitext(file)[-1] == ".patch":
                    patch_file = os.path.join(getcwd(), file)
                    print("Try to apply patch {} for this repo".format(file))
                    self.repo.git.am(patch_file)
            print("-----Patch successfully-----")
        return True
Esempio n. 5
0
def get_osp():
    toolchain_root = os.environ.get("TOOLCHAIN_CACHE_FOLDER")
    store_gnu_toolchain(toolchain_root)
    current_path = getcwd()
    runcmd(["config", "osp", "--add", "new_osp", EMBARC_OSP_URL])
    runcmd(["config", "osp", "--set", "new_osp"])

    app_path = os.path.join(current_path, "helloworld")
    if not os.path.exists(app_path):
        runcmd(["new", "--quick"])
Esempio n. 6
0
def get_patch_root(path=None):
    result = list()
    if not path:
        path = getcwd()
    if os.path.exists(path):
        for root, dirs, files in os.walk(path):
            for file in files:
                if os.path.splitext(file)[-1] == ".patch":
                    result.append(root)
                    break
    return result
Esempio n. 7
0
def runcmd(command, **kwargs):

    pre_command = [
        "python",
        os.path.join(os.environ.get("SOURCE_PATH"), "main.py")
    ]
    proc = None
    try:
        pre_command.extend(command)
        proc = subprocess.Popen(pre_command, **kwargs)
    except OSError as e:
        if e.args[0] == errno.ENOENT:
            print(
                "Could not execute \"%s\".\n"
                "Please verify that it's installed and accessible from your current path by executing \"%s\".\n"
                % (command[0], command[0]), e.args[0])
        else:
            raise e

    if proc and proc.wait() != 0:
        raise ProcessException(proc.returncode, command[0], ' '.join(command),
                               getcwd())