"build-tools" module + "buildTools" Ant target added
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
@@ -24,6 +24,15 @@
|
||||
</dirset>
|
||||
</path>
|
||||
|
||||
<path id="buildToolsSourcepath">
|
||||
<dirset dir="${basedir}/build-tools">
|
||||
<include name="core/src"/>
|
||||
<include name="ant/src"/>
|
||||
<include name="maven/src"/>
|
||||
<include name="gradle/src"/>
|
||||
</dirset>
|
||||
</path>
|
||||
|
||||
<target name="compileRT">
|
||||
<mkdir dir="${output}/classes/runtime"/>
|
||||
<javac destdir="${output}/classes/runtime" debug="true" debuglevel="lines,vars,source">
|
||||
@@ -52,7 +61,7 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
<target name="compile" depends="compileRT">
|
||||
<mkdir dir="${output}/classes/compiler"/>
|
||||
<javac destdir="${output}/classes/compiler" debug="true" debuglevel="lines,vars,source">
|
||||
@@ -72,7 +81,18 @@
|
||||
<delete dir="${output}"/>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="clean,jarRT,jar">
|
||||
<target name="buildTools" depends="compile">
|
||||
<mkdir dir="${output}/classes/buildTools"/>
|
||||
<javac destdir="${output}/classes/buildTools" debug="true" debuglevel="lines,vars,source">
|
||||
<src refid="buildToolsSourcepath"/>
|
||||
<classpath refid="classpath.kotlin"/>
|
||||
</javac>
|
||||
<jar destfile="${output}/kotlin-build-tools.jar">
|
||||
<fileset dir="${output}/classes/buildTools"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="clean,jarRT,jar,buildTools">
|
||||
<echo file="${output}/build.txt" message="${build.number}"/>
|
||||
<zip destfile="${output}/${output.name}.zip">
|
||||
<zipfileset prefix="kotlinc" file="${output}/build.txt"/>
|
||||
|
||||
@@ -32,12 +32,12 @@ public class KotlinCompiler {
|
||||
@Argument(value = "help", alias = "h", description = "show help")
|
||||
public boolean help;
|
||||
}
|
||||
|
||||
|
||||
private static void usage(PrintStream target) {
|
||||
target.println("Usage: KotlinCompiler [-output <outputDir>|-jar <jarFileName>] [-src <filename or dirname>|-module <module file>] [-includeRuntime] [-excludeStdlib]");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String ... args) {
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
Arguments arguments = new Arguments();
|
||||
try {
|
||||
@@ -53,7 +53,7 @@ public class KotlinCompiler {
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (arguments.help) {
|
||||
usage(System.out);
|
||||
System.exit(0);
|
||||
|
||||
Reference in New Issue
Block a user