Add an implementation for SubprocessFactory based on the new JNI interface to Windows process management.
With this change, Bazel can build itself using native Windows process management and Ctrl-C works in server mode as expected. Yay!
Flipping the flag will come in a separate change that's easy to roll back if need be.
--
MOS_MIGRATED_REVID=126408264
diff --git a/src/test/java/com/google/devtools/build/lib/windows/MockSubprocess.java b/src/test/java/com/google/devtools/build/lib/windows/MockSubprocess.java
index 7e2d90c..1562532 100644
--- a/src/test/java/com/google/devtools/build/lib/windows/MockSubprocess.java
+++ b/src/test/java/com/google/devtools/build/lib/windows/MockSubprocess.java
@@ -16,6 +16,7 @@
import java.io.PrintStream;
import java.nio.charset.Charset;
+import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
@@ -28,6 +29,8 @@
* <li><code>E-<string></code>: Write a string to stderr</li>
* <li><code>O$<variable></code>: Write an environment variable to stdout</li>
* <li><code>E$<variable></code>: Write an environment variable to stderr</li>
+ * <li><code>O.</code>: Write the cwd stdout</li>
+ * <li><code>E.</code>: Write the cwd stderr</li>
* <li><code>O<register></code>: Write the contents of a register to stdout</li>
* <li><code>E<register></code>: Write the contents of a register to stderr</li>
* <li><code>X<exit code%gt;</code>: Exit with the specified exit code</li>
@@ -45,18 +48,24 @@
*/
public class MockSubprocess {
private static Map<Character, byte[]> registers = new HashMap<>();
+ private static final Charset UTF8 = Charset.forName("UTF-8");
private static void writeBytes(PrintStream stream, String arg) throws Exception {
+
byte[] buf;
switch (arg.charAt(1)) {
case '-':
// Immediate string
- buf = arg.substring(2).getBytes(Charset.forName("UTF-8"));
+ buf = arg.substring(2).getBytes(UTF8);
break;
case '$':
// Environment variable
- buf = System.getenv(arg.substring(2)).getBytes(Charset.forName("UTF-8"));
+ buf = System.getenv(arg.substring(2)).getBytes(UTF8);
+ break;
+
+ case '.':
+ buf = Paths.get(".").toAbsolutePath().normalize().toString().getBytes(UTF8);
break;
default: