Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions scripts/catkin-to-ament.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def port(cls, dryrun=False):

# TODO: need to handle the different semantics of tags between format 1 and 2
# see: http://www.ros.org/reps/rep-0140.html

generatesMessages = False
foundExport = False
foundBuildTool = False
for child in packageRoot.getchildren():
for child in packageRoot:
# Handle specific elements
if child.tag == "build_depend":
# Message generation no longer exists
Expand All @@ -111,7 +111,7 @@ def port(cls, dryrun=False):

# Found an export, check children for build type
foundBuildType = False
for export in child.getchildren():
for export in child:
# The build type needs to be specified for ament packages
if export.tag == "build_type":
export.text = "ament_cmake"
Expand All @@ -125,8 +125,8 @@ def port(cls, dryrun=False):
buildTypeElement.tail = "\n " # Spacing for export close

# Add spacing for open of the build type element
if len(child.getchildren()) > 0:
lastExport = child.getchildren()[-1]
if len(list(child)) > 0:
lastExport = list(child)[-1]
lastExport.tail = "\n " # Spacing to open of build type
else:
child.tail = "\n " # Spacing to build type element
Expand Down Expand Up @@ -154,7 +154,7 @@ def port(cls, dryrun=False):
execDependElement.tail = "\n " # Spacing to next element

# Add spacing before the open of the build tool depend element
lastChild = packageRoot.getchildren()[-1]
lastChild = list(packageRoot)[-1]
lastChild.tail = "\n\n " # Spacing for open build tool depend

packageRoot.append(buildToolElement)
Expand All @@ -168,7 +168,7 @@ def port(cls, dryrun=False):
buildToolElement.tail = "\n" # Spacing to next element

# Add spacing before the open of the build tool depend element
lastChild = packageRoot.getchildren()[-1]
lastChild = list(packageRoot)[-1]
lastChild.tail = "\n\n " # Spacing for open build tool depend

packageRoot.append(buildToolElement)
Expand All @@ -188,7 +188,7 @@ def port(cls, dryrun=False):
exportElement.append(buildTypeElement)

# Add spacing before the open of the export element
lastChild = packageRoot.getchildren()[-1]
lastChild = list(packageRoot)[-1]
lastChild.tail = "\n\n " # Spacing for open export

packageRoot.append(exportElement)
Expand All @@ -211,6 +211,7 @@ def port(cls, dryrun=False):
os.remove(tempFilename)

# Print the content
print("Printing content for file %s on this dry run\n"%os.path.join(os.getcwd(), PACKAGE_XML))
print(content)

return True # Success
Expand Down Expand Up @@ -270,7 +271,7 @@ def port(cls, dryrun=False):
for arg in args:
if "-std=c++11" in arg:
hasCpp11 = True
break
break
elif item.name == "find_package":
if len(args) > 0 and "catkin" == args[0]:
removeIndices.append(index)
Expand Down Expand Up @@ -412,10 +413,10 @@ def port(cls, dryrun=False):
for pkg in NO_CMAKE_FIND_PACKAGES:
if pkg in catkinDepends:
catkinDepends.remove(pkg)

# Add calls to find all other dependency packages
for pkg in catkinDepends:

findPkg = cls.__findPackage(pkg)
projectDeclIndex += 1
cmake.insert(projectDeclIndex, findPkg)
Expand Down Expand Up @@ -560,6 +561,7 @@ def port(cls, dryrun=False):
fid.write("%s\n" % cmakeData.strip())
fid.close()
else:
print("\nPrinting content for file %s on this dry run\n"%os.path.join(os.getcwd(), CMAKELISTS))
print(cmakeData)

return True # Success
Expand Down Expand Up @@ -600,7 +602,7 @@ def __addBlankLine(cls, cmake, index):
exit(1)

if args.dryrun:
print("Performing a dryrun...")
print("Performing a dryrun...\n")

# Port the package XML
if not PackageXmlPorter.port(args.dryrun):
Expand Down