diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java index 89aca88ef585..b25524fd804a 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java @@ -42,7 +42,6 @@ import java.util.function.Function; import java.util.stream.Collectors; -import jdk.graal.compiler.options.OptionsContainer; import org.graalvm.collections.EconomicMap; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; @@ -74,6 +73,7 @@ import jdk.graal.compiler.options.OptionDescriptor; import jdk.graal.compiler.options.OptionDescriptors; import jdk.graal.compiler.options.OptionStability; +import jdk.graal.compiler.options.OptionsContainer; import jdk.graal.compiler.options.OptionsParser; class APIOptionHandler extends NativeImage.OptionHandler { @@ -410,7 +410,10 @@ String translateOption(ArgumentQueue argQueue) { OptionInfo option = null; boolean whitespaceSeparated = false; String[] optionNameAndOptionValue = null; - OptionOrigin argumentOrigin = OptionOrigin.from(argQueue.argumentOrigin); + String argumentOriginString = OptionOrigin.from(argQueue.argumentOrigin).toString(); + if (nativeImage.useBundle()) { + argumentOriginString = nativeImage.bundleSupport.cleanupBuilderOutput(argumentOriginString); + } found: for (OptionInfo optionInfo : apiOptions.values()) { for (String variant : optionInfo.variants) { String optionName; @@ -437,7 +440,7 @@ String translateOption(ArgumentQueue argQueue) { argQueue.poll(); String optionValue = argQueue.peek(); if (optionValue == null) { - NativeImage.showError(headArg + " from " + argumentOrigin + " requires option argument"); + NativeImage.showError(headArg + " from " + argumentOriginString + " requires option argument"); } option = optionInfo; optionNameAndOptionValue = new String[]{headArg, optionValue}; @@ -457,14 +460,14 @@ String translateOption(ArgumentQueue argQueue) { } if (option != null) { if (!option.deprecationWarning.isEmpty()) { - LogUtils.warning("Using a deprecated option " + optionNameAndOptionValue[0] + " from " + argumentOrigin + ". " + option.deprecationWarning); + LogUtils.warning("Using a deprecated option " + optionNameAndOptionValue[0] + " from " + argumentOriginString + ". " + option.deprecationWarning); } String builderOption = option.builderOption; /* If option is in group, defaultValue has different use */ String optionValue = option.group != null ? null : option.defaultValue; if (optionNameAndOptionValue.length == 2) { if (option.defaultFinal) { - NativeImage.showError("Passing values to option " + optionNameAndOptionValue[0] + " from " + argumentOrigin + " is not supported."); + NativeImage.showError("Passing values to option " + optionNameAndOptionValue[0] + " from " + argumentOriginString + " is not supported."); } optionValue = optionNameAndOptionValue[1]; } diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java index 7fb5ec0bd4f4..8128e5c7ac41 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java @@ -113,6 +113,7 @@ final class BundleSupport { private static final String CONTAINER_OPTION = "container"; private static final String DOCKERFILE_OPTION = "dockerfile"; static final String BUNDLE_FILE_EXTENSION = ".nib"; + static final String BUNDLE_ALIAS = ""; ContainerSupport containerSupport; boolean useContainer; @@ -604,6 +605,15 @@ Path getExternalOutputDir() { return bundlePath.resolve(bundleName + '.' + outputDir.getFileName()); } + String cleanupBuilderOutput(String output) { + var transformedOutput = output; + if (bundlePath != null) { + transformedOutput = transformedOutput.replace(outputDir.toString(), getExternalOutputDir().toString()); + } + transformedOutput = transformedOutput.replace(rootDir.toString(), BUNDLE_ALIAS); + return transformedOutput; + } + void updateBundleLocation(Path bundleFile, boolean redefine) { if (redefine) { bundlePath = null; @@ -877,7 +887,7 @@ private void loadAndVerify() { String currentPlatform = bundlePlatform.equals(NativeImage.platform) ? "" : " != '" + NativeImage.platform + "'"; String bundleCreationTimestamp = properties.getOrDefault(PROPERTY_KEY_BUNDLE_FILE_CREATION_TIMESTAMP, ""); nativeImage.showNewline(); - nativeImage.showMessage("%sLoaded Bundle from %s", BUNDLE_INFO_MESSAGE_PREFIX, bundleFileName); + nativeImage.showMessage("%sLoaded Bundle from %s referred to as %s from here on.", BUNDLE_INFO_MESSAGE_PREFIX, bundleFileName, BUNDLE_ALIAS); nativeImage.showMessage("%sBundle created at '%s'", BUNDLE_INFO_MESSAGE_PREFIX, ArchiveSupport.parseTimestamp(bundleCreationTimestamp)); nativeImage.showMessage("%sUsing version: '%s'%s (vendor '%s'%s) on platform: '%s'%s", BUNDLE_INFO_MESSAGE_PREFIX, bundleVersion, currentVersion, diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java index c55462e3ebab..c5735097ee7f 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java @@ -1908,11 +1908,8 @@ protected int buildImage(List javaArgs, LinkedHashSet cp, LinkedHa } p = pb.start(); if (useBundle()) { - var internalOutputDir = bundleSupport.outputDir.toString(); - var externalOutputDir = bundleSupport.getExternalOutputDir().toString(); - Function filter = line -> line.replace(internalOutputDir, externalOutputDir); - ProcessOutputTransformer.attach(p.getInputStream(), filter, System.out); - ProcessOutputTransformer.attach(p.getErrorStream(), filter, System.err); + ProcessOutputTransformer.attach(p.getInputStream(), bundleSupport::cleanupBuilderOutput, System.out); + ProcessOutputTransformer.attach(p.getErrorStream(), bundleSupport::cleanupBuilderOutput, System.err); } imageBuilderPid = p.pid(); return p.waitFor(); @@ -1925,16 +1922,16 @@ protected int buildImage(List javaArgs, LinkedHashSet cp, LinkedHa } } - private record ProcessOutputTransformer(InputStream in, Function filter, PrintStream out) implements Runnable { + private record ProcessOutputTransformer(InputStream in, Function mapper, PrintStream out) implements Runnable { - static void attach(InputStream in, Function filter, PrintStream out) { - Thread.ofVirtual().start(new ProcessOutputTransformer(in, filter, out)); + static void attach(InputStream in, Function mapper, PrintStream out) { + Thread.ofVirtual().start(new ProcessOutputTransformer(in, mapper, out)); } @Override public void run() { try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { - reader.lines().map(filter).forEach(out::println); + reader.lines().map(mapper).forEach(out::println); } catch (IOException e) { throw showError("Unable to process stdout/stderr of image builder process", e); }