def IMPModuleBuild(env, version=None, required_modules=[], lib_only_required_modules=[], optional_modules=[], lib_only_optional_modules=[], optional_dependencies=[], config_macros=[], module=None, module_libname=None, module_pylibname=None, module_include_path=None, module_preproc=None, module_namespace=None, module_nicename=None, required_dependencies=[], alias_name=None, cxxflags=[], cppdefines=[], cpppath=[], python_docs=False, local_module=False, standards=True): if env.GetOption('help'): return dta= scons_tools.data.get(env) if module is None: module=Dir('.').abspath.split('/')[-1] if module=="local": module=Dir('.').abspath.split('/')[-2]+"_local" if not module_libname and (module != module.lower() or module.find("-") != -1): scons_tools.utility.report_error("Module names can only have lower case characters and numbers") if module_libname is None: module_libname="imp_"+module if module_pylibname is None: module_pylibname="_IMP_"+module if module_include_path is None: module_include_path="IMP/"+module if module_namespace is None: module_namespace="IMP::"+module if module_preproc is None: module_preproc=module_namespace.replace("::","_").upper() if module_nicename is None: module_nicename= "IMP."+module if alias_name is None: alias_name=module if python_docs: env.Append(IMP_PYTHON_DOCS=[module]) optm=optional_modules+lib_only_optional_modules optd=optional_dependencies reqd=required_dependencies reqm=required_modules+lib_only_required_modules all_sconscripts=stp.get_sconscripts(env, ['data', 'examples']) nenv = scons_tools.utility.configure_module(env, module, alias_name, module_libname, version, required_modules=reqm, optional_dependencies=optd, optional_modules=optm, required_dependencies= reqd) if not nenv: return preclone=env env = nenv vars={'module_include_path':module_include_path, 'module':module, 'PREPROC':module_preproc, 'EXPORT':module_preproc.replace("_", ""), 'namespace':module_namespace, 'module_libname':module_libname, 'module_pylibname':module_pylibname, 'module_nicename':module_nicename, 'module_alias':alias_name} env['IMP_MODULE_VARS']=vars build_config=[] if cxxflags: env.Replace(CXXFLAGS=cxxflags) if cppdefines: env.Append(CPPDEFINES=cppdefines) if cpppath: env.Append(CPPPATH=cpppath) #if len(found_optional_modules + found_optional_dependencies)>0: # print " (using " +", ".join(found_optional_modules + found_optional_dependencies) +")" real_config_macros=config_macros[:] #print "config", module, real_config_macros env['IMP_MODULE_CONFIG']=real_config_macros for s in all_sconscripts: env.SConscript(s, exports='env') if env['IMP_PASS']=="BUILD": dta.add_to_alias("all", _get_module_alias(env)) # needed for data for m in _get_module_modules(env): env.Requires(dta.get_alias(_get_module_alias(env)), dta.get_alias(dta.modules[m].alias)) if standards: root=Dir(".").abspath if env.get('repository', None): old=Dir("#").abspath #print old, root, env['repository'] root=root.replace(old, Dir(Dir("#").abspath+"/"+env['repository']).abspath) scons_tools.standards.add(env, [root+"/"+x for x in ["include/*.h", "include/internal/*.h", "src/*.cpp", "src/internal/*.cpp", "test/*.py", "bin/*.cpp"]]) return env
def IMPSystem(env, name=None, version=None, authors=[], brief="", overview="", publications=None, license="standard", required_modules=[], optional_dependencies=[], required_dependencies=[], extra_data=[], testable=False, parallelizable=False, last_imp_version="unknown", python=True): if not name: name= Dir(".").abspath.split("/")[-1] if env.GetOption('help'): return dirs = scons_tools.paths.get_sconscripts(env) local_module=False for d in dirs: env.SConscript(d, exports=['env']) (nenv, version, found_optional_modules, found_optional_dependencies) =\ utility.configure(env, name, "system", version, required_modules=required_modules, optional_dependencies=optional_dependencies, required_dependencies= required_dependencies) if not nenv: data.get(env).add_application(name, ok=False) return else: if nenv["IMP_PASS"] != "RUN": return lkname="system_"+name.replace(" ", "_").replace(":", "_") pre="\page "+lkname+" "+name extrasections=[] if testable: extrasections.append(("Testable", "Yes")) else: extrasections.append(("Testable", "No")) if parallelizable: extrasections.append(("Parallelizeable", "Yes")) else: extrasections.append(("Parallelizeable", "No")) if last_imp_version != "unknown": extrasections.append(("Last known good \imp version", last_imp_version)) else: vtxt= "\n\\section lkgversion Last known good IMP version\n"+\ "unknown"+"\n" data.get(env).add_system(name, link="\\ref "+lkname+' "'+name+'"', dependencies=required_dependencies\ +found_optional_dependencies, unfound_dependencies=[x for x in optional_dependencies if not x in found_optional_dependencies], modules= required_modules+found_optional_modules, version=version) for d in dirs: if str(d).split("/")[0] != "local": env.SConscript(d, exports=['env']) scons_tools.data.get(env).add_to_alias("all", env.Alias(name)) env= nenv for m in required_modules+found_optional_modules: env.Depends(scons_tools.data.get(env).get_alias(name), scons_tools.data.get(env).get_alias(m)) if testable: samples= Glob("sample_[0123456789]*.py") samples.sort(utility.file_compare) analysis= Glob("analyze_[0123456789]*.py") analysis.sort(utility.file_compare) tt= [] tests = test.add_tests(env, samples+analysis, "system") for t in tests: env.Depends(t, scons_tools.data.get(env).get_alias(name)) # link files in build dir allfiles= [] for suff in ["*.txt", "*.mrc", "*.pdb", ".py", ".param", ".input", ".lib"]: allfiles.extend(Glob("*/*"+suff)) allfiles.extend(Glob("*"+suff)) for f in allfiles+extra_data: inst=install.install(env, "biological_systems/"+name+"/", f) scons_tools.data.get(env).add_to_alias(env.Alias(name), inst) #if f.path.endswith(".py"): # example.add_python_example(env, f, f.path) #env.AlwaysBuild(install) doc.add_doc_page(env, "\\page "+lkname+" "+name.capitalize(), authors, version, brief, overview, publications, license, extra_sections=extrasections) return env