From 7d15ff85baf1fc30afe62950e69a3c145d1dbe33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20W=C3=B6gerer?= Date: Tue, 10 May 2022 13:51:40 +0200 Subject: [PATCH] Make CommandLineOptionOrigin detection for @argfile-use work for Windows --- .../src/com/oracle/svm/core/option/OptionOrigin.java | 7 ++----- .../src/com/oracle/svm/driver/DefaultOptionHandler.java | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/OptionOrigin.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/OptionOrigin.java index a82237bed85d..b3878619b55a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/OptionOrigin.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/OptionOrigin.java @@ -42,6 +42,7 @@ public abstract class OptionOrigin { public static final OptionOrigin commandLineOptionOriginSingleton = new CommandLineOptionOrigin(); + public static final String argFilePrefix = "argfile:"; public URI container() { return null; @@ -66,7 +67,7 @@ public List getRedirectionValues(@SuppressWarnings("unused") Path values public static OptionOrigin from(String origin) { - if (origin == null) { + if (origin == null || origin.startsWith(argFilePrefix)) { return commandLineOptionOriginSingleton; } @@ -78,10 +79,6 @@ public static OptionOrigin from(String origin) { } throw VMError.shouldNotReachHere("Unsupported OptionOrigin: " + origin); } - if (originURI.getScheme() == null) { - /* @argument files use path as origin */ - return commandLineOptionOriginSingleton; - } switch (originURI.getScheme()) { case "jar": return new JarOptionOrigin(originURI); diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java index c14edae42e4f..121d431ed9e1 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java @@ -36,6 +36,7 @@ import org.graalvm.compiler.options.OptionType; +import com.oracle.svm.core.option.OptionOrigin; import com.oracle.svm.core.option.OptionUtils; import com.oracle.svm.driver.NativeImage.ArgumentQueue; @@ -319,7 +320,7 @@ public boolean consume(ArgumentQueue args) { args.poll(); headArg = headArg.substring(1); Path argFile = Paths.get(headArg); - NativeImage.NativeImageArgsProcessor processor = nativeImage.new NativeImageArgsProcessor(argFile.toString()); + NativeImage.NativeImageArgsProcessor processor = nativeImage.new NativeImageArgsProcessor(OptionOrigin.argFilePrefix + argFile); readArgFile(argFile).forEach(processor::accept); List leftoverArgs = processor.apply(false); if (leftoverArgs.size() > 0) {