use of org.eclipse.ceylon.langtools.tools.javac.main.Main.Result in project ceylon by eclipse.
the class CeylonCompileTool method run.
/**
* Run the compilation
* @throws IOException
* @throws CompilerErrorException If the source code had errors
* @throws SystemErrorException If there was a system error
* @throws CompilerBugException If a bug in the compiler was detected.
*/
@Override
public void run() throws IOException {
Result result = compiler.compile(arguments.toArray(new String[arguments.size()]));
handleExitCode(result.exitCode, compiler.exitState);
}
use of org.eclipse.ceylon.langtools.tools.javac.main.Main.Result in project ceylon by eclipse.
the class Main method compile.
/**
* Programmatic interface for main function.
* @param args The command line parameters.
*/
@Override
public Result compile(String[] args) {
Context context = new Context();
// can't create it until Log
CeyloncFileManager.preRegister(context);
// has been set up
CeylonLog.preRegister(context);
Result result = compile(args, context);
if (fileManager instanceof JavacFileManager) {
// A fresh context was created above, so jfm must be a
// JavacFileManager
((JavacFileManager) fileManager).close();
}
return result;
}
use of org.eclipse.ceylon.langtools.tools.javac.main.Main.Result in project ceylon by eclipse.
the class CeylonModuleRunner method compileAndRun.
private boolean compileAndRun(File srcDir, File resDir, File outRepo, String[] modules, String[] dependencies, String[] options, Set<String> removeAtRuntime, String[] modulesUsingCheckFunction, String[] modulesUsingCheckModule) throws Exception {
// Compile all the .ceylon files into a .car
Context context = new Context();
final ErrorCollector listener = new ErrorCollector();
// can't create it until Log
CeyloncFileManager.preRegister(context);
// has been set up
CeylonLog.preRegister(context);
context.put(DiagnosticListener.class, listener);
org.eclipse.ceylon.compiler.java.launcher.Main compiler = new org.eclipse.ceylon.compiler.java.launcher.Main("ceylonc");
List<String> args = new ArrayList<>();
// args.add("-verbose:code");
args.add("-g");
args.add("-sysrep");
args.add("../dist/dist/repo");
args.add("-src");
args.add(srcDir.getCanonicalPath());
args.add("-res");
args.add(resDir.getCanonicalPath());
args.add("-out");
args.add(outRepo.getAbsolutePath());
for (String option : options) {
args.add(option);
}
for (String module : modules) args.add(module);
for (String module : dependencies) args.add(module);
Result result = compiler.compile(args.toArray(new String[args.size()]), context);
TreeSet<CompilerError> errors = listener.get(Kind.ERROR);
if (!errors.isEmpty()) {
List<Runner> errorRunners = new LinkedList<Runner>();
for (final CompilerError compileError : errors) {
createFailingTest(errorRunners, compileError.filename, new CompilationException(compileError.toString()));
}
for (Runner errorRunner : errorRunners) {
children.put(errorRunner, errorRunner.getDescription());
}
// absolutely no point going on if we have errors
return false;
}
// for invalid options we don't get errors from the listener
if (!result.isOK()) {
List<Runner> errorRunners = new LinkedList<Runner>();
createFailingTest(errorRunners, "Invalid option?", new CompilationException("Invalid option? Check stdout."));
for (Runner errorRunner : errorRunners) {
children.put(errorRunner, errorRunner.getDescription());
}
// absolutely no point going on if we have errors
return false;
}
// remove what we need for runtime
for (String module : removeAtRuntime) {
File moduleFolder = new File(outRepo, module.replace('.', File.separatorChar));
FileUtil.delete(moduleFolder);
}
for (String module : modules) {
postCompile(context, listener, module, srcDir, dependencies, removeAtRuntime, modulesUsingCheckFunction, modulesUsingCheckModule);
}
return true;
}
Aggregations