Exemple #1
0
    def collect_modules(mod):
        if licant.core.core.runtime["trace"]:
            print("trace: collect_modules( {} )".format(mod.name))

        for md in mod.opts["mdepends"]:
            if isinstance(md, str):
                if md in mdepends:
                    continue

                request_implementation(name=md, incfrom=mod.name)

            elif isinstance(md, tuple):
                nmod = mlibrary.get(md[0], md[1])

                if md[0] in mdepends and mdepends[md[0]] is not nmod:
                    licant.error(
                        "This module added early and it's different: mod:{} now:{} early:{}".format(
                            licant.util.yellow(nmod.name),
                            licant.util.yellow(nmod.impl),
                            licant.util.yellow(mdepends[md[0]].impl),
                        )
                    )

                specify_implementation(name=md[0], mod=nmod, incfrom=mod.name)

                if "mdepends" in nmod.opts:
                    # Сразу же выполняем обход по данному модулю
                    collect_modules(nmod)

            else:
                licant.error("Very strange mpdepend")
Exemple #2
0
def included_from(target, *args):
    if len(args) > 0:
        name = args[0]
    else:
        print("You should specify target name")
        return

    for m in sorted(collect_modules(mlibrary.get(name)), key=lambda x: x.name):
        print(m.name, ":", m.included_from)
Exemple #3
0
def print_collect_list(target, *args):
    if len(args) > 0:
        name = args[0]
    else:
        print("You should specify target name")
        return
    for m in sorted(collect_modules(mlibrary.get(name)), key=lambda x: x.name):
        if hasattr(m, "impl"):
            print("{}:{}".format(m.name, m.impl))
        else:
            print(m.name)
Exemple #4
0
        def include_modules(locopts, lst):
            retopts = locopts
            for simod in lst:
                imod = mlibrary.get(simod.name, simod.impl)
                retopts = retopts.merge(imod, "include")

                if "include_modules" in imod.opts:
                    retopts = include_modules(
                        retopts, imod.opts["include_modules"])

            return retopts
Exemple #5
0
    def modmake(name, impl, baseopts):
        mod = mlibrary.get(name, impl)

        modopts = CXXModuleOptions(**mod.opts)
        locopts = baseopts.merge(modopts, "merge")

        adddeps = []  # mod.stack

        # Проходим по include_modules, рекурсивно формируем локальные опции.
        def include_modules(locopts, lst):
            retopts = locopts
            for simod in lst:
                imod = mlibrary.get(simod.name, simod.impl)
                retopts = retopts.merge(imod, "include")

                if "include_modules" in imod.opts:
                    retopts = include_modules(
                        retopts, imod.opts["include_modules"])

            return retopts

        locopts = include_modules(locopts, locopts["include_modules"])

        # Система модулей mdepends
        for imod in collect_modules(mod):
            locopts = locopts.merge(imod, "include")

        local_headers_targets = []
        if len(locopts["local_headers"]):
            locopts["include_paths"].append(
                locopts["builddir"] + "/__LOCAL_HEADERS__/")
            for pair in locopts["local_headers"]:
                licant.make.source(pair[1])
                tgtpath = os.path.join(
                    locopts["builddir"], "__LOCAL_HEADERS__", pair[0]
                )
                licant.make.copy(src=pair[1], tgt=tgtpath)

                local_headers_targets.append(tgtpath)

        licant.make.fileset(name + "__local_headers__", local_headers_targets)
        adddeps.append(name + "__local_headers__")

        locsrcs = sources_paths(locopts)
        locobjs = build_paths(locsrcs, locopts, "o")
        locdeps = build_paths(locsrcs, locopts, "d")

        cxxopts = cxx_options_from_modopts(locopts)

        if len(locopts["qt_ui"]) != 0:
            uidir = os.path.join(locopts.opts["builddir"], "ui")
            locui = qt_ui_paths(locopts)
            locuihxx = build_paths(locui, locopts, "h",
                                   builddir=uidir,
                                   prefix="ui_")
            link_qt_ui(locui, locuihxx, cxxopts, adddeps)
            adddeps.extend(locuihxx)

            if uidir not in locopts.opts["include_paths"]:
                locopts.opts["include_paths"].append(uidir)

            # Recompile with ui include path
            cxxopts = cxx_options_from_modopts(locopts)

        if len(locopts["qt_moc"]) != 0:
            locmoc = qt_moc_paths(locopts)
            locmoccxx = build_paths(locmoc, locopts, "h.cxx")
            locmocobjs = build_paths(locmoc, locopts, "h.cxx.o")
            locmocdeps = build_paths(locmoc, locopts, "h.cxx.d")
            link_qt_moc(locmoc, locmoccxx, cxxopts, adddeps)

            locsrcs.extend(locmoccxx)
            locobjs.extend(locmocobjs)
            locdeps.extend(locmocdeps)

        link_objects(locsrcs, locobjs, locdeps, cxxopts, adddeps)

        if len(locopts["objects"]) != 0:
            for t in locopts["objects"]:
                licant.make.source(t)
            locobjs.extend(locopts["objects"])

        submodules_results = []
        # print(locopts["modules"])
        for smod in locopts["modules"]:
            submodules_results += modmake(smod.name, smod.impl, locopts)

        if locopts["type"] == "application":
            return ([executable(locobjs + submodules_results, locopts)], locopts)
        elif locopts["type"] == "shared_library":
            return ([dynlib(locobjs + submodules_results, locopts)], locopts)
        elif locopts["type"] == "static_library":
            return ([statlib(locobjs + submodules_results, locopts)], locopts)
        elif locopts["type"] == "objects":
            return (locobjs + submodules_results, locopts)
        else:
            print("Wrong type of assemble: {}".format(gu.red(locopts["type"])))
            exit(-1)