-# Copyright (C) 2009-2016 EDF R&D
+# Copyright (C) 2009-2021 EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
>>> s1 = module_generator.Service('myservice', inport=[("a","double"),],
instream=[("aa","CALCIUM_double","I")],
- body="print a")
+ body="print( a)")
"""
component_libs = "".join([x.libraryName()+" " for x in module.components])
add_modules = ""
for x in self.used_modules:
- cmake_text = cmake_find_module.substitute(module=x)
if x == "MED":
+ cmake_text = cmake_find_module.substitute(module="FIELDS")
cmake_text = cmake_text + """
#####################################
# FIND MEDCOUPLING
#####################################
"""
+ else:
+ cmake_text = cmake_find_module.substitute(module=x)
+
add_modules = add_modules + cmake_text
pass
# other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc "
include_template=Template("$${${module}_ROOT_DIR}/idl/salome")
- opt_inc="".join([include_template.substitute(module=x)+"\n " for x in self.used_modules])
link_template=Template("$${${module}_SalomeIDL${module}}")
- opt_link="".join([link_template.substitute(module=x)+"\n " for x in self.used_modules])
+ opt_inc=""
+ opt_link=""
+ for x in self.used_modules:
+ if x=="MED":
+ # here template cannot be used as we mix FIELDS and MED
+ opt_inc+="${FIELDS_ROOT_DIR}/idl/salome\n "
+ opt_link+="${FIELDS_SalomeIDLMED}\n "
+ else:
+ opt_inc+=include_template.substitute(module=x)+"\n "
+ opt_link+=link_template.substitute(module=x)+"\n "
+
idlfiles={"CMakeLists.txt":cmake_idl.substitute(module=module.name,
extra_idl=other_idls,
for name, content in list(dic.items()):
filename = os.path.join(basedir, name)
if isinstance(content, str):
- fil = open(filename, 'w')
- fil.write(content)
- fil.close()
+ # encodage to utf-8 if unicode string / on python3 str are unicode
+ with open(filename, 'w') as fil:
+ fil.write(content)
else:
if not os.path.exists(filename):
os.makedirs(filename)
#add the generated module
modules.append(' <module name="%s" path="%s"/>' % (self.module.name, os.path.abspath(self.module.prefix)))
-
+ ROOT_SALOME=os.getenv("ROOT_SALOME")
#try to find a prerequisites file
prerequisites = self.context.get("prerequisites")
if not prerequisites:
#try to find one in rootdir
- prerequisites = os.path.join(rootdir, "profile%s.sh" % suffix)
+ prerequisites = os.path.join(ROOT_SALOME, "salome_prerequisites.sh")
if not os.path.exists(prerequisites):
raise Invalid("Can not create an application : prerequisites file not defined or does not exist")
+ salome_context = self.context.get("salome_context")
+ if not salome_context:
+ #try to find one in rootdir
+ salome_context = os.path.join(ROOT_SALOME, "salome_context.cfg")
+ if not os.path.exists(salome_context):
+ raise Invalid("Can not create an application : salome_context file not defined or does not exist")
+
#add resources catalog if it exists
resources_spec=""
if os.path.isfile(resources):
#create config_appli.xml file
appli = application.substitute(prerequisites=prerequisites,
+ context=salome_context,
modules="\n".join(modules),
resources=resources_spec)
fil = open(os.path.join(appliname, "config_appli.xml"), 'w')