Salome HOME
sat #8606 : effacement des répertoires générés avant une nouvelle generation, extensi...
authorcrouzet <nicolas.crouzet@cea.fr>
Tue, 22 Jan 2019 11:12:01 +0000 (12:12 +0100)
committercrouzet <nicolas.crouzet@cea.fr>
Tue, 22 Jan 2019 11:12:01 +0000 (12:12 +0100)
commands/clean.py
commands/generate.py
complete_sat.sh
doc/src/commands/clean.rst
src/i18n/fr/LC_MESSAGES/salomeTools.po

index 1077297675980897a07e8c4cccf78ab6358fa329..cd8d5f88e7dcf8dd1a21fcb17f3bda97074c064a 100644 (file)
@@ -17,6 +17,7 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
 import re
+import os
 
 import src
 
@@ -38,6 +39,8 @@ parser.add_option('b', 'build', 'boolean', 'build',
     _("Optional: Clean the product build directories."))
 parser.add_option('i', 'install', 'boolean', 'install', 
     _("Optional: Clean the product install directories."))
+parser.add_option('g', 'generated', 'boolean', 'generated', 
+    _("Optional: Clean source, build and install directories for generated products."))
 parser.add_option('a', 'all', 'boolean', 'all', 
     _("Optional: Clean the product source, build and install directories."))
 parser.add_option('', 'sources_without_dev', 'boolean', 'sources_without_dev', 
@@ -94,6 +97,34 @@ def get_install_directories(products_infos):
             l_dir_install.append(src.Path(product_info.install_dir))
     return l_dir_install
 
+def get_generated_directories(config, products_infos):
+    """\
+    Returns the list of directories (source, build, install) corresponding to the 
+    list of products information given as input.
+    Nothing is returned for non generated products (those with...)
+    
+    :param products_infos list: The list of (name, config) corresponding to one product.
+    :return: the list of install paths.
+    :rtype: list
+    """
+    l_dir_install = []
+    for __, product_info in products_infos:
+        if not src.product.product_is_generated(product_info):
+            continue
+        workdir = config.APPLICATION.workdir
+        compo = product_info.component_name
+        generate_dir = os.path.join(workdir, "GENERATED")
+        source_dir = os.path.join(generate_dir, compo + "_SRC")
+        build_dir = os.path.join(os.path.join(workdir, "BUILD"), compo)
+        install_dir = os.path.join(os.path.join(workdir, "INSTALL"), compo)
+        l_dir_install.append(src.Path(source_dir))
+        l_dir_install.append(src.Path(build_dir))
+        l_dir_install.append(src.Path(install_dir))
+        
+    return l_dir_install
+
+
+
 def product_has_dir(product_info, without_dev=False):
     """\
     Returns a boolean at True if there is a source, build and install
@@ -162,7 +193,8 @@ def run(args, runner, logger):
         l_dir_to_suppress += (get_source_directories(products_infos, 
                                             options.sources_without_dev) +
                              get_build_directories(products_infos) + 
-                             get_install_directories(products_infos))
+                             get_install_directories(products_infos) + 
+                             get_generated_directories(runner.cfg, products_infos) )
     else:
         if options.install:
             l_dir_to_suppress += get_install_directories(products_infos)
@@ -173,6 +205,8 @@ def run(args, runner, logger):
         if options.sources or options.sources_without_dev:
             l_dir_to_suppress += get_source_directories(products_infos, 
                                                 options.sources_without_dev)
+        if options.generated:
+            l_dir_to_suppress += get_generated_directories(runner.cfg, products_infos)
     
     if len(l_dir_to_suppress) == 0:
         logger.write(src.printcolors.printcWarning(_("Nothing to suppress\n")))
index a8d2dc969502d2e62b6b01834fd706ac617b9c2d..b34b0b6b684cdca138aedda1f6c45e41382ccce9 100644 (file)
@@ -369,6 +369,15 @@ def run(args, runner, logger):
             logger.write(_("not a generated product\n"), 3, False)
             continue
 
+        logger.write(_("\nCleaning generated directories\n"), 3, False)
+        # clean source, build and install directories of the generated product
+        # no verbosity to avoid warning at the first generation, for which dirs don't exist
+        runner.clean(runner.cfg.VARS.application + 
+                  " --products " + pi.name + 
+                  " --generated",
+                  batch=True,
+                  verbose=0,
+                  logger_add_link = logger)
         nbgen += 1
         try:
             result = generate_component_list(runner.cfg,
index db6b7cdcaa77e42ebefdb3458e4a94046a283635..15a0c551aebf9796c796c60422c86571725b7fbb 100755 (executable)
@@ -167,7 +167,7 @@ _salomeTools_complete()
             return 0
             ;;
         clean)
-            opts="--products --sources --build --install --all --sources_without_dev --properties"
+            opts="--products --sources --build --install --generated --all --sources_without_dev --properties"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
index e5d2f388b7d746f3c0045e62e35337c5ad492729..4aa2413ff01869b0cc17d525ef9c68e0017aa92b 100644 (file)
@@ -46,6 +46,8 @@ Availables options
 
   * **--install** : Clean the product install directories.
 
+  * **--generated : Clean source, build and install directories for generated products.
+
   * **--all** : Clean the product source, build and install directories.
 
   * **--sources_without_dev** : 
index 434c1deee8a3abe29190f7a0a98956f3cb71eefc..e1f8840ac8582b545481d424a3bea561de882324 100644 (file)
@@ -181,6 +181,9 @@ msgstr ""
 msgid "Optional: Clean the product install directories."
 msgstr ""
 
+msgid "Optional: Clean source, build and install directories for generated products."
+msgstr ""
+
 msgid "Optional: Clean the product source, build and install directories."
 msgstr ""