34
34
/** {@link RunfilesSupplier} implementation wrapping a single {@link Runfiles} directory mapping. */
35
35
@ AutoCodec
36
36
public final class SingleRunfilesSupplier implements RunfilesSupplier {
37
+
37
38
private final PathFragment runfilesDir ;
38
39
private final Runfiles runfiles ;
39
40
private final Supplier <Map <PathFragment , Artifact >> runfilesInputs ;
40
41
@ Nullable private final Artifact manifest ;
42
+ @ Nullable private final Artifact repoMappingManifest ;
41
43
private final boolean buildRunfileLinks ;
42
44
private final boolean runfileLinksEnabled ;
43
45
@@ -50,28 +52,31 @@ public static SingleRunfilesSupplier create(RunfilesSupport runfilesSupport) {
50
52
runfilesSupport .getRunfiles (),
51
53
/*runfilesCachingEnabled=*/ false ,
52
54
/*manifest=*/ null ,
55
+ runfilesSupport .getRepoMappingManifest (),
53
56
runfilesSupport .isBuildRunfileLinks (),
54
57
runfilesSupport .isRunfilesEnabled ());
55
58
}
56
59
57
60
/**
58
61
* Same as {@link SingleRunfilesSupplier#SingleRunfilesSupplier(PathFragment, Runfiles, Artifact,
59
- * boolean, boolean)}, except adds caching for {@linkplain Runfiles#getRunfilesInputs runfiles
60
- * inputs}.
62
+ * Artifact, boolean, boolean)}, except adds caching for {@linkplain Runfiles#getRunfilesInputs
63
+ * runfiles inputs}.
61
64
*
62
65
* <p>The runfiles inputs are computed lazily and softly cached. Caching is shared across
63
66
* instances created via {@link #withOverriddenRunfilesDir}.
64
67
*/
65
68
public static SingleRunfilesSupplier createCaching (
66
69
PathFragment runfilesDir ,
67
70
Runfiles runfiles ,
71
+ @ Nullable Artifact repoMappingManifest ,
68
72
boolean buildRunfileLinks ,
69
73
boolean runfileLinksEnabled ) {
70
74
return new SingleRunfilesSupplier (
71
75
runfilesDir ,
72
76
runfiles ,
73
77
/*runfilesCachingEnabled=*/ true ,
74
78
/*manifest=*/ null ,
79
+ repoMappingManifest ,
75
80
buildRunfileLinks ,
76
81
runfileLinksEnabled );
77
82
}
@@ -92,13 +97,15 @@ public SingleRunfilesSupplier(
92
97
PathFragment runfilesDir ,
93
98
Runfiles runfiles ,
94
99
@ Nullable Artifact manifest ,
100
+ @ Nullable Artifact repoMappingManifest ,
95
101
boolean buildRunfileLinks ,
96
102
boolean runfileLinksEnabled ) {
97
103
this (
98
104
runfilesDir ,
99
105
runfiles ,
100
106
/*runfilesCachingEnabled=*/ false ,
101
107
manifest ,
108
+ repoMappingManifest ,
102
109
buildRunfileLinks ,
103
110
runfileLinksEnabled );
104
111
}
@@ -108,15 +115,19 @@ private SingleRunfilesSupplier(
108
115
Runfiles runfiles ,
109
116
boolean runfilesCachingEnabled ,
110
117
@ Nullable Artifact manifest ,
118
+ @ Nullable Artifact repoMappingManifest ,
111
119
boolean buildRunfileLinks ,
112
120
boolean runfileLinksEnabled ) {
113
121
this (
114
122
runfilesDir ,
115
123
runfiles ,
116
124
runfilesCachingEnabled
117
- ? new RunfilesCacher (runfiles )
118
- : () -> runfiles .getRunfilesInputs (/*eventHandler=*/ null , /*location=*/ null ),
125
+ ? new RunfilesCacher (runfiles , repoMappingManifest )
126
+ : () ->
127
+ runfiles .getRunfilesInputs (
128
+ /*eventHandler=*/ null , /*location=*/ null , repoMappingManifest ),
119
129
manifest ,
130
+ repoMappingManifest ,
120
131
buildRunfileLinks ,
121
132
runfileLinksEnabled );
122
133
}
@@ -126,13 +137,15 @@ private SingleRunfilesSupplier(
126
137
Runfiles runfiles ,
127
138
Supplier <Map <PathFragment , Artifact >> runfilesInputs ,
128
139
@ Nullable Artifact manifest ,
140
+ @ Nullable Artifact repoMappingManifest ,
129
141
boolean buildRunfileLinks ,
130
142
boolean runfileLinksEnabled ) {
131
143
checkArgument (!runfilesDir .isAbsolute ());
132
144
this .runfilesDir = checkNotNull (runfilesDir );
133
145
this .runfiles = checkNotNull (runfiles );
134
146
this .runfilesInputs = checkNotNull (runfilesInputs );
135
147
this .manifest = manifest ;
148
+ this .repoMappingManifest = repoMappingManifest ;
136
149
this .buildRunfileLinks = buildRunfileLinks ;
137
150
this .runfileLinksEnabled = runfileLinksEnabled ;
138
151
}
@@ -199,17 +212,21 @@ public SingleRunfilesSupplier withOverriddenRunfilesDir(PathFragment newRunfiles
199
212
runfiles ,
200
213
runfilesInputs ,
201
214
manifest ,
215
+ repoMappingManifest ,
202
216
buildRunfileLinks ,
203
217
runfileLinksEnabled );
204
218
}
205
219
206
220
/** Softly caches the result of {@link Runfiles#getRunfilesInputs}. */
207
221
private static final class RunfilesCacher implements Supplier <Map <PathFragment , Artifact >> {
222
+
208
223
private final Runfiles runfiles ;
224
+ @ Nullable private final Artifact repoMappingManifest ;
209
225
private volatile SoftReference <Map <PathFragment , Artifact >> ref = new SoftReference <>(null );
210
226
211
- RunfilesCacher (Runfiles runfiles ) {
227
+ RunfilesCacher (Runfiles runfiles , @ Nullable Artifact repoMappingManifest ) {
212
228
this .runfiles = runfiles ;
229
+ this .repoMappingManifest = repoMappingManifest ;
213
230
}
214
231
215
232
@ Override
@@ -221,7 +238,9 @@ public Map<PathFragment, Artifact> get() {
221
238
synchronized (this ) {
222
239
result = ref .get ();
223
240
if (result == null ) {
224
- result = runfiles .getRunfilesInputs (/*eventHandler=*/ null , /*location=*/ null );
241
+ result =
242
+ runfiles .getRunfilesInputs (
243
+ /*eventHandler=*/ null , /*location=*/ null , repoMappingManifest );
225
244
ref = new SoftReference <>(result );
226
245
}
227
246
}
0 commit comments