"build-tools" module + "buildTools" Ant target added

This commit is contained in:
Evgeny Goldin
2012-01-15 17:35:49 +02:00
parent 90fb61f63c
commit 28044c18cd
4 changed files with 80 additions and 5 deletions
@@ -0,0 +1,47 @@
package org.jetbrains.jet.buildtools.core;
import org.jetbrains.jet.cli.KotlinCompiler;
import java.io.File;
import java.io.IOException;
/**
* Wrapper class for Kotlin bytecode compiler.
*/
public class KotlinBytecodeCompiler {
/**
* Compiles a single file.
*
* @param sourceFile source file to compile
* @param destinationDirectory destination directory to compile the file to
*/
public static void file ( File sourceFile, File destinationDirectory ) {
String sourcePath = getPath( sourceFile );
String destinationPath = getPath( destinationDirectory );
try {
KotlinCompiler.main( "-src", sourcePath, "-output", destinationPath );
}
catch ( Exception e ) {
throw new RuntimeException( String.format( "Failed to compile [%s] to [%s]: %s", sourcePath, destinationPath, e ), e );
}
}
/**
* {@code file.getCanonicalFile().getPath()} convenience wrapper.
* @param f file to get its canonical path.
* @return file's canonical path
*/
private static String getPath( File f ) {
try {
return f.getCanonicalFile().getPath();
}
catch ( IOException e ) {
throw new RuntimeException( String.format( "Failed to resolve canonical file of [%s]: %s", f, e ), e );
}
}
}
@@ -0,0 +1,8 @@
package org.jetbrains.jet.buildtools.core;
/**
* Wrapper class for Kotlin JavaScript compiler.
*/
public class KotlinJavaScriptCompiler {
}