@@ -236,11 +236,12 @@ def filenames_of_lib_helper(lib, non_recursive_libnames, ext):
236
236
* libprefix , lib = lib .split ("." )
237
237
if "." .join (libprefix ) == logical_name :
238
238
cur_lib = os .path .join (physical_name , lib )
239
+ # TODO HERE USE pathlib
239
240
yield fix_path (os .path .relpath (os .path .normpath (cur_lib + ext ), "." ))
240
241
241
242
242
243
@memoize
243
- def filename_of_lib_helper (lib , non_recursive_libnames , ext ):
244
+ def filename_of_lib_helper (lib , non_recursive_libnames , ext , base_dir ):
244
245
filenames = list (filenames_of_lib_helper (lib , non_recursive_libnames , ext ))
245
246
existing_filenames = [f for f in filenames if os_path_isfile (f ) or os_path_isfile (os .path .splitext (f )[0 ] + ".v" )]
246
247
if len (existing_filenames ) > 0 :
@@ -271,7 +272,7 @@ def filename_of_lib_helper(lib, non_recursive_libnames, ext):
271
272
level = LOG_ALWAYS ,
272
273
)
273
274
return retval
274
- return fix_path (os .path .relpath (os .path .normpath (lib .replace ("." , os .sep ) + ext ), "." ))
275
+ return fix_path (os .path .relpath (os .path .normpath (lib .replace ("." , os .sep ) + ext ), base_dir ))
275
276
276
277
277
278
def filename_of_lib (lib , ext = ".v" , ** kwargs ):
@@ -284,7 +285,7 @@ def filename_of_lib(lib, ext=".v", **kwargs):
284
285
285
286
286
287
@memoize
287
- def lib_of_filename_helper (filename , non_recursive_libnames , exts ):
288
+ def lib_of_filename_helper (filename , non_recursive_libnames , exts , base_dir ):
288
289
for ext in exts :
289
290
if filename .endswith (ext ):
290
291
filename = filename [: - len (ext )]
@@ -301,10 +302,12 @@ def lib_of_filename_helper(filename, non_recursive_libnames, exts):
301
302
if close_matches :
302
303
DEFAULT_LOG (f"Close matches: { close_matches } " , level = LOG_ALWAYS )
303
304
else :
304
- DEFAULT_LOG (f"Looked in { non_recursive_libnames } " , level = 1 )
305
- raise Exception
306
- if os .path .relpath (os .path .normpath (filename ), "." ).startswith (".." + os .sep ) and not os .path .isabs (filename ):
305
+ DEFAULT_LOG (f"Looked in { non_recursive_libnames } " , level = 3 )
306
+ # if not allow_nomatch:
307
+ # raise RuntimeError(f"Could not find logical name for physical name {filename}")
308
+ if os .path .relpath (os .path .normpath (filename ), base_dir ).startswith (".." + os .sep ) and not os .path .isabs (filename ):
307
309
filename = os .path .abspath (filename )
310
+ DEFAULT_LOG (f"Returning { filename .replace (os .sep , '.' )} " , level = LOG_ALWAYS )
308
311
return filename , filename .replace (os .sep , "." )
309
312
310
313
0 commit comments