GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setWorkDirectory(PathUtil.getParentPath(context.getProject().getProjectFilePath()));
commandLine.setPassParentEnvironment(true);
for (Module module : moduleChunk.getNodes()) {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
for (VirtualFile sourceRoot : moduleRootManager.getSourceRoots()) {
commandLine.addParameter("-I");
String path = sourceRoot.getCanonicalPath();
if (path != null) {
commandLine.addParameter(path);
}
}
VirtualFile outDir = context.getModuleOutputDirectory(module);
if (outDir == null) {
context.addMessage(CompilerMessageCategory.ERROR, "No output dir for module: " + module.getName(), null, -1, -1);
return;
}
commandLine.setWorkDirectory(outDir.getCanonicalPath());
for (VirtualFile o : files) {
String canonicalPath = o.getCanonicalPath();
if (canonicalPath == null) continue;
commandLine.addParameter(canonicalPath);
}
// commandLine.addParameters("+warn_unused_vars", "+nowarn_shadow_vars", "+warn_unused_import");
Sdk sdk = moduleRootManager.getSdk();
if (sdk == null) {
context.addMessage(CompilerMessageCategory.ERROR, "No SDK for module: " + module.getName(), null, -1, -1);
return;
}