Skip to content

Commit

Permalink
Add --silent option to silence the build output.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Aug 1, 2022
1 parent 04c6b39 commit 8dcfd50
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Run `native-image --expert-options-all | grep "BuildOutput"` to see all build ou
-H:±BuildOutputLinks Show links in build output. Default: + (enabled).
-H:±BuildOutputPrefix Prefix build output with '<pid>:<name of binary>'. Default: - (disabled).
-H:±BuildOutputProgress Report progress in build output. Default: + (enabled).
-H:±BuildOutputSilent Silence build output. Default: - (disabled).
```
### Related Documentation
Expand Down
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-35721) Remove old build output style and the `-H:±BuildOutputUseNewStyle` option.
* (GR-39390) (GR-39649) (GR-40033) Red Hat added support for the JFR events `JavaMonitorEnter`, `JavaMonitorWait`, and `ThreadSleep`.
* (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.
* (GR-40170) Add `--silent` option to silence the build output.

## Version 22.2.0
* (GR-20653) Re-enable the usage of all CPU features for JIT compilation on AMD64.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ public Boolean getValue(OptionValues values) {
/*
* Build output options.
*/
@APIOption(name = "--silent")//
@Option(help = "Silence build output", type = OptionType.User)//
public static final HostedOptionKey<Boolean> BuildOutputSilent = new HostedOptionKey<>(false);

@Option(help = "Prefix build output with '<pid>:<image name>'", type = OptionType.User)//
public static final HostedOptionKey<Boolean> BuildOutputPrefix = new HostedOptionKey<>(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.oracle.svm.hosted;

import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Objects;

Expand Down Expand Up @@ -57,6 +58,10 @@ public static NativeImageSystemIOWrappers singleton() {
return NativeImageSystemClassLoader.singleton().systemIOWrappers;
}

public static NativeImageSystemIOWrappers disabled() {
return new NativeImageSystemIOWrappersDisabled();
}

public PrintStream getOut() {
return outWrapper.delegate;
}
Expand Down Expand Up @@ -103,4 +108,18 @@ private void maybeInformProgressReporterOnce() {
}
}
}

private static class NativeImageSystemIOWrappersDisabled extends NativeImageSystemIOWrappers {
private static final PrintStream NULL_PRINT_STREAM = new PrintStream(OutputStream.nullOutputStream());

@Override
public PrintStream getOut() {
return NULL_PRINT_STREAM;
}

@Override
public PrintStream getErr() {
return NULL_PRINT_STREAM;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ public static ProgressReporter singleton() {
}

public ProgressReporter(OptionValues options) {
builderIO = NativeImageSystemIOWrappers.singleton();
if (SubstrateOptions.BuildOutputSilent.getValue(options)) {
builderIO = NativeImageSystemIOWrappers.disabled();
} else {
builderIO = NativeImageSystemIOWrappers.singleton();
}

if (SubstrateOptions.BuildOutputJSONFile.hasBeenSet(options)) {
jsonHelper = new ProgressReporterJsonHelper(SubstrateOptions.BuildOutputJSONFile.getValue(options));
Expand Down

0 comments on commit 8dcfd50

Please sign in to comment.