From: crouzet Date: Fri, 31 Jul 2020 14:25:49 +0000 (+0200) Subject: option compile --update X-Git-Tag: 5.6.1^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c7954d2dbe563a25747441b444f55e2dcd6e9c8f;p=tools%2Fsat.git option compile --update --- diff --git a/commands/compile.py b/commands/compile.py index f2b98d6..526f70b 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -36,6 +36,8 @@ parser.add_option('p', 'products', 'list2', 'products', _('Optional: products to compile. This option accepts a comma separated list.')) parser.add_option('f', 'force', 'boolean', 'force', 'Optional: force the compilation of product, even if it is already installed. The BUILD directory is cleaned before compilation.') +parser.add_option('u', 'update', 'boolean', 'update', + 'Optional: update mode, compile only products which sources has changed, including the dependencies.') parser.add_option('', 'with_fathers', 'boolean', 'fathers', _("Optional: build all necessary products to the given product (KERNEL is " "build before building GUI)."), False) @@ -137,7 +139,7 @@ def log_res_step(logger, res): logger.write("%s \n" % src.printcolors.printcError("KO"), 4) logger.flush() -def compile_all_products(sat, config, options, products_infos, all_products_dict, logger): +def compile_all_products(sat, config, options, products_infos, all_products_dict, all_products_graph, logger): '''Execute the proper configuration commands in each product build directory. @@ -145,15 +147,19 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict :param products_info list: List of (str, Config) => (product_name, product_info) :param all_products_dict: Dict of all products + :param all_products_graph: graph of all products :param logger Logger: The logger instance to use for the display and logging :return: the number of failing commands. :rtype: int ''' # first loop for the cleaning check_salome_configuration=False + updated_products=[] for p_name_info in products_infos: p_name, p_info = p_name_info + if src.product.product_is_salome(p_info): + check_salome_configuration=True # nothing to clean for native or fixed products if (not src.product.product_compiles(p_info)) or\ @@ -171,28 +177,52 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict verbose=0, logger_add_link = logger) + else: + # Clean the the install directory + # if the corresponding option was called + if options.clean_install: + sat.clean(config.VARS.application + + " --products " + p_name + + " --install", + batch=True, + verbose=0, + logger_add_link = logger) + + # Clean the the install directory + # if the corresponding option was called + if options.force: + sat.clean(config.VARS.application + + " --products " + p_name + + " --build", + batch=True, + verbose=0, + logger_add_link = logger) - # Clean the the install directory - # if the corresponding option was called - if options.clean_install and not options.clean_all: - sat.clean(config.VARS.application + - " --products " + p_name + - " --install", - batch=True, - verbose=0, - logger_add_link = logger) - - # Clean the the install directory - # if the corresponding option was called - if options.force and not options.clean_all: - sat.clean(config.VARS.application + - " --products " + p_name + - " --build", - batch=True, - verbose=0, - logger_add_link = logger) - if src.product.product_is_salome(p_info): - check_salome_configuration=True + if options.update: + try: + do_update=False + if len(updated_products)>0: + # if other products where updated, check that the current product is a child + # in this case it will be also updated + if find_path_graph(all_products_graph, p_name, updated_products): + logger.write("\nUpdate product %s (child)" % p_name, 5) + do_update=True + if not do_update: + source_time=os.path.getatime(p_info.source_dir) + install_time=os.path.getatime(p_info.install_dir) + if install_time --products med --force +* Update mode, compile only git products which source has changed, including the dependencies. + The option is not implemented for svn and cvs, only for git. + One has to call sat prepare before, to check if git sources where modified. + The mecanism is based upon git log -1 command, and the modification of the source directory date accordingly: :: + + # update SALOME sources + ./sat prepare --properties is_SALOME_module:yes + + # only compile modules that has to be recompiled. + sat compile --update + * Clean the build and install directories before starting compilation: :: sat compile --products GEOM --clean_all diff --git a/doc/src/commands/prepare.rst b/doc/src/commands/prepare.rst index ad2c871..5ea8eba 100644 --- a/doc/src/commands/prepare.rst +++ b/doc/src/commands/prepare.rst @@ -69,6 +69,11 @@ Usage sat prepare --products , ... +* Prepare only some modules with a given property: :: + + # prepare only SALOME modules, not prerequisites + ./sat prepare --properties is_SALOME_module:yes + * Use --force to force to prepare the products in development mode (this will remove the sources and do a new clone/checkout): :: diff --git a/src/system.py b/src/system.py index 56141bc..672149d 100644 --- a/src/system.py +++ b/src/system.py @@ -89,6 +89,7 @@ def git_extract(from_what, tag, where, logger, environment=None): DBG.write("git_extract", [from_what, tag, str(where)]) if not where.exists(): where.make() + where_git = os.path.join(str(where), ".git") if tag == "master" or tag == "HEAD": if src.architecture.is_windows(): cmd = "git clone %(remote)s %(where)s" @@ -96,12 +97,13 @@ def git_extract(from_what, tag, where, logger, environment=None): cmd = r""" set -x git clone %(remote)s %(where)s +touch -d "$(git --git-dir=%(where_git)s log -1 --format=date_format)" %(where)s """ - cmd = cmd % {'remote': from_what, 'tag': tag, 'where': str(where)} +#git --git-dir=%(where_git)s log -1 --format=date_format > %(where)s/last_commit_date.txt + cmd = cmd % {'remote': from_what, 'tag': tag, 'where': str(where), 'where_git': where_git} else: # NOTICE: this command only works with recent version of git # because --work-tree does not work with an absolute path - where_git = os.path.join(str(where), ".git") if src.architecture.is_windows(): cmd = "rmdir %(where)s && git clone %(remote)s %(where)s && git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s" else: @@ -110,6 +112,7 @@ set -x rmdir %(where)s git clone %(remote)s %(where)s && \ git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s +touch -d "$(git --git-dir=%(where_git)s log -1 --format=date_format)" %(where)s """ cmd = cmd % {'remote': from_what, 'tag': tag, @@ -117,6 +120,7 @@ git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s 'where_git': where_git} + cmd=cmd.replace('date_format','"%ai"') logger.logTxtFile.write("\n" + cmd + "\n") logger.logTxtFile.flush()