Skip to content

Commit

Permalink
use project's common.j blizzard.j files for pjass checks, resolves #645
Browse files Browse the repository at this point in the history
and don't ignore "-noPJass" flag in ProjectConfigBuilder
  • Loading branch information
Frotty committed Jan 8, 2020
1 parent 7471c43 commit 9f6a733
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ public List<CompileError> 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<String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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());
Expand All @@ -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");
}

/**
Expand Down

0 comments on commit 9f6a733

Please sign in to comment.