except NameError:
pass
-PROPERTY_EXPRESSION = "^.+:.+$"
# Define all possible option for the compile command : sat compile <options>
parser = src.options.Options()
parser.add_option('p', 'products', 'list2', 'products',
- _('Optional: products to compile. This option can be'
- ' passed several time to compile several products.'))
-parser.add_option('', 'properties', 'string', 'properties',
- _('Optional: Filter the products by their properties.\n\tSyntax: '
- '--properties <property>:<value>'))
+ _('Optional: products to compile. This option accepts a comma separated list.'))
parser.add_option('', 'with_fathers', 'boolean', 'fathers',
_("Optional: build all necessary products to the given product (KERNEL is "
"build before building GUI)."), 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
- configuration regarding the passed options.
-
- :param options Options: The Options instance that stores the commands
- arguments
- :param cfg Config: The global configuration
- :param logger Logger: The logger instance to use for the display and
- logging
- :return: The list of (product name, product_informations).
- :rtype: List
- '''
- # Get the products to be prepared, regarding the options
- if options.products is None:
- # No options, get all products sources
- products = cfg.APPLICATION.products
- else:
- # if option --products, check that all products of the command line
- # are present in the application.
- products = options.products
- for p in products:
- if p not in cfg.APPLICATION.products:
- raise src.SatException(_("Product %(product)s "
- "not defined in application %(application)s") %
- { 'product': p, 'application': cfg.VARS.application} )
-
- # Construct the list of tuple containing
- # the products name and their definition
- products_infos = src.product.get_products_infos(products, cfg)
-
- # if the property option was passed, filter the list
- if options.properties:
- [prop, value] = options.properties.split(":")
- products_infos = [(p_name, p_info) for
- (p_name, p_info) in products_infos
- if "properties" in p_info and
- prop in p_info.properties and
- p_info.properties[prop] == value]
-
-
- # get rid of fixed products
- products_infos = [pi for pi in products_infos if not(
- src.product.product_is_fixed(pi[1]))]
-
- return products_infos
def get_children(config, p_name_p_info):
l_res = []
def log_step(logger, header, step):
logger.write("\r%s%s" % (header, " " * 30), 3)
logger.write("\r%s%s" % (header, step), 3)
- logger.write("\n==== %s \n" % src.printcolors.printcInfo(step), 4)
logger.flush()
def log_res_step(logger, res):
# Logging
len_end_line = 30
- logger.write("\n", 4, False)
- logger.write("################ ", 4)
header = _("Compilation of %s") % src.printcolors.printcLabel(p_name)
header += " %s " % ("." * (len_end_line - len(p_name)))
logger.write(header, 3)
- logger.write("\n", 4, False)
logger.flush()
# Do nothing if the product is not compilable
- if ("properties" in p_info and
- "compilation" in p_info.properties and
- p_info.properties.compilation == "no"):
-
+ if not src.product.product_compiles(p_info):
log_step(logger, header, "ignored")
logger.write("\n", 3, False)
continue
batch=True,
verbose=0,
logger_add_link = logger)
-
+
+
# Clean the the install directory
# if the corresponding option was called
if options.clean_install and not options.clean_all:
# Check if sources was already successfully installed
check_source = src.product.check_source(p_info)
- if not check_source:
- logger.write(_("Sources of product not found (try 'sat -h prepare') \n"))
- res += 1 #BUG
- continue
+ if not options.no_compile: # don't check sources with option --show!
+ if not check_source:
+ logger.write(_("Sources of product not found (try 'sat -h prepare') \n"))
+ res += 1 # one more error
+ continue
if src.product.product_is_salome(p_info):
# For salome modules, we check if the sources of configuration modules are present
# Check if it was already successfully installed
if src.product.check_installation(p_info):
- logger.write(_("Already installed\n"))
+ logger.write(_("Already installed"))
+ logger.write(_(" in %s" % p_info.install_dir), 4)
+ logger.write(_("\n"))
continue
# If the show option was called, do not launch the compilation
if options.no_compile:
- logger.write(_("Not installed\n"))
+ logger.write(_("Not installed in %s\n" % p_info.install_dir))
continue
# Check if the dependencies are installed
# 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)
+ src.product.add_compile_config_file(p_info, config)
if options.check:
# Do the unit tests (call the check command)
return res, len_end_line, error_step
-def add_compile_config_file(p_info, config):
- '''Execute the proper configuration command(s)
- in the product build directory.
-
- :param p_info Config: The specific config of the product
- :param config Config: The global configuration
- '''
- # Create the compile config
- compile_cfg = src.pyconf.Config()
- for prod_name in p_info.depend:
- if prod_name not in compile_cfg:
- compile_cfg.addMapping(prod_name,
- src.pyconf.Mapping(compile_cfg),
- "")
- prod_dep_info = src.product.get_product_config(config, prod_name, False)
- compile_cfg[prod_name] = prod_dep_info.version
- # Write it in the install directory of the product
- compile_cfg_path = os.path.join(p_info.install_dir, src.CONFIG_FILENAME)
- f = open(compile_cfg_path, 'w')
- compile_cfg.__save__(f)
- f.close()
def description():
'''method that is called when salomeTools is called with --help option.
# check that the command has been called with an application
src.check_config_has_application( runner.cfg )
- # Verify the --properties option
- if options.properties:
- oExpr = re.compile(PROPERTY_EXPRESSION)
- if not oExpr.search(options.properties):
- msg = _('WARNING: the "--properties" options must have the '
- 'following syntax:\n--properties <property>:<value>')
- logger.write(src.printcolors.printcWarning(msg), 1)
- logger.write("\n", 1)
- options.properties = None
-
# Print some informations
logger.write(_('Executing the compile commands in the build '
'directories of the products of '
src.print_info(logger, info)
# Get the list of products to treat
- products_infos = get_products_list(options, runner.cfg, logger)
+ products_infos = src.product.get_products_list(options, runner.cfg, logger)
+ products_infos = [pi for pi in products_infos if not(
+ src.product.product_is_fixed(pi[1]))]
if options.fathers:
# Extend the list with all recursive dependencies of the given products