Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ protected File executeBuildMapPipeline(ModelManager modelManager, WurstGui gui,
File targetMapFile = getBuildOutputMapFile(projectConfig, buildDir);
targetMapFile = ensureWritableBuildOutput(targetMapFile, false);

CompilationResult result = compileScript(modelManager, gui, Optional.of(targetMapFile), projectConfig, buildDir, true);
CompilationResult result = compileScript(modelManager, gui, Optional.of(targetMapFile), projectConfig, buildDir, isProductionBuild());
injectMapData(gui, Optional.of(targetMapFile), result);

targetMapFile = ensureWritableBuildOutput(targetMapFile, true);
Expand All @@ -787,6 +787,10 @@ protected File executeBuildMapPipeline(ModelManager modelManager, WurstGui gui,
return targetMapFile;
}

protected boolean isProductionBuild() {
return !runArgs.isDevBuild();
}

protected File ensureWritableBuildOutput(File targetMapFile, boolean isFinalWrite) {
String lockMessage = isFinalWrite
? "The output map file is still in use and cannot be replaced.\nClick Retry, choose Rename to use a temporary file name, or Cancel."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class RunArgs {
private final RunOption optionHotStartmap;
private final RunOption optionHotReload;
private final RunOption optionTestTimeout;
private final RunOption optionDevBuild;
private int functionSplitLimit = 10000;

/**
Expand Down Expand Up @@ -144,6 +145,7 @@ public RunArgs(String... args) {
optionHotReload = addOption("hotreload", "Reloads the mapscript after running the map with Jass Hot Code Reload (JHCR).");

optionBuild = addOption("build", "Builds an output map from the input map and library directories.");
optionDevBuild = addOption("dev", "Builds an output map in development/run mode, so compiletime isProductionBuild() is false.");
addOptionWithArg("workspaceroot", "The next argument should be the root folder of the project to build.", arg -> workspaceroot = arg);
addOptionWithArg("inputmap", "The next argument should be the input map.", arg -> inputmap = arg);
optionLua = addOption("lua", "Choose Lua as the compilation target.");
Expand Down Expand Up @@ -398,6 +400,10 @@ public boolean isBuild() {
return optionBuild.isSet;
}

public boolean isDevBuild() {
return optionDevBuild.isSet;
}

public String getWorkspaceroot() {
return workspaceroot;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,15 @@ public void pre124PatchPropagatesLegacyJassChecksToCompileArgs() throws Exceptio
"modern build must not carry the legacy flag: " + modern.exposedCompileArgs());
}

@Test
public void devBuildFlagMakesBuildPipelineNonProduction() throws Exception {
TestMapRequest dev = new TestMapRequest(projectWithPatch("v2.0"), Optional.empty(), Optional.empty(), List.of("-dev"));
assertFalse(dev.exposedIsProductionBuild(), "CLI build with -dev should expose isProductionBuild() = false to compiletime");

TestMapRequest release = new TestMapRequest(projectWithPatch("v2.0"), Optional.empty(), Optional.empty());
assertTrue(release.exposedIsProductionBuild(), "CLI build without -dev should remain production by default");
}

private static Path projectWithPatch(String patch) throws Exception {
Path project = Files.createTempDirectory("wurst-map-request-patch");
Files.createDirectories(project.resolve("wurst"));
Expand All @@ -264,7 +273,11 @@ private static Path projectWithPatch(String patch) throws Exception {

private static final class TestMapRequest extends MapRequest {
TestMapRequest(Path projectRoot, Optional<String> wc3Path, Optional<String> gameExePath) {
super(null, Optional.empty(), List.of(), WFile.create(projectRoot), wc3Path, gameExePath);
this(projectRoot, wc3Path, gameExePath, List.of());
}

TestMapRequest(Path projectRoot, Optional<String> wc3Path, Optional<String> gameExePath, List<String> compileArgs) {
super(null, Optional.empty(), compileArgs, WFile.create(projectRoot), wc3Path, gameExePath);
}

Optional<GameVersion> detectedVersion() {
Expand All @@ -279,6 +292,10 @@ List<String> exposedCompileArgs() {
return compileArgs;
}

boolean exposedIsProductionBuild() {
return isProductionBuild();
}

@Override
public Object execute(ModelManager modelManager) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public void compactOutputFlag() {
Assert.assertTrue(new RunArgs("-compactOutput").isCompactOutput());
}

@Test
public void devBuildFlag() {
Assert.assertTrue(new RunArgs("-dev").isDevBuild());
Assert.assertFalse(new RunArgs().isDevBuild());
}

@Test
public void compactCompileErrorIsSingleLine() {
CompileError error = new CompileError((WPos) null, "first line\nsecond line");
Expand Down
Loading