37from typing
import List, Tuple
38from pathlib
import Path
42/*********************************************************************
43 * All MoveIt 2 headers have been updated to use the .hpp extension.
45 * .h headers are now autogenerated via {},
46 * and will import the corresponding .hpp with a deprecation warning.
48 * imports via .h files may be removed in future releases, so please
49 * modify your imports to use the corresponding .hpp imports.
51 * See https://github.com/moveit/moveit2/pull/3113 for extra details.
52 *********************************************************************/
57 ERROR =
"No include guard found in {}.hpp. Unable to generate pretext."
64 ERROR =
"No include directory found for {}.hpp. Unable to generate relative .hpp include"
78 return data[: data.find(match) + len(match)]
82 contains_guard = self.
guard in data
83 if not contains_guard:
92 ends_with_include =
lambda p: str(p).endswith(
"include")
93 include_paths = [p
for p
in self.
path.parents
if ends_with_include(p)]
96 relative_import = self.
path.relative_to(include_paths[0])
97 return f
"#include <{relative_import}>"
103 self.
path = hpp.path.with_suffix(
".h")
104 self.
warn =
'#pragma message(".h header is obsolete. Please use the .hpp header instead.")'
108 disclaimer = DISCLAIMER.format(Path(__file__).name).rstrip(
"\n")
109 items = [disclaimer, self.
hpp.pretext, self.
warn, self.
hpp.include]
110 return "\n".join(items) +
"\n"
114 def __init__(self, n_processed_hpps: int, bad_hpps: List[str]):
122 summary = f
"Can generate {self.n_processed_hpps} .h files."
124 summary += f
" Cannot generate {len(self.bad_hpps)} .h files:\n\n"
125 summary +=
"\n".join([f
"❌ {hpp}" for hpp
in self.
bad_hpps])
136 def __process_hpp(self, hpp: str) ->
None:
139 except (NoIncludeDirectory, NoIncludeGuard)
as e:
143 print(f
"\nProcessing {len(self.hpp_paths)} .hpp files...")
148 print(f
"Proceeding to generate {len(self.processed_hpps)} .h files...")
150 _ = [open(h.path,
"w").write(h.contents)
for h
in h_files]
153if __name__ ==
"__main__":
154 parser = argparse.ArgumentParser()
156 parser.add_argument(
"--apply", action=
"store_true", help=
"Generates the .h files")
157 args = parser.parse_args()
159 summary = generator.process_all_hpps()
161 if args.apply
and not summary.were_all_hpps_processed():
162 args.apply =
input(
"Continue? (y/n): ").lower() ==
"y"
164 generator.create_h_files()
166 print(
"Skipping file generation...")
void print(PropagationDistanceField &pdf, int numX, int numY, int numZ)