|
35 | 35 | import java.nio.file.NoSuchFileException;
|
36 | 36 | import java.nio.file.Paths;
|
37 | 37 | import java.util.ArrayList;
|
| 38 | +import java.util.HashMap; |
38 | 39 | import java.util.List;
|
39 | 40 | import java.util.ListIterator;
|
40 | 41 | import java.util.Map;
|
41 | 42 | import java.util.Set;
|
42 | 43 |
|
43 |
| -import com.oracle.truffle.llvm.toolchain.launchers.common.Driver; |
44 |
| - |
45 | 44 | import org.graalvm.launcher.AbstractLanguageLauncher;
|
46 | 45 | import org.graalvm.nativeimage.ImageInfo;
|
47 | 46 | import org.graalvm.nativeimage.ProcessProperties;
|
|
55 | 54 | import org.graalvm.polyglot.SourceSection;
|
56 | 55 | import org.graalvm.polyglot.Value;
|
57 | 56 |
|
| 57 | +import com.oracle.truffle.llvm.toolchain.launchers.common.Driver; |
| 58 | + |
58 | 59 | import jline.console.UserInterruptException;
|
59 | 60 |
|
60 | 61 | public class GraalPythonMain extends AbstractLanguageLauncher {
|
@@ -82,6 +83,7 @@ public static void main(String[] args) {
|
82 | 83 | private List<String> givenArguments;
|
83 | 84 | private List<String> relaunchArgs;
|
84 | 85 | private boolean wantsExperimental = false;
|
| 86 | + private Map<String, String> enginePolyglotOptions; |
85 | 87 |
|
86 | 88 | @Override
|
87 | 89 | protected List<String> preprocessArguments(List<String> givenArgs, Map<String, String> polyglotOptions) {
|
@@ -267,6 +269,16 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
|
267 | 269 | return unrecognized;
|
268 | 270 | }
|
269 | 271 |
|
| 272 | + @Override |
| 273 | + protected void validateArguments(Map<String, String> polyglotOptions) { |
| 274 | + if (multiContext) { |
| 275 | + // Hack to pass polyglot options to the shared engine, not to the context which would |
| 276 | + // refuse them |
| 277 | + this.enginePolyglotOptions = new HashMap<>(polyglotOptions); |
| 278 | + polyglotOptions.clear(); |
| 279 | + } |
| 280 | + } |
| 281 | + |
270 | 282 | private void addRelaunchArg(String arg) {
|
271 | 283 | if (relaunchArgs == null) {
|
272 | 284 | relaunchArgs = new ArrayList<>();
|
@@ -371,7 +383,7 @@ protected void launch(Builder contextBuilder) {
|
371 | 383 | contextBuilder.option("python.TerminalHeight", Integer.toString(consoleHandler.getTerminalHeight()));
|
372 | 384 |
|
373 | 385 | if (multiContext) {
|
374 |
| - contextBuilder.engine(Engine.create()); |
| 386 | + contextBuilder.engine(Engine.newBuilder().allowExperimentalOptions(true).options(enginePolyglotOptions).build()); |
375 | 387 | }
|
376 | 388 |
|
377 | 389 | int rc = 1;
|
|
0 commit comments