Salome HOME
Add configure command first version
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 18 May 2016 09:14:11 +0000 (11:14 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Wed, 18 May 2016 09:14:11 +0000 (11:14 +0200)
commands/configure.py [new file with mode: 0644]
data/products/PRODUCT_CVS.pyconf
src/compilation.py
src/logger.py
src/product.py

diff --git a/commands/configure.py b/commands/configure.py
new file mode 100644 (file)
index 0000000..17341d8
--- /dev/null
@@ -0,0 +1,216 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+#  Copyright (C) 2010-2012  CEA/DEN
+#
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
+#
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+
+import os
+
+import src
+
+# Define all possible option for configure command :  sat configure <options>
+parser = src.options.Options()
+parser.add_option('p', 'products', 'list2', 'products',
+    _('products to configure. This option can be'
+    ' passed several time to configure several products.'))
+parser.add_option('o', 'option', 'string', 'option',
+    _('Option to add to the configure or cmake command.'), "")
+
+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)
+    
+    products_infos = [pi for pi in products_infos if not(src.product.product_is_native(pi[1]) or src.product.product_is_fixed(pi[1]))]
+    
+    return products_infos
+
+def log_step(logger, header, step):
+    logger.write("\r%s%s" % (header, " " * 20), 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):
+    if res == 0:
+        logger.write("%s \n" % src.printcolors.printcSuccess("OK"), 4)
+        logger.flush()
+    else:
+        logger.write("%s \n" % src.printcolors.printcError("KO"), 4)
+        logger.flush()
+
+def configure_all_products(config, products_infos, conf_option, logger):
+    '''Execute the proper configuration commands 
+       in each product build directory.
+
+    :param config Config: The global configuration
+    :param products_info list: List of 
+                                 (str, Config) => (product_name, product_info)
+    :param conf_option str: The options to add to the command
+    :param logger Logger: The logger instance to use for the display and logging
+    :return: the number of failing commands.
+    :rtype: int
+    '''
+    res = 0
+    for p_name_info in products_infos:
+        res_prod = configure_product(p_name_info, conf_option, config, logger)
+        if res_prod != 0:
+            res += 1 
+    return res
+
+def configure_product(p_name_info, conf_option, config, logger):
+    '''Execute the proper configuration command(s) 
+       in the product build directory.
+    
+    :param p_name_info tuple: (str, Config) => (product_name, product_info)
+    :param conf_option str: The options to add to the command
+    :param config Config: The global configuration
+    :param logger Logger: The logger instance to use for the display 
+                          and logging
+    :return: 1 if it fails, else 0.
+    :rtype: int
+    '''
+    
+    p_name, p_info = p_name_info
+    
+    # Logging
+    logger.write("\n", 4, False)
+    logger.write("################ ", 4)
+    header = _("Configuration of %s") % src.printcolors.printcLabel(p_name)
+    header += " %s " % ("." * (20 - len(p_name)))
+    logger.write(header, 3)
+    logger.write("\n", 4, False)
+    logger.flush()
+    
+    # Instantiate the class that manages all the construction commands
+    # like cmake, make, make install, make test, environment management, etc...
+    builder = src.compilation.Builder(config, logger, p_info)
+    
+    # Prepare the environment
+    log_step(logger, header, "PREPARE ENV")
+    res_prepare = builder.prepare()
+    log_res_step(logger, res_prepare)
+    
+    # Execute buildconfigure, configure if the product is autotools
+    # Execute cmake if the product is cmake
+    res = 0
+    if src.product.product_is_autotools(p_info):
+        log_step(logger, header, "BUILDCONFIGURE")
+        res_bc = builder.build_configure()
+        log_res_step(logger, res_bc)
+        res += res_bc
+        log_step(logger, header, "CONFIGURE")
+        res_c = builder.configure(conf_option)
+        log_res_step(logger, res_c)
+        res += res_c
+    if src.product.product_is_cmake(p_info):
+        log_step(logger, header, "CMAKE")
+        res_cm = builder.cmake(conf_option)
+        log_res_step(logger, res_cm)
+        res += res_cm
+    
+    # Log the result
+    if res > 0:
+        logger.write("\r%s%s" % (header, " " * 20), 3)
+        logger.write("\r" + header + src.printcolors.printcError("KO"))
+        logger.write("==== %(KO)s in configuration of %(name)s \n" %
+            { "name" : p_name , "KO" : src.printcolors.printcInfo("ERROR")}, 4)
+        logger.flush()
+    else:
+        logger.write("\r%s%s" % (header, " " * 20), 3)
+        logger.write("\r" + header + src.printcolors.printcSuccess("OK"))
+        logger.write("==== %s \n" % src.printcolors.printcInfo("OK"), 4)
+        logger.write("==== Configuration of %(name)s %(OK)s \n" %
+            { "name" : p_name , "OK" : src.printcolors.printcInfo("OK")}, 4)
+        logger.flush()
+    logger.write("\n", 3, False)
+
+    return res
+
+def description():
+    '''method that is called when salomeTools is called with --help option.
+    
+    :return: The text to display for the configure command description.
+    :rtype: str
+    '''
+    return _("The configure command executes in the build directory"
+             " the configure commands corresponding to the compilation mode"
+             " of the application products.\nThe possible compilation modes"
+             " are \"cmake\", \"autotools\", or a script.\n\nHere are the "
+             "commands to be run :\nautotools: build_configure and configure\n"
+             "cmake: cmake\nscript: N\A")
+  
+def run(args, runner, logger):
+    '''method that is called when salomeTools is called with prepare parameter.
+    '''
+    
+    # Parse the options
+    (options, args) = parser.parse_args(args)
+
+    # check that the command has been called with an application
+    src.check_config_has_application( runner.cfg )
+
+    # Get the list of products to threat
+    products_infos = get_products_list(options, runner.cfg, logger)
+    
+    # Print some informations
+    logger.write(_('Configuring the sources of the application %s\n') % 
+                src.printcolors.printcLabel(runner.cfg.VARS.application), 1)
+    
+    info = [(_("BUILD directory"),
+             os.path.join(runner.cfg.APPLICATION.workdir, 'BUILD'))]
+    src.print_info(logger, info)
+    
+    # Call the function that will loop over all the products and execute
+    # the right command(s)
+    res = configure_all_products(runner.cfg, products_infos, options.option, logger)
+    
+    # Print the final state
+    nb_products = len(products_infos)
+    if res == 0:
+        final_status = "OK"
+    else:
+        final_status = "KO"
+   
+    logger.write(_("\nConfiguration: %(status)s (%(valid_result)d/%(nb_products)d)\n") % \
+        { 'status': src.printcolors.printc(final_status), 
+          'valid_result': nb_products - res,
+          'nb_products': nb_products }, 1)    
+    
+    return res 
\ No newline at end of file
index 7f722a571557613a9d24c1745315a92c2970620a..144febdd34f2b3fc77cd68779fbac272eb9ececa 100644 (file)
@@ -1,7 +1,7 @@
 PRODUCT_CVS_V6_7_0 :
 {
-       name : "MODULE_CVS"
-    build_source : "cmake"
+       name : "PRODUCT_CVS"
+    build_source : "autotools"
     get_source : "cvs"
     git_info:
     {
index afbefc366dc7cb14f5d70750d24e6ffae08d7327..12ee8e94e5d7f206fe9136758926e1496f9373bd 100644 (file)
@@ -30,65 +30,10 @@ C_COMPILE_ENV_LIST = ["CC",
                       "LIBS",
                       "LDFLAGS"]
 
-class CompilationResult:
-    def __init__(self):
-        self.prepare = False
-        self.buildconfigure = False
-        self.configure = False
-        self.cmake = False
-        self.make = False
-        self.install = False
-        self.check = False
-        self.check_tried = False
-        self.ignored = False
-        self.reason = ""
-
-    def isOK(self):
-        if self.ignored:
-            return False
-
-        return self.prepare \
-            and self.buildconfigure \
-            and self.configure \
-            and self.cmake \
-            and self.make \
-            and self.install \
-            and self.check
-
-    def setAllFail(self):
-        self.prepare = False
-        self.buildconfigure = False
-        self.configure = False
-        self.cmake = False
-        self.make = False
-        self.install = False
-        self.check = False
-
-    def setIgnored(self, reason=None):
-        self.ignored = True
-        if reason:
-            self.reason = reason
-        else:
-            self.reason = _("ignored")
-
-    def getErrorText(self):
-        if self.ignored or len(self.reason):
-            return self.reason
-
-        if not self.prepare: return "PREPARE BUILD"
-        if not self.buildconfigure: return "BUILD CONFIGURE"
-        if not self.configure: return "CONFIGURE"
-        if not self.cmake: return "CMAKE"
-        if not self.make: return "MAKE"
-        if not self.install: return "INSTALL"
-        if not self.check: return "CHECK"
-        
-        return ""
-
 class Builder:
     """Class to handle all construction steps, like cmake, configure, make, ...
     """
-    def __init__(self, config, logger, options, product_info, debug_mode=False, check_src=True):
+    def __init__(self, config, logger, product_info, options = src.options.OptResult(), debug_mode=False, check_src=True):
         self.config = config
         self.logger = logger
         self.options = options
@@ -111,88 +56,23 @@ class Builder:
             if 'install_dir' in dep_info and not os.path.exists(dep_info.install_dir):
                 raise src.SatException(_("Module %s is required") % dep)
         """
-        self.results = CompilationResult()
 
     ##
     # Shortcut method to log in both log files.
     def log(self, text, level, showInfo=True):
         self.logger.write(text, level, showInfo)
         self.logger.logTxtFile.write(src.printcolors.cleancolor(text))
+        self.logger.flush()
 
     ##
     # Shortcut method to log a command.
     def log_command(self, command):
         self.log("> %s\n" % command, 5)
 
-    def log_result(self, res):
-        if res == 0:
-            self.logger.write("%s\n" % src.printcolors.printc(src.OK_STATUS), 5)
-        else:
-            self.logger.write("%s, code = %s\n" % (src.printcolors.printc(src.KO_STATUS), res), 5)
-
-    ##
-    # Logs a compilation step (configure, make ...)
-    def log_step(self, step):
-        if self.config.USER.output_verbose_level == 3:
-            self.logger.write("\r%s%s" % (self.header, " " * 20), 3)
-            self.logger.write("\r%s%s" % (self.header, step), 3)
-        self.log("==== %s \n" % src.printcolors.printcInfo(step), 4)
-        self.logger.flush()
-
-    ##
-    # Prepares the environment for windows.
-    # Build two environment: one for building and one for testing (launch).
-    def wprepare(self):
-        self.log_step('PREPARE BUILD')
-
-        if not self.build_dir.exists():
-            # create build dir
-            self.build_dir.make()
-        elif self.options.clean_all:
-            self.log('  %s\n' % src.printcolors.printcWarning("CLEAN ALL"), 4)
-            # clean build dir if clean_all option given
-            self.log('  clean previous build = %s\n' % str(self.build_dir), 4)
-            self.build_dir.rm()
-            self.build_dir.make()
-
-        if self.options.clean_all or self.options.clean_install:
-            if os.path.exists(str(self.install_dir)) and not self.single_dir:
-                self.log('  clean previous install = %s\n' % str(self.install_dir), 4)
-                self.install_dir.rm()
-
-        self.log('  build_dir   = %s\n' % str(self.build_dir), 4)
-        self.log('  install_dir = %s\n' % str(self.install_dir), 4)
-        self.log('\n', 4)
-        
-        environ_info = {}
-        
-        # add products in depend and opt_depend list recursively
-        environ_info['products'] = src.product.get_product_dependencies(self.config, self.product_info)
-
-        # create build environment
-        self.build_environ = src.environment.SalomeEnviron(self.config, src.environment.Environ(dict(os.environ)), True)
-        self.build_environ.silent = (self.config.USER.output_verbose_level < 5)
-        self.build_environ.set_full_environ(self.logger, environ_info)
-
-        # create runtime environment
-        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)
-
-        for ee in C_COMPILE_ENV_LIST:
-            vv = self.build_environ.get(ee)
-            if len(vv) > 0:
-                self.log("  %s = %s\n" % (ee, vv), 4, False)
-
-        self.results.prepare = True
-        self.log_result(0)
-        return self.results.prepare
-
     ##
     # Prepares the environment.
     # Build two environment: one for building and one for testing (launch).
     def prepare(self):
-        self.log_step('PREPARE BUILD')
 
         if not self.build_dir.exists():
             # create build dir
@@ -220,20 +100,14 @@ class Builder:
             if len(vv) > 0:
                 self.log("  %s = %s\n" % (ee, vv), 4, False)
 
-        self.results.prepare = True
-        self.log_result(0)
-        return self.results.prepare
+        return 0
 
     ##
     # Runs cmake with the given options.
     def cmake(self, options=""):
-        self.log_step('CMAKE')
-
-        # cmake so no (build)configure
-        self.results.configure = True
 
         cmake_option = options
-        cmake_option +=' -DCMAKE_VERBOSE_MAKEFILE=ON -DSALOME_CMAKE_DEBUG=ON'
+        cmake_option +=' -DCMAKE_VERBOSE_MAKEFILE=ON -DSALOME_CMAKE_DEBUG=ON'
         if 'cmake_options' in self.product_info:
             cmake_option += " %s " % " ".join(self.product_info.cmake_options.split())
 
@@ -242,12 +116,9 @@ class Builder:
             cmake_option += " -DCMAKE_BUILD_TYPE=Debug"
         else :
             cmake_option += " -DCMAKE_BUILD_TYPE=Release"
-
-        # 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.PRODUCT.cmake_generator
         
-        command = "cmake %s -DCMAKE_INSTALL_PREFIX=%s %s" %(cmake_option, self.install_dir, self.source_dir)
+        command = ("cmake %s -DCMAKE_INSTALL_PREFIX=%s %s" %
+                            (cmake_option, self.install_dir, self.source_dir))
 
         self.log_command(command)
         res = subprocess.call(command,
@@ -257,47 +128,37 @@ class Builder:
                               stdout=self.logger.logTxtFile,
                               stderr=subprocess.STDOUT)
 
-        self.results.cmake = (res == 0)
-        self.log_result(res)
-        return self.results.cmake
+        if res == 0:
+            return res
+        else:
+            return 1
 
     ##
     # Runs build_configure with the given options.
     def build_configure(self, options=""):
-        skip = src.get_cfg_param(self.product_info, "build_configure", False)
-        if skip:
-            self.results.buildconfigure = True
-            res = 0
-        else:
-            self.log_step('BUILD CONFIGURE')
-
-            self.results.buildconfigure = False
 
-            if 'buildconfigure_options' in self.product_info:
-                options += " %s " % self.product_info.buildconfigure_options
+        if 'buildconfigure_options' in self.product_info:
+            options += " %s " % self.product_info.buildconfigure_options
 
-            command = str('./build_configure')
-            command = command + " " + options
-            self.log_command(command)
+        command = str('%s/build_configure') % (self.source_dir)
+        command = command + " " + options
+        self.log_command(command)
 
-            res = subprocess.call(command,
-                                  shell=True,
-                                  cwd=str(self.source_dir),
-                                  env=self.build_environ.environ.environ,
-                                  stdout=self.logger.logTxtFile,
-                                  stderr=subprocess.STDOUT)
-            self.results.buildconfigure = (res == 0)
+        res = subprocess.call(command,
+                              shell=True,
+                              cwd=str(self.build_dir),
+                              env=self.build_environ.environ.environ,
+                              stdout=self.logger.logTxtFile,
+                              stderr=subprocess.STDOUT)
 
-        self.log_result(res)
-        return self.results.buildconfigure
+        if res == 0:
+            return res
+        else:
+            return 1
 
     ##
     # Runs configure with the given options.
     def configure(self, options=""):
-        self.log_step('CONFIGURE')
-
-        # configure so no cmake
-        self.results.cmake = True
 
         if 'configure_options' in self.product_info:
             options += " %s " % self.product_info.configure_options
@@ -314,9 +175,10 @@ class Builder:
                               stdout=self.logger.logTxtFile,
                               stderr=subprocess.STDOUT)
 
-        self.log_result(res)
-        self.results.configure = (res == 0)
-        return self.results.configure
+        if res == 0:
+            return res
+        else:
+            return 1
 
     def hack_libtool(self):
         if not os.path.exists(str(self.build_dir + 'libtool')):
@@ -389,9 +251,10 @@ CC=\\"hack_libtool\\"%g" libtool'''
                               stdout=self.logger.logTxtFile,
                               stderr=subprocess.STDOUT)
 
-        self.results.make = (res == 0)
-        self.log_result(res)
-        return self.results.make
+        if res == 0:
+            return res
+        else:
+            return 1
     
     ##
     # Runs msbuild to build the module.
@@ -422,14 +285,14 @@ CC=\\"hack_libtool\\"%g" libtool'''
                               stdout=self.logger.logTxtFile,
                               stderr=subprocess.STDOUT)
 
-        self.results.make = (res == 0)
-        self.log_result(res)
-        return self.results.make
+        if res == 0:
+            return res
+        else:
+            return 1
 
     ##
     # Runs 'make install'.
     def install(self):
-        self.log_step('INSTALL')
         if self.config.VARS.dist_name=="Win":
             command = 'msbuild INSTALL.vcxproj'
             if self.debug_mode:
@@ -448,14 +311,14 @@ CC=\\"hack_libtool\\"%g" libtool'''
                               stdout=self.logger.logTxtFile,
                               stderr=subprocess.STDOUT)
 
-        self.results.install = (res == 0)
-        self.log_result(res)
-        return self.results.install
+        if res == 0:
+            return res
+        else:
+            return 1
 
     ##
     # Runs 'make_check'.
     def check(self):
-        self.log_step('CHECK')
         if src.architecture.is_windows():
             command = 'msbuild RUN_TESTS.vcxproj'
         else :
@@ -466,7 +329,6 @@ CC=\\"hack_libtool\\"%g" libtool'''
             
         self.log_command(command)
 
-        self.results.check_tried = True
         res = subprocess.call(command,
                               shell=True,
                               cwd=str(self.build_dir),
@@ -474,9 +336,10 @@ CC=\\"hack_libtool\\"%g" libtool'''
                               stdout=self.logger.logTxtFile,
                               stderr=subprocess.STDOUT)
 
-        self.results.check = (res == 0)
-        self.log_result(res)
-        return self.results.check
+        if res == 0:
+            return res
+        else:
+            return 1
       
     ##
     # Performs a default build for this module.
@@ -517,27 +380,20 @@ CC=\\"hack_libtool\\"%g" libtool'''
             if not self.configure(configure_options): return self.get_result()
             if not self.make(): return self.get_result()
             if not self.install(): return self.get_result()
-            self.results.check = True
             if not self.clean(): return self.get_result()
            
         else: # CMake
             if self.config.VARS.dist_name=='Win':
                 if not self.wprepare(): return self.get_result()
-                self.results.buildconfigure = True
                 if not self.cmake(): return self.get_result()
-                self.results.ctest = True
                 if not self.wmake(): return self.get_result()
                 if not self.install(): return self.get_result()
-                self.results.check = True
                 if not self.clean(): return self.get_result()
             else :
                 if not self.prepare(): return self.get_result()
-                self.results.buildconfigure = True
                 if not self.cmake(): return self.get_result()
-                self.results.ctest = True
                 if not self.make(): return self.get_result()
                 if not self.install(): return self.get_result()
-                self.results.check = True
                 if not self.clean(): return self.get_result()
 
         return self.get_result()
@@ -545,8 +401,6 @@ CC=\\"hack_libtool\\"%g" libtool'''
     ##
     # Performs a build with a script.
     def do_script_build(self, script):
-        retcode = CompilationResult()
-        retcode.setAllFail()
         # script found
         self.logger.write(_("Compile %(module)s using script %(script)s\n") % \
             { 'module': self.module, 'script': src.printcolors.printcLabel(script) }, 4)
@@ -563,64 +417,3 @@ CC=\\"hack_libtool\\"%g" libtool'''
 
         return retcode
 
-    ##
-    # Builds the module.
-    # If a script is specified used it, else use 'default' method.
-    def run_compile(self, no_compile=False):
-        retcode = CompilationResult()
-        retcode.setAllFail()
-
-        if no_compile:
-            if os.path.exists(str(self.install_dir)):
-                retcode.setIgnored(_("already installed"))
-            else:
-                retcode.setIgnored(src.printcolors.printcError(_("NOT INSTALLED")))
-
-            self.log_file.close()
-            os.remove(os.path.realpath(self.log_file.name))
-            return retcode
-
-        # check if the module is already installed
-        if not self.single_dir and os.path.exists(str(self.install_dir)) \
-            and not self.options.clean_all and not self.options.clean_install:
-
-            retcode.setIgnored(_("already installed"))
-            self.log_file.close()
-            os.remove(os.path.realpath(self.log_file.name))
-            return retcode
-
-        if 'compile_method' in self.product_info:
-            if self.product_info.compile_method == "copy":
-                self.prepare()
-                retcode.prepare = self.results.prepare
-                retcode.buildconfigure = True
-                retcode.configure = True
-                retcode.make = True
-                retcode.cmake = True
-                retcode.ctest = True
-                
-                if not self.source_dir.smartcopy(self.install_dir):
-                    raise src.SatException(_("Error when copying %s sources to install dir") % self.module)
-                retcode.install = True
-                retcode.check = True
-
-            elif self.product_info.compile_method == "default":
-                retcode = self.do_default_build(show_warning=False)
-                
-
-            elif os.path.isfile(self.product_info.compile_method):
-                retcode = self.do_script_build(self.product_info.compile_method)
-
-            else:
-                raise src.SatException(_("Unknown compile_method: %s") % self.product_info.compile_method)
-
-        else:
-            script = os.path.join(self.config.VARS.dataDir, 'compil_scripts', 'modules', self.module + '.py')
-
-            if not os.path.exists(script):
-                # no script use default method
-                retcode = self.do_default_build(show_warning=False)
-            else:
-                retcode = self.do_script_build(script)
-
-        return retcode
index eddcd55c4b3289c90cded6e21518c7b73f89e02f..6b4d8fe5785317b3dc0ac902d79d63c709380ae0 100644 (file)
@@ -147,6 +147,7 @@ class Logger(object):
         '''Flush terminal
         '''
         sys.stdout.flush()
+        self.logTxtFile.flush()
         
     def end_write(self, attribute):
         '''Method called just after command end : Put all fields 
index 9010123da00f3edace12f29dd67ffc848e829bec..b607b659ede08309998db33b7386989a904fef94 100644 (file)
@@ -252,4 +252,26 @@ def product_is_debug(product_info):
     :rtype: boolean
     '''
     debug = product_info.debug
-    return debug.lower() == 'yes'
\ No newline at end of file
+    return debug.lower() == 'yes'
+
+def product_is_autotools(product_info):
+    '''Know if a product is compiled using the autotools
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product is autotools, else False
+    :rtype: boolean
+    '''
+    build_src = product_info.build_source
+    return build_src.lower() == 'autotools'
+
+def product_is_cmake(product_info):
+    '''Know if a product is compiled using the cmake
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product is cmake, else False
+    :rtype: boolean
+    '''
+    build_src = product_info.build_source
+    return build_src.lower() == 'cmake'
\ No newline at end of file