|
62 | 62 | import com.oracle.svm.core.JavaMainWrapper.JavaMainSupport;
|
63 | 63 | import com.oracle.svm.core.OS;
|
64 | 64 | import com.oracle.svm.core.SubstrateOptions;
|
| 65 | +import com.oracle.svm.core.option.HostedOptionKey; |
65 | 66 | import com.oracle.svm.core.option.SubstrateOptionsParser;
|
66 | 67 | import com.oracle.svm.core.util.ExitStatus;
|
67 | 68 | import com.oracle.svm.core.util.InterruptImageBuilding;
|
@@ -393,13 +394,16 @@ private int buildImage(ImageClassLoader classLoader) {
|
393 | 394 | Pair<Method, CEntryPointData> mainEntryPointData = Pair.empty();
|
394 | 395 | JavaMainSupport javaMainSupport = null;
|
395 | 396 |
|
396 |
| - NativeImageKind imageKind; |
| 397 | + NativeImageKind imageKind = null; |
397 | 398 | boolean isStaticExecutable = SubstrateOptions.StaticExecutable.getValue(parsedHostedOptions);
|
398 | 399 | boolean isSharedLibrary = SubstrateOptions.SharedLibrary.getValue(parsedHostedOptions);
|
399 | 400 | boolean isImageLayer = SubstrateOptions.ImageLayer.getValue(parsedHostedOptions);
|
400 |
| - if ((isStaticExecutable && isSharedLibrary) || (isStaticExecutable && isImageLayer) || (isSharedLibrary && isImageLayer)) { |
401 |
| - throw UserError.abort("Cannot pass multiple options: %s, %s, %s", SubstrateOptionsParser.commandArgument(SubstrateOptions.SharedLibrary, "+"), |
402 |
| - SubstrateOptionsParser.commandArgument(SubstrateOptions.StaticExecutable, "+"), SubstrateOptionsParser.commandArgument(SubstrateOptions.ImageLayer, "+")); |
| 401 | + if (isStaticExecutable && isSharedLibrary) { |
| 402 | + reportConflictingOptions(SubstrateOptions.SharedLibrary, SubstrateOptions.StaticExecutable); |
| 403 | + } else if (isStaticExecutable && isImageLayer) { |
| 404 | + reportConflictingOptions(SubstrateOptions.StaticExecutable, SubstrateOptions.ImageLayer); |
| 405 | + } else if (isSharedLibrary && isImageLayer) { |
| 406 | + reportConflictingOptions(SubstrateOptions.SharedLibrary, SubstrateOptions.ImageLayer); |
403 | 407 | } else if (isSharedLibrary) {
|
404 | 408 | imageKind = NativeImageKind.SHARED_LIBRARY;
|
405 | 409 | } else if (isImageLayer) {
|
@@ -583,6 +587,10 @@ private int buildImage(ImageClassLoader classLoader) {
|
583 | 587 | return ExitStatus.OK.getValue();
|
584 | 588 | }
|
585 | 589 |
|
| 590 | + private static void reportConflictingOptions(HostedOptionKey<Boolean> o1, HostedOptionKey<Boolean> o2) { |
| 591 | + throw UserError.abort("Cannot pass both options: %s and %s", SubstrateOptionsParser.commandArgument(o1, "+"), SubstrateOptionsParser.commandArgument(o2, "+")); |
| 592 | + } |
| 593 | + |
586 | 594 | protected void reportEpilog(String imageName, ProgressReporter reporter, ImageClassLoader classLoader, boolean wasSuccessfulBuild, Throwable unhandledThrowable, OptionValues parsedHostedOptions) {
|
587 | 595 | reporter.printEpilog(Optional.ofNullable(imageName), Optional.ofNullable(generator), classLoader, wasSuccessfulBuild, Optional.ofNullable(unhandledThrowable), parsedHostedOptions);
|
588 | 596 | }
|
|
0 commit comments