From 9f6a7336083771f724ebd989f0670152d09c15eb Mon Sep 17 00:00:00 2001 From: Frotty Date: Wed, 8 Jan 2020 17:19:42 +0100 Subject: [PATCH] use project's common.j blizzard.j files for pjass checks, resolves #645 and don't ignore "-noPJass" flag in ProjectConfigBuilder --- .../java/de/peeeq/wurstio/CompilationProcess.java | 10 +++++++++- .../src/main/java/de/peeeq/wurstio/Pjass.java | 8 ++++++-- .../languageserver/ProjectConfigBuilder.java | 7 +++++-- .../languageserver/requests/MapRequest.java | 14 ++++++++------ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/CompilationProcess.java b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/CompilationProcess.java index 54f4129ee..01e7ae2dc 100644 --- a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/CompilationProcess.java +++ b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/CompilationProcess.java @@ -117,7 +117,15 @@ public CompilationProcess(WurstGui gui, RunArgs runArgs) { } private boolean runPjass(File outputMapscript) { - Pjass.Result pJassResult = Pjass.runPjass(outputMapscript); + File commonJ = new File(outputMapscript.getParent(), "common.j"); + File blizzJ = new File(outputMapscript.getParent(), "blizzard.j"); + + Pjass.Result pJassResult; + if (commonJ.exists() && blizzJ.exists()) { + pJassResult = Pjass.runPjass(outputMapscript, commonJ.getAbsolutePath(), blizzJ.getAbsolutePath()); + } else { + pJassResult = Pjass.runPjass(outputMapscript); + } WLogger.info(pJassResult.getMessage()); if (!pJassResult.isOk()) { for (CompileError err : pJassResult.getErrors()) { diff --git a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/Pjass.java b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/Pjass.java index 42065cd15..760a4d2e8 100644 --- a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/Pjass.java +++ b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/Pjass.java @@ -88,13 +88,17 @@ public List getErrors() { } public static Result runPjass(File outputFile) { + return runPjass(outputFile, Utils.getResourceFile("common.j"), Utils.getResourceFile("blizzard.j")); + } + + public static Result runPjass(File outputFile, String commonJPath, String blizzardJPath) { try { Process p; WLogger.info("Starting pjass"); List args = new ArrayList<>(); args.add(Utils.getResourceFile("pjass.exe")); - args.add(Utils.getResourceFile("common.j")); - args.add(Utils.getResourceFile("blizzard.j")); + args.add(commonJPath); + args.add(blizzardJPath); args.add(outputFile.getPath()); if (Orient.isLinuxSystem()) { File fileName = Utils.getResourceFileF("pjass"); diff --git a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/ProjectConfigBuilder.java b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/ProjectConfigBuilder.java index d9cb627a6..1cf02d229 100644 --- a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/ProjectConfigBuilder.java +++ b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/ProjectConfigBuilder.java @@ -34,7 +34,7 @@ public static void apply(WurstProjectConfigData projectConfig, File targetMap, F try (MpqEditor mpq = MpqEditorFactory.getEditor((targetMap))) { - File file = new File(buildDir, "wc3libs.j"); + File file = new File(buildDir, "wc3libs_injected.j"); byte[] scriptBytes; if (!projectConfig.getBuildMapData().getName().isEmpty()) { // Apply w3i config values @@ -67,7 +67,10 @@ public static void apply(WurstProjectConfigData projectConfig, File targetMap, F } Files.write(scriptBytes, file); - Pjass.runPjass(file); + if (!runArgs.isDisablePjass()) { + Pjass.runPjass(file, new File(buildDir, "common.j").getAbsolutePath(), + new File(buildDir, "blizzard.j").getAbsolutePath()); + } String mapScriptName; if (runArgs.isLua()) { mapScriptName = "war3map.lua"; diff --git a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/MapRequest.java b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/MapRequest.java index 775c2b4fe..13c718de5 100644 --- a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/MapRequest.java +++ b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/MapRequest.java @@ -201,7 +201,9 @@ protected File compileMap(File projectFolder, WurstGui gui, File mapCopy, RunArg if (!runArgs.isDisablePjass()) { gui.sendProgress("Running PJass"); - Pjass.Result pJassResult = Pjass.runPjass(outFile); + Pjass.Result pJassResult = Pjass.runPjass(outFile, + new File(buildDir, "common.j").getAbsolutePath(), + new File(buildDir, "blizzard.j").getAbsolutePath()); WLogger.info(pJassResult.getMessage()); if (!pJassResult.isOk()) { for (CompileError err : pJassResult.getErrors()) { @@ -224,9 +226,9 @@ protected File compileMap(File projectFolder, WurstGui gui, File mapCopy, RunArg } private File runJassHotCodeReload(File mapScript) throws IOException, InterruptedException { - File mapScriptFolder = mapScript.getParentFile(); - File commonJ = new File(mapScriptFolder, "common.j"); - File blizzardJ = new File(mapScriptFolder, "blizzard.j"); + File buildDir = getBuildDir(); + File commonJ = new File(buildDir, "common.j"); + File blizzardJ = new File(buildDir, "blizzard.j"); if (!commonJ.exists()) { throw new IOException("Could not find file " + commonJ.getAbsolutePath()); @@ -237,9 +239,9 @@ private File runJassHotCodeReload(File mapScript) throws IOException, Interrupte } ProcessBuilder pb = new ProcessBuilder(configProvider.getJhcrExe(), "init", commonJ.getName(), blizzardJ.getName(), mapScript.getName()); - pb.directory(mapScriptFolder); + pb.directory(buildDir); Utils.ExecResult result = Utils.exec(pb, Duration.ofSeconds(30), System.err::println); - return new File(mapScriptFolder, "jhcr_war3map.j"); + return new File(buildDir, "jhcr_war3map.j"); } /**