diff options
author | paltherr <paltherr@epfl.ch> | 2004-01-19 09:05:29 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-01-19 09:05:29 +0000 |
commit | a15110d8837e3cd351d956566516d656f4f84a55 (patch) | |
tree | af583024d79852693b58381fceb55d3cdc541bbf /support | |
parent | 6f0bb4891c2e4c23c33462ff977c4805fea1338c (diff) | |
download | scala-a15110d8837e3cd351d956566516d656f4f84a55.tar.gz scala-a15110d8837e3cd351d956566516d656f4f84a55.tar.bz2 scala-a15110d8837e3cd351d956566516d656f4f84a55.zip |
- Renamed scalac4ant into scala4ant
- Moved scala4ant sources into sources/scala/tools/scala4ant Removed
- examples from support/ant
Diffstat (limited to 'support')
-rw-r--r-- | support/ant/src.java/scala/tools/scalac4ant/AntAdaptor.java | 105 | ||||
-rw-r--r-- | support/ant/src.java/scala/tools/scalac4ant/AntTask.java | 139 |
2 files changed, 0 insertions, 244 deletions
diff --git a/support/ant/src.java/scala/tools/scalac4ant/AntAdaptor.java b/support/ant/src.java/scala/tools/scalac4ant/AntAdaptor.java deleted file mode 100644 index bb682cf815..0000000000 --- a/support/ant/src.java/scala/tools/scalac4ant/AntAdaptor.java +++ /dev/null @@ -1,105 +0,0 @@ -package scala.tools.scalac4ant; - -import scalac.*; -import scalac.util.Reporter; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Execute; -import org.apache.tools.ant.taskdefs.Javac; -import org.apache.tools.ant.taskdefs.LogStreamHandler; -import org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Path; -import java.io.IOException; - - -/** a compiler adaptor for Scalac. - * - * author: Burak Emir - * adapted from package jaco.framework.ant.AntCompilerAdaptor - * (part of Matthias Zenger's jaco framework) - */ - -public class AntAdaptor extends DefaultCompilerAdapter { - - private String source; - private String target; - - public static final String PRODUCT = - System.getProperty("scala.product", "scalac"); - public static final String VERSION = - System.getProperty("scala.version", "unknown version"); - - - public boolean runCompiler(String[] args) { - // dirty work, to get rid of debugging (-g) option, set in setupJavac... - String[] nargs = new String[ args.length - 1 ]; - int j = 0; - for( int i = 0; i<args.length; i++ ) - if( !args[ i ].startsWith("-g") ) { - //System.err.print( args[ i ] +" ") - nargs[ j++ ] = args[ i ]; - } - // compile - Reporter reporter = new Reporter(); - CompilerCommand command = new CompilerCommand( - PRODUCT, VERSION, reporter, new CompilerPhases()); - if (command.parse(nargs) && command.files.list.size() > 0) { - Global global = new Global(command); - try { - global.compile(command.files.toArray(), false); - } catch (Throwable e) { - e.printStackTrace(); - //throw new BuildException(e.message()); - return false; - } - global.stop("total"); - global.reporter.printSummary(); - /* - PizzaSettings js = new PizzaSettings(); - js.parse(args); - return js.JavaContext().JavaCompiler().compile(); - */ - } - return true; - - } - - public String compilerName() { - return "scalac"; - } - - public void setJavac(Javac attributes) { - super.setJavac(attributes); - AntTask myattribs = (AntTask)attributes; - source = myattribs.getSource(); - target = myattribs.getTarget(); - } - - public boolean execute() throws BuildException { - attributes.log("Using " + compilerName() + " as scala compiler", - Project.MSG_VERBOSE); - return runCompiler(setupScalacCommand().getArguments()); - } - - public Commandline setupScalacCommand() { - Commandline cmd = new Commandline(); - setupJavacCommandlineSwitches(cmd); - //setupScalacCommandlineSwitches(cmd); - logAndAddFilesToCompile(cmd); - return cmd; - } - /* - public void setupScalacCommandlineSwitches(Commandline cmd) { - if (source != null) { - cmd.createArgument().setValue("-source"); - cmd.createArgument().setValue(source); - } - if (target != null) { - cmd.createArgument().setValue("-target"); - cmd.createArgument().setValue(target); - } - } - */ -} diff --git a/support/ant/src.java/scala/tools/scalac4ant/AntTask.java b/support/ant/src.java/scala/tools/scalac4ant/AntTask.java deleted file mode 100644 index 963cc5af17..0000000000 --- a/support/ant/src.java/scala/tools/scalac4ant/AntTask.java +++ /dev/null @@ -1,139 +0,0 @@ -package scala.tools.scalac4ant; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Javac; -import org.apache.tools.ant.util.*; -import java.io.File; -import java.util.*; - - -/** Scala AntTask. - * - * author: Burak Emir - * adapted from package jaco.framework.ant.AntCompilerTask - * (part of Matthias Zenger's jaco framework) - * - * $Id$ - */ - - -public class AntTask extends Javac { - - private String suffixes = "scala"; - private boolean force = false; - private String source = null; - private String target = null; - private FileUtils fileUtils = FileUtils.newFileUtils(); - - public void execute() { - Project project = getProject(); - String old = project.getProperty("build.compiler"); - project.setProperty("build.compiler", "scala.tools.scalac4ant.AntAdaptor"); - super.execute(); - if (old == null) - project.setProperty("build.compiler", "modern"); - else - project.setProperty("build.compiler", old); - } - - public void setForce(boolean fc) { - force = fc; - } - - public boolean getForce() { - return force; - } - - public void setSource(String source) { - this.source = source; - } - - public String getSource() { - return source; - } - - public void setTarget(String target) { - this.target = target; - } - - public String getTarget() { - return target; - } - - public void setSuffixes(String s) { - suffixes = s; - } - - public String getSuffixes() { - return suffixes; - } - - public void setScalaClasspath(String s) { - System.setProperty("scala.class.path",s); - } - public String getScalaClasspath() { - return System.getProperty("scala.class.path"); - } - public void setScalaBootClasspath(String s) { - System.setProperty("scala.boot.class.path",s); - } - public String getScalaBootClasspath() { - return System.getProperty("scala.boot.class.path"); - } - - protected String[] parseSuffixes() { - StringTokenizer st = new StringTokenizer(suffixes, " ,"); - ArrayList al = new ArrayList(); - while (st.hasMoreTokens()) - al.add("." + st.nextToken()); - return (String[])al.toArray(new String[al.size()]); - } - - private static boolean hasLegalSuffix(String[] suffixes, String file) { - for (int i = 0; i < suffixes.length; i++) - if (file.endsWith(suffixes[i])) - return true; - return false; - } - - protected void scanDir(File srcDir, File destDir, String files[]) { - String[] sfx = parseSuffixes(); - if (force) { - File[] newCompileList = new File[compileList.length + files.length]; - System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); - int j = 0; - for (int i = 0; i < files.length; i++) - if (hasLegalSuffix(sfx, files[i])) { - if (srcDir == null) - newCompileList[compileList.length + (j++)] = new File(files[i]); - else - newCompileList[compileList.length + (j++)] = - fileUtils.resolveFile(srcDir, files[i]); - } - if (j == files.length) - compileList = newCompileList; - else { - compileList = new File[j]; - System.arraycopy(newCompileList, 0, compileList, 0, j); - } - } else { - GlobPatternMapper m = new GlobPatternMapper(); - for (int i = 0; i < sfx.length; i++) { - m.setFrom("*" + sfx[i]); - m.setTo("*.class"); - SourceFileScanner sfs = new SourceFileScanner(this); - File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); - if (newFiles.length > 0) { - File[] newCompileList = new File[compileList.length + - newFiles.length]; - System.arraycopy(compileList, 0, newCompileList, 0, - compileList.length); - System.arraycopy(newFiles, 0, newCompileList, - compileList.length, newFiles.length); - compileList = newCompileList; - } - } - } - } -} |