Skip to content

Commit 8dcfd50

Browse files
committed
Add --silent option to silence the build output.
1 parent 04c6b39 commit 8dcfd50

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

docs/reference-manual/native-image/BuildOutput.md

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Run `native-image --expert-options-all | grep "BuildOutput"` to see all build ou
220220
-H:±BuildOutputLinks Show links in build output. Default: + (enabled).
221221
-H:±BuildOutputPrefix Prefix build output with '<pid>:<name of binary>'. Default: - (disabled).
222222
-H:±BuildOutputProgress Report progress in build output. Default: + (enabled).
223+
-H:±BuildOutputSilent Silence build output. Default: - (disabled).
223224
```
224225
225226
### Related Documentation

substratevm/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This changelog summarizes major changes to GraalVM Native Image.
66
* (GR-35721) Remove old build output style and the `-H:±BuildOutputUseNewStyle` option.
77
* (GR-39390) (GR-39649) (GR-40033) Red Hat added support for the JFR events `JavaMonitorEnter`, `JavaMonitorWait`, and `ThreadSleep`.
88
* (GR-39497) Add `-H:BuildOutputJSONFile=<file.json>` option for [JSON build output](https://github.com/oracle/graal/edit/master/docs/reference-manual/native-image/BuildOutput.md#machine-readable-build-output). Please feel free to provide feedback so that we can stabilize the schema/API.
9+
* (GR-40170) Add `--silent` option to silence the build output.
910

1011
## Version 22.2.0
1112
* (GR-20653) Re-enable the usage of all CPU features for JIT compilation on AMD64.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

+4
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ public Boolean getValue(OptionValues values) {
408408
/*
409409
* Build output options.
410410
*/
411+
@APIOption(name = "--silent")//
412+
@Option(help = "Silence build output", type = OptionType.User)//
413+
public static final HostedOptionKey<Boolean> BuildOutputSilent = new HostedOptionKey<>(false);
414+
411415
@Option(help = "Prefix build output with '<pid>:<image name>'", type = OptionType.User)//
412416
public static final HostedOptionKey<Boolean> BuildOutputPrefix = new HostedOptionKey<>(false);
413417

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageSystemIOWrappers.java

+19
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package com.oracle.svm.hosted;
2727

28+
import java.io.OutputStream;
2829
import java.io.PrintStream;
2930
import java.util.Objects;
3031

@@ -57,6 +58,10 @@ public static NativeImageSystemIOWrappers singleton() {
5758
return NativeImageSystemClassLoader.singleton().systemIOWrappers;
5859
}
5960

61+
public static NativeImageSystemIOWrappers disabled() {
62+
return new NativeImageSystemIOWrappersDisabled();
63+
}
64+
6065
public PrintStream getOut() {
6166
return outWrapper.delegate;
6267
}
@@ -103,4 +108,18 @@ private void maybeInformProgressReporterOnce() {
103108
}
104109
}
105110
}
111+
112+
private static class NativeImageSystemIOWrappersDisabled extends NativeImageSystemIOWrappers {
113+
private static final PrintStream NULL_PRINT_STREAM = new PrintStream(OutputStream.nullOutputStream());
114+
115+
@Override
116+
public PrintStream getOut() {
117+
return NULL_PRINT_STREAM;
118+
}
119+
120+
@Override
121+
public PrintStream getErr() {
122+
return NULL_PRINT_STREAM;
123+
}
124+
}
106125
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ public static ProgressReporter singleton() {
174174
}
175175

176176
public ProgressReporter(OptionValues options) {
177-
builderIO = NativeImageSystemIOWrappers.singleton();
177+
if (SubstrateOptions.BuildOutputSilent.getValue(options)) {
178+
builderIO = NativeImageSystemIOWrappers.disabled();
179+
} else {
180+
builderIO = NativeImageSystemIOWrappers.singleton();
181+
}
178182

179183
if (SubstrateOptions.BuildOutputJSONFile.hasBeenSet(options)) {
180184
jsonHelper = new ProgressReporterJsonHelper(SubstrateOptions.BuildOutputJSONFile.getValue(options));

0 commit comments

Comments
 (0)