@@ -35,7 +35,9 @@ def get_output_path(source, output_dir, split_from, extension):
3535 """
3636
3737 # split_path: contains the path after splitting. For split_path = pcl, contains the path as seen in the pcl directory
38- _ , split_path = source .split (f"{ split_from } { os .sep } " , 1 )
38+ split_path = source .split (f"{ split_from } { os .sep } " , 1 )
39+ # handle the case where there's nothing to split
40+ split_path = split_path [1 ] if len (split_path ) == 2 else split_path [0 ]
3941
4042 # relative_dir: contains the relative output path for the json file
4143 # source_filename: contains the source's file name
@@ -93,17 +95,22 @@ def parse_arguments(script):
9395 )
9496 parser .add_argument (
9597 "--json_output_path" ,
96- default = get_parent_directory ( file = __file__ ),
98+ default = os . getcwd ( ),
9799 help = "Output path for generated json" ,
98100 )
101+ parser .add_argument (
102+ "--project-root" ,
103+ default = os .path .dirname (os .getcwd ()),
104+ help = "Path to split to make output paths shorter" ,
105+ )
99106 parser .add_argument ("files" , nargs = "+" , help = "The source files to parse" )
100107
101108 if script == "generate" :
102109 parser = argparse .ArgumentParser (description = "JSON to pybind11 generation" )
103110 parser .add_argument ("files" , nargs = "+" , help = "JSON input" )
104111 parser .add_argument (
105112 "--pybind11_output_path" ,
106- default = get_parent_directory ( file = __file__ ),
113+ default = os . getcwd ( ),
107114 help = "Output path for generated cpp" ,
108115 )
109116
0 commit comments