From 10322415aeea472260abd25324f707728fe55f4d Mon Sep 17 00:00:00 2001 From: Gilles Dubochet Date: Wed, 21 Dec 2005 20:31:59 +0000 Subject: 1. 2. Improved the generation of a distribution. 3. 'scalanstest' works again. --- src/compiler/scala/tools/nsc/Settings.scala | 38 ++++++++--- src/compiler/scala/tools/util/ClassPath.java | 98 ++-------------------------- 2 files changed, 35 insertions(+), 101 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index a7a5dfe73c..63def3b60d 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -5,24 +5,42 @@ // $Id$ package scala.tools.nsc; +import java.io.File; + class Settings(error: String => unit) { private var allsettings: List[Setting] = List(); + private val classpathDefault = { + val scalaCp = System.getProperty("scala.class.path"); + if (scalaCp != null) scalaCp + File.pathSeparator + "." + else "." + } + private val bootclasspathDefault = { + val javaBcp = System.getProperty("sun.boot.class.path"); + val scalaBcp = System.getProperty("scala.boot.class.path"); + if (javaBcp != null && scalaBcp != null) javaBcp + File.pathSeparator + scalaBcp + else if (javaBcp != null) javaBcp + else if (scalaBcp != null) scalaBcp + else "" + } + private val extdirsDefault = { + val javaExt = System.getProperty("java.ext.dirs"); + val scalaExt = System.getProperty("scala.ext.dirs"); + if (javaExt != null && scalaExt != null) javaExt + File.pathSeparator + scalaExt + else if (javaExt != null) javaExt + else if (scalaExt != null) scalaExt + else "" + } + val debuginfo = BooleanSetting("-g", "Generate debugging info"); val nowarnings = BooleanSetting("-nowarn", "Generate no warnings"); val noassertions = BooleanSetting("-noassert", "Generate no assertions and assumptions"); val verbose = BooleanSetting("-verbose", "Output messages about what the compiler is doing"); - val classpath = StringSetting ("-classpath", "path", "Specify where to find user class files", - System.getProperty("scala.class.path", - System.getProperty("java.class.path", "."))); - val sourcepath = StringSetting ("-sourcepath", "path", "Specify where to find input source files", - System.getProperty("scala.source.path", - System.getProperty("java.source.path", "."))); - val bootclasspath = StringSetting ("-bootclasspath", "path", "Override location of bootstrap class files", - System.getProperty("sun.boot.class.path", "")); - val extdirs = StringSetting ("-extdirs", "dirs", "Override location of installed extensions", - System.getProperty("java.ext.dirs", "")); + val classpath = StringSetting ("-classpath", "path", "Specify where to find user class files", classpathDefault); + val sourcepath = StringSetting ("-sourcepath", "path", "Specify where to find input source files", ""); + val bootclasspath = StringSetting ("-bootclasspath", "path", "Override location of bootstrap class files", bootclasspathDefault); + val extdirs = StringSetting ("-extdirs", "dirs", "Override location of installed extensions", extdirsDefault); val outdir = StringSetting ("-d", "directory", "Specify where to place generated class files", ""); val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files", "ISO-8859-1"); val separate = ChoiceSetting ("-separate", "Read symbol files for separate compilation", List("yes","no"), "default"); diff --git a/src/compiler/scala/tools/util/ClassPath.java b/src/compiler/scala/tools/util/ClassPath.java index 8df26355c8..182e8c2187 100644 --- a/src/compiler/scala/tools/util/ClassPath.java +++ b/src/compiler/scala/tools/util/ClassPath.java @@ -17,52 +17,6 @@ import java.util.Set; /** This class represents a Java/Scala class path. */ public class ClassPath { - //######################################################################## - // Public Constants - - /** The system-dependent path-separator character */ - public static final String PATH_SEPARATOR = - System.getProperty("path.separator", ":"); - - /** The location of the scala library classes */ - public static final String SCALA_LIBRARY_CLASSPATH = - System.getProperty("scala.library.class.path", ""); - - /** The location of the scala library sources */ - public static final String SCALA_LIBRARY_SOURCEPATH = - System.getProperty("scala.library.source.path", ""); - - /** The current VM's boot class path */ - public static final String RUNTIME_BOOTCLASSPATH = - System.getProperty("sun.boot.class.path", ""); - - /** The current VM's extension directory path */ - public static final String RUNTIME_EXTDIRS = - System.getProperty("java.ext.dirs", ""); - - /** The implicit boot class path */ - public static final String IMPLICIT_BOOTCLASSPATH = - concat(new String[]{ - SCALA_LIBRARY_CLASSPATH, - SCALA_LIBRARY_SOURCEPATH, - RUNTIME_BOOTCLASSPATH}); - - /** The default class path */ - public static final String DEFAULT_CLASSPATH = - System.getProperty("scala.class.path", "."); - - /** The default source path */ - public static final String DEFAULT_SOURCEPATH = - System.getProperty("scala.source.path", ""); - - /** The default boot class path */ - public static final String DEFAULT_BOOTCLASSPATH = - System.getProperty("scala.boot.class.path", IMPLICIT_BOOTCLASSPATH); - - /** The default extension directory path */ - public static final String DEFAULT_EXTDIRS = - System.getProperty("scala.ext.dirs", RUNTIME_EXTDIRS); - //######################################################################## // Public Functions @@ -100,32 +54,15 @@ public class ClassPath { * pass in an order preserving implementation of Set. */ public static void addFilesInPath(Set/**/ files, String path) { - path += PATH_SEPARATOR; + path += File.pathSeparator; for (int i = 0; i < path.length(); ) { - int j = path.indexOf(PATH_SEPARATOR, i); + int j = path.indexOf(File.pathSeparator, i); File file = new File(path.substring(i, j)); if (file.exists()) files.add(file); i = j + 1; } } - //######################################################################## - // Private Functions - - /** Returns the concatenation of the two paths. */ - private static String concat(String path1, String path2) { - if (path1.length() == 0) return path2; - if (path2.length() == 0) return path1; - return path1 + PATH_SEPARATOR + path2; - } - - /** Returns the concatenation of the array of paths. */ - private static String concat(String[] paths) { - String path = ""; - for (int i = 0; i < paths.length; i++) path = concat(path, paths[i]); - return path; - } - //######################################################################## // Private Fields @@ -135,38 +72,17 @@ public class ClassPath { //######################################################################## // Public Constructors - /** Initializes this instance with default paths. */ - public ClassPath() { - this(DEFAULT_CLASSPATH); - } - - /** - * Initializes this instance with the specified class path and - * default source, boot class and extension directory paths. - */ - public ClassPath(String classpath) { - this(classpath, DEFAULT_SOURCEPATH, DEFAULT_BOOTCLASSPATH, - DEFAULT_EXTDIRS); - } - /** Initializes this instance with the specified paths. */ - public ClassPath(String classpath, String sourcepath, String bootclasspath, - String extdirs) + public ClassPath(String classpath, + String sourcepath, + String bootclasspath, + String extdirs) { - // replace first empty path in bootclasspath by IMPLICIT_BOOTCLASSPATH - if (!bootclasspath.equals(IMPLICIT_BOOTCLASSPATH)) { - String path = PATH_SEPARATOR + bootclasspath + PATH_SEPARATOR; - int index = path.indexOf(PATH_SEPARATOR + PATH_SEPARATOR); - if (index >= 0) - bootclasspath = - path.substring(1, index + 1) + IMPLICIT_BOOTCLASSPATH + - path.substring(index + 1, path.length() - 1); - } Set files = new LinkedHashSet(); addFilesInPath(files, bootclasspath); addArchivesInExtDirPath(files, extdirs); - addFilesInPath(files, classpath); addFilesInPath(files, sourcepath); + addFilesInPath(files, classpath); ArrayList dirs = new ArrayList(files.size()); for (Iterator i = files.iterator(); i.hasNext(); ) { AbstractFile dir = AbstractFile.getDirectory((File)i.next()); -- cgit v1.2.3