示例#1
0
def main():
    (options, args) = parser.parse_args()
    sorted_order = tools.get_sorted_order()
    if options.module != "":
        if options.module == "kernel":
            tools.rewrite("lib/IMP/__init__.py", imp_init)
        build_wrapper(
            options.module, os.path.join(
                options.source, "modules", options.module),
            options.source, sorted_order,
            tools.get_module_description(
                options.source,
                options.module,
                options.datapath),
            os.path.join("swig", "IMP_" + options.module + ".i"),
            options.datapath)
    else:
        tools.rewrite("lib/IMP/__init__.py", imp_init)
        for m, path in tools.get_modules(options.source):
            build_wrapper(m, path, options.source, sorted_order,
                          tools.get_module_description(
                              options.source,
                              m,
                              options.datapath),
                          os.path.join("swig", "IMP_" + m + ".i"),
                          options.datapath)
示例#2
0
def main():
    (options, args) = parser.parse_args()
    sorted_order = tools.get_sorted_order()
    if options.module != "":
        if options.module == "kernel":
            tools.rewrite("lib/IMP/__init__.py", imp_init)
        build_wrapper(
            options.module,
            os.path.join(options.source, "modules",
                         options.module), options.source, sorted_order,
            tools.get_module_description(options.source, options.module,
                                         options.datapath),
            os.path.join("swig", "IMP_" + options.module + ".i"),
            options.datapath)
    else:
        tools.rewrite("lib/IMP/__init__.py", imp_init)
        for m, path in tools.get_modules(options.source):
            build_wrapper(
                m, path, options.source, sorted_order,
                tools.get_module_description(options.source, m,
                                             options.datapath),
                os.path.join("swig", "IMP_" + m + ".i"), options.datapath)
示例#3
0
def main():
    (options, args) = parser.parse_args()
    sorted_order = tools.get_sorted_order()
    if options.module != "":
        build_wrapper(
            options.module, os.path.join(
                options.source, "modules", options.module),
            options.source, sorted_order,
            tools.get_module_description(
                options.source,
                options.module,
                options.datapath),
            os.path.join("swig", "IMP_" + options.module + ".i"),
            options.datapath)
示例#4
0
def setup_module(module, source, datapath):
    sys.stdout.write("Configuring module %s ..." % module)
    data = tools.get_module_description(source, module, datapath)
    for d in data["required_dependencies"]:
        if not tools.get_dependency_info(d, datapath)["ok"]:
            print("Required dependency %s not found" % d)
            write_no_ok(module)
            return False, []
    dependencies = data["required_dependencies"]
    unfound_dependencies = []
    for d in data["optional_dependencies"]:
        if tools.get_dependency_info(d, datapath)["ok"]:
            dependencies.append(d)
        else:
            unfound_dependencies.append(d)
    for d in data["required_modules"]:
        if not tools.get_module_info(d, datapath)["ok"]:
            print("Required module IMP.%s not available" % d)
            write_no_ok(module)
            return False, []
    modules = data["required_modules"]
    unfound_modules = []
    for d in data["optional_modules"]:
        if tools.get_module_info(d, datapath)["ok"]:
            modules.append(d)
        else:
            unfound_modules.append(d)
    all_modules = tools.get_dependent_modules(modules, datapath)
    moddir = os.path.join('IMP', '' if module == 'kernel' else module)
    swig_includes = [os.path.split(x)[1]
                     for x in tools.get_glob(
                         [os.path.join(source, "modules", module, "pyext",
                                       "include", "*.i")])] \
                    + [os.path.join(moddir, os.path.split(x)[1])
                       for x in tools.get_glob(
                           [os.path.join("include", moddir, "*_macros.h")])]
    swig_wrapper_includes = [os.path.join(moddir, "internal",
                                          os.path.split(x)[1])
                             for x in tools.get_glob(
                                 [os.path.join(source, "modules", module,
                                               "include", "internal",
                                               "swig*.h")])]
    tools.mkdir(os.path.join("src", module))
    tools.mkdir(os.path.join("src", module + "_swig"))
    write_ok(module, all_modules, unfound_modules,
             tools.get_dependent_dependencies(all_modules, dependencies,
                                              datapath),
             unfound_dependencies, swig_includes, swig_wrapper_includes)
    return True, all_modules
示例#5
0
def setup_module(module, source, datapath):
    sys.stdout.write("Configuring module %s ..." % module)
    data = tools.get_module_description(source, module, datapath)
    for d in data["required_dependencies"]:
        if not tools.get_dependency_info(d, datapath)["ok"]:
            print("Required dependency %s not found" % d)
            write_no_ok(module)
            return False, []
    dependencies = data["required_dependencies"]
    unfound_dependencies = []
    for d in data["optional_dependencies"]:
        if tools.get_dependency_info(d, datapath)["ok"]:
            dependencies.append(d)
        else:
            unfound_dependencies.append(d)
    for d in data["required_modules"]:
        if not tools.get_module_info(d, datapath)["ok"]:
            print("Required module IMP.%s not available" % d)
            write_no_ok(module)
            return False, []
    modules = data["required_modules"]
    unfound_modules = []
    for d in data["optional_modules"]:
        if tools.get_module_info(d, datapath)["ok"]:
            modules.append(d)
        else:
            unfound_modules.append(d)
    all_modules = tools.get_dependent_modules(modules, datapath)
    moddir = os.path.join('IMP', '' if module == 'kernel' else module)
    swig_includes = [os.path.split(x)[1] for x
                     in tools.get_glob([os.path.join(source, "modules", module,
                                                     "pyext", "include", "*.i")])]\
        + [os.path.join(moddir, os.path.split(x)[1]) for x
           in tools.get_glob([os.path.join("include", moddir, "*_macros.h")])]
    swig_wrapper_includes = [os.path.join(moddir, "internal", os.path.split(x)[1]) for x
                             in tools.get_glob([os.path.join(source, "modules", module, "include", "internal", "swig*.h")])]
    tools.mkdir(os.path.join("src", module))
    tools.mkdir(os.path.join("src", module + "_swig"))
    write_ok(module, all_modules,
             unfound_modules, tools.get_dependent_dependencies(
                 all_modules, dependencies, datapath),
             unfound_dependencies, swig_includes, swig_wrapper_includes)
    return True, all_modules
示例#6
0
def setup_module(module, source, datapath):
    print "Configuring module", module, "...",
    data = tools.get_module_description(source, module, datapath)
    for d in data["required_dependencies"]:
        if not tools.get_dependency_info(d, datapath)["ok"]:
            print d, "not found"
            write_no_ok(module)
            return False, []
    dependencies = data["required_dependencies"]
    unfound_dependencies = []
    for d in data["optional_dependencies"]:
        if tools.get_dependency_info(d, datapath)["ok"]:
            dependencies.append(d)
        else:
            unfound_dependencies.append(d)
    for d in data["required_modules"]:
        if not tools.get_module_info(d, datapath)["ok"]:
            print "IMP." + d, "not found"
            write_no_ok(module)
            return False, []
    modules = data["required_modules"]
    unfound_modules = []
    for d in data["optional_modules"]:
        if tools.get_module_info(d, datapath)["ok"]:
            modules.append(d)
        else:
            unfound_modules.append(d)
    all_modules = tools.get_dependent_modules(modules, datapath)
    swig_includes = [os.path.split(x)[1] for x
                     in tools.get_glob([os.path.join(source, "modules", module,
                                                     "pyext", "include", "*.i")])]\
        + ["IMP/" + module + "/" + os.path.split(x)[1] for x
           in tools.get_glob([os.path.join("include", "IMP", module, "*_macros.h")])]
    swig_wrapper_includes = ["IMP/" + module + "/internal/" + os.path.split(x)[1] for x
                             in tools.get_glob([os.path.join(source, "modules", module, "include", "internal", "swig*.h")])]
    tools.mkdir(os.path.join("src", module))
    tools.mkdir(os.path.join("src", module + "_swig"))
    write_ok(module, all_modules,
             unfound_modules, tools.get_dependent_dependencies(
                 all_modules, dependencies, datapath),
             unfound_dependencies, swig_includes, swig_wrapper_includes)
    return True, all_modules
示例#7
0
def setup_module(module, source, datapath):
    print "Configuring module", module, "...",
    data= tools.get_module_description(source, module, datapath)
    for d in data["required_dependencies"]:
        if not tools.get_dependency_info(d, datapath)["ok"]:
            print d, "not found"
            write_no_ok(module)
            return False
    dependencies = data["required_dependencies"]
    unfound_dependencies = []
    for d in data["optional_dependencies"]:
        if tools.get_dependency_info(d, datapath)["ok"]:
            dependencies.append(d)
        else:
            unfound_dependencies.append(d)
    for d in data["required_modules"]:
        if not tools.get_module_info(d, datapath)["ok"]:
            print "IMP."+d, "not found"
            write_no_ok(module)
            return False
    modules= data["required_modules"]
    unfound_modules = []
    for d in data["optional_modules"]:
        if tools.get_module_info(d, datapath)["ok"]:
            modules.append(d)
        else:
            unfound_modules.append(d)
    all_modules=tools.get_dependent_modules(modules, datapath)
    swig_includes=[os.path.split(x)[1] for x
                   in tools.get_glob([os.path.join(source, "modules", module,
                                                   "pyext", "include", "*.i")])]\
                 + ["IMP/"+module+"/"+os.path.split(x)[1] for x
                            in tools.get_glob([os.path.join("include", "IMP", module, "*_macros.h")])]
    swig_wrapper_includes= ["IMP/"+module+"/internal/"+os.path.split(x)[1] for x
                   in tools.get_glob([os.path.join(source, "modules", module, "include", "internal", "swig*.h")])]
    tools.mkdir(os.path.join("src", module))
    tools.mkdir(os.path.join("src", module+"_swig"))
    write_ok(module, all_modules,
             unfound_modules, tools.get_dependent_dependencies(all_modules, dependencies,datapath),
             unfound_dependencies, swig_includes, swig_wrapper_includes)
    return True
示例#8
0
def setup_module(module, path, ordered):
    checks = []
    deps = []
    contents = []
    defines = []
    for cc in tools.get_glob([os.path.join(path, "compiler", "*.cpp")]):
        ret = make_check(cc, module, path)
        checks.append(ret[0])
        defines.append(ret[1])
    for cc in tools.get_glob([os.path.join(path, "dependency", "*.description")]):
        ret = make_dependency_check(cc, module, path)
        if ret:
            deps.append(ret)

    g = tools.CMakeFileGenerator()
    if len(checks) > 0:
        g.write("modules/%s/compiler/CMakeLists.txt" % module,
                "\n".join(["include(${CMAKE_SOURCE_DIR}/%s)\n" %
                               tools.to_cmake_path(x) for x in checks]))
        contents.append(
            "add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/compiler)" %
            module)
    if len(deps) > 0:
        g.write("modules/%s/dependency/CMakeLists.txt" % module,
                "\n".join(["include(${CMAKE_SOURCE_DIR}/%s)" %
                               tools.to_cmake_path(x) for x in deps]))
        contents.append(
            "add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/dependency)" %
            module)
    local = os.path.join(path, "Setup.cmake")
    if os.path.exists(local):
        contents.append("include(${CMAKE_SOURCE_DIR}/%s)"
                        % tools.to_cmake_path(local))

    values = {"name": module}
    if module == 'kernel':
        values['subdir'] = 'IMP'
        values['pymod'] = 'IMP'
        values['allh_header'] = 'IMP.h'
    else:
        values['subdir'] = 'IMP/' + module
        values['pymod'] = 'IMP.' + module
        values['allh_header'] = 'IMP/%s.h' % module
    values["NAME"] = module.upper()
    values["CPPNAME"] = module.upper().replace('_', '')
    data = tools.get_module_description(".", module, "")
    all_modules = tools.get_all_modules(".", [module], "", ordered)
    modules = ["${IMP_%s_LIBRARY}" % s for s in all_modules]
    dependencies = ["${%s_LIBRARIES}" % s.upper()
                    for s in tools.get_all_dependencies(".", [module], "", ordered)]
    values["modules"] = ";".join(modules)
    values["tags"] = "\n".join(["${IMP_%s_DOC}" % m for m in all_modules])
    values["other_pythons"] = "\n".join(
        ["${IMP_%s_PYTHON}" %
         m for m in all_modules])
    values["dependencies"] = ";".join(dependencies)
    values["headers"] = get_sources(module, path, "include", "*.h")
    values["includepath"] = get_dep_merged([module], "include_path", ordered)
    values["libpath"] = get_dep_merged([module], "link_path", ordered)
    values["swigpath"] = get_dep_merged([module], "swig_path", ordered)
    values["defines"] = ":".join(defines)
    cppbins = tools.get_glob([os.path.join(path, "bin", "*.cpp")])
    cppbins = [os.path.splitext(e)[0] for e in cppbins]
    pybins = get_app_sources(os.path.join(path, "bin"), ["*"],
                             tools.filter_pyapps)
    values["pybins"] = "\n".join(pybins)
    values["bin_names"] = "\n".join([os.path.basename(x) \
                                     for x in pybins + cppbins])
    main = os.path.join(path, "src", "CMakeLists.txt")
    tests = os.path.join(path, "test", "CMakeLists.txt")
    swig = os.path.join(path, "pyext", "CMakeLists.txt")
    util = os.path.join(path, "utility", "CMakeLists.txt")
    bin = os.path.join(path, "bin", "CMakeLists.txt")
    benchmark = os.path.join(path, "benchmark", "CMakeLists.txt")
    examples = os.path.join(path, "examples", "CMakeLists.txt")
    lib_template.write(main, values)
    test_template.write(tests, values)
    swig_template.write(swig, values)
    util_template.write(util, values)
    bin_template.write(bin, values)
    benchmark_template.write(benchmark, values)
    examples_template.write(examples, values)
    values["tests"] = "\n".join(contents)
    values["subdirs"] = """add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/src)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/test)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/examples)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/benchmark)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/bin)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/utility)""" % ((module,) * 6)

    out = os.path.join(path, "CMakeLists.txt")
    module_template.write(out, values)

    # at end so directories exist
    cmd = subprocess.Popen(
        ["python",
         os.path.join(
             "..",
             "..",
             "tools",
             "dev_tools",
             "setup_cmake.py")],
        cwd=path, universal_newlines=True)

    return out
示例#9
0
def setup_module(module, path, ordered):
    checks = []
    deps = []
    contents = []
    defines = []
    for cc in tools.get_glob([os.path.join(path, "compiler", "*.cpp")]):
        ret = make_check(cc, module, path)
        checks.append(ret[0])
        defines.append(ret[1])
    for cc in tools.get_glob(
        [os.path.join(path, "dependency", "*.description")]):
        ret = make_dependency_check(cc, module, path)
        if ret:
            deps.append(ret)

    if len(checks) > 0:
        tools.rewrite(
            "modules/%s/compiler/CMakeLists.txt" % module, "\n".join([
                "include(${CMAKE_SOURCE_DIR}/%s)\n" % tools.to_cmake_path(x)
                for x in checks
            ]))
        contents.append(
            "add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/compiler)" %
            module)
    if len(deps) > 0:
        tools.rewrite(
            "modules/%s/dependency/CMakeLists.txt" % module, "\n".join([
                "include(${CMAKE_SOURCE_DIR}/%s)" % tools.to_cmake_path(x)
                for x in deps
            ]))
        contents.append(
            "add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/dependency)" %
            module)
    local = os.path.join(path, "Setup.cmake")
    if os.path.exists(local):
        contents.append("include(${CMAKE_SOURCE_DIR}/%s)" %
                        tools.to_cmake_path(local))

    values = {"name": module}
    values["NAME"] = module.upper()
    values["CPPNAME"] = module.upper().replace('_', '')
    data = tools.get_module_description(".", module, "")
    all_modules = tools.get_all_modules(".", [module], "", ordered)
    modules = ["${IMP_%s_LIBRARY}" % s for s in all_modules]
    dependencies = [
        "${%s_LIBRARIES}" % s.upper()
        for s in tools.get_all_dependencies(".", [module], "", ordered)
    ]
    values["modules"] = ";".join(modules)
    values["tags"] = "\n".join(["${IMP_%s_DOC}" % m for m in all_modules])
    values["other_pythons"] = "\n".join(
        ["${IMP_%s_PYTHON}" % m for m in all_modules])
    values["dependencies"] = ";".join(dependencies)
    values["headers"] = get_sources(module, path, "include", "*.h")
    values["includepath"] = get_dep_merged([module], "include_path", ordered)
    values["libpath"] = get_dep_merged([module], "link_path", ordered)
    values["swigpath"] = get_dep_merged([module], "swig_path", ordered)
    values["defines"] = ":".join(defines)
    cppbins = tools.get_glob([os.path.join(path, "bin", "*.cpp")])
    cppbins = [os.path.splitext(e)[0] for e in cppbins]
    pybins = get_app_sources(os.path.join(path, "bin"), ["*"],
                             tools.filter_pyapps)
    values["pybins"] = "\n".join(pybins)
    values["bin_names"] = "\n".join([os.path.basename(x) \
                                     for x in pybins + cppbins])
    main = os.path.join(path, "src", "CMakeLists.txt")
    tests = os.path.join(path, "test", "CMakeLists.txt")
    swig = os.path.join(path, "pyext", "CMakeLists.txt")
    util = os.path.join(path, "utility", "CMakeLists.txt")
    bin = os.path.join(path, "bin", "CMakeLists.txt")
    benchmark = os.path.join(path, "benchmark", "CMakeLists.txt")
    examples = os.path.join(path, "examples", "CMakeLists.txt")
    tools.rewrite(main, lib_template % values)
    tools.rewrite(tests, test_template % values)
    tools.rewrite(swig, swig_template % values)
    tools.rewrite(util, util_template % values)
    tools.rewrite(bin, bin_template % values)
    tools.rewrite(benchmark, benchmark_template % values)
    tools.rewrite(examples, examples_template % values)
    values["tests"] = "\n".join(contents)
    values["subdirs"] = """add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/src)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/test)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/examples)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/benchmark)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/bin)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/utility)""" % ((module, ) * 6)

    out = os.path.join(path, "CMakeLists.txt")
    tools.rewrite(out, module_template % values)

    # at end so directories exist
    cmd = subprocess.Popen([
        "python",
        os.path.join("..", "..", "tools", "dev_tools", "setup_cmake.py")
    ],
                           cwd=path,
                           universal_newlines=True)

    return out
示例#10
0
def setup_module(module, path, ordered):
    checks = []
    deps = []
    contents = []
    defines = []
    for cc in tools.get_glob([os.path.join(path, "compiler", "*.cpp")]):
        ret = make_check(cc, module, path)
        checks.append(ret[0])
        defines.append(ret[1])
    for cc in tools.get_glob([os.path.join(path, "dependency", "*.description")]):
        ret = make_dependency_check(cc, module, path)
        if ret:
            deps.append(ret)

    if len(checks) > 0:
        tools.rewrite(
            "modules/%s/compiler/CMakeLists.txt" % module,
            "\n".join(["include(${CMAKE_SOURCE_DIR}/%s)\n" % tools.to_cmake_path(x) for x in checks]),
        )
        contents.append("add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/compiler)" % module)
    if len(deps) > 0:
        tools.rewrite(
            "modules/%s/dependency/CMakeLists.txt" % module,
            "\n".join(["include(${CMAKE_SOURCE_DIR}/%s)" % tools.to_cmake_path(x) for x in deps]),
        )
        contents.append("add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/dependency)" % module)
    local = os.path.join(path, "Setup.cmake")
    if os.path.exists(local):
        contents.append("include(${CMAKE_SOURCE_DIR}/%s)" % tools.to_cmake_path(local))

    values = {"name": module}
    values["NAME"] = module.upper()
    values["CPPNAME"] = module.upper().replace("_", "")
    data = tools.get_module_description(".", module, "")
    all_modules = tools.get_all_modules(".", [module], "", ordered)
    modules = ["${IMP_%s_LIBRARY}" % s for s in all_modules]
    dependencies = ["${%s_LIBRARIES}" % s.upper() for s in tools.get_all_dependencies(".", [module], "", ordered)]
    values["modules"] = ";".join(modules)
    values["tags"] = "\n".join(["${IMP_%s_DOC}" % m for m in all_modules])
    values["other_pythons"] = "\n".join(["${IMP_%s_PYTHON}" % m for m in all_modules])
    values["dependencies"] = ";".join(dependencies)
    values["sources"] = get_sources(module, path, "src", "*.cpp")
    values["headers"] = get_sources(module, path, "include", "*.h")
    values["cppbins"] = get_sources(module, path, "bin", "*.cpp")
    values["cppbenchmarks"] = get_sources(module, path, "benchmark", "*.cpp")
    values["pybenchmarks"] = get_sources(module, path, "benchmark", "*.py")
    values["pytests"] = get_sources(module, path, "test", "test_*.py")
    values["expytests"] = get_sources(module, path, "test", "expensive_test_*.py")
    values["mdpytests"] = get_sources(module, path, "test", "medium_test_*.py")
    values["cpptests"] = get_sources(module, path, "test", "test_*.cpp")
    values["mdcpptests"] = get_sources(module, path, "test", "medium_test_*.cpp")
    values["excpptests"] = get_sources(module, path, "test", "expensive_test_*.cpp")
    values["pyexamples"] = get_sources(module, path, "examples", "[a-zA-Z]*.py")
    values["cppexamples"] = get_sources(module, path, "examples", "*.cpp")
    values["excpptests"] = get_sources(module, path, "test", "expensive_test_*.cpp")
    values["includepath"] = get_dep_merged([module], "include_path", ordered)
    values["libpath"] = get_dep_merged([module], "link_path", ordered)
    values["swigpath"] = get_dep_merged([module], "swig_path", ordered)
    values["defines"] = ":".join(defines)

    main = os.path.join(path, "src", "CMakeLists.txt")
    tests = os.path.join(path, "test", "CMakeLists.txt")
    swig = os.path.join(path, "pyext", "CMakeLists.txt")
    bin = os.path.join(path, "bin", "CMakeLists.txt")
    benchmark = os.path.join(path, "benchmark", "CMakeLists.txt")
    examples = os.path.join(path, "examples", "CMakeLists.txt")
    tools.rewrite(main, lib_template % values)
    tools.rewrite(tests, test_template % values)
    tools.rewrite(swig, swig_template % values)
    tools.rewrite(bin, bin_template % values)
    tools.rewrite(benchmark, benchmark_template % values)
    tools.rewrite(examples, examples_template % values)
    values["tests"] = "\n".join(contents)
    values[
        "subdirs"
    ] = """add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/src)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/test)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/examples)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/benchmark)
add_subdirectory(${CMAKE_SOURCE_DIR}/modules/%s/bin)""" % (
        (module,) * 5
    )

    out = os.path.join(path, "CMakeLists.txt")
    tools.rewrite(out, module_template % values)
    return out