fix(users/edef/depot-scan): properly trace readFile/readDir
Change-Id: I493e7d20504d34f83a53db50b69e86668874756e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1651 Reviewed-by: edef <edef@edef.eu> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									88a6bea6e8
								
							
						
					
					
						commit
						fcffacf8c9
					
				
					 3 changed files with 19 additions and 2 deletions
				
			
		
							
								
								
									
										17
									
								
								users/edef/depot-scan-wrap.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								users/edef/depot-scan-wrap.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| # this wraps import to override readFile and readDir to trace the files it touches | ||||
| # technique inspired by lorri | ||||
| { ... }: | ||||
| 
 | ||||
| let | ||||
| 
 | ||||
|   global = { | ||||
|     import = global.scopedImport {}; | ||||
|     scopedImport = x: builtins.scopedImport (global // x); | ||||
|     builtins = builtins // { | ||||
|       inherit (global) import scopedImport; | ||||
|       readFile = path: builtins.trace "depot-scan '${toString path}'" (builtins.readFile path); | ||||
|       readDir  = path: builtins.trace "depot-scan '${toString path}'" (builtins.readDir  path); | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
| in global.import | ||||
|  | @ -8,5 +8,5 @@ pkgs.writeShellScriptBin "depot-scan" '' | |||
|   attr="''${path//\//.}" | ||||
|   root="$(git rev-parse --show-toplevel)" | ||||
|   echo "scanning //$path" >&2 | ||||
|   nix-instantiate "$root" -A "$attr" -vv 2> >(${pkgs.perl}/bin/perl ${./depot-scan.pl}) >&2 | ||||
|   nix-instantiate -E "import ${./depot-scan-wrap.nix} {} $root" -A "$attr" -vv 2> >(${pkgs.perl}/bin/perl ${./depot-scan.pl}) >&2 | ||||
| '' | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ use strict; | |||
| 
 | ||||
| if (/^evaluating file '(.*)'$/ or | ||||
|     /^copied source '(.*)' -> '.*'$/ or | ||||
|     /^trace: lorri read: '(.*)'$/) { | ||||
|     /^trace: depot-scan '(.*)'$/) { | ||||
|     print $1; | ||||
|     next; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue