Skip to content
Closed
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
58 changes: 0 additions & 58 deletions .gitignore

This file was deleted.

41 changes: 14 additions & 27 deletions de.peeeq.wurstscript/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {
dependencies {
classpath 'de.undercouch:gradle-download-task:3.2.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:1.0.2'
classpath 'org.eclipse.jgit:org.eclipse.jgit:5.7.+'
}
}

Expand All @@ -19,6 +20,10 @@ plugins {
}

import de.undercouch.gradle.tasks.download.Download
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.internal.storage.file.FileRepository
import org.eclipse.jgit.lib.Constants
import org.eclipse.jgit.lib.ObjectId

import java.util.regex.Matcher
import java.util.regex.Pattern
Expand All @@ -27,8 +32,10 @@ import java.util.regex.Pattern
mainClassName = "de.peeeq.wurstio.Main"
version = "1.8.1.0"

sourceCompatibility = '1.8'
targetCompatibility = '1.8'
allprojects {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

jacoco {
toolVersion = "0.8.5"
Expand Down Expand Up @@ -105,7 +112,7 @@ dependencies {
compile 'com.github.inwc3:jmpq3:1.7.14'

// Water's wc3 libs
compile 'com.github.inwc3:wc3libs:257fcbd610'
compile 'com.github.inwc3:wc3libs:fd4b2fd5aa'

// The setup tool for wurst.build handling
compile 'com.github.wurstscript:wurstsetup:e038293d07'
Expand Down Expand Up @@ -156,23 +163,11 @@ task versionInfoFile {
String gitRevision = "unknown-version"
String gitRevisionlong = "unknown-version"

new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = 'git'
args = ['describe', '--tags', '--always']
standardOutput = os
}
gitRevision = os.toString().trim()
}
Git git = Git.open(new File(rootProject.projectDir, '..'))
ObjectId head = git.getRepository().resolve(Constants.HEAD)

new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = 'git'
args = ['describe', '--tags', '--always', '--abbrev=0']
standardOutput = os
}
gitRevisionlong = os.toString().trim()
}
gitRevision = head.abbreviate(8).name()
gitRevisionlong = head.getName()

String wurstVersion = "${version}-${gitRevision}"
inputs.property("wurstVersion", wurstVersion)
Expand Down Expand Up @@ -225,11 +220,6 @@ clean.doFirst {
delete genDir
}

//task wrapper(type: Wrapper) {
// gradleVersion = '2.12'
//}



apply plugin: 'de.undercouch.download'

Expand All @@ -244,6 +234,3 @@ task downloadAndUnzipFile(dependsOn: downloadZipFile, type: Copy) {
}

apply from: 'deploy.gradle'



Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Optional;

/**
*
Expand Down Expand Up @@ -77,8 +78,6 @@ public CompilationProcess(WurstGui gui, RunArgs runArgs) {
return null;
}

File mapFile = compiler.getMapFile();

if (runArgs.isRunTests()) {
timeTaker.measure("Run tests",
() -> runTests(compiler.getImTranslator(), compiler));
Expand Down Expand Up @@ -142,7 +141,6 @@ private File writeMapscript(CharSequence mapScript) {
if (runArgs.getOutFile() != null) {
outputMapscript = new File(runArgs.getOutFile());
} else {
//outputMapscript = File.createTempFile("outputMapscript", ".j");
outputMapscript = new File("./temp/output.j");
}
outputMapscript.getParentFile().mkdirs();
Expand All @@ -159,13 +157,13 @@ private void runTests(ImTranslator translator, WurstCompilerJassImpl compiler) {
// tests
gui.sendProgress("Running tests");
System.out.println("Running tests");
RunTests runTests = new RunTests(null, 0, 0, null) {
RunTests runTests = new RunTests(Optional.empty(), 0, 0, Optional.empty()) {
@Override
protected void print(String message) {
out.print(message);
}
};
runTests.runTests(translator, compiler.getImProg(), null, null);
runTests.runTests(translator, compiler.getImProg(), Optional.empty(), Optional.empty());

for (RunTests.TestFailure e : runTests.getFailTests()) {
gui.sendError(new CompileError(e.getFunction(), e.getMessage()));
Expand All @@ -179,6 +177,4 @@ protected void print(String message) {

System.out.println("Finished running tests");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public boolean matches(ImFunction f) {
}


public CompiletimeFunctionRunner(ImTranslator tr, ImProg imProg, File mapFile, MpqEditor mpqEditor, WurstGui gui, FunctionFlagToRun flag) {
public CompiletimeFunctionRunner(
ImTranslator tr, ImProg imProg, Optional<File> mapFile, MpqEditor mpqEditor, WurstGui gui,
FunctionFlagToRun flag) {
Preconditions.checkNotNull(imProg);
this.translator = tr;
this.imProg = imProg;
Expand All @@ -92,8 +94,6 @@ public CompiletimeFunctionRunner(ImTranslator tr, ImProg imProg, File mapFile, M


public void run() {
// interpreter.executeFunction("main");
// interpreter.executeFunction("initGlobals");
try {
List<Either<ImCompiletimeExpr, ImFunction>> toExecute = new ArrayList<>();
collectCompiletimeExpressions(toExecute);
Expand Down
19 changes: 11 additions & 8 deletions de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.peeeq.wurstio.map.importer.ImportFile;
import de.peeeq.wurstio.mpq.MpqEditor;
import de.peeeq.wurstio.mpq.MpqEditorFactory;
import de.peeeq.wurstio.utils.W3InstallationData;
import de.peeeq.wurstscript.*;
import de.peeeq.wurstscript.attributes.CompileError;
import de.peeeq.wurstscript.gui.WurstGui;
Expand All @@ -30,6 +31,7 @@
import java.nio.file.StandardCopyOption;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;

import static de.peeeq.wurstio.languageserver.ProjectConfigBuilder.FILE_NAME;
import static de.peeeq.wurstio.languageserver.WurstCommands.getCompileArgs;
Expand Down Expand Up @@ -108,7 +110,7 @@ public static void main(String[] args) {
try {
WurstProjectConfigData projectConfig = null;
Path buildDir = null;
Path target = null;
Optional<Path> target = Optional.empty();
String workspaceroot = runArgs.getWorkspaceroot();
if (runArgs.isBuild() && runArgs.getInputmap() != null && workspaceroot != null) {
Path root = Paths.get(workspaceroot);
Expand All @@ -118,9 +120,9 @@ public static void main(String[] args) {
if (java.nio.file.Files.exists(inputMap) && projectConfig != null) {
buildDir = root.resolve("_build");
java.nio.file.Files.createDirectories(buildDir);
target = buildDir.resolve(projectConfig.getBuildMapData().getFileName() + ".w3x");
java.nio.file.Files.copy(inputMap, target, StandardCopyOption.REPLACE_EXISTING);
runArgs.setMapFile(target.toAbsolutePath().toString());
target = Optional.of(buildDir.resolve(projectConfig.getBuildMapData().getFileName() + ".w3x"));
java.nio.file.Files.copy(inputMap, target.get(), StandardCopyOption.REPLACE_EXISTING);
runArgs.setMapFile(target.get().toAbsolutePath().toString());
}
}

Expand All @@ -139,7 +141,7 @@ public static void main(String[] args) {
@Nullable CharSequence compiledScript;

if (mapFilePath != null && workspaceroot != null) {
try (MpqEditor mpqEditor = MpqEditorFactory.getEditor(new File(mapFilePath))) {
try (MpqEditor mpqEditor = MpqEditorFactory.getEditor(Optional.of(new File(mapFilePath)))) {
File projectFolder = Paths.get(workspaceroot).toFile();
compiledScript = compilationProcess.doCompilation(mpqEditor, projectFolder);
if (compiledScript != null) {
Expand All @@ -158,11 +160,12 @@ public static void main(String[] args) {
File scriptFile = new File("compiled.j.txt");
Files.write(compiledScript.toString().getBytes(Charsets.UTF_8), scriptFile);

if (projectConfig != null && target != null) {
ProjectConfigBuilder.apply(projectConfig, target.toFile(), scriptFile, buildDir.toFile(), runArgs);
if (projectConfig != null && target.isPresent()) {
ProjectConfigBuilder.apply(projectConfig, target.get().toFile(), scriptFile, buildDir.toFile(),
runArgs, new W3InstallationData());

WLogger.info("map build success");
System.out.println("Build succeeded. Output file: <" + target.toAbsolutePath() + ">");
System.out.println("Build succeeded. Output file: <" + target.get().toAbsolutePath() + ">");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class WurstCompilerJassImpl implements WurstCompiler {
private WurstGui gui;
private boolean hasCommonJ;
private RunArgs runArgs;
private @Nullable File mapFile;
private Optional<File> mapFile = Optional.empty();
private @Nullable File projectFolder;
private ErrorHandler errorHandler;
private @Nullable Map<String, File> libCache = null;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void loadWurstFilesInDir(File dir) {
loadFile(f);
} else if (f.getName().equals("wurst.dependencies")) {
addDependencyFile(f);
} else if ((mapFile == null || runArgs.isNoExtractMapScript()) && f.getName().equals("war3map.j")) {
} else if ((!mapFile.isPresent() || runArgs.isNoExtractMapScript()) && f.getName().equals("war3map.j")) {
loadFile(f);
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ private void addDependencyFolder(File f, String folderName) {
// search mapFile
for (File file : files) {
if (file.getName().endsWith(".w3x") || file.getName().endsWith(".w3m")) {
mapFile = file;
mapFile = Optional.ofNullable(file);
} else if (file.isDirectory()) {
if (projectFolder != null && !file.getParent().equals(projectFolder.getAbsolutePath())) {
throw new RuntimeException("Cannot set projectFolder to " + file + " because it is already set to non parent " + projectFolder);
Expand All @@ -190,10 +190,10 @@ private void addDependencyFolder(File f, String folderName) {


// import wurst folder if it exists
File l_mapFile = mapFile;
if (l_mapFile != null) {
Optional<File> l_mapFile = mapFile;
if (l_mapFile.isPresent()) {
if (projectFolder == null) {
projectFolder = l_mapFile.getParentFile();
projectFolder = l_mapFile.get().getParentFile();
}
File relativeWurstDir = new File(projectFolder, "wurst");
if (relativeWurstDir.exists()) {
Expand Down Expand Up @@ -626,7 +626,7 @@ private WurstModel mergeCompilationUnits(List<CompilationUnit> compilationUnits)

private CompilationUnit processMap(File file) {
gui.sendProgress("Processing Map " + file.getName());
if (!file.equals(mapFile)) {
if (!mapFile.isPresent() || !file.equals(mapFile.get())) {
// TODO check if file != mapFile is possible, would be strange
// so this should definitely be done differently
throw new Error("file: " + file + " is not the mapfile: " + mapFile);
Expand Down Expand Up @@ -747,7 +747,7 @@ public ImProg getImProg() {
}
}

public @Nullable File getMapFile() {
public Optional<File> getMapFile() {
return mapFile;
}

Expand Down Expand Up @@ -792,7 +792,7 @@ public void setRunArgs(RunArgs runArgs) {
this.runArgs = runArgs;
}

public void setMapFile(File mapFile) {
public void setMapFile(Optional<File> mapFile) {
this.mapFile = mapFile;
}

Expand Down
Loading