From 4536247a734eb2a0e853b0e1aa8ae945688fe3a5 Mon Sep 17 00:00:00 2001 From: crouzet Date: Tue, 22 Jan 2019 12:12:01 +0100 Subject: [PATCH] =?utf8?q?sat=20#8606=20:=20effacement=20des=20r=C3=A9pert?= =?utf8?q?oires=20g=C3=A9n=C3=A9r=C3=A9s=20avant=20une=20nouvelle=20genera?= =?utf8?q?tion,=20extension=20de=20sat=20clean=20avec=20option=20--generat?= =?utf8?q?ed?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands/clean.py | 36 +++++++++++++++++++++++++- commands/generate.py | 9 +++++++ complete_sat.sh | 2 +- doc/src/commands/clean.rst | 2 ++ src/i18n/fr/LC_MESSAGES/salomeTools.po | 3 +++ 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/commands/clean.py b/commands/clean.py index 1077297..cd8d5f8 100644 --- a/commands/clean.py +++ b/commands/clean.py @@ -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"))) diff --git a/commands/generate.py b/commands/generate.py index a8d2dc9..b34b0b6 100644 --- a/commands/generate.py +++ b/commands/generate.py @@ -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, diff --git a/complete_sat.sh b/complete_sat.sh index db6b7cd..15a0c55 100755 --- a/complete_sat.sh +++ b/complete_sat.sh @@ -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 ;; diff --git a/doc/src/commands/clean.rst b/doc/src/commands/clean.rst index e5d2f38..4aa2413 100644 --- a/doc/src/commands/clean.rst +++ b/doc/src/commands/clean.rst @@ -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** : diff --git a/src/i18n/fr/LC_MESSAGES/salomeTools.po b/src/i18n/fr/LC_MESSAGES/salomeTools.po index 434c1de..e1f8840 100644 --- a/src/i18n/fr/LC_MESSAGES/salomeTools.po +++ b/src/i18n/fr/LC_MESSAGES/salomeTools.po @@ -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 "" -- 2.39.2