self.install_dir = src.Path(self.product_info.install_dir)
self.header = ""
self.debug_mode = False
+ self.cmake_build_type = 'Release'
+ if "cmake_build_type" in self.config.APPLICATION:
+ self.set_cmake_build_type(self.config.APPLICATION.cmake_build_type)
+ # keep backward compatibility
+ if "debug" in self.config.APPLICATION and self.config.APPLICATION.debug == "yes":
+ self.debug_mode = True
+ self.cmake_build_type = 'Debug'
+
+ # in case a product defines its own configuration, then use it
+ if "cmake_build_type" in self.product_info:
+ self.set_cmake_build_type(self.product_info.cmake_build_type)
+ # keep backward compatibility
if "debug" in self.product_info and self.product_info.debug == "yes":
self.debug_mode = True
+ self.cmake_build_type = 'Debug'
+
self.verbose_mode = False
if "verbose" in self.product_info and self.product_info.verbose == "yes":
self.verbose_mode = True
- ##
+
+ # set cmake build type
+ def set_cmake_build_type(self, build_type):
+ if build_type.lower() in ['debug', 'relwithdebinfo', 'release', 'minsizerel']:
+ if build_type.lower() == 'debug':
+ self.cmake_build_type = 'Debug'
+ self.debug_mode = True
+ elif build_type.lower() == 'relwithdebinfo':
+ self.cmake_build_type = 'RelWithDebInfo'
+ elif build_type.lower() == 'release':
+ self.cmake_build_type = 'Release'
+ elif build_type.lower() == 'minsizerel':
+ self.cmake_build_type = 'MinSizeRel'
+ else:
+ raise src.SatException("Unknown cmake build mode: {}. Supported values are: Debug, RelWithDebInfo, Release or MinSizeRel".format(build_type))
+ return
+
# Shortcut method to log in log file.
def log(self, text, level, showInfo=True):
self.logger.write(text, level, showInfo)
##
# Prepares the environment.
# Build two environment: one for building and one for testing (launch).
- def prepare(self):
+ def prepare(self, add_env_launch=False):
if not self.build_dir.exists():
# create build dir
self.build_environ.silent = (self.config.USER.output_verbose_level < 5)
self.build_environ.set_full_environ(self.logger, environ_info)
+ if add_env_launch:
# create runtime environment
- self.launch_environ = src.environment.SalomeEnviron(self.config,
+ self.launch_environ = src.environment.SalomeEnviron(self.config,
src.environment.Environ(dict(os.environ)),
False)
- self.launch_environ.silent = True # no need to show here
- self.launch_environ.set_full_environ(self.logger, environ_info)
+ self.launch_environ.silent = True # no need to show here
+ self.launch_environ.set_full_environ(self.logger, environ_info)
for ee in C_COMPILE_ENV_LIST:
vv = self.build_environ.get(ee)
def cmake(self, options=""):
cmake_option = options
- # cmake_option +=' -DCMAKE_VERBOSE_MAKEFILE=ON -DSALOME_CMAKE_DEBUG=ON'
+ if "cmake_build_type" in self.config.APPLICATION:
+ self.set_cmake_build_type(self.config.APPLICATION.cmake_build_type)
+ # keep backward compatibility
+ if "debug" in self.config.APPLICATION and self.config.APPLICATION.debug == "yes":
+ self.debug_mode = True
+ self.cmake_build_type = 'Debug'
+
if 'cmake_options' in self.product_info:
cmake_option += " %s " % " ".join(
self.product_info.cmake_options.split())
- # add debug option
- if self.debug_mode:
- cmake_option += " -DCMAKE_BUILD_TYPE=Debug"
- else :
- cmake_option += " -DCMAKE_BUILD_TYPE=Release"
+ # add cmake build_type options
+ cmake_option += " -DCMAKE_BUILD_TYPE=" + self.cmake_build_type
# add verbose option if specified in application for this product.
if self.verbose_mode:
# In case CMAKE_GENERATOR is defined in environment,
# use it in spite of automatically detect it
if 'cmake_generator' in self.config.APPLICATION:
- cmake_option += " -DCMAKE_GENERATOR=\"%s\"" \
- % self.config.APPLICATION.cmake_generator
+ cmake_option += " -G \"%s\" -A x64 " % self.config.APPLICATION.cmake_generator
command = ("cmake %s -DCMAKE_INSTALL_PREFIX=%s %s" %
(cmake_option, self.install_dir, self.source_dir))
hh += " " + src.printcolors.printcWarning("DEBUG")
# make
command = 'msbuild'
- command = command + " /maxcpucount:" + str(nb_proc)
- if self.debug_mode:
- command = command + " /p:Configuration=Debug /p:Platform=x64 "
- else:
- command = command + " /p:Configuration=Release /p:Platform=x64 "
+ command+= " /maxcpucount:" + str(nb_proc)
+ command+= " /p:Configuration={} /p:Platform=x64 ".format(self.cmake_build_type)
command = command + " ALL_BUILD.vcxproj"
self.log_command(command)
def install(self):
if src.architecture.is_windows():
command = 'msbuild INSTALL.vcxproj'
- if self.debug_mode:
- command = command + " /p:Configuration=Debug /p:Platform=x64 "
- else:
- command = command + " /p:Configuration=Release /p:Platform=x64 "
+ command+= ' /p:Configuration={} /p:Platform=x64 '.format(self.cmake_build_type)
else :
command = 'make install'
self.log_command(command)
# Runs 'make_check'.
def check(self, command=""):
if src.architecture.is_windows():
- cmd = 'msbuild RUN_TESTS.vcxproj /p:Configuration=Release /p:Platform=x64 '
+ cmd = 'msbuild RUN_TESTS.vcxproj /p:Configuration={} /p:Platform=x64 '.format(self.cmake_build_type)
else :
if self.product_info.build_source=="autotools" :
cmd = 'make check'
pymodule = imp.load_source(product + "_compile_script", script)
self.nb_proc = nb_proc
retcode = pymodule.compil(self.config, self, self.logger)
- except:
+ except Exception:
__, exceptionValue, exceptionTraceback = sys.exc_info()
self.logger.write(str(exceptionValue), 1)
import traceback
self.build_environ.set("SAT_HPC", "1")
if self.debug_mode:
self.build_environ.set("SAT_DEBUG", "1")
+ if "cmake_build_type" in self.config.APPLICATION:
+ self.set_cmake_build_type(self.config.APPLICATION.cmake_build_type)
+ self.build_environ.set("SAT_CMAKE_BUILD_TYPE", self.cmake_build_type)
if self.verbose_mode:
self.build_environ.set("SAT_VERBOSE", "1")