本文整理汇总了Python中tools.get_glob函数的典型用法代码示例。如果您正苦于以下问题:Python get_glob函数的具体用法?Python get_glob怎么用?Python get_glob使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_glob函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: generate_all_cpp
def generate_all_cpp(source):
target=os.path.join("src")
tools.mkdir(target)
for module, g in tools.get_modules(source):
sources= tools.get_glob([os.path.join(g, "src", "*.cpp")])\
+tools.get_glob([os.path.join(g, "src", "internal", "*.cpp")])
targetf=os.path.join(target, module+"_all.cpp")
sources.sort()
tools.rewrite(targetf, "\n".join(["#include <%s>"%os.path.abspath(s) for s in sources]) + '\n')
开发者ID:apolitis,项目名称:imp,代码行数:9,代码来源:setup_all.py
示例2: main
def main():
(options, args) = parser.parse_args()
if not os.path.exists(os.path.join(options.source, "modules", options.module)):
print("Skipping alias as original module not found")
return
print("Setting up alias for module", options.module, "as", options.alias)
tools.mkdir("include/IMP/%s" % options.alias)
tools.mkdir("include/IMP/%s/internal" % options.alias)
var = {"module": options.module}
if options.deprecate != "":
var["deprecate"] = "IMP%s_DEPRECATED_HEADER(%s, \"%s\")" % (options.module.upper(),
options.deprecate,
"Use the one in IMP/%s instead." % options.module)
else:
var["deprecate"] = ""
if options.alias == "":
var["namespacebegin"] = "namespace IMP {"
var["namespaceend"] = "}"
var["slashalias"] = ""
else:
var["namespacebegin"] = "namespace IMP { namespace %s {" % options.alias
var["namespaceend"] = "} }"
var["slashalias"] = "/" + options.alias
for h in tools.get_glob([os.path.join("include", "IMP", options.module, "*.h")]):
if h.endswith("_config.h"):
continue
filename = os.path.split(h)[1]
var["file"] = filename
header = header_template % var
tools.rewrite(
"include/IMP%s/%s" %
(var["slashalias"], filename), header)
# Remove aliased header if the source header is gone
for h in glob.glob("include/IMP%s/*.h" % var["slashalias"]):
filename = os.path.split(h)[1]
orig_filename = os.path.join("include", "IMP", options.module, filename)
if not os.path.exists(orig_filename) \
and not os.path.exists(h[:-2]): # Exclude all-module headers
os.unlink(h)
for h in tools.get_glob([os.path.join("include", "IMP", options.module, "internal", "*.h")]):
filename = os.path.split(h)[1]
var["file"] = filename
header = internal_header_template % var
tools.rewrite(
"include/IMP/%s/internal/%s" %
(options.alias, filename), header)
allh = allh_template % var
tools.rewrite("include/IMP%s.h" % var["slashalias"], allh)
开发者ID:newtonjoo,项目名称:imp,代码行数:48,代码来源:setup_module_alias.py
示例3: get_sources
def get_sources(module, path, subdir, pattern):
matching = tools.get_glob([
os.path.join(path, subdir, pattern),
os.path.join(path, subdir, "*", pattern)
])
return "\n".join(
["${CMAKE_SOURCE_DIR}/%s" % tools.to_cmake_path(x) for x in matching])
开发者ID:salilab,项目名称:imp,代码行数:7,代码来源:setup_cmake.py
示例4: generate_all_h
def generate_all_h():
globbed = tools.get_glob([os.path.join("include", "IMP", "*")])
for m in [d for d in globbed if (d.find("internal") == -1 and not d.endswith(".h"))]:
headers= tools.get_glob([os.path.join(m, "*.h")])
module=os.path.split(m)[1]
if module=="compatibility":
# ick, maybe switch order and always do it here
continue
includepath="IMP/"+module+"/"
headers.sort()
headers= [x for x in headers if not x.endswith("_config.h")]
contents=[]
for h in headers:
name= os.path.split(h)[1]
contents.append("#include <"+includepath+name+">")
tools.rewrite(m+".h", "\n".join(contents) + '\n')
开发者ID:drussel,项目名称:imp,代码行数:16,代码来源:setup_all.py
示例5: generate_applications_list
def generate_applications_list(source):
apps= tools.get_glob([os.path.join(source, "applications", "*")])
names=[]
for a in apps:
if os.path.isdir(a):
name= os.path.split(a)[1]
names.append(name)
path=os.path.join("data", "build_info", "applications")
tools.rewrite(path, "\n".join(names))
开发者ID:drussel,项目名称:imp,代码行数:9,代码来源:setup.py
示例6: setup_module
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
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:43,代码来源:setup_module.py
示例7: main
def main():
# glob.glob(os.path.join("build", "doxygen", "xml", "*.xml")):
if len(sys.argv) > 1:
files= sys.argv[1:]
else:
files=tools.get_glob([os.path.join("doxygen", "xml", "*.xml")])
for f in files:
#for f in ["doxygen/xml/classIMP_1_1atom_1_1LennardJones.xml"]:
#["doxygen/xml/namespacetiny.xml",
# "doxygen/xml/classIMP_1_1display_1_1Color.xml"]:
module = os.path.split(os.path.split(os.path.split(f)[0])[0])[1]
try:
et= ET.parse(f)
except ET.ParseError:
print >> sys.stderr, "ERROR parsing", f
fname=os.path.basename(f)
if fname.startswith("namespaceIMP"):
if verbose:
print "namespace", fname
traverse_namespace(get_namespace_name(et.getroot()), et.getroot(), module)
#elif fname.startswith("namespace"):
#if verbose:
# print "example 1", fname
#traverse_example(get_example_name(et.getroot()), et.getroot())
elif fname.endswith("example.xml"):
if verbose:
print "example 2", fname
traverse_example_2(get_example_2_name(et.getroot()), et.getroot())
# skip structs for nwo
elif fname.startswith("classIMP"):
if verbose:
print "class", fname
traverse_class(get_file_class_name(et.getroot()), et.getroot(), module)
else:
if verbose:
print "skipping", fname
indexes = [("Factory Index", "factory_index"),
("Argument Index", "argument_index"),
("Class Examples", "class_example_index"),
("Function Examples", "function_example_index")]
create_index(indexes[0][0], indexes[0][1], indexes[1:],
"Functions that create objects of a given type:",
creates, "doxygen/generated/factory_index.md", "Class", "Factories")
create_index(indexes[1][0], indexes[1][1], indexes,
"Functions that take objects of a given type as arguments:",
takes, "doxygen/generated/argument_index.md", "Class", "Users")
create_index(indexes[2][0], indexes[2][1], indexes,
"Examples that use a given class:",
examples_classes, "doxygen/generated/class_example_index.md",
"Class", "Examples")
create_index(indexes[3][0], indexes[3][1], indexes[:-1],
"Examples that use a given function:",
examples_functions,
"doxygen/generated/function_example_index.md",
"Function", "Examples")
开发者ID:apolitis,项目名称:imp,代码行数:55,代码来源:make_cross_refs.py
示例8: setup_module
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
开发者ID:drussel,项目名称:imp,代码行数:41,代码来源:setup_module.py
示例9: link_python
def link_python(source):
target=os.path.join("lib")
tools.mkdir(target, clean=False)
for module, g in tools.get_modules(source):
path= os.path.join(target, "IMP", module)
tools.mkdir(path, clean=False)
for old in tools.get_glob([os.path.join(path, "*.py")]):
# don't unlink the generated file
if os.path.split(old)[1] != "__init__.py" and os.path.split(old)[1] != "_version_check.py":
os.unlink(old)
#print "linking", path
tools.link_dir(os.path.join(g, "pyext", "src"), path, clean=False)
开发者ID:drussel,项目名称:imp,代码行数:12,代码来源:setup.py
示例10: report_python_module
def report_python_module(cov, modname, srcdir, outdir):
if modname == 'kernel':
mods = glob.glob('lib/IMP/*.py')
else:
mods = glob.glob('lib/IMP/%s/*.py' % modname) \
+ glob.glob('lib/IMP/%s/*/*.py' % modname)
mods = [x for x in mods if not x.endswith('_version_check.py')]
bins = tools.get_glob([os.path.join(srcdir, 'modules', modname, 'bin',
'*')])
bins = [os.path.basename(x) for x in bins if tools.filter_pyapps(x)]
bins = [os.path.join('bin', x) for x in bins if x != 'dependencies.py']
report_python_component(cov, mods + bins, modname, 'module', '', outdir)
开发者ID:AljGaber,项目名称:imp,代码行数:12,代码来源:report.py
示例11: link_benchmark
def link_benchmark(options):
path = os.path.join("benchmark", options.name)
tools.mkdir(path, clean=False)
for old in tools.get_glob([os.path.join(path, "*.py")]):
os.unlink(old)
tools.link_dir(
os.path.join(options.source,
"modules",
options.name,
"benchmark"),
path,
clean=False,
match=["*.py"])
开发者ID:newtonjoo,项目名称:imp,代码行数:13,代码来源:setup_module.py
示例12: main
def main():
(options, args) = parser.parse_args()
main = []
ordered = tools.compute_sorted_order(".", "")
for m in ordered:
"""if m not in ["base", "kernel", "algebra", "cgal", "test", "statistics", "display", "core", "kmeans", "score_functor",
"container", "atom", "rmf", "domino", "example"]:
continue"""
p = os.path.join("modules", m)
main.append(setup_module(m, p, ordered))
for a in [x for x in tools.get_glob([os.path.join("applications", "*")]) if os.path.isdir(x)]:
main.append(setup_application(options, os.path.split(a)[1], ordered))
开发者ID:jennystone,项目名称:imp,代码行数:13,代码来源:setup_cmake.py
示例13: make_one
def make_one(path, params, test=True):
(
function_name,
type_name,
class_name,
variable_type,
argument_type,
return_type,
storage_type,
plural_variable_type,
plural_argument_type,
plural_storage_type,
index_type,
plural_index_type,
pass_index_type,
) = params
multi = class_name
plural_multi = multi + "s"
cname = function_name
inputs = tools.get_glob(
[
os.path.join(path, "*", "*.h"),
os.path.join(path, "*", "internal", "*.h"),
os.path.join(path, "*", "*.cpp"),
os.path.join(path, "*", "internal", "*.cpp"),
]
)
files = []
for ip in inputs:
p = ip[len(path) + 1 :]
module = os.path.split(p)[0]
rest = os.path.split(p)[1]
if module.find("internal") != -1:
module = os.path.split(module)[0]
rest = os.path.join("internal", rest)
name = filter(params, rest, rest)
if p.endswith(".h"):
out_path = os.path.join("include", "IMP", "" if module == "kernel" else module, name)
else:
out_path = os.path.join("src", module, name)
files.append((out_path, ip))
if test:
files.append(("test/container/test_" + cname + "_restraint.py", path + "/test.py"))
files.append(("test/container/test_" + cname + "_state.py", path + "/test_state.py"))
for p in files:
g = ContainerFileGenerator(p[1])
g.write(p[0], params)
all_outputs.append(p[0])
all_inputs.append(p[1])
开发者ID:AljGaber,项目名称:imp,代码行数:51,代码来源:make_containers.py
示例14: make_one
def make_one(source, params, test=True):
(function_name, type_name, class_name, variable_type, argument_type, return_type,
storage_type,
plural_variable_type, plural_argument_type, plural_storage_type,
index_type, plural_index_type, pass_index_type)= params
path= os.path.join(source, "tools", "build", "container_templates")
multi= class_name
plural_multi= multi+"s"
cname=function_name
inputs= tools.get_glob([os.path.join(path,"*", "*.h"), \
os.path.join(path,"*", "internal", "*.h"), \
os.path.join(path,"*", "*.cpp"),
os.path.join(path,"*", "internal", "*.cpp")])
files=[]
for ip in inputs:
p= ip[len(path)+1:]
module= os.path.split(p)[0]
rest= os.path.split(p)[1]
if module.find("internal") != -1:
module=os.path.split(module)[0]
rest=os.path.join("internal", rest)
name=filter(params, rest, rest)
if p.endswith(".h"):
out_path= os.path.join("include", "IMP", module, name)
else:
out_path= os.path.join("src", module, name)
files.append((out_path, ip))
if test:
files.append(("test/container/test_"+cname + "_restraint.py",
path+"/test.py"))
files.append(("test/container/test_"+cname + "_state.py",
path+"/test_state.py"))
for p in files:
contents = filter(params, open(p[1], 'r').read(), p[1])
tools.rewrite(p[0], contents)
开发者ID:apolitis,项目名称:imp,代码行数:38,代码来源:setup_containers.py
示例15: setup_module
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",
#.........这里部分代码省略.........
开发者ID:AljGaber,项目名称:imp,代码行数:101,代码来源:setup_cmake.py
示例16: get_app_sources
def get_app_sources(path, patterns, filt=lambda x:True):
matching = tools.get_glob([os.path.join(path, x) for x in patterns])
return ["${CMAKE_SOURCE_DIR}/%s" % tools.to_cmake_path(x) \
for x in matching if filt(x)]
开发者ID:AljGaber,项目名称:imp,代码行数:4,代码来源:setup_cmake.py
示例17: clean_pyc
def clean_pyc(dir):
for root, dirnames, filenames in os.walk('.'):
for d in dirnames:
for f in tools.get_glob([os.path.join(d, "*.pyc")]):
os.unlink(f)
开发者ID:newtonjoo,项目名称:imp,代码行数:5,代码来源:setup.py
示例18: generate_tests
def generate_tests(source, scons):
template = """import IMP
import IMP.test
import %(module)s
spelling_exceptions=%(spelling_exceptions)s
class StandardsTest(IMP.test.TestCase):
def test_value_objects(self):
"Test that module classes are either values or objects"
exceptions= %(value_object_exceptions)s
return self.assertValueObjects(%(module)s,exceptions)
def test_classes(self):
"Test that module class names follow the standards"
exceptions=%(value_object_exceptions)s
return self.assertClassNames(%(module)s, exceptions,
spelling_exceptions)
def test_functions(self):
"Test that module function names follow the standards"
exceptions= %(function_name_exceptions)s
return self.assertFunctionNames(%(module)s, exceptions,
spelling_exceptions)
def test_show(self):
"Test all objects have show"
exceptions=%(show_exceptions)s
return self.assertShow(%(module)s, exceptions)
if __name__ == '__main__':
IMP.test.main()
"""
target = os.path.join("test")
tools.mkdir(target)
for module, g in tools.get_modules(source):
targetdir = os.path.join(target, module)
tools.mkdir(targetdir)
exceptions = os.path.join(g, "test", "standards_exceptions")
d = {'plural_exceptions': [],
'show_exceptions': [],
'function_name_exceptions': [],
'value_object_exceptions': [],
'class_name_exceptions': [],
'spelling_exceptions': []}
try:
exec(open(exceptions, "r").read(), d)
except IOError:
pass
impmodule = "IMP." + module
test = template % ({'module': impmodule,
'plural_exceptions': str(d['plural_exceptions']),
'show_exceptions': str(d['show_exceptions']),
'function_name_exceptions':
str(d['function_name_exceptions']),
'value_object_exceptions':
str(d['value_object_exceptions']),
'class_name_exceptions':
str(d['class_name_exceptions']),
'spelling_exceptions':
str(d['spelling_exceptions'])})
open(
os.path.join("test",
module,
"medium_test_standards.py"),
"w").write(test)
cpptests = tools.get_glob([os.path.join(g, "test", "test_*.cpp")])
ecpptests = tools.get_glob(
[os.path.join(g, "test", "expensive_test_*.cpp")])
cppexamples = tools.get_glob([os.path.join(g, "examples", "*.cpp")])
if len(cpptests) > 0 and scons:
_make_test_driver(
os.path.join(
targetdir,
"test_cpp_tests.py"),
cpptests)
if len(ecpptests) > 0 and scons:
_make_test_driver(
os.path.join(targetdir,
"expensive_test_cpp_tests.py"),
cpptests)
if len(cppexamples) > 0 and scons:
_make_test_driver(
os.path.join(targetdir,
"cpp_examples_test.py"),
cppexamples)
开发者ID:newtonjoo,项目名称:imp,代码行数:85,代码来源:setup.py
示例19: get_app_sources
def get_app_sources(path, patterns):
matching = tools.get_glob([os.path.join(path, x) for x in patterns])
return "\n".join(
["${CMAKE_SOURCE_DIR}/%s" % tools.to_cmake_path(x) for x in matching if not x.endswith("dependencies.py")]
)
开发者ID:jennystone,项目名称:imp,代码行数:5,代码来源:setup_cmake.py
示例20: setup_module
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
开发者ID:jennystone,项目名称:imp,代码行数:86,代码来源:setup_cmake.py
注:本文中的tools.get_glob函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论