parser.add_option('', 'stop_first_fail', 'boolean', 'stop_first_fail', _(
"Optional: Stops the command at first product compilation"
" fail."), False)
+parser.add_option('', 'check', 'boolean', 'check', _(
+ "Optional: execute the unit tests after compilation"), False)
+
+parser.add_option('', 'clean_build_after', 'boolean', 'clean_build_after',
+ _('Optional: remove the build directory after successful compilation'), False)
def get_products_list(options, cfg, logger):
'''method that gives the product list with their informations from
verbose=0,
logger_add_link = logger)
+ # Recompute the product information to get the right install_dir
+ # (it could change if there is a clean of the install directory)
+ p_info = src.product.get_product_config(config, p_name)
+
# Check if it was already successfully installed
if src.product.check_installation(p_info):
logger.write(_("Already installed\n"))
len_end_line)
if res_prod != 0:
- # Clean the install directory if there is any
- logger.write(_("Cleaning the install directory if there is any\n"),
- 5)
- sat.clean(config.VARS.application +
- " --products " + p_name +
- " --install",
- batch=True,
- verbose=0,
- logger_add_link = logger)
res += 1
+ if error_step != "CHECK":
+ # Clean the install directory if there is any
+ logger.write(_(
+ "Cleaning the install directory if there is any\n"),
+ 5)
+ sat.clean(config.VARS.application +
+ " --products " + p_name +
+ " --install",
+ batch=True,
+ verbose=0,
+ logger_add_link = logger)
+ else:
+ # Clean the build directory if the compilation and tests succeed
+ if options.clean_build_after:
+ log_step(logger, header, "CLEAN BUILD")
+ sat.clean(config.VARS.application +
+ " --products " + p_name +
+ " --build",
+ batch=True,
+ verbose=0,
+ logger_add_link = logger)
+
# Log the result
if res_prod > 0:
logger.write("\r%s%s" % (header, " " * len_end_line), 3)
logger.write("\r" + header + src.printcolors.printcError("KO ") + error_step)
logger.write("\n==== %(KO)s in compile of %(name)s \n" %
{ "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
+ if error_step == "CHECK":
+ logger.write(_("\nINSTALL directory = %s" %
+ src.printcolors.printcInfo(p_info.install_dir)), 3)
logger.flush()
else:
logger.write("\r%s%s" % (header, " " * len_end_line), 3)
:param config Config: The global configuration
:param logger Logger: The logger instance to use for the display
and logging
+ :param header Str: the header to display when logging
+ :param len_end Int: the lenght of the the end of line (used in display)
:return: 1 if it fails, else 0.
:rtype: int
'''
p_name, p_info = p_name_info
-
+
+ # Get the build procedure from the product configuration.
+ # It can be :
+ # build_sources : autotools -> build_configure, configure, make, make install
+ # build_sources : cmake -> cmake, make, make install
+ # build_sources : script -> script executions
+ res = 0
+ if (src.product.product_is_autotools(p_info) or
+ src.product.product_is_cmake(p_info)):
+ res, len_end_line, error_step = compile_product_cmake_autotools(sat,
+ p_name_info,
+ config,
+ options,
+ logger,
+ header,
+ len_end)
+ if src.product.product_has_script(p_info):
+ res, len_end_line, error_step = compile_product_script(sat,
+ p_name_info,
+ config,
+ options,
+ logger,
+ header,
+ len_end)
+
+ # Check that the install directory exists
+ if res==0 and not(os.path.exists(p_info.install_dir)):
+ res = 1
+ error_step = "NO INSTALL DIR"
+ msg = _("Error: despite the fact that all the steps ended successfully,"
+ " no install directory was found !")
+ logger.write(src.printcolors.printcError(msg), 4)
+ logger.write("\n", 4)
+ return res, len_end_line, error_step
+
+ # Add the config file corresponding to the dependencies/versions of the
+ # product that have been successfully compiled
+ if res==0:
+ logger.write(_("Add the config file in installation directory\n"), 5)
+ add_compile_config_file(p_info, config)
+
+ if options.check:
+ # Do the unit tests (call the check command)
+ log_step(logger, header, "CHECK")
+ res_check = sat.check(
+ config.VARS.application + " --products " + p_name,
+ verbose = 0,
+ logger_add_link = logger)
+ if res_check != 0:
+ error_step = "CHECK"
+
+ res += res_check
+
+ return res, len_end_line, error_step
+
+def compile_product_cmake_autotools(sat,
+ p_name_info,
+ config,
+ options,
+ logger,
+ header,
+ len_end):
+ '''Execute the proper build procedure for autotools or cmake
+ in the product build directory.
+
+ :param p_name_info tuple: (str, Config) => (product_name, product_info)
+ :param config Config: The global configuration
+ :param logger Logger: The logger instance to use for the display
+ and logging
+ :param header Str: the header to display when logging
+ :param len_end Int: the lenght of the the end of line (used in display)
+ :return: 1 if it fails, else 0.
+ :rtype: int
+ '''
+ p_name, p_info = p_name_info
+
# Execute "sat configure", "sat make" and "sat install"
res = 0
error_step = ""
if res_c > 0:
error_step = "CONFIGURE"
- else:
+ else:
# Logging and sat command call for make step
# Logging take account of the fact that the product has a compilation
# script or not
if res_mi > 0:
error_step = "MAKE INSTALL"
+
+ return res, len_end_line, error_step
- # Check that the install directory exists
- if res==0 and not(os.path.exists(p_info.install_dir)):
- res = 1
- error_step = "NO INSTALL DIR"
- msg = _("Error: despite the fact that all the steps ended successfully,"
- " no install directory was found !")
- logger.write(src.printcolors.printcError(msg), 4)
- logger.write("\n", 4)
+def compile_product_script(sat,
+ p_name_info,
+ config,
+ options,
+ logger,
+ header,
+ len_end):
+ '''Execute the script build procedure in the product build directory.
- # Add the config file corresponding to the dependencies/versions of the
- # product that have been successfully compiled
- if res==0:
- logger.write(_("Add the config file in installation directory\n"), 5)
- add_compile_config_file(p_info, config)
+ :param p_name_info tuple: (str, Config) => (product_name, product_info)
+ :param config Config: The global configuration
+ :param logger Logger: The logger instance to use for the display
+ and logging
+ :param header Str: the header to display when logging
+ :param len_end Int: the lenght of the the end of line (used in display)
+ :return: 1 if it fails, else 0.
+ :rtype: int
+ '''
+ p_name, p_info = p_name_info
- return res, len_end_line, error_step
+ # Execute "sat configure", "sat make" and "sat install"
+ error_step = ""
+
+ # Logging and sat command call for the script step
+ scrit_path_display = src.printcolors.printcLabel(p_info.compil_script)
+ log_step(logger, header, "SCRIPT " + scrit_path_display)
+ len_end_line = len_end + len(scrit_path_display)
+ res = sat.script(config.VARS.application + " --products " + p_name,
+ verbose = 0,
+ logger_add_link = logger)
+ log_res_step(logger, res)
+
+ return res, len_end_line, error_step
def add_compile_config_file(p_info, config):
'''Execute the proper configuration command(s)
code = res
if code != 0:
code = 1
- return code
\ No newline at end of file
+ return code