diff options
author | buraq <buraq@epfl.ch> | 2004-01-22 15:24:35 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-01-22 15:24:35 +0000 |
commit | 34a75235f653d896e9b8448cff77f59f1a037c78 (patch) | |
tree | 10aa25f1ff03d685fd32d97defc15f2723ed8938 /sources | |
parent | 97626f9df675653e76758e81d40548971e7d954b (diff) | |
download | scala-34a75235f653d896e9b8448cff77f59f1a037c78.tar.gz scala-34a75235f653d896e9b8448cff77f59f1a037c78.tar.bz2 scala-34a75235f653d896e9b8448cff77f59f1a037c78.zip |
obsolete, scala versions up and running
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/scala4ant/AntAdaptor.java | 105 | ||||
-rw-r--r-- | sources/scala/tools/scala4ant/AntTask.java | 139 |
2 files changed, 0 insertions, 244 deletions
diff --git a/sources/scala/tools/scala4ant/AntAdaptor.java b/sources/scala/tools/scala4ant/AntAdaptor.java deleted file mode 100644 index bcd0b94c06..0000000000 --- a/sources/scala/tools/scala4ant/AntAdaptor.java +++ /dev/null @@ -1,105 +0,0 @@ -package scala.tools.scala4ant; - -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/sources/scala/tools/scala4ant/AntTask.java b/sources/scala/tools/scala4ant/AntTask.java deleted file mode 100644 index 2a9e83d336..0000000000 --- a/sources/scala/tools/scala4ant/AntTask.java +++ /dev/null @@ -1,139 +0,0 @@ -package scala.tools.scala4ant; - -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; - } - } - } - } -} |