Skip to content
Snippets Groups Projects
Commit 808ba657 authored by Daniel Stonier's avatar Daniel Stonier
Browse files

a rebuild avoidance check integrated into the catkin api.

parent 10519044
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,7 @@ macro(generate_rosjava_messages)
ALL
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENJAVA_BIN}
${verbosity}
--avoid-rebuilding
-o ${CMAKE_CURRENT_BINARY_DIR}
-p ${ARG_PACKAGES} # this has to be a list argument so it separates each arg (not a single string!)
DEPENDS
......
......@@ -90,6 +90,7 @@ def standalone_parse_arguments(argv):
parser.add_argument('-o', '--output-dir', action='store', default='build', help='output directory for the java code (e.g. build/foo_msgs)')
parser.add_argument('-v', '--verbose', default=False, action='store_true', help='enable verbosity in debugging (false)')
parser.add_argument('-f', '--fakeit', default=False, action='store_true', help='dont build, just list the packages it would build (false)')
parser.add_argument('-a', '--avoid-rebuilding', default=False, action='store_true', help='avoid rebuilding if the working directory is already present (false)')
parsed_arguments = parser.parse_args(argv)
return parsed_arguments
......@@ -105,7 +106,15 @@ def standalone_main(argv):
sorted_package_tuples = rosjava_build_tools.catkin.index_message_package_dependencies_from_local_environment(package_name_list=args.packages)
print("")
print("Generating message artifacts for: \n%s" % [p.name for (unused_relative_path, p) in sorted_package_tuples])
did_not_rebuild_these_packages = []
if not args.fakeit:
for unused_relative_path, p in sorted_package_tuples:
gradle_project.standalone_create_and_build(p.name, args.output_dir, args.verbose)
result = gradle_project.standalone_create_and_build(p.name, args.output_dir, args.verbose, args.avoid_rebuilding)
if not result:
did_not_rebuild_these_packages.append(p.name)
if did_not_rebuild_these_packages:
print("")
print("Skipped re-generation of these message artifacts (clean first): %s" % did_not_rebuild_these_packages)
print("")
......@@ -172,12 +172,20 @@ def build(msg_pkg_name, output_dir, verbosity):
subprocess.call(cmd, stderr=subprocess.STDOUT,)
def standalone_create_and_build(msg_pkg_name, output_dir, verbosity):
def standalone_create_and_build(msg_pkg_name, output_dir, verbosity, avoid_rebuilding=False):
'''
Brute force create and build the message artifact distregarding any smarts
Brute force create and build the message artifact disregarding any smarts
such as whether message files changed or not. For use with the standalone
package builder.
:param str msg_pkg_name:
:param str output_dir:
:param bool verbosity:
:param bool avoid_rebuilding: don't rebuild if working dir is already there
:return bool : whether it built, or skipped because it was avoiding a rebuild
'''
genjava_gradle_dir = os.path.join(output_dir, msg_pkg_name)
if os.path.exists(genjava_gradle_dir) and avoid_rebuilding:
return False
create(msg_pkg_name, output_dir)
working_directory = os.path.join(os.path.abspath(output_dir), msg_pkg_name)
gradle_wrapper = os.path.join(os.path.abspath(output_dir), msg_pkg_name, 'gradlew')
......@@ -186,3 +194,4 @@ def standalone_create_and_build(msg_pkg_name, output_dir, verbosity):
cmd.append('--quiet')
#print("COMMAND........................%s" % cmd)
subprocess.call(cmd, stderr=subprocess.STDOUT,)
return True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment