def main(): (options, args) = parser.parse_args() data = {} data["examplepath"] = options.examplepath data["datapath"] = options.datapath g = tools.CPPFileGenerator() g.write(options.output, template % data)
def generate_all_cpp(modules): target = os.path.join("src") tools.mkdir(target) gen = tools.CPPFileGenerator() for module in modules: sources = tools.get_glob([os.path.join(module.path, "src", "*.cpp")])\ + tools.get_glob([os.path.join(module.path, "src", "internal", "*.cpp")]) targetf = os.path.join(target, module.name + "_all.cpp") sources.sort() gen.write(targetf, "\n".join(["#include <%s>" % os.path.abspath(s) for s in sources]) + '\n')
def make_cpp(options): dir = os.path.join("src") file = os.path.join(dir, "%s_config.cpp" % options.name) cpp_template = tools.CPPFileGenerator( os.path.join(TOPDIR, "config_templates", "src.cpp")) try: os.makedirs(dir) except: # exists pass data = {} if options.name == 'kernel': data["filename"] = "IMP/%s_config.h" % options.name else: 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) cpp_template.write(file, data)
def make_header(options): if options.name == 'kernel': dir = os.path.join("include", "IMP") else: dir = os.path.join("include", "IMP", options.name) file = os.path.join(dir, "%s_config.h" % options.name) header_template = tools.CPPFileGenerator( os.path.join(options.source, "tools", "build", "config_templates", "header.h")) try: os.makedirs(dir) except: # exists pass data = {} data["name"] = options.name if options.name == 'kernel': data["namespace"] = "IMP" data["begin_ns"] = "namespace IMP{" data["end_ns"] = "}" data["filename"] = "IMP/%s_config.h" % options.name else: data["namespace"] = "IMP::%s" % options.name data["begin_ns"] = "namespace IMP{ namespace %s {" % options.name data["end_ns"] = "} }" data["filename"] = "IMP/%s/%s_config.h" % (options.name, options.name) data["cppprefix"] = "IMP%s" % options.name.upper().replace("_", "") if data["name"] != "kernel": data["showable"] = """#if !defined(IMP_DOXYGEN) && !defined(SWIG) #include <IMP/Showable.h> #include <IMP/hash.h> %(begin_ns)s using ::IMP::Showable; using ::IMP::operator<<; using ::IMP::hash_value; %(end_ns)s // namespace %(begin_ns)s namespace internal { using ::IMP::Showable; using ::IMP::operator<<; using ::IMP::hash_value; } %(end_ns)s // namespace #endif // !defined(SWIG) && !defined(IMP_DOXYGEN) """ % data else: data["showable"] = "" # Hack: add module alias for IMP::kernel and IMP::base if data["name"] == "kernel": data["showable"] = "namespace IMP{ namespace kernel = IMP; " \ "namespace base = IMP; }\n" \ + 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) header_template.write(file, data)
def make_header(options, module): if module.python_only: return if module.name == 'kernel': dir = os.path.join("include", "IMP") else: dir = os.path.join("include", "IMP", module.name) file = os.path.join(dir, "%s_config.h" % module.name) header_template = tools.CPPFileGenerator(os.path.join(TOPDIR, "config_templates", "header.h")) try: os.makedirs(dir) except: # exists pass data = {} data["name"] = module.name if module.name == 'kernel': data["namespace"] = "IMP" data["begin_ns"] = "namespace IMP{" data["end_ns"] = "}" data["filename"] = "IMP/%s_config.h" % module.name else: data["namespace"] = "IMP::%s" % module.name data["begin_ns"] = "namespace IMP{ namespace %s {" % module.name data["end_ns"] = "} }" data["filename"] = "IMP/%s/%s_config.h" % (module.name, module.name) data["cppprefix"] = "IMP%s" % module.name.upper().replace("_", "") if data["name"] != "kernel": data["showable"] = """#if !defined(IMP_DOXYGEN) && !defined(SWIG) #include <IMP/Showable.h> #include <IMP/hash.h> %(begin_ns)s using ::IMP::Showable; using ::IMP::operator<<; using ::IMP::hash_value; %(end_ns)s // namespace %(begin_ns)s namespace internal { using ::IMP::Showable; using ::IMP::operator<<; using ::IMP::hash_value; } %(end_ns)s // 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]) cf = module.configured optional_modules = [x for x in cf.modules if x not in module.required_modules] optional_dependencies = [x for x in cf.dependencies if x not in module.required_dependencies] add_list_to_defines(cppdefines, data, "USE", 1, ["imp_" + x.name for x in optional_modules]) add_list_to_defines(cppdefines, data, "NO", 0, ["imp_" + x.name for x in cf.unfound_modules]) add_list_to_defines(cppdefines, data, "USE", 1, optional_dependencies) add_list_to_defines(cppdefines, data, "NO", 0, cf.unfound_dependencies) data["cppdefines"] = "\n".join(cppdefines) header_template.write(file, data)