String getModuleDirPath();
}
public static boolean compile(final CompilationContext context) {
HaxeModuleSettingsBase settings = context.getModuleSettings();
if (settings.isExcludeFromCompilation()) {
context.log("Module " + context.getModuleName() + " is excluded from compilation.");
return true;
}
final String mainClass = settings.getMainClass();
final String fileName = settings.getOutputFileName();
if (settings.isUseUserPropertiesToBuild()) {
if (mainClass == null || mainClass.length() == 0) {
context.errorHandler(HaxeCommonBundle.message("no.main.class.for.module", context.getModuleName()));
return false;
}
if (fileName == null || fileName.length() == 0) {
context.errorHandler(HaxeCommonBundle.message("no.output.file.name.for.module", context.getModuleName()));
return false;
}
}
final HaxeTarget target = settings.getHaxeTarget();
final NMETarget nmeTarget = settings.getNmeTarget();
final OpenFLTarget openFLTarget = settings.getOpenFLTarget();
if (target == null && !settings.isUseNmmlToBuild()) {
context.errorHandler(HaxeCommonBundle.message("no.target.for.module", context.getModuleName()));
return false;
}
if (nmeTarget == null && settings.isUseNmmlToBuild()) {
context.errorHandler(HaxeCommonBundle.message("no.target.for.module", context.getModuleName()));
return false;
}
if (openFLTarget == null && settings.isUseOpenFLToBuild()) {
context.errorHandler(HaxeCommonBundle.message("no.target.for.module", context.getModuleName()));
return false;
}
if (context.getSdkHomePath() == null) {
context.errorHandler(HaxeCommonBundle.message("no.sdk.for.module", context.getModuleName()));
return false;
}
final String sdkExePath = HaxeSdkUtilBase.getCompilerPathByFolderPath(context.getSdkHomePath());
if (sdkExePath == null || sdkExePath.isEmpty()) {
context.errorHandler(HaxeCommonBundle.message("invalid.haxe.sdk.for.module", context.getModuleName()));
return false;
}
final String haxelibPath = context.getHaxelibPath();
if ((settings.isUseOpenFLToBuild() || settings.isUseNmmlToBuild()) && (haxelibPath == null || haxelibPath.isEmpty())) {
context.errorHandler(HaxeCommonBundle.message("no.haxelib.for.sdk", context.getSdkName()));
return false;
}
final List<String> commandLine = new ArrayList<String>();
if (settings.isUseOpenFLToBuild() || settings.isUseNmmlToBuild()) {
commandLine.add(haxelibPath);
}
else {
commandLine.add(sdkExePath);
}
String workingPath = context.getCompileOutputPath() + "/" + (context.isDebug() ? "debug" : "release");
if (settings.isUseOpenFLToBuild()) {
setupOpenFL(commandLine, context);
workingPath = context.getModuleDirPath();
context.setErrorRoot(workingPath);
}
else if (settings.isUseNmmlToBuild()) {
setupNME(commandLine, context);
String nmmlPath = settings.getNmmlPath();
String nmmlDir = PathUtil.getParentPath(nmmlPath);
if (!StringUtil.isEmpty(nmmlDir)) {
context.setErrorRoot(nmmlDir);
}
}
else if (settings.isUseHxmlToBuild()) {
String hxmlPath = settings.getHxmlPath();
commandLine.add(FileUtil.toSystemDependentName(hxmlPath));
final int endIndex = hxmlPath.lastIndexOf('/');
if (endIndex > 0) {
workingPath = hxmlPath.substring(0, endIndex);
}
if (context.isDebug() && settings.getHaxeTarget() == HaxeTarget.FLASH) {
commandLine.add("-D");
commandLine.add("fdb");
commandLine.add("-debug");
}
}