def get_reverse_deps(toc, project_name):
    bproject_names = []
    rproject_names = []
    for p in toc.projects:
        dep_solver = DependenciesSolver(projects=toc.projects, packages=toc.packages, active_projects=toc.active_projects)
        (bp, _, _) = dep_solver.solve([p.name], runtime=False)
        (rp, _, _) = dep_solver.solve([p.name], runtime=True)
        if project_name in bp:
            bproject_names.append(p.name)
        if project_name in rp:
            rproject_names.append(p.name)
    return (bproject_names, rproject_names, set(), set())
Beispiel #2
0
    def resolve_deps(self, runtime=False):
        """ Return a tuple of three lists:
        (projects, package, not_foud), see :py:mod:`qibuild.dependencies_solver`
        for more information.

        Note that the result depends on how the Toc object has been built.

        For instance, assuming you have 'hello' depending on 'world', and
        'world' is also a package, you will get:

        (['hello'], ['world'], [])  if user used

        .. code-block:: console

           $ qibuild configure hello

        but:

        (['world', 'hello], [], []) if user used:

        .. code-block:: console

           $ qibuild configure world hello

        """
        if not self.solve_deps:
            return (self.active_projects, list(), list())
        else:
            dep_solver = DependenciesSolver(projects=self.projects,
                                            packages=self.packages,
                                            active_projects=self.active_projects)
            return dep_solver.solve(self.active_projects,
                                    runtime=runtime)
    def resolve_deps(self, runtime=False):
        """ Return a tuple of three lists:
        (projects, packages, not_foud), see :py:mod:`qibuild.dependencies_solver`
        for more information.

        Note that the result depends on how the Toc object has been built.

        For instance, assuming you have 'hello' depending on 'world', and
        'world' is also a package, you will get:

        (['hello'], ['world'], [])  if user used

        .. code-block:: console

           $ qibuild configure hello

        but:

        (['world', 'hello], [], []) if user used:

        .. code-block:: console

           $ qibuild configure world hello

        """
        if not self.solve_deps:
            return (self.active_projects, list(), list())
        else:
            dep_solver = DependenciesSolver(
                projects=self.projects,
                packages=self.packages,
                active_projects=self.active_projects)
            return dep_solver.solve(self.active_projects, runtime=runtime)
Beispiel #4
0
 def test_package_dep_wins_on_project_dep_unless_user_asked(self):
     world_package = Package("world")
     world_project = Project("world")
     hello = Project("hello")
     hello.depends = ["world"]
     projects = [hello, world_project]
     packages = [world_package]
     dep_solver = DependenciesSolver(projects=projects, packages=packages)
     (projects, packages, not_found) = dep_solver.solve(["hello", "world"])
     self.assertEquals(projects,  ["world", "hello"])
     self.assertEquals(packages,  [])
     self.assertEquals(not_found, [])
Beispiel #5
0
    def test_project_dep(self):
        world = Project("world")
        hello = Project("hello")
        hello.depends = ["world"]
        projects = [hello, world]
        packages = []

        dep_solver = DependenciesSolver(projects=projects, packages=packages)
        (projects, packages, not_found) = dep_solver.solve(["hello"])
        self.assertEquals(projects,  ["world", "hello"])
        self.assertEquals(packages,  [])
        self.assertEquals(not_found, [])
Beispiel #6
0
 def test_package_dep_wins_on_project_dep_unless_user_asked(self):
     world_package = Package("world")
     world_project = Project("world")
     hello = Project("hello")
     hello.depends = ["world"]
     projects = [hello, world_project]
     packages = [world_package]
     dep_solver = DependenciesSolver(projects=projects, packages=packages)
     (projects, packages, not_found) = dep_solver.solve(["hello", "world"])
     self.assertEquals(projects, ["world", "hello"])
     self.assertEquals(packages, [])
     self.assertEquals(not_found, [])
Beispiel #7
0
    def test_project_dep(self):
        world = Project("world")
        hello = Project("hello")
        hello.depends = ["world"]
        projects = [hello, world]
        packages = []

        dep_solver = DependenciesSolver(projects=projects, packages=packages)
        (projects, packages, not_found) = dep_solver.solve(["hello"])
        self.assertEquals(projects, ["world", "hello"])
        self.assertEquals(packages, [])
        self.assertEquals(not_found, [])
Beispiel #8
0
def resolv_git_deps(toc, qiwt, args):

    project_names = None

    #all
    if args.all:
        LOGGER.debug("All projects have been selected")
        project_names = qiwt.git_projects.values()
        return project_names

    #no specified projects, search on cwd, fallback on all
    if not len(args.projects):
        pn = _search_git_directory(os.getcwd())
        if pn:
            LOGGER.debug("Selecting project from cwd.")
            project_names = [pn]
        else:
            LOGGER.debug(
                "Selecting project all projects (none specified, and no in cwd)."
            )
            project_names = qiwt.git_projects.values()
            return project_names
    else:
        project_names = list()
        for p in args.projects:
            if not qiwt.git_projects.get(p):
                raise Exception("Cant find %s\n" % (p))
            project_names.append(qiwt.git_projects[p])

    #single => no deps, returns
    if args.single:
        LOGGER.debug("Single project selected")
        return project_names

    # # Magic happen here #
    #convert git-project-list to a toc-project-list
    #resolv deps
    #convert the toc-project-list to git-project-list again
    #merge new deps into current list of git projects
    toc_projects = git_dep_to_toc_dep(project_names, toc.projects)

    dep_solver = DependenciesSolver(projects=toc.projects,
                                    packages=toc.packages)
    (all_toc_projects, _, _) = dep_solver.solve(toc_projects, runtime=False)
    toc_project_names = [
        toc.get_project(x).directory for x in all_toc_projects
    ]
    new_toc_deps = toc_dep_to_git_proj(toc_project_names,
                                       qiwt.git_projects.values())
    new_toc_deps.extend(project_names)
    return uniq(new_toc_deps)
Beispiel #9
0
def _generate_solib_search_path(toc, project_name):
    """ generate the solib_search_path useful for gdb """
    res = []
    dep_solver = DependenciesSolver(projects=toc.projects, packages=toc.packages, active_projects=toc.active_projects)

    (r_project_names, _package_names, not_found) = dep_solver.solve([project_name])
    for p in r_project_names:
        ppath = toc.get_project(p).build_directory
        ppath = os.path.join(ppath, "deploy", "lib")
        res.extend(_get_subfolder(ppath))
    for p in _package_names:
        ppath = toc.toolchain.get(p)
        ppath = os.path.join(ppath, "lib")
        res.extend(_get_subfolder(ppath))
    return _uniq(res)
    def get_sdk_dirs(self, project_name):
        """ Return a list of sdk needed to build a project.

        Iterate through the dependencies.
        When it is a package (pre-compiled), add the path of
        the package, when it is a project, add the path to the "sdk" dir
        under the build directory of the project.

        If a name is both in source and in package, use the package
        (saves compile time), unless user asked explicitely for a list
        of projects

        """
        dirs = list()

        known_project_names = [p.name for p in self.projects]
        if project_name not in known_project_names:
            raise TocException("%s is not a buildable project" % project_name)

        # Here do not honor self.solve_deps or the software won't compile :)
        dep_solver = DependenciesSolver(projects=self.projects,
                                        packages=self.packages,
                                        active_projects=self.active_projects)
        (r_project_names, _package_names,
         not_found) = dep_solver.solve([project_name])

        # Nothing to do with with the packages:
        # SDK dirs from toolchain are managed by the toolchain file in
        # self.toolchain

        if not_found:
            # FIXME: right now there are tons of case where you could have missing
            # projects. (using a cross-toolchain, or an Aldebaran SDK)
            # Put this back later.
            # LOGGER.warning("Could not find projects %s", ", ".join(not_found))
            pass

        # Remove self from the list:
        r_project_names.remove(project_name)

        for project_name in r_project_names:
            project = self.get_project(project_name)
            dirs.append(project.get_sdk_dir())

        LOGGER.debug("sdk_dirs for %s : %s", project_name, dirs)
        return dirs
Beispiel #11
0
def resolv_git_deps(toc, qiwt, args):

    project_names = None

    #all
    if args.all:
        LOGGER.debug("All projects have been selected")
        project_names = qiwt.git_projects.values()
        return project_names

    #no specified projects, search on cwd, fallback on all
    if not len(args.projects):
        pn = _search_git_directory(os.getcwd())
        if pn:
            LOGGER.debug("Selecting project from cwd.")
            project_names = [pn]
        else:
            LOGGER.debug("Selecting project all projects (none specified, and no in cwd).")
            project_names = qiwt.git_projects.values()
            return project_names
    else:
        project_names = list()
        for p in args.projects:
            if not qiwt.git_projects.get(p):
                raise Exception("Cant find %s\n" % (p))
            project_names.append(qiwt.git_projects[p])

    #single => no deps, returns
    if args.single:
        LOGGER.debug("Single project selected")
        return project_names

    # # Magic happen here #
    #convert git-project-list to a toc-project-list
    #resolv deps
    #convert the toc-project-list to git-project-list again
    #merge new deps into current list of git projects
    toc_projects = git_dep_to_toc_dep(project_names, toc.projects)

    dep_solver = DependenciesSolver(projects=toc.projects, packages=toc.packages)
    (all_toc_projects, _, _) = dep_solver.solve(toc_projects, runtime=False)
    toc_project_names = [ toc.get_project(x).directory for x in all_toc_projects ]
    new_toc_deps = toc_dep_to_git_proj(toc_project_names, qiwt.git_projects.values())
    new_toc_deps.extend(project_names)
    return uniq(new_toc_deps)
Beispiel #12
0
    def get_sdk_dirs(self, project_name):
        """ Return a list of sdk needed to build a project.

        Iterate through the dependencies.
        When it is a package (pre-compiled), add the path of
        the package, when it is a project, add the path to the "sdk" dir
        under the build directory of the project.

        If a name is both in source and in package, use the package
        (saves compile time), unless user asked explicitely for a list
        of projects

        """
        dirs = list()

        known_project_names = [p.name for p in self.projects]
        if project_name not in known_project_names:
            raise TocException("%s is not a buildable project" % project_name)

        # Here do not honor self.solve_deps or the software won't compile :)
        dep_solver = DependenciesSolver(projects=self.projects, packages=self.packages,
            active_projects=self.active_projects)
        (r_project_names, _package_names, not_found) = dep_solver.solve([project_name])

        # Nothing to do with with the packages:
        # SDK dirs from toolchain are managed by the toolchain file in
        # self.toolchain

        if not_found:
            # FIXME: right now there are tons of case where you could have missing
            # projects. (using a cross-toolchain, or an Aldebaran SDK)
            # Put this back later.
            # LOGGER.warning("Could not find projects %s", ", ".join(not_found))
            pass

        # Remove self from the list:
        r_project_names.remove(project_name)


        for project_name in r_project_names:
            project = self.get_project(project_name)
            dirs.append(project.get_sdk_dir())

        LOGGER.debug("sdk_dirs for %s : %s", project_name, dirs)
        return dirs
Beispiel #13
0
    def test_runtime_args(self):
        static_lib = Project("static-lib")
        big_lib    = Project("big-lib")
        my_exe     = Project("my-exe")

        my_exe.depends = ["big-lib"]
        my_exe.rdepends = ["big-lib"]

        big_lib.depends = ["static-lib"]
        big_lib.rdepends = []

        projects = [static_lib, big_lib, my_exe]
        packages = []
        dep_solver = DependenciesSolver(projects=projects, packages=packages)
        (projects, packages, not_found) = dep_solver.solve(["my-exe"], runtime=True)
        self.assertEquals(projects,  ["big-lib", "my-exe"])
        self.assertEquals(packages,  [])
        self.assertEquals(not_found, [])
Beispiel #14
0
    def test_runtime_args(self):
        static_lib = Project("static-lib")
        big_lib = Project("big-lib")
        my_exe = Project("my-exe")

        my_exe.depends = ["big-lib"]
        my_exe.rdepends = ["big-lib"]

        big_lib.depends = ["static-lib"]
        big_lib.rdepends = []

        projects = [static_lib, big_lib, my_exe]
        packages = []
        dep_solver = DependenciesSolver(projects=projects, packages=packages)
        (projects, packages, not_found) = dep_solver.solve(["my-exe"],
                                                           runtime=True)
        self.assertEquals(projects, ["big-lib", "my-exe"])
        self.assertEquals(packages, [])
        self.assertEquals(not_found, [])
def get_deps(toc, project_name):
    dep_solver = DependenciesSolver(projects=toc.projects, packages=toc.packages, active_projects=toc.active_projects)
    (bproject_names, bpackage_names, _) = dep_solver.solve([project_name], runtime=False)
    (rproject_names, rpackage_names, _) = dep_solver.solve([project_name], runtime=True)
    return (bproject_names, rproject_names, bpackage_names, rpackage_names)