Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void complete() {
}

if (writeOutput) {
Path externalOutputDir = bundlePath.resolve(bundleName + "." + outputDir.getFileName());
Path externalOutputDir = getExternalOutputDir();
copyFiles(outputDir, externalOutputDir, true);
nativeImage.showMessage(BUNDLE_INFO_MESSAGE_PREFIX + "Bundle build output written to " + externalOutputDir);
}
Expand All @@ -598,6 +598,12 @@ void complete() {
}
}

Path getExternalOutputDir() {
Objects.requireNonNull(bundlePath);
Objects.requireNonNull(bundleName);
return bundlePath.resolve(bundleName + '.' + outputDir.getFileName());
}

void updateBundleLocation(Path bundleFile, boolean redefine) {
if (redefine) {
bundlePath = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.lang.module.FindException;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder;
Expand Down Expand Up @@ -83,6 +84,7 @@
import com.oracle.svm.common.option.CommonOptions;
import com.oracle.svm.core.FallbackExecutor;
import com.oracle.svm.core.FallbackExecutor.Options;
import com.oracle.svm.core.JavaVersionUtil;
import com.oracle.svm.core.NativeImageClassLoaderOptions;
import com.oracle.svm.core.OS;
import com.oracle.svm.core.SharedConstants;
Expand Down Expand Up @@ -111,7 +113,6 @@
import com.oracle.svm.util.StringUtil;

import jdk.graal.compiler.options.OptionKey;
import com.oracle.svm.core.JavaVersionUtil;
import jdk.internal.jimage.ImageReader;

public class NativeImage {
Expand Down Expand Up @@ -1865,7 +1866,17 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa

Process p = null;
try {
p = pb.inheritIO().start();
if (!useBundle()) {
pb.inheritIO();
}
p = pb.start();
if (useBundle()) {
var internalOutputDir = bundleSupport.outputDir.toString();
var externalOutputDir = bundleSupport.getExternalOutputDir().toString();
Function<String, String> filter = line -> line.replace(internalOutputDir, externalOutputDir);
ProcessOutputTransformer.attach(p.getInputStream(), filter, System.out);
ProcessOutputTransformer.attach(p.getErrorStream(), filter, System.err);
}
imageBuilderPid = p.pid();
return p.waitFor();
} catch (IOException | InterruptedException e) {
Expand All @@ -1877,6 +1888,22 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
}
}

private record ProcessOutputTransformer(InputStream in, Function<String, String> filter, PrintStream out) implements Runnable {

static void attach(InputStream in, Function<String, String> filter, PrintStream out) {
Thread.ofVirtual().start(new ProcessOutputTransformer(in, filter, out));
}

@Override
public void run() {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
reader.lines().map(filter).forEach(out::println);
} catch (IOException e) {
throw showError("Unable to process stdout/stderr of image builder process", e);
}
}
}

/**
* Creates a file with name 'fileName' in the {@link NativeImage#driverTempDir temporary
* directory} and returns the path to the newly created file. Note: the file will be deleted if
Expand Down
Loading