def make_doxygen(name, source, modules): file = os.path.join("doxygen", name, "Doxyfile") template_file = os.path.join(source, "tools", "build", "doxygen_templates", "Doxyfile.in") template = open(template_file, "r").read() template = template.replace("@IMP_SOURCE_PATH@", source) template = template.replace("@VERSION@", "0") template = template.replace("@NAME@", name) template = template.replace("@PROJECT_BRIEF@", '"The Integrative Modeling Platform"') template = template.replace("@RECURSIVE@", "YES") template = template.replace("@EXCLUDE_PATTERNS@", "*/tutorial/*") template = template.replace("@IS_HTML@", "YES") template = template.replace("@PROJECT_NAME@", "IMP."+name) template = template.replace("@HTML_OUTPUT@", "../../doc/html/" + name) template = template.replace("@GENERATE_TAGFILE@", "tags") template = template.replace("@IS_XML@", "YES") template = template.replace("@XML_OUTPUT@", "xml") template = template.replace("@LAYOUT_FILE@", "%s/doc/doxygen/module_layout.xml" % source) template = template.replace("@MAINPAGE@", "README.md") template = template.replace("@EXAMPLE_PATH@", "") template = template.replace("@EXCLUDE@", "") template = template.replace("@INCLUDE_PATH@", "") template = template.replace("@FILE_PATTERNS@", "*.dox *.md") template = template.replace("@WARNINGS@", "warnings.txt") # include lib and doxygen in imput inputs = [] inputs.append(source + "/applications/" + name + "/doc") template = template.replace("@INPUT_PATH@", " \\\n ".join(inputs)) tags = [] for m in modules: tags.append(os.path.join("../", m, "tags") + "=" + "../"+m) template = template.replace("@TAGS@", " \\\n ".join(tags)) tools.rewrite(file, template)
def setup_one(module, ordered, build_system, swig): info = tools.get_module_info(module, "/") if not info["ok"]: tools.rewrite("src/%s_swig.deps" % module, "", False) return includepath = get_dep_merged([module], "includepath", ordered) swigpath = get_dep_merged([module], "swigpath", ordered) depf = open("src/%s_swig.deps.in" % module, "w") cmd = [swig, "-MM", "-Iinclude", "-Iswig", "-ignoremissing"]\ + ["-I" + x for x in swigpath] + ["-I" + x for x in includepath]\ + ["swig/IMP_%s.i" % module] lines = tools.run_subprocess(cmd).split("\n") names = [] for x in lines: if x.endswith("\\"): x = x[:-1] x = x.strip() if not x.endswith(".h") and not x.endswith(".i") and not x.endswith(".i-in"): continue names.append(x) final_names = [_fix(x, build_system) for x in names] final_list = "\n".join(final_names) tools.rewrite("src/%s_swig.deps" % module, final_list)
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)
def write_ok( module, modules, unfound_modules, dependencies, unfound_dependencies, swig_includes, swig_wrapper_includes): print("yes") config = ["ok=True"] if len(modules) > 0: config.append("modules = \"" + ":".join(modules) + "\"") if len(unfound_modules) > 0: config.append( "unfound_modules = \"" + ":".join( unfound_modules) + "\"") if len(dependencies) > 0: config.append("dependencies = \"" + ":".join(dependencies) + "\"") if len(unfound_dependencies) > 0: config.append( "unfound_dependencies = \"" + ":".join( unfound_dependencies) + "\"") if len(swig_includes) > 0: config.append("swig_includes = \"" + ":".join(swig_includes) + "\"") if len(swig_wrapper_includes) > 0: config.append( "swig_wrapper_includes = \"" + ":".join( swig_wrapper_includes) + "\"") tools.rewrite( os.path.join("data", "build_info", "IMP." + module), "\n".join(config))
def make_version(source, bindir): forced = os.path.join(source, "VERSION") if os.path.exists(forced): version = open(forced, "r").read() elif os.path.exists(os.path.join(source, '.git')): process = subprocess.Popen( ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=source, stdout=subprocess.PIPE, universal_newlines=True) branch, err = process.communicate() branch = branch.strip() if branch == "develop" or branch.startswith("feature"): version = branch + "-" + get_short_rev(source) elif branch == "master" or branch.startswith("release"): process = subprocess.Popen(['git', 'describe'], cwd=source, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) version, err = process.communicate() if err: version = branch + "-" + get_short_rev(source) else: version = get_short_rev(source) else: version = 'unknown' tools.rewrite(os.path.join(bindir, "VERSION"), version)
def setup_one(module, ordered, build_system, swig): info = tools.get_module_info(module, "/") if not info["ok"]: tools.rewrite("src/%s_swig.deps"%module, "") return includepath = get_dep_merged([module], "includepath", ordered) swigpath = get_dep_merged([module], "swigpath", ordered) depf= open("src/%s_swig.deps.in"%module, "w") cmd= [swig, "-MM", "-Iinclude", "-Iswig", "-ignoremissing"]\ + ["-I"+x for x in swigpath] + ["-I"+x for x in includepath]\ + ["swig/IMP_%s.i"%module] ret = subprocess.call(cmd, stdout=depf) del depf if ret != 0: raise OSError("subprocess failed with return code %d: %s" \ % (ret, str(cmd))) lines= open("src/%s_swig.deps.in"%module, "r").readlines() names= [x[:-2].strip() for x in lines[1:]] final_names=[_fix(x, build_system) for x in names] final_list= "\n".join(final_names) tools.rewrite("src/%s_swig.deps"%module, final_list)
def write_no_ok(module): print "no" apps= tools.split(open(applist, "r").read(), "\n") apps= [a for a in apps if a != module] tools.rewrite(applist, "\n".join(apps)) tools.rewrite(os.path.join("data", "build_info", "IMP."+module), "ok=False\n") sys.exit(1)
def make_overview(app, source): rmd = open(os.path.join(source, "applications", app, "README.md"), "r").read() tools.rewrite(os.path.join("doxygen", "generated", "IMP_%s.dox" % app), """/** \\page imp%s IMP.%s \\tableofcontents %s */ """ %(app, app, rmd))
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))
def make_check(path, module, module_path): name = os.path.splitext(os.path.split(path)[1])[0] cppsource = open(path, "r").read() macro = "IMP_COMPILER_%s" % name.upper() output = check_template % {"macro": macro, "cppsource": tools.quote(cppsource), "module": module, "name": name} filename = os.path.join(module_path, "CMakeModules", "Check" + name + ".cmake") tools.rewrite(filename, output) defr = "%s=${%s}" % (macro, macro) return filename, defr
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')
def write_no_ok(module): new_order = [x for x in tools.get_sorted_order() if x != module] tools.set_sorted_order(new_order) tools.rewrite( os.path.join( "data", "build_info", "IMP." + module), "ok=False\n", verbose=False)
def alias_headers(fromdir, kerneldir, basedir, incdir, kernel_headers, base_renames): kernel_headers = dict.fromkeys(kernel_headers) for g in glob.glob(os.path.join(fromdir, '*.h')): if "Include all non-deprecated headers" not in open(g).read(): fname = os.path.basename(g) contents = get_header_contents(incdir, fname) if fname in kernel_headers: tools.rewrite(os.path.join(kerneldir, fname), contents) else: to_name = base_renames.get(fname, fname) tools.rewrite(os.path.join(basedir, to_name), contents)
def main(): alias_headers(os.path.join('include', 'IMP'), os.path.join('include', 'IMP', 'kernel'), os.path.join('include', 'IMP', 'base'), 'IMP', [ 'AttributeOptimizer.h', 'base_types.h', 'Configuration.h', 'ConfigurationSet.h', 'constants.h', 'Constraint.h', 'container_base.h', 'container_macros.h', 'Decorator.h', 'decorator_macros.h', 'dependency_graph.h', 'DerivativeAccumulator.h', 'doxygen.h', 'FloatIndex.h', 'functor.h', 'generic.h', 'input_output.h', 'io.h', 'Key.h', 'macros.h', 'Model.h', 'ModelObject.h', 'model_object_helpers.h', 'Optimizer.h', 'OptimizerState.h', 'Particle.h', 'particle_index.h', 'ParticleTuple.h', 'python_only.h', 'Refiner.h', 'Restraint.h', 'RestraintSet.h', 'Sampler.h', 'scoped.h', 'ScoreAccumulator.h', 'ScoreState.h', 'ScoringFunction.h', 'UnaryFunction.h', 'Undecorator.h', 'utility.h' ], {'base_utility.h': 'utility.h' }) alias_headers(os.path.join('include', 'IMP', 'internal'), os.path.join('include', 'IMP', 'kernel', 'internal'), os.path.join('include', 'IMP', 'base', 'internal'), 'IMP/internal', [ 'AccumulatorScoreModifier.h', 'AttributeTable.h', 'attribute_tables.h', 'constants.h', 'ContainerConstraint.h', 'container_helpers.h', 'ContainerRestraint.h', 'ContainerScoreState.h', 'create_decomposition.h', 'DynamicListContainer.h', 'evaluate_utility.h', 'ExponentialNumber.h', 'functors.h', 'graph_utility.h', 'IndexingIterator.h', 'input_output_exception.h', 'key_helpers.h', 'ListLikeContainer.h', 'NestedIterator.h', 'pdb.h', 'PrefixStream.h', 'restraint_evaluation.h', 'RestraintsScoringFunction.h', 'scoring_functions.h', 'static.h', 'StaticListContainer.h', 'swig.h', 'swig_helpers.h', 'TupleConstraint.h', 'TupleRestraint.h', 'Unit.h', 'units.h', 'utility.h' ], {'base_graph_utility.h': 'graph_utility.h', 'base_static.h': 'static.h', 'swig_base.h': 'swig.h', 'swig_helpers_base.h': 'swig_helpers.h'}) tools.rewrite(os.path.join('include', 'IMP', 'base', 'base_config.h'), get_header_contents('IMP', 'kernel_config.h')) tools.link(os.path.join('include', 'IMP.h'), os.path.join('include', 'IMP', 'kernel.h')) tools.link(os.path.join('include', 'IMP.h'), os.path.join('include', 'IMP', 'base.h')) for mod in ('base', 'kernel'): subdir = os.path.join('lib', 'IMP', mod) if not os.path.exists(subdir): os.mkdir(subdir) pymod = os.path.join(subdir, '__init__.py') with open(pymod, 'w') as fh: fh.write("""import sys sys.stderr.write('IMP.%s is deprecated - use "import IMP" instead\\n') from IMP import * """ % mod)
def make_version_check(options): dir= os.path.join("lib", "IMP", options.name) tools.mkdir(dir, clean=False) outf= os.path.join(dir, "_version_check.py") template="""def check_version(myversion): def _check_one(name, expected, found): if expected != found: raise RuntimeError('Expected version '+expected+' but got '+ found \ +' when loading module '+name\ +'. Please make sure IMP is properly built and installed and that matching python and C++ libraries are used.') _check_one('%s', '%s', myversion) """ tools.rewrite(outf, template%(options.name, get_version(options)))
def make_cpp(options): dir= os.path.join("src", options.name) file=os.path.join(dir, "config.cpp") try: os.makedirs(dir) except: # exists pass data={} data["filename"]="IMP/%s/%s_config.h"%(options.name, options.name) data["cppprefix"]="IMP%s"%options.name.upper().replace("_", "") data["name"]= options.name data["version"]= get_version(options) tools.rewrite(file, cpp_template%data)
def make_version_check(options): dir= os.path.join("lib", "IMP", options.name) tools.mkdir(dir, clean=False) version = tools.get_module_version(options.name, options.source) outf= os.path.join(dir, "_version_check.py") template="""def check_version(myversion): def _check_one(name, expected, found): if expected != found: message = "Expected version " + expected + " but got " + found + " when loading module " + name + ". Please make sure IMP is properly built and installed and that matching python and C++ libraries are used." raise RuntimeError(message) version = '%s' _check_one('%s', version, myversion) """ tools.rewrite(outf, template%(version, version))
def setup_application(options, name, ordered): contents = [] path = os.path.join("applications", name) local = os.path.join(path, "Setup.cmake") if os.path.exists(local): contents.append("include(%s)" % tools.to_cmake_path(local)) values = {"name": name} values["NAME"] = name.upper() data = tools.get_application_description(".", name, "") all_modules = data["required_modules"] + tools.get_all_modules(".", data["required_modules"], "", ordered) all_dependencies = tools.get_all_dependencies(".", all_modules, "", ordered) modules = ["${IMP_%s_LIBRARY}" % s for s in all_modules] dependencies = ["${%s_LIBRARIES}" % s.upper() for s in all_dependencies] values["modules"] = "\n".join(modules) values["tags"] = "\n".join(["${IMP_%s_DOC}" % m for m in all_modules]) values["dependencies"] = "\n".join(dependencies) values["module_deps"] = "\n".join("${IMP_%s}" % m for m in all_modules) exes = tools.get_application_executables(path) exedirs = list(set(sum([x[1] for x in exes], []))) exedirs.sort() localincludes = "\n ".join(["${CMAKE_SOURCE_DIR}/" + tools.to_cmake_path(x) for x in exedirs]) bintmpl = """ add_executable("IMP.%(name)s-%(cname)s" %(cpps)s) target_link_libraries(IMP.%(name)s-%(cname)s %(modules)s %(dependencies)s) set_target_properties(IMP.%(name)s-%(cname)s PROPERTIES OUTPUT_NAME %(cname)s RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set_property(TARGET "IMP.%(name)s-%(cname)s" PROPERTY FOLDER "IMP.%(name)s") install(TARGETS IMP.%(name)s-%(cname)s DESTINATION ${CMAKE_INSTALL_BINDIR}) set(bins ${bins} IMP.%(name)s-%(cname)s) """ bins = [] for e in exes: cpps = e[0] cname = os.path.splitext(os.path.split(cpps[0])[1])[0] values["cname"] = cname values["cpps"] = "\n".join(["${CMAKE_SOURCE_DIR}/%s" % tools.to_cmake_path(c) for c in cpps]) bins.append(bintmpl % values) values["bins"] = "\n".join(bins) values["includepath"] = get_dep_merged(all_modules, "include_path", ordered) + " " + localincludes values["libpath"] = get_dep_merged(all_modules, "link_path", ordered) values["swigpath"] = get_dep_merged(all_modules, "swig_path", ordered) values["pybins"] = get_app_sources(path, ["*.py"]) values["pytests"] = get_app_sources(os.path.join(path, "test"), ["test_*.py", "expensive_test_*.py"]) contents.append(application_template % values) out = os.path.join(path, "CMakeLists.txt") tools.rewrite(out, "\n".join(contents)) return out
def generate_overview_pages(source): name = os.path.join("doxygen", "generated", "all.dox") contents = [] contents.append("/** ") contents.append("\\page allmod All IMP Modules and Applications") contents.append("<table><tr>") contents.append("<th>Modules</th><th>Applications</th></tr><tr><td>") for bs, g in tools.get_modules(source): contents.append("- \\subpage imp%s \"IMP.%s\""%(bs,bs)) contents.append("</td><td style=\"vertical-align:top;\">") for bs, g in tools.get_applications(source): contents.append("- \subpage imp%s \"IMP.%s\""%(bs,bs)) contents.append("</td></tr></table>") contents.append("*/") tools.rewrite(name, "\n".join(contents))
def make_cpp(options): dir= os.path.join("src") file=os.path.join(dir, "%s_config.cpp"%options.name) cpp_template = open(os.path.join(options.source, "tools", "build", "config_templates", "src.cpp"), "r").read() try: os.makedirs(dir) except: # exists pass data={} data["filename"]="IMP/%s/%s_config.h"%(options.name, options.name) data["cppprefix"]="IMP%s"%options.name.upper().replace("_", "") data["name"]= options.name data["version"]= tools.get_module_version(options.name, options.source) tools.rewrite(file, cpp_template%data)
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')
def make_overview(options, cmdline_tools): docdir = os.path.join(options.source, "modules", options.name) cmdline_links = find_cmdline_links(options.name, docdir, cmdline_tools) pickle.dump(cmdline_links, open(os.path.join("data", "build_info", "IMP_%s.pck" % options.name), 'wb'), -1) rmd = tools.open_utf8(os.path.join(options.source, "modules", options.name, "README.md"), "r").read() tools.rewrite( os.path.join("doxygen", "generated", "IMP_%s.dox" % options.name), """/** \\namespace %s \\tableofcontents %s */ """ % ('IMP' if options.name == 'kernel' else 'IMP::' + options.name, rmd))
def write_ok( module, modules, unfound_modules, dependencies, unfound_dependencies, swig_includes, swig_wrapper_includes): print("yes") config = ["ok=True"] for varname in ("modules", "unfound_modules", "dependencies", "unfound_dependencies", "swig_includes", "swig_wrapper_includes"): var = eval(varname) if len(var) > 0: config.append("%s = %s" % (varname, repr(":".join(var)))) tools.rewrite( os.path.join("data", "build_info", "IMP." + module), "\n".join(config))
def main(): (options, args) = parser.parse_args() clean_pyc(options.source) tools.mkdir(os.path.join("data", "build_info")) tools.mkdir(os.path.join("cmake_tests")) tools.rewrite(os.path.join("data", "build_info", "disabled"), options.disabled.replace(":", "\n")) tools.setup_sorted_order(options.source, options.datapath) link_headers(options.source) link_examples(options.source) link_swig(options.source) link_python(options.source) link_data(options.source) generate_tests(options.source, options.scons) generate_src_dirs(options.source)
def write_ok(module, modules, unfound_modules, dependencies, unfound_dependencies): print "yes" config=["ok=True"] if len(modules) > 0: config.append("modules = \"" + ":".join(modules)+"\"") if len(unfound_modules) > 0: config.append("unfound_modules = \""+ ":".join(unfound_modules)+"\"") if len(dependencies) > 0: config.append("dependencies = \"" + ":".join(dependencies)+"\"") if len(unfound_dependencies) > 0: config.append("unfound_dependencies = \"" + ":".join(unfound_dependencies)+"\"") apps= tools.split(open(applist, "r").read(), "\n") if module not in apps: apps.append(module) tools.rewrite(applist, "\n".join(apps)) tools.rewrite(os.path.join("data", "build_info", "IMP."+module), "\n".join(config)) sys.exit(0)
def make_dependency_check(descr_path, module, module_path): descr = tools.get_dependency_description(descr_path) name = os.path.splitext(os.path.split(descr_path)[1])[0] if len(descr["cmake"]) > 0: ret = descr_path[0 : -len("description")] + "cmake" return ret descr["pkgname"] = name descr["PKGNAME"] = name.upper() filename = os.path.join(module_path, "CMakeModules", "Find" + name + ".cmake") if descr["python_module"] != "": # don't bother checking python deps as they aren't needed for compilation # and it makes cross compilation easier return None else: descr["includes"] = "\n".join(["#include <%s>" % h for h in descr["headers"]]) descr["headers"] = ";".join(descr["headers"]) descr["libraries"] = ";".join(descr["libraries"]) descr["body"] = tools.quote(descr["body"]) if len(descr["cmake"]) > 0: descr["path"] = os.path.splitext(descr_path)[0] descr["on_failure"] = ( """set(%(PKGNAME)s_INTERNAL 1 CACHE INTERNAL "" FORCE) %(cmake)s """ % descr ) descr["on_setup"] = ( """if(DEFINED %(PKGNAME)s_INTERNAL) %(cmake)s endif(DEFINED %(PKGNAME)s_INTERNAL)""" % descr ) else: descr["on_failure"] = ( """message("%s not found")\nfile(WRITE "${CMAKE_BINARY_DIR}/data/build_info/%s" "ok=False")""" % (name, name) ) descr["on_setup"] = "" output = dep_template % descr tools.rewrite(filename, output) return filename
def patch_file(infile, out, options): lines = open(infile, 'r').readlines() preproc = "IMP_%s" % options.module.upper() repl1 = '"swig::%s_PySwigIterator *"' % preproc repl2 = '"swig::%s_SwigPyIterator *"' % preproc orig = 'SWIG_IMP.%s_WRAP_H_' % options.module repl = 'SWIG_IMP_%s_WRAP_H_' % options.module for i in range(len(lines)): line = lines[i] line = line.replace('"swig::PySwigIterator *"', repl1) line = line.replace('"swig::SwigPyIterator *"', repl2) line = line.replace(orig, repl) line = line.replace("wrap.h-in", "wrap.h") # for some reason swig has issues with directors and VersionInfo # when %extend is used line = line.replace(" VersionInfo ", " IMP::VersionInfo ") line = line.replace("(VersionInfo ", "(IMP::VersionInfo ") line = line.replace("<VersionInfo ", "<IMP::VersionInfo ") line = line.replace("<:", "< :") # swig generates bad C++ code lines[i] = line tools.rewrite(out, "".join(lines), verbose=False)
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)
def generate_overview_pages(source): name = os.path.join("doxygen", "generated", "applications.dox") contents = [] contents.append("/** ") contents.append("\\page applications All IMP Applications") contents.append(""" IMP provides a number of applications (command line tools). These are listed below:""") for bs, g in tools.get_applications(source): contents.append("- \subpage imp%s \"IMP.%s\"" % (bs, bs)) p = pickle.load( open(os.path.join("data", "build_info", "IMP_%s.pck" % bs))) apps = sorted([[k] + list(v) for k, v in p.iteritems() if v], key=lambda x: x[3]) for app in apps: contents.append(" - [%s](\\ref %s): %s" % (app[0], app[1], app[2])) contents.append(""" See also the [command line tools provided by RMF](http://integrativemodeling.org/rmf/nightly/doc/executables.html).""" ) contents.append("*/") tools.rewrite(name, "\n".join(contents))
def make_doxygen(name, source, modules): file = os.path.join("doxygen", name, "Doxyfile") template_file = os.path.join(source, "tools", "build", "doxygen_templates", "Doxyfile.in") template = open(template_file, "r").read() template = template.replace("@IMP_SOURCE_PATH@", source) template = template.replace("@VERSION@", "0") template = template.replace("@NAME@", name) template = template.replace("@PROJECT_BRIEF@", '"The Integrative Modeling Platform"') template = template.replace("@RECURSIVE@", "YES") template = template.replace("@EXCLUDE_PATTERNS@", "*/tutorial/*") template = template.replace("@IS_HTML@", "YES") template = template.replace("@PROJECT_NAME@", "IMP." + name) template = template.replace("@HTML_OUTPUT@", "../../doc/html/" + name) template = template.replace("@GENERATE_TAGFILE@", "tags") template = template.replace("@IS_XML@", "YES") template = template.replace("@XML_OUTPUT@", "xml") template = template.replace("@LAYOUT_FILE@", "%s/doc/doxygen/module_layout.xml" % source) template = template.replace("@MAINPAGE@", "README.md") template = template.replace("@EXAMPLE_PATH@", "") template = template.replace("@EXCLUDE@", "") template = template.replace("@INCLUDE_PATH@", "") template = template.replace("@FILE_PATTERNS@", "*.dox *.md") template = template.replace("@WARNINGS@", "warnings.txt") # include lib and doxygen in imput inputs = [] docpath = os.path.join(source, "applications", name, "doc") if os.path.exists(docpath): inputs.append(docpath) template = template.replace("@INPUT_PATH@", " \\\n ".join(inputs)) tags = [] for m in modules: tags.append(os.path.join("../", m, "tags") + "=" + "../" + m) template = template.replace("@TAGS@", " \\\n ".join(tags)) tools.rewrite(file, template)
def main(): (options, args) = parser.parse_args() info = tools.get_module_info(options.name, "/") if not info["ok"]: tools.rewrite("src/%s_swig.deps"%options.name, "") return cmd = [options.swig, '-MM', '-Iinclude', '-Iswig', '-ignoremissing'] \ + ["-I"+x for x in tools.split(options.swigpath)] \ + ["-I"+x for x in tools.split(options.includepath)] \ + ["swig/IMP_%s.i" % options.name] outfile = open("src/%s_swig.deps.in"%options.name, "w") ret = subprocess.call(cmd, stdout=outfile) outfile.close() if ret != 0: raise OSError("subprocess failed with return code %d: %s" \ % (ret, " ".join(cmd))) lines= open("src/%s_swig.deps.in"%options.name, "r").readlines() names= [x[:-2].strip() for x in lines[1:]] final_names=[_fix(x, options.build_system) for x in names] final_list= "\n".join(final_names) tools.rewrite("src/%s_swig.deps"%options.name, final_list)
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", 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) all_outputs.append(p[0]) all_inputs.append(p[1])
def make_cpp(options): dir = os.path.join("src") file = os.path.join(dir, "%s_config.cpp" % options.name) cpp_template = open( os.path.join( options.source, "tools", "build", "config_templates", "src.cpp"), "r").read( ) try: os.makedirs(dir) except: # exists pass data = {} data["filename"] = "IMP/%s/%s_config.h" % (options.name, options.name) data["cppprefix"] = "IMP%s" % options.name.upper().replace("_", "") data["name"] = options.name data["version"] = tools.get_module_version(options.name, options.source) tools.rewrite(file, cpp_template % data)
def generate_overview_pages(source): name = os.path.join("doxygen", "generated", "cmdline_tools.dox") contents = [] contents.append("/** ") contents.append("\\page cmdline_tools All IMP command line tools") contents.append(""" IMP modules provide a number of command line tools. These are listed below under their parent module:""") for bs, g in tools.get_modules(source): if tools.get_module_info(bs, '')['ok']: p = pickle.load(open(os.path.join("data", "build_info", "IMP_%s.pck" % bs))) if len(p) > 0: contents.append("- IMP::%s" % bs) apps = sorted([[k]+list(v) for k,v in p.iteritems() if v], key=lambda x:x[3]) for app in apps: contents.append(" - [%s](\\ref %s): %s" % (app[0], app[1], app[2])) contents.append(""" See also the [command line tools provided by RMF](http://integrativemodeling.org/rmf/nightly/doc/executables.html).""") contents.append("*/") tools.rewrite(name, "\n".join(contents))
def make_dependency_check(descr_path, module, module_path): descr = tools.get_dependency_description(descr_path) name = os.path.splitext(os.path.split(descr_path)[1])[0] if len(descr["cmake"]) > 0: ret = descr_path[0:-len("description")] + "cmake" return ret descr["pkgname"] = name descr["PKGNAME"] = name.upper() filename = os.path.join(module_path, "CMakeModules", "Find" + name + ".cmake") if descr["python_module"] != "": # don't bother checking python deps as they aren't needed for compilation # and it makes cross compilation easier return None else: descr["includes"] = "\n".join( ["#include <%s>" % h for h in descr["headers"]]) descr["headers"] = ";".join(descr["headers"]) descr["libraries"] = ";".join(descr["libraries"]) descr["body"] = tools.quote(descr["body"]) if len(descr["cmake"]) > 0: descr["path"] = os.path.splitext(descr_path)[0] descr[ "on_failure"] = """set(%(PKGNAME)s_INTERNAL 1 CACHE INTERNAL "" FORCE) %(cmake)s """ % descr descr["on_setup"] = """if(DEFINED %(PKGNAME)s_INTERNAL) %(cmake)s endif(DEFINED %(PKGNAME)s_INTERNAL)""" % descr else: descr[ "on_failure"] = """message("%s not found")\nfile(WRITE "${CMAKE_BINARY_DIR}/data/build_info/%s" "ok=False")""" % ( name, name) descr["on_setup"] = "" output = dep_template % descr tools.rewrite(filename, output) return filename
def generate_overview_pages(source): name = os.path.join("doxygen", "generated", "cmdline_tools.dox") contents = [] contents.append("/** ") contents.append("\\page cmdline_tools All IMP command line tools") contents.append(""" IMP modules provide a number of command line tools. These are listed below under their parent module:""") for bs, g in tools.get_modules(source): if tools.get_module_info(bs, '')['ok']: p = pickle.load( open(os.path.join("data", "build_info", "IMP_%s.pck" % bs))) if len(p) > 0: contents.append("- IMP::%s" % bs) apps = sorted([[k] + list(v) for k, v in p.iteritems() if v], key=lambda x: x[3]) for app in apps: contents.append(" - [%s](\\ref %s): %s" % (app[0], app[1], app[2])) contents.append(""" See also the [command line tools provided by RMF](http://integrativemodeling.org/rmf/nightly/doc/executables.html).""" ) contents.append("*/") tools.rewrite(name, "\n".join(contents))
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)
def make_header(options): dir = os.path.join("include", "IMP", options.name) file = os.path.join(dir, "%s_config.h" % options.name) header_template = open( os.path.join(options.source, "tools", "build", "config_templates", "header.h"), "r").read() try: os.makedirs(dir) except: # exists pass data = {} data["name"] = options.name data["filename"] = "IMP/%s/%s_config.h" % (options.name, options.name) data["cppprefix"] = "IMP%s" % options.name.upper().replace("_", "") if data["name"] != "base": data["showable"] = """#if !defined(IMP_DOXYGEN) && !defined(SWIG) #include <IMP/base/Showable.h> #include <IMP/base/hash.h> namespace IMP { namespace %(name)s { using ::IMP::base::Showable; using ::IMP::base::operator<<; using ::IMP::base::hash_value; } } // namespace namespace IMP { namespace %(name)s { namespace internal { using ::IMP::base::Showable; using ::IMP::base::operator<<; using ::IMP::base::hash_value; } } } // namespace #endif // !defined(SWIG) && !defined(IMP_DOXYGEN) """ % data else: data["showable"] = "" cppdefines = [] if options.defines != "": for define in tools.split(options.defines): parts = define.split("=") if len(parts) == 2: cppdefines.append("#define %s %s" % (parts[0], parts[1])) else: cppdefines.append("#define %s" % parts[0]) d = { 'required_modules': "", 'lib_only_required_modules': "", 'required_dependencies': "", 'optional_dependencies': "" } exec( open( os.path.join(options.source, "modules", data["name"], "dependencies.py"), "r").read(), d) info = tools.get_module_info(data["name"], options.datapath) optional_modules = [ x for x in info["modules"] if x not in tools.split(d['required_modules']) and x != "" ] unfound_modules = [x for x in info["unfound_modules"] if x != ""] optional_dependencies = [ x for x in info["dependencies"] if x not in tools.split(d['required_dependencies']) and x != "" ] unfound_dependencies = [x for x in info["unfound_dependencies"] if x != ""] add_list_to_defines(cppdefines, data, "USE", 1, ["imp_" + x for x in optional_modules]) add_list_to_defines(cppdefines, data, "NO", 0, ["imp_" + x for x in unfound_modules]) add_list_to_defines(cppdefines, data, "USE", 1, optional_dependencies) add_list_to_defines(cppdefines, data, "NO", 0, info["unfound_dependencies"]) data["cppdefines"] = "\n".join(cppdefines) tools.rewrite(file, header_template % data)
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
def main(): source = os.path.join(os.path.split(sys.argv[0])[0], "container_templates") #(function_name, class_name, variable_type, argument_type, # return_type, storage_type, # plural_variable_type, plural_argument_type, plural_storage_type) tools.mkdir(os.path.join("src", "core"), clean=False) tools.mkdir(os.path.join("src", "container"), clean=False) tools.mkdir(os.path.join("src", "kernel"), clean=False) make_one( source, ("particle", "Particle", "Singleton", "kernel::Particle*", "kernel::Particle*", "kernel::Particle*", "base::Pointer<kernel::Particle>", "kernel::ParticlesTemp", "kernel::ParticlesTemp", "kernel::Particles", "kernel::ParticleIndex", "kernel::ParticleIndexes", "kernel::ParticleIndex")) make_one(source, ("particle_pair", "ParticlePair", "Pair", "kernel::ParticlePair", "const kernel::ParticlePair&", "const kernel::ParticlePair", "kernel::ParticlePair", "kernel::ParticlePairsTemp", "kernel::ParticlePairsTemp", "kernel::ParticlePairs", "kernel::ParticleIndexPair", "kernel::ParticleIndexPairs", "const kernel::ParticleIndexPair&")) make_one(source, ("particle_triplet", "ParticleTriplet", "Triplet", "kernel::ParticleTriplet", "const kernel::ParticleTriplet&", "const kernel::ParticleTriplet", "kernel::ParticleTriplet", "kernel::ParticleTripletsTemp", "kernel::ParticleTripletsTemp", "kernel::ParticleTriplets", "kernel::ParticleIndexTriplet", "kernel::ParticleIndexTriplets", "const kernel::ParticleIndexTriplet&"), test=False) make_one(source, ("particle_quad", "ParticleQuad", "Quad", "kernel::ParticleQuad", "const kernel::ParticleQuad&", "const kernel::ParticleQuad", "kernel::ParticleQuad", "kernel::ParticleQuadsTemp", "kernel::ParticleQuadsTemp", "kernel::ParticleQuads", "kernel::ParticleIndexQuad", "kernel::ParticleIndexQuads", "const kernel::ParticleIndexQuad&"), test=False) if True: deps = [ "${PROJECT_SOURCE_DIR}/tools/build/%s" % x[x.find("container_templates"):] for x in all_inputs ] targets = ["${PROJECT_BINARY_DIR}/%s" % x for x in all_outputs] def get_files(module, suffix, prefix, allh): ret = [] for h in allh: if h.endswith(suffix) and os.path.split( os.path.split(h)[0])[1] == module: ret.append(prefix + os.path.split(h)[1]) return ret out = """ add_custom_command(OUTPUT %s COMMAND "python" "${PROJECT_SOURCE_DIR}/tools/build/make_containers.py" DEPENDS "${PROJECT_SOURCE_DIR}/tools/build/make_containers.py" %s WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" COMMENT "Making decorator headers") add_custom_target(IMP-containers ALL DEPENDS %s) set_property(TARGET "IMP-containers" PROPERTY FOLDER "IMP") set( IMP_kernel_LIBRARY_EXTRA_DEPENDENCIES ${IMP_kernel_LIBRARY_EXTRA_DEPENDENCIES} IMP-containers) set( IMP_core_LIBRARY_EXTRA_DEPENDENCIES ${IMP_core_LIBRARY_EXTRA_DEPENDENCIES} IMP-containers) set( IMP_container_LIBRARY_EXTRA_DEPENDENCIES ${IMP_container_LIBRARY_EXTRA_DEPENDENCIES} IMP-containers) set( IMP_kernel_PYTHON_EXTRA_DEPENDENCIES ${IMP_kernel_LIBRARY_EXTRA_DEPENDENCIES} IMP-containers) set( IMP_core_PYTHON_EXTRA_DEPENDENCIES ${IMP_core_LIBRARY_EXTRA_DEPENDENCIES} IMP-containers) set( IMP_container_PYTHON_EXTRA_DEPENDENCIES ${IMP_container_LIBRARY_EXTRA_DEPENDENCIES} IMP-containers) set( IMP_kernel_LIBRARY_EXTRA_SOURCES ${IMP_kernel_LIBRARY_EXTRA_SOURCES} %s) set( IMP_core_LIBRARY_EXTRA_SOURCES ${IMP_container_LIBRARY_EXTRA_SOURCES} %s) set( IMP_container_LIBRARY_EXTRA_SOURCES ${IMP_core_LIBRARY_EXTRA_SOURCES} %s) set( IMP_kernel_EXTRA_HEADERS ${IMP_kernel_EXTRA_HEADERS} %s) set( IMP_core_EXTRA_HEADERS ${IMP_core_EXTRA_HEADERS} %s) set( IMP_container_EXTRA_HEADERS ${IMP_container_EXTRA_HEADERS} %s) """ % ("\n ".join(targets), "\n ".join(deps), "\n ".join(targets), "\n ".join( get_files("kernel", ".cpp", "${CMAKE_BINARY_DIR}/src/kernel/", targets)), "\n ".join( get_files("core", ".cpp", "${CMAKE_BINARY_DIR}/src/core/", targets)), "\n ".join( get_files("container", ".cpp", "${CMAKE_BINARY_DIR}/src/container/", targets)), "\n ".join(get_files("kernel", ".h", "", targets)), "\n ".join( get_files("core", ".h", "", targets)), "\n ".join( get_files("container", ".h", "", targets))) tools.rewrite( os.path.join( os.path.split(sys.argv[0])[0], "cmake_files", "MakeContainers.cmake"), out)
def main(): (options, args) = parser.parse_args() data = {} data["examplepath"] = options.examplepath data["datapath"] = options.datapath tools.rewrite(options.output, template % data)
def build_wrapper(module, module_path, source, sorted, info, target, datapath): info = tools.get_module_info(module, datapath) if not info["ok"]: return contents = [] swig_module_name = "IMP." + module contents.append("""%%module(directors="1", allprotected="1") "%s" %%feature("autodoc", 1); // Warning 314: 'lambda' is a python keyword, renaming to '_lambda' %%warnfilter(321,302,314); %%inline %%{ namespace IMP { namespace kernel { } using namespace kernel; } %%} %%{ #include <boost/version.hpp> #if BOOST_VERSION > 103600 #if BOOST_VERSION > 103800 #include <boost/exception/all.hpp> #else #include <boost/exception.hpp> #endif #endif #include <boost/type_traits/is_convertible.hpp> #include <boost/utility/enable_if.hpp> #include <exception> #ifdef __cplusplus extern "C" #endif // suppress warning SWIGEXPORT #if PY_VERSION_HEX >= 0x03000000 PyObject* #else void #endif SWIG_init(); %%} """ % swig_module_name) # some of the typemap code ends up before this is swig sees the # typemaps first all_deps = [ x for x in tools.get_dependent_modules([module], datapath) if x != module ] for m in reversed(all_deps): write_module_cpp(m, contents, datapath) write_module_cpp(module, contents, datapath) contents.append(""" %implicitconv; %include "std_vector.i" %include "std_string.i" %include "std_pair.i" %pythoncode %{ _value_types=[] _object_types=[] _raii_types=[] _plural_types=[] %} %include "typemaps.i" #ifdef NDEBUG #error "The python wrappers must not be built with NDEBUG" #endif """) for m in reversed(all_deps): write_module_swig(m, source, contents, datapath) write_module_swig(module, source, contents, datapath, True) contents.append("%%include \"IMP_%s.impl.i\"" % module) #contents.append(open(os.path.join(module_path, "pyext", "swig.i-in"), "r").read()) contents.append(""" namespace IMP { namespace %s { const std::string get_module_version(); std::string get_example_path(std::string fname); std::string get_data_path(std::string fname); } } """ % module) contents.append("""%pythoncode %{ import _version_check _version_check.check_version(get_module_version()) %} """) tools.rewrite(target, "\n".join(contents))
def write_file(self): pypathsep = ";" if self.options.python_pathsep == 'w32' else os.pathsep outfile = self.options.output pythonpath = self.native_paths(self.options.python_path, True) ldpath = self.native_paths(self.options.ld_path) precommand = self.options.precommand path = self.get_path() externdata = self.native_paths(self.options.external_data) libdir = self.get_abs_binary_path("lib") impdir = os.path.join(libdir, "IMP") bindir = self.get_abs_binary_path("bin") datadir = os.path.abspath("data") exampledir = os.path.abspath(os.path.join("doc", "examples")) tmpdir = os.path.abspath("tmp") if platform.system() == 'Linux': varname = "LD_LIBRARY_PATH" elif platform.system() == 'Darwin': varname = "DYLD_LIBRARY_PATH" else: varname = None lines = { "@LDPATH@": (varname, os.pathsep.join([libdir] + ldpath), True, True), "@PYTHONPATH@": ("PYTHONPATH", pypathsep.join([libdir] + pythonpath), True, True), "@IMP_BIN_DIR@": ("IMP_BIN_DIR", bindir, True, False), "@PATH@": ("PATH", os.pathsep.join(uniq([bindir] + path)), True, True), "@PRECOMMAND@": ("precommand", precommand, False, False), "@IMP_DATA@": ("IMP_DATA", ":".join([datadir] + externdata), True, False), "@IMP_EXAMPLE_DATA@": ("IMP_EXAMPLE_DATA", os.pathsep.join([exampledir]), True, False), "@TMPDIR@": ("IMP_TMP_DIR", tmpdir, True, False) } contents = [] for line in self.template: if line in lines: val = lines[line] if val[0] and len(val[1]) > 0: # ick if self.options.propagate == "no" or not val[3]: contents.extend( self.set_variable(val[0], val[1], val[2])) else: if 'PYTHONPATH' in val[0]: sep = pypathsep else: sep = os.pathsep contents.extend( self.set_variable_propagate( val[0], val[1], val[2], sep)) else: contents.append(line) tools.rewrite(outfile, "\n".join(contents), verbose=False) os.chmod(outfile, stat.S_IRWXU)
def make_doxygen(options, modules): file = os.path.join("doxygen", options.name, "Doxyfile") name = options.name template_file = os.path.join(options.source, "tools", "build", "doxygen_templates", "Doxyfile.in") template = open(template_file, "r").read() template = template.replace("@IMP_SOURCE_PATH@", options.source) template = template.replace("@VERSION@", "NONE") template = template.replace("@NAME@", name) template = template.replace("@PROJECT_BRIEF@", '"The Integrative Modeling Platform"') template = template.replace("@RECURSIVE@", "YES") template = template.replace("@EXCLUDE_PATTERNS@", "*/tutorial/*") template = template.replace("@IS_HTML@", "NO") template = template.replace("@IS_XML@", "YES") template = template.replace("@PROJECT_NAME@", "IMP." + name) template = template.replace("@HTML_OUTPUT@", "../../doc/html/" + name) template = template.replace("@XML_OUTPUT@", "xml") template = template.replace("@TREEVIEW@", "NO") template = template.replace("@GENERATE_TAGFILE@", "tags") template = template.replace( "@LAYOUT_FILE@", "%s/doc/doxygen/module_layout.xml" % options.source) template = template.replace("@MAINPAGE@", "README.md") template = template.replace("@INCLUDE_PATH@", "include") template = template.replace("@FILE_PATTERNS@", "*.cpp *.h *.py *.md *.dox") template = template.replace("@WARNINGS@", "warnings.txt") # include lib and doxygen in imput inputs = [] if options.name == "kernel": inputs.append("include/IMP/") exclude = [ "include/IMP/%s include/IMP/%s.h" % (m, m) for m, g in tools.get_modules(options.source) if m != "kernel" ] template = template.replace( "@EXCLUDE@", " \\\n ".join(exclude)) else: template = template.replace("@EXCLUDE@", "") inputs.append("include/IMP/" + options.name) inputs.append("lib/IMP/" + options.name) inputs.append("examples/" + options.name) # suppress a warning since git removes empty dirs and doxygen gets confused # if the input path doesn't exist docpath = os.path.join(options.source, "modules", options.name, "doc") if os.path.exists(docpath): inputs.append(docpath) # overview for module inputs.append("../generated/IMP_%s.dox" % options.name) template = template.replace("@INPUT_PATH@", " \\\n ".join(inputs)) tags = [] for m in modules: tags.append(os.path.join("../", m, "tags") + "=" + "../" + m) template = template.replace("@TAGS@", " \\\n ".join(tags)) if options.name == "example": template = template.replace( "@EXAMPLE_PATH@", "examples/example %s/modules/example" % options.source) else: template = template.replace("@EXAMPLE_PATH@", "examples/" + options.name) tools.rewrite(file, template)
def write_no_ok(module): new_order = [x for x in tools.get_sorted_order() if x != module] tools.set_sorted_order(new_order) tools.rewrite(os.path.join("data", "build_info", "IMP." + module), "ok=False\n", verbose=False)