forked from coqui-ai/STT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bazel.patch
264 lines (250 loc) · 10.9 KB
/
bazel.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/FileWriteAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/FileWriteAction.java
index c7aa4cb63..e084bc27c 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/FileWriteAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/FileWriteAction.java
@@ -28,6 +28,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.PrintWriter;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -73,6 +74,8 @@ public final class FileWriteAction extends AbstractFileWriteAction {
*/
private final CharSequence fileContents;
+ private final Artifact output;
+
/** Minimum length (in chars) for content to be eligible for compression. */
private static final int COMPRESS_CHARS_THRESHOLD = 256;
@@ -90,6 +93,7 @@ public final class FileWriteAction extends AbstractFileWriteAction {
fileContents = new CompressedString((String) fileContents);
}
this.fileContents = fileContents;
+ this.output = output;
}
/**
@@ -230,11 +234,32 @@ public final class FileWriteAction extends AbstractFileWriteAction {
*/
@Override
protected String computeKey() {
+ // System.err.println("src/main/java/com/google/devtools/build/lib/analysis/actions/FileWriteAction.java => output: " + output.getExecPath());
+ // ".ckd" Compute Key Debug
+ PrintWriter computeKeyDebugWriter = null;
+ String computeKeyDebugFile = output.getExecPath() + ".FileWriteAction.ckd";
+ try {
+ computeKeyDebugWriter = new PrintWriter(computeKeyDebugFile, "UTF-8");
+ } catch (java.io.FileNotFoundException ex) {
+ System.err.println("Unable to create " + computeKeyDebugFile);
+ } catch (java.io.UnsupportedEncodingException ex) {
+ System.err.println("Unsupported encoding");
+ }
+
Fingerprint f = new Fingerprint();
f.addString(GUID);
+ computeKeyDebugWriter.println("GUID: " + GUID);
+
f.addString(String.valueOf(makeExecutable));
+ computeKeyDebugWriter.println("MAKEEXECUTABLE: " + String.valueOf(makeExecutable));
+
f.addString(getFileContents());
- return f.hexDigestAndReset();
+ computeKeyDebugWriter.println("FILECONTENTS: " + getFileContents());
+
+ String rv = f.hexDigestAndReset();
+ computeKeyDebugWriter.println("KEY: " + rv);
+ computeKeyDebugWriter.close();
+ return rv;
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
index 580788160..26883eb92 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
@@ -60,6 +60,7 @@ import com.google.devtools.build.lib.util.ShellEscaper;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.protobuf.GeneratedMessage.GeneratedExtension;
import java.nio.charset.Charset;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -91,6 +92,9 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
private final CommandLine argv;
+ private final Iterable<Artifact> inputs;
+ private final Iterable<Artifact> outputs;
+
private final boolean executeUnconditionally;
private final boolean isShellCommand;
private final String progressMessage;
@@ -197,6 +201,9 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
this.mnemonic = mnemonic;
this.executeUnconditionally = executeUnconditionally;
this.extraActionInfoSupplier = extraActionInfoSupplier;
+
+ this.inputs = inputs;
+ this.outputs = outputs;
}
@Override
@@ -312,23 +319,89 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
@Override
protected String computeKey() {
+ boolean genruleSetup = String.valueOf(Iterables.get(inputs, 0).getExecPath()).contains("genrule/genrule-setup.sh");
+ boolean validGenrule = genruleSetup && (Iterables.size(inputs) > 1);
+
+ String genruleScript = null;
+ if (validGenrule) {
+ genruleScript = String.valueOf(Iterables.get(inputs, 1).getExecPath());
+ }
+
+ // ".ckd" Compute Key Debug
+ PrintWriter computeKeyDebugWriter = null;
+ if (validGenrule) {
+ String computeKeyDebugFile = genruleScript + ".SpawnAction.ckd";
+ try {
+ computeKeyDebugWriter = new PrintWriter(computeKeyDebugFile, "UTF-8");
+ } catch (java.io.FileNotFoundException ex) {
+ System.err.println("Unable to create " + computeKeyDebugFile);
+ } catch (java.io.UnsupportedEncodingException ex) {
+ System.err.println("Unsupported encoding");
+ }
+ }
+
+ validGenrule = validGenrule && (computeKeyDebugWriter != null);
+
Fingerprint f = new Fingerprint();
f.addString(GUID);
+ if (validGenrule) { computeKeyDebugWriter.println("GUID: " + GUID); }
+
f.addStrings(argv.arguments());
+ if (validGenrule) {
+ for (String input : argv.arguments()) {
+ computeKeyDebugWriter.println("ARGUMENTS: " + input);
+ }
+ }
+
f.addString(getMnemonic());
+ if (validGenrule) { computeKeyDebugWriter.println("MNEMONIC: " + getMnemonic()); }
+
// We don't need the toolManifests here, because they are a subset of the inputManifests by
// definition and the output of an action shouldn't change whether something is considered a
// tool or not.
f.addPaths(getRunfilesSupplier().getRunfilesDirs());
+ if (validGenrule) {
+ for (PathFragment path : getRunfilesSupplier().getRunfilesDirs()) {
+ computeKeyDebugWriter.println("RUNFILESDIRS: " + path.getPathString());
+ }
+ }
+
ImmutableList<Artifact> runfilesManifests = getRunfilesSupplier().getManifests();
f.addInt(runfilesManifests.size());
+ if (validGenrule) { computeKeyDebugWriter.println("RUNFILESMANIFESTSSIZE: " + runfilesManifests.size()); }
+
for (Artifact runfilesManifest : runfilesManifests) {
f.addPath(runfilesManifest.getExecPath());
+ if (validGenrule) { computeKeyDebugWriter.println("RUNFILESMANIFEST: " + runfilesManifest.getExecPath().getPathString()); }
}
+
f.addStringMap(getEnvironment());
+ if (validGenrule) {
+ for (Map.Entry<String, String> entry : getEnvironment().entrySet()) {
+ computeKeyDebugWriter.println("ENV: " + entry.getKey() + "=" + entry.getValue());
+ }
+ }
+
f.addStrings(getClientEnvironmentVariables());
+ if (validGenrule) {
+ for (String input : argv.arguments()) {
+ computeKeyDebugWriter.println("CLIENTENV: " + input);
+ }
+ }
+
f.addStringMap(getExecutionInfo());
- return f.hexDigestAndReset();
+ if (validGenrule) {
+ for (Map.Entry<String, String> entry : executionInfo.entrySet()) {
+ computeKeyDebugWriter.println("EXECINFO: " + entry.getKey() + "=" + entry.getValue());
+ }
+ }
+
+ String rv = f.hexDigestAndReset();
+ if (validGenrule) {
+ computeKeyDebugWriter.println("KEY: " + rv);
+ computeKeyDebugWriter.close();
+ }
+ return rv;
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
index 3559fffde..3ba39617c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
@@ -1111,10 +1111,30 @@ public class CppCompileAction extends AbstractAction
@Override
public String computeKey() {
+ // ".ckd" Compute Key Debug
+ PrintWriter computeKeyDebugWriter = null;
+ String computeKeyDebugFile = getInternalOutputFile() + ".CppCompileAction.ckd";
+ try {
+ computeKeyDebugWriter = new PrintWriter(computeKeyDebugFile, "UTF-8");
+ } catch (java.io.FileNotFoundException ex) {
+ System.err.println("Unable to create " + computeKeyDebugFile);
+ } catch (java.io.UnsupportedEncodingException ex) {
+ System.err.println("Unsupported encoding");
+ }
+
Fingerprint f = new Fingerprint();
f.addUUID(actionClassId);
+ computeKeyDebugWriter.println("UUID: " + actionClassId);
+
f.addStringMap(getEnvironment());
+ for (Map.Entry<String, String> entry : getEnvironment().entrySet()) {
+ computeKeyDebugWriter.println("ENV: " + entry.getKey() + "=" + entry.getValue());
+ }
+
f.addStringMap(executionInfo);
+ for (Map.Entry<String, String> entry : executionInfo.entrySet()) {
+ computeKeyDebugWriter.println("EXECINFO: " + entry.getKey() + "=" + entry.getValue());
+ }
// For the argv part of the cache key, ignore all compiler flags that explicitly denote module
// file (.pcm) inputs. Depending on input discovery, some of the unused ones are removed from
@@ -1124,6 +1144,9 @@ public class CppCompileAction extends AbstractAction
// A better long-term solution would be to make the compiler to find them automatically and
// never hand in the .pcm files explicitly on the command line in the first place.
f.addStrings(compileCommandLine.getArgv(getInternalOutputFile(), null));
+ for (String input : compileCommandLine.getArgv(getInternalOutputFile(), null)) {
+ computeKeyDebugWriter.println("COMMAND: " + input);
+ }
/*
* getArgv() above captures all changes which affect the compilation
@@ -1133,19 +1156,31 @@ public class CppCompileAction extends AbstractAction
* have changed, otherwise we might miss some errors.
*/
f.addPaths(context.getDeclaredIncludeDirs());
+ for (PathFragment path : context.getDeclaredIncludeDirs()) {
+ computeKeyDebugWriter.println("DECLAREDINCLUDEDIRS: " + path.getPathString());
+ }
f.addPaths(context.getDeclaredIncludeWarnDirs());
+ for (PathFragment path : context.getDeclaredIncludeWarnDirs()) {
+ computeKeyDebugWriter.println("DECLAREDINCLUDEWARNDIRS: " + path.getPathString());
+ }
for (Artifact declaredIncludeSrc : context.getDeclaredIncludeSrcs()) {
f.addPath(declaredIncludeSrc.getExecPath());
+ computeKeyDebugWriter.println("DECLAREDINCLUDESRCS: " + declaredIncludeSrc.getExecPath().getPathString());
}
f.addInt(0); // mark the boundary between input types
for (Artifact input : getMandatoryInputs()) {
f.addPath(input.getExecPath());
+ computeKeyDebugWriter.println("MANDATORYINPUTS: " + input.getExecPath().getPathString());
}
f.addInt(0);
for (Artifact input : prunableInputs) {
f.addPath(input.getExecPath());
+ computeKeyDebugWriter.println("PRUNABLEINPUTS: " + input.getExecPath().getPathString());
}
- return f.hexDigestAndReset();
+ String rv = f.hexDigestAndReset();
+ computeKeyDebugWriter.println("KEY: " + rv);
+ computeKeyDebugWriter.close();
+ return rv;
}
@Override