3 # Copyright (C) 2010-2012 CEA/DEN
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 In this file are implemented the methods
21 relative to the product notion of salomeTools
29 import src.debug as DBG
30 import src.versionMinorMajorPatch as VMMP
32 AVAILABLE_VCS = ['git', 'svn', 'cvs']
34 CONFIG_FILENAME = "sat-config.pyconf" # trace product depends version(s)
35 PRODUCT_FILENAME = "sat-product.pyconf" # trace product compile config
36 config_expression = "^config-\d+$"
38 def get_product_config(config, product_name, with_install_dir=True):
39 """Get the specific configuration of a product from the global configuration
41 :param config Config: The global configuration
42 :param product_name str: The name of the product
43 :param with_install_dir boolean: If false, do not provide an install
44 directory (at false only for internal use
45 of the function check_config_exists)
46 :return: the specific configuration of the product
50 # Get the version of the product from the application definition
51 version = config.APPLICATION.products[product_name]
53 # Define debug and dev modes
54 # Get the tag if a dictionary is given in APPLICATION.products for the
63 # if no version, then take the default one defined in the application
64 if isinstance(version, bool) or isinstance(version, str):
65 # in this case tag is mandatory, not debug, verbose, dev
66 if 'debug' in config.APPLICATION:
67 debug = config.APPLICATION.debug
68 if 'verbose' in config.APPLICATION:
69 verbose = config.APPLICATION.verbose
70 if 'dev' in config.APPLICATION:
71 dev = config.APPLICATION.dev
72 if 'hpc' in config.APPLICATION:
73 hpc = config.APPLICATION.hpc
74 if 'base' in config.APPLICATION:
75 base = config.APPLICATION.base
77 # special case for which only the product name is mentionned
78 if isinstance(version, bool):
79 version = config.APPLICATION.tag
81 if isinstance(version, src.pyconf.Mapping):
84 if not 'tag' in dic_version:
85 version = config.APPLICATION.tag
87 version = dic_version.tag
89 # Get the debug if any
90 if 'debug' in dic_version:
91 debug = dic_version.debug
92 elif 'debug' in config.APPLICATION:
93 debug = config.APPLICATION.debug
95 # Get the verbose if any
96 if 'verbose' in dic_version:
97 verbose = dic_version.verbose
98 elif 'verbose' in config.APPLICATION:
99 verbose = config.APPLICATION.verbose
102 if 'dev' in dic_version:
103 dev = dic_version.dev
104 elif 'dev' in config.APPLICATION:
105 dev = config.APPLICATION.dev
108 if 'hpc' in dic_version:
109 hpc = dic_version.hpc
110 elif 'hpc' in config.APPLICATION:
111 hpc = config.APPLICATION.hpc
113 # Get the base if any
114 if 'base' in dic_version:
115 base = dic_version.base
117 # Get the section if any
118 if 'section' in dic_version:
119 section = dic_version.section
121 # this case occur when version is overwritten, cf sat # 8897
122 if isinstance(version, dict):
123 dic_version = version
124 # Get the version/tag
125 if not 'tag' in dic_version:
126 version = config.APPLICATION.tag
128 version = dic_version["tag"]
130 # Get the debug if any
131 if 'debug' in dic_version:
132 debug = dic_version["debug"]
133 elif 'debug' in config.APPLICATION:
134 debug = config.APPLICATION.debug
136 # Get the verbose if any
137 if 'verbose' in dic_version:
138 verbose = dic_version["verbose"]
139 elif 'verbose' in config.APPLICATION:
140 verbose = config.APPLICATION.verbose
143 if 'dev' in dic_version:
144 dev = dic_version["dev"]
145 elif 'dev' in config.APPLICATION:
146 dev = config.APPLICATION.dev
149 if 'hpc' in dic_version:
150 hpc = dic_version.hpc
151 elif 'hpc' in config.APPLICATION:
152 hpc = config.APPLICATION.hpc
154 # Get the base if any
155 if 'base' in dic_version:
156 base = dic_version["base"]
158 # Get the section if any
159 if 'section' in dic_version:
160 section = dic_version['section']
163 # substitute some character with _ in order to get the correct definition
164 # in config.PRODUCTS. This is done because the pyconf tool does not handle
165 # the . and - characters
166 for c in ".-": vv = vv.replace(c, "_")
169 if product_name in config.PRODUCTS:
170 # Search for the product description in the configuration
171 prod_info = get_product_section(config, product_name, vv, section)
173 # get salomeTool version
174 prod_info.sat_version = src.get_salometool_version(config)
176 # merge opt_depend in depend
177 if prod_info is not None and 'opt_depend' in prod_info:
178 for depend in prod_info.opt_depend:
179 if depend in config.APPLICATION.products:
180 prod_info.depend.append(depend,'')
183 # In case of a product get with a vcs,
184 # put the tag (equal to the version)
185 if prod_info is not None and prod_info.get_source in AVAILABLE_VCS:
187 if prod_info.get_source == 'git':
188 prod_info.git_info.tag = version
190 if prod_info.get_source == 'svn':
191 prod_info.svn_info.tag = version
193 if prod_info.get_source == 'cvs':
194 prod_info.cvs_info.tag = version
196 # In case of a fixed product,
197 # define the install_dir (equal to the version)
198 if prod_info is not None and \
199 (os.path.isdir(version) or version.startswith("/")):
200 # we consider a (fixed) path existing paths;
201 # or paths starting with '/' (the objective is to print a correct
202 # message to the user in case of non existing path.)
203 prod_info.install_dir = version
204 prod_info.get_source = "fixed"
206 # Check if the product is defined as native in the application
207 if prod_info is not None:
208 if version == "native":
209 prod_info.get_source = "native"
210 elif prod_info.get_source == "native":
211 msg = _("The product %(prod)s has version %(ver)s but is "
212 "declared as native in its definition" %
213 { 'prod': prod_info.name, 'ver': version})
214 raise src.SatException(msg)
216 # If there is no definition but the product is declared as native,
217 # construct a new definition containing only the get_source key
218 if prod_info is None and version == "native":
219 prod_info = src.pyconf.Config()
220 prod_info.name = product_name
221 prod_info.get_source = "native"
223 # If there is no definition but the product is fixed,
224 # construct a new definition containing only the product name
225 if prod_info is None and os.path.isdir(version):
226 prod_info = src.pyconf.Config()
227 prod_info.name = product_name
228 prod_info.get_source = "fixed"
229 prod_info.addMapping("environ", src.pyconf.Mapping(prod_info), "")
232 # If prod_info is still None, it means that there is no product definition
233 # in the config. The user has to provide it.
234 if prod_info is None:
235 prod_pyconf_path = src.find_file_in_lpath(product_name + ".pyconf",
236 config.PATHS.PRODUCTPATH)
237 if not prod_pyconf_path:
239 No definition found for the product %(1)s.
240 Please create a %(1)s.pyconf file somewhere in:
243 "2": PP.pformat(config.PATHS.PRODUCTPATH) }
246 No definition corresponding to the version %(1)s was found in the file:
248 Please add a section in it.""") % {"1" : vv, "2" : prod_pyconf_path}
249 raise src.SatException(msg)
251 # Set the debug, dev and version keys
252 prod_info.debug = debug
253 prod_info.verbose = verbose
256 prod_info.version = version
258 # Set the archive_info if the product is get in archive mode
259 if prod_info.get_source == "archive":
260 if not "archive_info" in prod_info:
261 prod_info.addMapping("archive_info",
262 src.pyconf.Mapping(prod_info),
264 if "archive_name" in prod_info.archive_info:
265 arch_name = prod_info.archive_info.archive_name
266 elif "archive_prefix" in prod_info.archive_info:
267 arch_name = prod_info.archive_info.archive_prefix + "-" + version + ".tar.gz"
270 arch_name = product_name + "-" + version + ".tar.gz"
272 arch_path = src.find_file_in_lpath(arch_name,
273 config.PATHS.ARCHIVEPATH)
275 # arch_path is not found. It may generate an error in sat source,
276 # unless the archive is found in ftp serveur
277 msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
278 {"1" : arch_name, "2" : prod_info.name}
279 DBG.tofix(msg, config.PATHS.ARCHIVEPATH)
280 prod_info.archive_info.archive_name = arch_name #without path
282 prod_info.archive_info.archive_name = arch_path
285 # If the product compiles with a script, check the script existence
286 # and if it is executable
287 if product_has_script(prod_info):
288 # Check the compil_script key existence
289 if "compil_script" not in prod_info:
291 No compilation script found for the product %s.
292 Please provide a 'compil_script' key in its definition.""") % product_name
293 raise src.SatException(msg)
295 # Get the path of the script file
296 # if windows supposed '.bat', if linux supposed '.sh'
297 # but user set extension script file in his pyconf as he wants, no obligation.
298 script = prod_info.compil_script
299 script_name = os.path.basename(script)
300 if script == script_name:
301 # Only a name is given. Search in the default directory
302 script_path = src.find_file_in_lpath(script_name, config.PATHS.PRODUCTPATH, "compil_scripts")
304 msg = _("Compilation script %s not found in") % script_name
305 DBG.tofix(msg, config.PATHS.PRODUCTPATH, True) # say where searched
306 script_path = "%s_(Not_Found_by_Sat!!)" % script_name
307 prod_info.compil_script = script_path
310 # Check that the script is executable
311 if os.path.exists(prod_info.compil_script) and not os.access(prod_info.compil_script, os.X_OK):
312 DBG.tofix("Compilation script file is not in 'execute mode'", prod_info.compil_script, True)
314 # Get the full paths of all the patches
315 if product_has_patches(prod_info):
318 for patch in prod_info.patches:
320 # If only a filename, then search for the patch in the PRODUCTPATH
321 if os.path.basename(patch_path) == patch_path:
322 # Search in the PRODUCTPATH/patches
323 patch_path = src.find_file_in_lpath(patch,
324 config.PATHS.PRODUCTPATH,
327 msg = _("Patch %(patch_name)s for %(prod_name)s not found:"
328 "\n" % {"patch_name" : patch,
329 "prod_name" : prod_info.name})
330 raise src.SatException(msg)
331 patches.append(patch_path)
333 DBG.tofix("problem in prod_info.patches", prod_info)
334 prod_info.patches = patches
336 # Get the full paths of the environment scripts
337 if product_has_env_script(prod_info):
338 env_script_path = prod_info.environ.env_script
339 # If only a filename, then search for the environment script
340 # in the PRODUCTPATH/env_scripts
341 if os.path.basename(env_script_path) == env_script_path:
342 # Search in the PRODUCTPATH/env_scripts
343 env_script_path = src.find_file_in_lpath(
344 prod_info.environ.env_script,
345 config.PATHS.PRODUCTPATH,
347 if not env_script_path:
348 msg = _("Environment script %(env_name)s for %(prod_name)s not "
349 "found.\n" % {"env_name" : env_script_path,
350 "prod_name" : prod_info.name})
351 raise src.SatException(msg)
353 prod_info.environ.env_script = env_script_path
356 # The variable with_install_dir is at false only for internal use
357 # of the function get_install_dir
359 # Save the install_dir key if there is any
360 if "install_dir" in prod_info and not "install_dir_save" in prod_info:
361 prod_info.install_dir_save = prod_info.install_dir
363 # if it is not the first time the install_dir is computed, it means
364 # that install_dir_save exists and it has to be taken into account.
365 if "install_dir_save" in prod_info:
366 prod_info.install_dir = prod_info.install_dir_save
368 # Set the install_dir key
369 prod_info.install_dir = get_install_dir(config, base, version, prod_info)
373 def get_product_section(config, product_name, version, section=None, verbose=False):
374 """Get the product description from the configuration
376 :param config Config: The global configuration
377 :param product_name str: The product name
378 :param version str: The version of the product as 'V8_4_0', or else.
379 :param section str: The searched section (if not None, the section is
381 :return: The product description
385 # if section is not None, try to get the corresponding section
386 aProd = config.PRODUCTS[product_name]
388 versionMMP = VMMP.MinorMajorPatch(version)
389 except: # example setuptools raise "minor in major_minor_patch is not integer: '0_6c11'"
391 DBG.write("get_product_section for product %s '%s' as version '%s'" % (product_name, version, versionMMP),
392 (section, aProd.keys()), verbose)
393 # DBG.write("yoo1", aProd, True)
395 if section not in aProd:
397 # returns specific information for the given version
398 prod_info = aProd[section]
399 prod_info.section = section
400 prod_info.from_file = aProd.from_file
403 # If it exists, get the information of the product_version
404 # ex: 'version_V6_6_0' as salome version classical syntax
405 if "version_" + version in aProd:
406 DBG.write("found section for version_" + version, "", verbose)
407 # returns specific information for the given version
408 prod_info = aProd["version_" + version]
409 prod_info.section = "version_" + version
410 prod_info.from_file = aProd.from_file
413 # Else, check if there is a description for multiple versions
414 l_section_names = aProd.keys()
415 l_section_ranges = []
417 for name in l_section_names:
418 # DBG.write("name", name,True)
419 aRange = VMMP.getRange_majorMinorPatch(name)
420 if aRange is not None:
421 DBG.write("found version range for section '%s'" % name, aRange, verbose)
422 l_section_ranges.append((name, aRange))
424 if versionMMP is not None and len(l_section_ranges) > 0:
425 for name, (vmin, vmax) in l_section_ranges:
426 if versionMMP >= vmin and versionMMP <= vmax:
427 tagged.append((name, [vmin, vmax]))
430 DBG.write("multiple version ranges tagged for '%s', fix it" % version,
431 PP.pformat(tagged), True)
433 if len(tagged) == 1: # ok
434 DBG.write("one version range tagged for '%s'" % version,
435 PP.pformat(tagged), verbose)
436 name, (vmin, vmax) = tagged[0]
437 prod_info = aProd[name]
438 prod_info.section = name
439 prod_info.from_file = aProd.from_file
442 # Else, get the standard informations
443 if "default" in aProd:
444 # returns the generic information (given version not found)
445 prod_info = aProd.default
446 DBG.write("default tagged for '%s'" % version, prod_info, verbose)
447 prod_info.section = "default"
448 prod_info.from_file = aProd.from_file
451 # if noting was found, return None
454 def get_install_dir(config, base, version, prod_info):
455 """Compute the installation directory of a given product
457 :param config Config: The global configuration
458 :param base str: This corresponds to the value given by user in its
459 application.pyconf for the specific product. If "yes", the
460 user wants the product to be in base. If "no", he wants the
461 product to be in the application workdir
462 :param version str: The version of the product
463 :param product_info Config: The configuration specific to
466 :return: The path of the product installation
471 # base : corresponds to what is specified in application pyconf (either from the global key, or from a product dict)
472 # prod_info.install_dir : corresponds to what is specified in product pyconf (usually "base" for prerequisites)
473 if (("install_dir" in prod_info and prod_info.install_dir == "base")
476 # what was declared in application has precedence over what was said in product pyconf
477 # no_base="yes" has precedence over base == "yes"
478 if (base == "no" or ("no_base" in config.APPLICATION
479 and config.APPLICATION.no_base == "yes")):
483 install_dir = get_base_install_dir(config, prod_info, version)
485 if "install_dir" not in prod_info or prod_info.install_dir == "base":
486 # Set it to the default value (in application directory)
487 install_dir = os.path.join(config.APPLICATION.workdir,
488 config.INTERNAL.config.install_dir,
491 install_dir = prod_info.install_dir
495 def get_base_install_dir(config, prod_info, version):
496 """Compute the installation directory of a product in base
498 :param config Config: The global configuration
499 :param product_info Config: The configuration specific to
501 :param version str: The version of the product
502 :return: The path of the product installation
505 base_path = src.get_base_path(config)
506 prod_dir = os.path.join(base_path, prod_info.name + "-" + version)
507 if not os.path.exists(prod_dir):
508 return os.path.join(prod_dir, "config-1")
510 exists, install_dir = check_config_exists(config, prod_dir, prod_info)
514 # Find the first config-<i> directory that is available in the product
519 install_dir = os.path.join(prod_dir, "config-%i" % label)
520 if os.path.exists(install_dir):
527 def add_compile_config_file(p_info, config):
528 '''Execute the proper configuration command(s)
529 in the product build directory.
531 :param p_info Config: The specific config of the product
532 :param config Config: The global configuration
534 # Create the compile config
535 # DBG.write("add_compile_config_file", p_info, True)
536 res = src.pyconf.Config()
537 res.addMapping(p_info.name, src.pyconf.Mapping(res), "")
538 res[p_info.name]= p_info.version
540 for prod_name in p_info.depend:
541 if prod_name not in res:
542 res.addMapping(prod_name, src.pyconf.Mapping(res), "")
543 prod_dep_info = src.product.get_product_config(config, prod_name, False)
544 res[prod_name] = prod_dep_info.version
545 # Write it in the install directory of the product
546 # This file is for automatic reading/checking
547 # see check_config_exists method
548 aFile = os.path.join(p_info.install_dir, CONFIG_FILENAME)
549 with open(aFile, 'w') as f:
552 # this file is not mandatory, is for human eye reading
553 aFile = os.path.join(p_info.install_dir, PRODUCT_FILENAME)
555 with open(aFile, 'w') as f:
556 p_info.__save__(f, evaluated=True) # evaluated expressions mode
558 # sometime some information cannot be evaluated.
559 # for example, in the context of non VCS archives, information on git server is not available.
560 DBG.write("Warning : sat was not able to evaluate and write down some information in file %s" % aFile)
563 def check_config_exists(config, prod_dir, prod_info, verbose=False):
565 Verify that the installation directory of a product in a base exists.
566 Check all the config-<i>/sat-config.py files found for correspondence
567 with current config and prod_info depend-version-tags
569 :param config Config: The global configuration
570 :param prod_dir str: The product installation directory path
572 :param product_info Config: The configuration specific to
574 :return: True or false is the installation is found or not
575 and if it is found, the path of the found installation
576 :rtype: (boolean, str)
578 # check if the directories or files of the directory corresponds to the
579 # directory installation of the product
580 if os.path.isdir(prod_dir):
581 l_dir_and_files = os.listdir(prod_dir)
583 raise Exception("Inexisting directory '%s'" % prod_dir)
585 DBG.write("check_config_exists 000", (prod_dir, l_dir_and_files), verbose)
586 DBG.write("check_config_exists 111", prod_info, verbose)
588 for dir_or_file in l_dir_and_files:
589 oExpr = re.compile(config_expression)
590 if not(oExpr.search(dir_or_file)):
591 # in mode BASE, not config-<i>, not interesting
592 # DBG.write("not interesting", dir_or_file, True)
594 # check if there is the file sat-config.pyconf file in the installation
596 config_file = os.path.join(prod_dir, dir_or_file, CONFIG_FILENAME)
597 DBG.write("check_config_exists 222", config_file, verbose)
598 if not os.path.exists(config_file):
601 # check if there is the config described in the file corresponds the
602 # dependencies of the product
603 config_corresponds = True
604 compile_cfg = src.pyconf.Config(config_file)
605 for prod_dep in prod_info.depend:
606 # if the dependency is not in the config,
607 # the config does not correspond
608 if prod_dep not in compile_cfg:
609 config_corresponds = False
612 prod_dep_info = get_product_config(config, prod_dep, False)
613 # If the version of the dependency does not correspond,
614 # the config does not correspond
615 if prod_dep_info.version != compile_cfg[prod_dep]:
616 config_corresponds = False
619 if config_corresponds:
620 for prod_name in compile_cfg:
621 # assume new compatibility with prod_name in sat-config.pyconf files
622 if prod_name == prod_info.name:
623 if prod_info.version == compile_cfg[prod_name]:
624 DBG.write("check_config_exists OK 333", compile_cfg, verbose)
626 else: # no correspondence with newer with prod_name sat-config.pyconf files
627 config_corresponds = False
630 # as old compatibility without prod_name sat-config.pyconf files
631 if prod_name not in prod_info.depend:
632 # here there is an unexpected depend in an old compilation
633 config_corresponds = False
636 if config_corresponds: # returns (and stops) at first correspondence found
637 DBG.write("check_config_exists OK 444", dir_or_file, verbose)
638 return True, os.path.join(prod_dir, dir_or_file)
640 # no correspondence found
645 def get_products_infos(lproducts, config):
646 """Get the specific configuration of a list of products
648 :param lproducts List: The list of product names
649 :param config Config: The global configuration
650 :return: the list of tuples
651 (product name, specific configuration of the product)
652 :rtype: [(str, Config)]
655 # Loop on product names
656 for prod in lproducts:
657 # Get the specific configuration of the product
658 prod_info = get_product_config(config, prod)
659 if prod_info is not None:
660 products_infos.append((prod, prod_info))
662 msg = _("The %s product has no definition in the configuration.") % prod
663 raise src.SatException(msg)
664 return products_infos
667 def get_products_list(options, cfg, logger):
669 method that gives the product list with their informations from
670 configuration regarding the passed options.
672 :param options Options: The Options instance that stores the commands arguments
673 :param cfg Config: The global configuration
674 :param logger Logger: The logger instance to use for the display and logging
675 :return: The list of (product name, product_informations).
678 # Get the products to be prepared, regarding the options
679 if options.products is None:
680 # No options, get all products sources
681 products = cfg.APPLICATION.products
683 # if option --products, check that all products of the command line
684 # are present in the application.
685 """products = options.products
687 if p not in cfg.APPLICATION.products:
688 raise src.SatException(_("Product %(product)s "
689 "not defined in application %(application)s") %
690 { 'product': p, 'application': cfg.VARS.application} )"""
692 products = src.getProductNames(cfg, options.products, logger)
694 # Construct the list of tuple containing
695 # the products name and their definition
696 resAll = src.product.get_products_infos(products, cfg)
698 # if the property option was passed, filter the list
699 if options.properties: # existing properties
703 prop, value = options.properties # for example 'is_SALOME_module', 'yes'
704 for p_name, p_info in resAll:
706 if p_info.properties[prop] == value:
707 res.append((p_name, p_info))
714 if len(ok) != len(resAll):
715 logger.trace("on properties %s\n products accepted:\n %s\n products rejected:\n %s\n" %
716 (options.properties, PP.pformat(sorted(ok)), PP.pformat(sorted(ko))))
718 logger.warning("properties %s\n seems useless with no products rejected" %
719 (options.properties))
721 res = resAll # not existing properties as all accepted
726 def get_product_dependencies(config, product_info):
728 Get recursively the list of products that are
729 in the product_info dependencies
731 :param config Config: The global configuration
732 :param product_info Config: The configuration specific to
734 :return: the list of products in dependence
737 if "depend" not in product_info or product_info.depend == []:
740 for prod in product_info.depend:
741 if prod == product_info.name:
745 prod_info = get_product_config(config, prod)
746 dep_prod = get_product_dependencies(config, prod_info)
747 for prod_in_dep in dep_prod:
748 if prod_in_dep not in res:
749 res.append(prod_in_dep)
752 def check_installation(product_info):
754 Verify if a product is well installed. Checks install directory presence
755 and some additional files if it is defined in the config
757 :param product_info Config: The configuration specific to
759 :return: True if it is well installed
762 if not product_compiles(product_info):
764 install_dir = product_info.install_dir
765 if not os.path.exists(install_dir):
767 if ("present_files" in product_info and
768 "install" in product_info.present_files):
769 for file_relative_path in product_info.present_files.install:
770 file_path = os.path.join(install_dir, file_relative_path)
771 if not os.path.exists(file_path):
775 def check_source(product_info):
776 """Verify if a sources of product is preset. Checks source directory presence
778 :param product_info Config: The configuration specific to
780 :return: True if it is well installed
783 DBG.write("check_source product_info", product_info)
784 source_dir = product_info.source_dir
785 if not os.path.exists(source_dir):
787 if ("present_files" in product_info and
788 "source" in product_info.present_files):
789 for file_relative_path in product_info.present_files.source:
790 file_path = os.path.join(source_dir, file_relative_path)
791 if not os.path.exists(file_path):
795 def product_is_salome(product_info):
796 """Know if a product is a SALOME module
798 :param product_info Config: The configuration specific to
800 :return: True if the product is a SALOME module, else False
803 return ("properties" in product_info and
804 "is_SALOME_module" in product_info.properties and
805 product_info.properties.is_SALOME_module == "yes")
807 def product_is_fixed(product_info):
808 """Know if a product is fixed
810 :param product_info Config: The configuration specific to
812 :return: True if the product is fixed, else False
815 get_src = product_info.get_source
816 return get_src.lower() == 'fixed'
818 def product_is_native(product_info):
819 """Know if a product is native
821 :param product_info Config: The configuration specific to
823 :return: True if the product is native, else False
826 get_src = product_info.get_source
827 return get_src.lower() == 'native'
829 def product_is_dev(product_info):
830 """Know if a product is in dev mode
832 :param product_info Config: The configuration specific to
834 :return: True if the product is in dev mode, else False
837 dev = product_info.dev
838 res = (dev.lower() == 'yes')
839 DBG.write('product_is_dev %s' % product_info.name, res)
840 # if product_info.name == "XDATA": return True #test #10569
843 def product_is_hpc(product_info):
844 """Know if a product is in hpc mode
846 :param product_info Config: The configuration specific to
848 :return: True if the product is in hpc mode, else False
851 hpc = product_info.hpc
852 res = (hpc.lower() == 'yes')
855 def product_is_debug(product_info):
856 """Know if a product is in debug mode
858 :param product_info Config: The configuration specific to
860 :return: True if the product is in debug mode, else False
863 debug = product_info.debug
864 return debug.lower() == 'yes'
866 def product_is_verbose(product_info):
867 """Know if a product is in verbose mode
869 :param product_info Config: The configuration specific to
871 :return: True if the product is in verbose mode, else False
874 verbose = product_info.verbose
875 return verbose.lower() == 'yes'
877 def product_is_autotools(product_info):
878 """Know if a product is compiled using the autotools
880 :param product_info Config: The configuration specific to
882 :return: True if the product is autotools, else False
885 build_src = product_info.build_source
886 return build_src.lower() == 'autotools'
888 def product_is_cmake(product_info):
889 """Know if a product is compiled using the cmake
891 :param product_info Config: The configuration specific to
893 :return: True if the product is cmake, else False
896 build_src = product_info.build_source
897 return build_src.lower() == 'cmake'
899 def product_is_vcs(product_info):
900 """Know if a product is download using git, svn or cvs (not archive)
902 :param product_info Config: The configuration specific to
904 :return: True if the product is vcs, else False
907 return product_info.get_source in AVAILABLE_VCS
909 def product_is_smesh_plugin(product_info):
910 """Know if a product is a SMESH plugin
912 :param product_info Config: The configuration specific to
914 :return: True if the product is a SMESH plugin, else False
917 return ("properties" in product_info and
918 "smesh_plugin" in product_info.properties and
919 product_info.properties.smesh_plugin == "yes")
921 def product_is_cpp(product_info):
922 """Know if a product is cpp
924 :param product_info Config: The configuration specific to
926 :return: True if the product is a cpp, else False
929 return ("properties" in product_info and
930 "cpp" in product_info.properties and
931 product_info.properties.cpp == "yes")
933 def product_compiles(product_info):
935 Know if a product compiles or not
936 (some products do not have a compilation procedure)
938 :param product_info Config: The configuration specific to
940 :return: True if the product compiles, else False
943 return not("properties" in product_info and
944 "compilation" in product_info.properties and
945 product_info.properties.compilation == "no")
947 def product_has_script(product_info):
948 """Know if a product has a compilation script
950 :param product_info Config: The configuration specific to
952 :return: True if the product it has a compilation script, else False
955 if "build_source" not in product_info:
958 build_src = product_info.build_source
959 return build_src.lower() == 'script'
961 def product_has_env_script(product_info):
962 """Know if a product has an environment script
964 :param product_info Config: The configuration specific to
966 :return: True if the product it has an environment script, else False
969 return "environ" in product_info and "env_script" in product_info.environ
971 def product_has_patches(product_info):
972 """Know if a product has one or more patches
974 :param product_info Config: The configuration specific to
976 :return: True if the product has one or more patches
979 res = ( "patches" in product_info and len(product_info.patches) > 0 )
980 DBG.write('product_has_patches %s' % product_info.name, res)
981 # if product_info.name == "XDATA": return True #test #10569
984 def product_has_logo(product_info):
985 """Know if a product has a logo (YACSGEN generate)
987 :param product_info Config: The configuration specific to
989 :return: The path of the logo if the product has a logo, else False
992 if ("properties" in product_info and
993 "logo" in product_info.properties):
994 return product_info.properties.logo
998 def product_has_licence(product_info, path):
999 """Find out if a product has a licence
1001 :param product_info Config: The configuration specific to the product
1002 :param path Str: The path where to search for the licence
1003 :return: The name of the licence file (the complete path if it is found in the path, else the name, else False
1006 if ("properties" in product_info and
1007 "licence" in product_info.properties):
1008 licence_name = product_info.properties.licence
1010 # search for licence_name in path
1011 # a- consolidate the path into one signe string licence_path
1012 licence_path=path[0]
1013 for lpath in path[1:]:
1014 licence_path=licence_path+":"+lpath
1015 licence_path_list=licence_path.split(":")
1016 licence_fullname = src.find_file_in_lpath(licence_name, licence_path_list)
1017 if licence_fullname:
1018 return licence_fullname
1020 # if the search of licence in path failed, we return its name (not the full path)
1024 return False # product has no licence
1026 def product_has_salome_gui(product_info):
1027 """Know if a product has a SALOME gui
1029 :param product_info Config: The configuration specific to
1031 :return: True if the product has a SALOME gui, else False
1034 return ("properties" in product_info and
1035 "has_salome_gui" in product_info.properties and
1036 product_info.properties.has_salome_gui == "yes")
1038 def product_is_mpi(product_info):
1039 """Know if a product has openmpi in its dependencies
1041 :param product_info Config: The configuration specific to
1043 :return: True if the product has openmpi inits dependencies
1046 return "openmpi" in product_info.depend
1048 def product_is_generated(product_info):
1049 """Know if a product is generated (YACSGEN)
1051 :param product_info Config: The configuration specific to
1053 :return: True if the product is generated
1056 return ("properties" in product_info and
1057 "generate" in product_info.properties and
1058 product_info.properties.generate == "yes")
1060 def product_is_compile_time(product_info):
1061 """Know if a product is only used at compile time
1063 :param product_info Config: The configuration specific to
1065 :return: True if the product is only used at compile time
1068 return ("properties" in product_info and
1069 "compile_time" in product_info.properties and
1070 product_info.properties.compile_time == "yes")
1073 def product_test_property(product_info, property_name, property_value):
1074 """Generic function to test if a product has a property set to a value
1076 :param product_info Config: The configuration specific to
1078 :param property_name : The name of the property to check
1079 :param property_value : The value of the property to test
1080 :return: True if the product has the property and the property is set to property_value
1083 # first check if product has the property
1084 if not ("properties" in product_info and
1085 property_name in product_info.properties):
1088 # then check to the property is set to property_value
1089 eval_expression = 'product_info.properties.%s == "%s"' % (property_name,property_value)
1090 result = eval(eval_expression)
1095 def get_product_components(product_info):
1096 """Get the component list to generate with the product
1098 :param product_info Config: The configuration specific to
1100 :return: The list of names of the components
1104 if not product_is_generated(product_info):
1108 if "component_name" in product_info:
1109 compo_list = product_info.component_name
1111 if isinstance(compo_list, str):
1112 compo_list = [ compo_list ]