@@ -61,6 +61,13 @@ def __init__(self, target: str, **_kwargs: str):
6161 # if we are initializing this, it is indeed a foundry project and thus has a root path
6262 assert project_root is not None
6363 self ._project_root : Path = project_root
64+ self ._config : PlatformConfig | None = None
65+
66+ def _get_config (self ) -> PlatformConfig | None :
67+ """Get cached platform config, loading it if needed."""
68+ if self ._config is None :
69+ self ._config = self .config (self ._project_root )
70+ return self ._config
6471
6572 def compile (self , crytic_compile : "CryticCompile" , ** kwargs : str ) -> None :
6673 """Compile
@@ -106,7 +113,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
106113
107114 compile_all = kwargs .get ("foundry_compile_all" , False )
108115
109- foundry_config = self .config ( self . _project_root )
116+ foundry_config = self ._get_config ( )
110117
111118 if not targeted_build and not compile_all and foundry_config :
112119 compilation_command += [
@@ -250,7 +257,14 @@ def is_dependency(self, path: str) -> bool:
250257 """
251258 if path in self ._cached_dependencies :
252259 return self ._cached_dependencies [path ]
253- ret = "lib" in Path (path ).parts or "node_modules" in Path (path ).parts
260+ path_parts = Path (path ).parts
261+ config = self ._get_config ()
262+ libs_path = (config .libs_path if config else None ) or []
263+ ret = (
264+ "lib" in path_parts
265+ or "node_modules" in path_parts
266+ or any (lib in path_parts for lib in libs_path )
267+ )
254268 self ._cached_dependencies [path ] = ret
255269 return ret
256270
0 commit comments