Salome HOME
sat #8596 : add --properties option to compile, prepare, patch and source commands nct/8596
authorcrouzet <nicolas.crouzet@cea.fr>
Fri, 18 May 2018 08:31:47 +0000 (10:31 +0200)
committercrouzet <nicolas.crouzet@cea.fr>
Fri, 18 May 2018 08:31:47 +0000 (10:31 +0200)
commands/compile.py
commands/patch.py
commands/prepare.py
commands/source.py
complete_sat.sh

index 9b51a87a56dd1e509874736f264133dbcb82eb10..4154005375c4b65178f5e69d41f2c261cd967d01 100644 (file)
@@ -17,7 +17,7 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
 import os
-
+import re
 import src
 import src.debug as DBG
 
@@ -28,11 +28,16 @@ try:
 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>'))
 parser.add_option('', 'with_fathers', 'boolean', 'fathers',
     _("Optional: build all necessary products to the given product (KERNEL is "
       "build before building GUI)."), False)
@@ -87,7 +92,18 @@ def get_products_list(options, cfg, logger):
     # 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]))]
     
@@ -681,6 +697,16 @@ def run(args, runner, logger):
     # 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 '
index f9e88e52e2b469891df35642750972a3f3a3a4c7..974c28aafe79e4499fc0caa8d0107615b544618b 100644 (file)
@@ -18,6 +18,7 @@
 
 import os
 import subprocess
+import re
 
 import src
 import prepare
@@ -27,6 +28,9 @@ parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
     _('Optional: products to get the sources. This option can be'
     ' passed several time to get the sources of several products.'))
+parser.add_option('', 'properties', 'string', 'properties',
+    _('Optional: Filter the products by their properties.\n\tSyntax: '
+      '--properties <property>:<value>'))
 
 def apply_patch(config, product_info, max_product_name_len, logger):
     '''The method called to apply patches on a product
@@ -140,6 +144,16 @@ def run(args, runner, logger):
     # 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(prepare.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('Patching sources of the application %s\n' % 
                 src.printcolors.printcLabel(runner.cfg.VARS.application), 1)
@@ -183,4 +197,4 @@ def run(args, runner, logger):
     logger.write(" " + src.printcolors.printc(status), 1, False)
     logger.write(" (%s)\n" % res_count, 1, False)
     
-    return len(products_infos) - good_result
\ No newline at end of file
+    return len(products_infos) - good_result
index fc40f6458f66a3f01102b4454d8c660212a029cc..687d051b6748649886755ce25ed7945a0a1f4500 100644 (file)
@@ -22,11 +22,16 @@ import os
 import src
 import src.debug as DBG
 
+PROPERTY_EXPRESSION = "^.+:.+$"
+
 # Define all possible option for prepare command :  sat prepare <options>
 parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
     _('Optional: products to prepare. This option can be'
     ' passed several time to prepare several products.'))
+parser.add_option('', 'properties', 'string', 'properties',
+    _('Optional: Filter the products by their properties.\n\tSyntax: '
+      '--properties <property>:<value>'))
 parser.add_option('f', 'force', 'boolean', 'force', 
     _("Optional: force to prepare the products in development mode."))
 parser.add_option('', 'force_patch', 'boolean', 'force_patch', 
@@ -61,6 +66,15 @@ def get_products_list(options, cfg, logger):
     # 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]
+        
     return products_infos
 
 def remove_products(arguments, l_products_info, logger):
@@ -142,6 +156,16 @@ def run(args, runner, logger):
     # 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
+
     products_infos = get_products_list(options, runner.cfg, logger)
 
     # Construct the arguments to pass to the clean, source and patch commands
index c8d34f13bdd5af965c18ae15950827610a31c26c..9580ef2ae78868aadb30b75274288002e437bed2 100644 (file)
@@ -18,6 +18,7 @@
 
 import os
 import shutil
+import re
 
 import src
 import prepare
@@ -28,6 +29,9 @@ parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
     _('Optional: products from which to get the sources. This option can be'
     ' passed several time to get the sources of several products.'))
+parser.add_option('', 'properties', 'string', 'properties',
+    _('Optional: Filter the products by their properties.\n\tSyntax: '
+      '--properties <property>:<value>'))
 
 def get_source_for_dev(config, product_info, source_dir, logger, pad):
     '''The method called if the product is in development mode
@@ -507,6 +511,16 @@ def run(args, runner, logger):
     # 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(prepare.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(_('Getting sources of the application %s\n') % 
                 src.printcolors.printcLabel(runner.cfg.VARS.application), 1)
index 6873137681a4ec83541aa1c2ea496516ec157611..ad1d94bd672634554df907790ebbc0254ac283bc 100755 (executable)
@@ -172,17 +172,17 @@ _salomeTools_complete()
             return 0
             ;;
         source)
-            opts="--products"
+            opts="--products --properties"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
         patch)
-            opts="--products"
+            opts="--products --properties"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
         prepare)
-            opts="--products --force --force_patch"
+            opts="--products --properties --force --force_patch"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
@@ -207,7 +207,7 @@ _salomeTools_complete()
             return 0
             ;;
         compile)
-            opts="--products --with_fathers --with_children --clean_all --clean_make --install_flags --show --stop_first_fail --check --clean_build_after"
+            opts="--products --properties --with_fathers --with_children --clean_all --clean_make --install_flags --show --stop_first_fail --check --clean_build_after"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;