@@ -20,8 +20,8 @@ def walk_dir(file_name, directory):
20
20
return walk_dir (file_name , os .path .join (root , subdir ))
21
21
22
22
23
- def locate_file (file_name , search_dirs ):
24
- cur_dir = os .path .dirname (sys .argv [0 ])
23
+ def locate_file (file_name , search_dirs , base_directory = None ):
24
+ cur_dir = base_directory or os .path .dirname (sys .argv [0 ])
25
25
initial_path = os .path .join (cur_dir , file_name )
26
26
27
27
if os .path .isfile (initial_path ):
@@ -35,10 +35,10 @@ def locate_file(file_name, search_dirs):
35
35
return None
36
36
37
37
38
- def split (lib_name , search_dirs = [], extension = "cc" , out = "out" ):
38
+ def split (lib_name , search_dirs = [], extension = "cc" , out = "out" , base_directory = None ):
39
39
header_name = lib_name + ".h"
40
40
source_name = lib_name + "." + extension
41
- in_file = locate_file (header_name , search_dirs )
41
+ in_file = locate_file (header_name , search_dirs , base_directory )
42
42
if not in_file :
43
43
print ("File not found: {}" .format (header_name ))
44
44
return
@@ -104,13 +104,24 @@ def main():
104
104
dest = "libraries" ,
105
105
help = "the libraries to split (default: [httplib])" ,
106
106
)
107
+ args_parser .add_argument (
108
+ "-b" ,
109
+ "--base-directory" ,
110
+ help = "where to look for files (default: <script directory>)" ,
111
+ )
107
112
args = args_parser .parse_args ()
108
113
109
114
default_libraries = ["httplib" ]
110
115
search_dirs = ["example" ]
111
116
112
117
for lib_name in args .libraries or default_libraries :
113
- split (lib_name , search_dirs , args .extension , args .out )
118
+ split (
119
+ lib_name ,
120
+ search_dirs ,
121
+ args .extension ,
122
+ args .out ,
123
+ args .base_directory ,
124
+ )
114
125
115
126
116
127
if __name__ == "__main__" :
0 commit comments