Permalink
Browse files

Fixes SI-4909 and SI-5763

Finally, -sourcepath is split into:
-Ysourcepath     - for the library bootstrapping
-doc-source-path - for scaladoc links to source code

(squished the resident compiler test fix into this commit)

Review by @jsuereth.
  • Loading branch information...
VladUreche authored and xeno-by committed Jun 4, 2012
1 parent 7b0f0a1 commit 13213e3df0384b1fd815c0798758a22284572cdb
View
@@ -1731,7 +1731,7 @@ DOCUMENTATION
docfooter="epfl"
docsourceurl="${scaladoc.url}€{FILE_PATH}.scala#L1"
docUncompilable="${src.dir}/library-aux"
- sourcepath="${src.dir}"
+ docSourcePath="${src.dir}"
classpathref="pack.classpath"
addparams="${scalac.args.all}"
docRootContent="${src.dir}/library/rootdoc.txt"
@@ -1813,7 +1813,7 @@ DOCUMENTATION
doctitle="Scala Compiler"
docversion="${version.number}"
docsourceurl="${scaladoc.url}€{FILE_PATH}.scala#L1"
- sourcepath="${src.dir}"
+ docSourcePath="${src.dir}"
classpathref="pack.classpath"
srcdir="${src.dir}/compiler"
docRootContent="${src.dir}/compiler/rootdoc.txt"
@@ -1836,7 +1836,7 @@ DOCUMENTATION
destdir="${build-docs.dir}/jline"
doctitle="Scala JLine"
docversion="${version.number}"
- sourcepath="${src.dir}"
+ docSourcePath="${src.dir}"
classpathref="pack.classpath"
srcdir="${src.dir}/jline/src/main/java"
addparams="${scalac.args.all}"
@@ -1860,7 +1860,7 @@ DOCUMENTATION
doctitle="Scalap"
docversion="${version.number}"
docsourceurl="${scaladoc.url}€{FILE_PATH}.scala#L1"
- sourcepath="${src.dir}"
+ docSourcePath="${src.dir}"
classpathref="pack.classpath"
srcdir="${src.dir}/scalap"
addparams="${scalac.args.all}"
@@ -1882,7 +1882,7 @@ DOCUMENTATION
destdir="${build-docs.dir}/scala-partest"
doctitle="Scala Parallel Testing Framework"
docversion="${version.number}"
- sourcepath="${src.dir}"
+ docSourcePath="${src.dir}"
classpathref="pack.classpath"
srcdir="${src.dir}/partest"
addparams="${scalac.args.all}"
@@ -1904,7 +1904,7 @@ DOCUMENTATION
destdir="${build-docs.dir}/continuations-plugin"
doctitle="Delimited Continuations Compiler Plugin"
docversion="${version.number}"
- sourcepath="${src.dir}"
+ docSourcePath="${src.dir}"
classpathref="pack.classpath"
srcdir="${src.dir}/continuations/plugin"
addparams="${scalac.args.all}"
@@ -1926,7 +1926,7 @@ DOCUMENTATION
destdir="${build-docs.dir}/actors-migration"
doctitle="Actors Migration Kit"
docversion="${version.number}"
- sourcepath="${src.dir}"
+ docSourcePath="${src.dir}"
classpathref="pack.classpath"
srcdir="${src.dir}/actors-migration"
addparams="${scalac.args.all}"
View
@@ -359,7 +359,7 @@ object ScalaBuild extends Build with Layers {
},
compile := inc.Analysis.Empty,
// scaladocOptions in Compile <++= (baseDirectory) map (bd =>
- // Seq("-sourcepath", (bd / "src" / "library").getAbsolutePath,
+ // Seq("-doc-source-path", (bd / "src" / "library").getAbsolutePath,
// "-doc-no-compile", (bd / "src" / "library-aux").getAbsolutePath,
// "-doc-source-url", """https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/€{FILE_PATH}.scala#L1""",
// "-doc-root-content", (bd / "compiler/scala/tools/nsc/doc/html/resource/lib/rootdoc.txt").getAbsolutePath
View
@@ -71,7 +71,7 @@ trait Layers extends Build {
resourceDirectory in Compile <<= baseDirectory apply (_ / "src" / "library"),
defaultExcludes in unmanagedResources := ("*.scala" | "*.java" | "*.disabled"),
// TODO - Allow other scalac option settings.
- scalacOptions in Compile <++= (scalaSource in Compile) map (src => Seq("-sourcepath", src.getAbsolutePath)),
+ scalacOptions in Compile <++= (scalaSource in Compile) map (src => Seq("-Ysourcepath", src.getAbsolutePath)),
resourceGenerators in Compile <+= (resourceManaged, Versions.scalaVersions, skip in Compile, streams) map Versions.generateVersionPropertiesFile("library.properties"),
referenceScala
)
@@ -100,7 +100,7 @@ class FastScalac extends Scalac {
List(
/*scalac*/
s.bootclasspath, s.classpath, s.extdirs, s.dependencyfile, s.encoding,
- s.outdir, s.sourcepath,
+ s.outdir, s.Ysourcepath,
/*fsc*/
s.server
) filter (_.value != "") flatMap (x => List(x.name, x.value))
@@ -10,13 +10,20 @@ package scala.tools.ant
import java.io.{ File, InputStream, FileWriter }
-import org.apache.tools.ant.{ Task, BuildException }
+import org.apache.tools.ant.{ Task, BuildException, Project }
import org.apache.tools.ant.taskdefs.MatchingTask
import org.apache.tools.ant.types.{ Path, Reference }
trait ScalaTask {
self: Task =>
+ /** Logs a warning message from the ant task (such as deprecated warnings) */
+ protected def buildWarning(message: String): Unit = {
+ log("warning:", Project.MSG_WARN)
+ log(" " + message, Project.MSG_WARN)
+ log("", Project.MSG_WARN)
+ }
+
/** Generates a build error. Error location will be the
* current task in the ant file.
*
@@ -30,8 +30,8 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
* - `destdir`,
* - `classpath`,
* - `classpathref`,
- * - `sourcepath`,
- * - `sourcepathref`,
+ * - `Ysourcepath`,
+ * - `Ysourcepathref`,
* - `bootclasspath`,
* - `bootclasspathref`,
* - `extdirs`,
@@ -61,7 +61,7 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
* It also takes the following parameters as nested elements:
* - `src` (for `srcdir`),
* - `classpath`,
- * - `sourcepath`,
+ * - `Ysourcepath`,
* - `bootclasspath`,
* - `extdirs`,
* - `compilerarg`.
@@ -119,7 +119,7 @@ class Scalac extends ScalaMatchingTask with ScalacShared {
/** The class path to use for this compilation. */
protected var classpath: Option[Path] = None
/** The source path to use for this compilation. */
- protected var sourcepath: Option[Path] = None
+ protected var Ysourcepath: Option[Path] = None
/** The boot class path to use for this compilation. */
protected var bootclasspath: Option[Path] = None
/** The path to use when finding scalac - *only used for forking!* */
@@ -253,19 +253,32 @@ class Scalac extends ScalaMatchingTask with ScalacShared {
createClasspath().setRefid(input)
}
- /** Sets the `sourcepath` attribute. Used by [[http://ant.apache.org Ant]].
+ // bridge to setYsourcepath
+ @deprecated("The scalac sourcepath attribute is deprecated. Please use ySourcePath instead!")
+ def setSourcepath(input: Path) = {
+ buildWarning("The scalac sourcepath attribute is deprecated. Please use ySourcePath instead!")
+ setYSourcepath(input)
+ }
+
+ @deprecated("The scalac sourcepath attribute is deprecated. Please use ySourcePath instead!")
+ def setSourcepathref(input: Reference) = {
+ buildWarning("The scalac sourcepath attribute is deprecated. Please use ySourcePath instead!")
+ setYSourcepathref(input)
+ }
+
+ /** Sets the `Ysourcepath` attribute. Used by [[http://ant.apache.org Ant]].
* @param input The value of `sourcepath`. */
- def setSourcepath(input: Path) {
- sourcepath = setOrAppend(sourcepath, input)
+ def setYSourcepath(input: Path) {
+ Ysourcepath = setOrAppend(Ysourcepath, input)
}
/** Sets the `sourcepath` as a nested sourcepath Ant parameter.
* @return A source path to be configured. */
- def createSourcepath(): Path = createNewPath(sourcepath _, p => sourcepath = p)
+ def createSourcepath(): Path = createNewPath(Ysourcepath _, p => Ysourcepath = p)
- /** Sets the `sourcepath` as an external reference Ant parameter.
+ /** Sets the `docSourcePath` as an external reference Ant parameter.
* @param input A reference to a source path. */
- def setSourcepathref(input: Reference) {
+ def setYSourcepathref(input: Reference) {
createSourcepath().setRefid(input)
}
@@ -452,10 +465,10 @@ class Scalac extends ScalaMatchingTask with ScalacShared {
if (destination.isEmpty) buildError("Member 'destination' is empty.")
else existing(getProject resolveFile destination.get.toString)
- /** Gets the value of the `sourcepath` attribute in a
+ /** Gets the value of the `ySourcepath` attribute in a
* Scala-friendly form.
* @return The source path as a list of files. */
- protected def getSourcepath: List[File] = pathAsList(sourcepath, "sourcepath")
+ protected def getSourcepath: List[File] = pathAsList(Ysourcepath, "sourcepath")
/** Gets the value of the `bootclasspath` attribute in a
* Scala-friendly form.
@@ -585,10 +598,10 @@ class Scalac extends ScalaMatchingTask with ScalacShared {
settings.outdir.value = asString(destination.get)
if (!classpath.isEmpty)
settings.classpath.value = asString(getClasspath)
- if (!sourcepath.isEmpty)
- settings.sourcepath.value = asString(getSourcepath)
+ if (!Ysourcepath.isEmpty)
+ settings.Ysourcepath.value = asString(getSourcepath)
else if (origin.get.size() > 0)
- settings.sourcepath.value = origin.get.list()(0)
+ settings.Ysourcepath.value = origin.get.list()(0)
if (!bootclasspath.isEmpty)
settings.bootclasspath.value = asString(getBootclasspath)
if (!extdirs.isEmpty) settings.extdirs.value = asString(getExtdirs)
@@ -27,8 +27,8 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
* - `destdir`,
* - `classpath`,
* - `classpathref`,
- * - `sourcepath`,
- * - `sourcepathref`,
+ * - `docSourcePath`,
+ * - `docSourcePathref`,
* - `bootclasspath`,
* - `bootclasspathref`,
* - `extdirs`,
@@ -44,12 +44,12 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
* - `docgenerator`,
* - `docrootcontent`,
* - `unchecked`,
- * - `nofail`.
+ * - `nofail` and others :)
*
* It also takes the following parameters as nested elements:
* - `src` (for srcdir),
* - `classpath`,
- * - `sourcepath`,
+ * - `docSourcePath`,
* - `bootclasspath`,
* - `extdirs`.
*
@@ -90,7 +90,7 @@ class Scaladoc extends ScalaMatchingTask {
/** The class path to use for this compilation. */
private var classpath: Option[Path] = None
/** The source path to use for this compilation. */
- private var sourcepath: Option[Path] = None
+ private var docSourcePath: Option[Path] = None
/** The boot class path to use for this compilation. */
private var bootclasspath: Option[Path] = None
/** The external extensions path to use for this compilation. */
@@ -214,29 +214,33 @@ class Scaladoc extends ScalaMatchingTask {
def setClasspathref(input: Reference) =
createClasspath().setRefid(input)
- /** Sets the `sourcepath` attribute. Used by [[http://ant.apache.org Ant]].
- *
- * @param input The value of `sourcepath`.
- */
- def setSourcepath(input: Path) =
- if (sourcepath.isEmpty) sourcepath = Some(input)
- else sourcepath.get.append(input)
+ // Bridge the gap between sourcepath and docSourcePath
+ @deprecated("The scaladoc sourcepath attribute is deprecated. Please use docSourcePath instead.")
+ def setSourcepath(input: Path) = {
+ buildWarning("The scaladoc sourcepath attribute is deprecated. Please use docSourcePath instead.")
+ setDocSourcePath(input)
+ }
- /** Sets the `sourcepath` as a nested sourcepath Ant parameter.
- *
- * @return A source path to be configured.
- */
- def createSourcepath(): Path = {
- if (sourcepath.isEmpty) sourcepath = Some(new Path(getProject))
- sourcepath.get.createPath()
+ @deprecated("The scaladoc sourcepath attribute is deprecated. Please use docSourcePath instead.")
+ def setSourcepathref(input: Reference) = {
+ buildWarning("The scaladoc sourcepath attribute is deprecated. Please use docSourcePath instead.")
+ setDocSourcePathRef(input)
}
- /** Sets the `sourcepath` as an external reference Ant parameter.
- *
- * @param input A reference to a source path.
- */
- def setSourcepathref(input: Reference) =
- createSourcepath().setRefid(input)
+ /** Sets the `docSourcePath` attribute. */
+ def setDocSourcePath(input: Path) =
+ if (docSourcePath.isEmpty) docSourcePath = Some(input)
+ else docSourcePath.get.append(input)
+
+ /** Sets the `docSourcePath` as a nested docSourcePath Ant parameter. */
+ def createSourcePath(): Path = {
+ if (docSourcePath.isEmpty) docSourcePath = Some(new Path(getProject))
+ docSourcePath.get.createPath()
+ }
+
+ /** Sets the `docSourcePath` as an external reference Ant parameter. */
+ def setDocSourcePathRef(input: Reference) =
+ createSourcePath().setRefid(input)
/** Sets the `bootclasspath` attribute. Used by [[http://ant.apache.org Ant]].
*
@@ -246,7 +250,7 @@ class Scaladoc extends ScalaMatchingTask {
if (bootclasspath.isEmpty) bootclasspath = Some(input)
else bootclasspath.get.append(input)
- /** Sets the `bootclasspath` as a nested `sourcepath` Ant parameter.
+ /** Sets the `bootclasspath` as a nested `docSourcePath` Ant parameter.
*
* @return A source path to be configured.
*/
@@ -272,7 +276,7 @@ class Scaladoc extends ScalaMatchingTask {
else extdirs.get.append(input)
}
- /** Sets the `extdirs` as a nested sourcepath Ant parameter.
+ /** Sets the `extdirs` as a nested docSourcePath Ant parameter.
*
* @return An extensions path to be configured.
*/
@@ -456,8 +460,8 @@ class Scaladoc extends ScalaMatchingTask {
* @return The source path as a list of files.
*/
private def getSourcepath: List[File] =
- if (sourcepath.isEmpty) buildError("Member 'sourcepath' is empty.")
- else sourcepath.get.list().toList map nameToFile
+ if (docSourcePath.isEmpty) buildError("Member 'sourcepath' is empty.")
+ else docSourcePath.get.list().toList map nameToFile
/** Gets the value of the `bootclasspath` attribute in a
* Scala-friendly form.
@@ -595,12 +599,11 @@ class Scaladoc extends ScalaMatchingTask {
docSettings.outdir.value = asString(destination.get)
if (!classpath.isEmpty)
docSettings.classpath.value = asString(getClasspath)
- if (!sourcepath.isEmpty)
- docSettings.sourcepath.value = asString(getSourcepath)
- /*else if (origin.get.size() > 0)
- settings.sourcepath.value = origin.get.list()(0)*/
+ if (!docSourcePath.isEmpty)
+ docSettings.docSourcePath.value = asString(getSourcepath)
if (!bootclasspath.isEmpty)
docSettings.bootclasspath.value = asString(getBootclasspath)
+
if (!extdirs.isEmpty) docSettings.extdirs.value = asString(getExtdirs)
if (!encoding.isEmpty) docSettings.encoding.value = encoding.get
if (!doctitle.isEmpty) docSettings.doctitle.value = decodeEscapes(doctitle.get)
@@ -20,7 +20,7 @@ class Make extends Task with TaskArgs {
if (!destinationDir.isEmpty) settings.d = destinationDir.get
if (!compTarget.isEmpty) settings.target = compTarget.get
if (!compilationPath.isEmpty) settings.classpath = compilationPath.get
- if (!sourcePath.isEmpty) settings.sourcepath = sourcePath.get
+ if (!sourcePath.isEmpty) settings.Ysourcepath = sourcePath.get
settings.extraParams = extraArgsFlat
Compilers.make(id.get, (compilerPath.get.list.map{ path => new File(path).toURI.toURL }), settings)
}
@@ -101,7 +101,7 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs {
compTarget foreach (settings.target = _)
compilationPath foreach (settings.classpath = _)
- sourcePath foreach (settings.sourcepath = _)
+ sourcePath foreach (settings.Ysourcepath = _)
settings.extraParams = extraArgsFlat
if (isMSIL)
@@ -27,8 +27,8 @@ class Settings {
def classpath_=(p: Path): this.type = { classpathBf = Some(p); this }
private var sourcepathBf: Option[Path] = None
- def sourcepath = sourcepathBf.get
- def sourcepath_=(p: Path): this.type = { sourcepathBf = Some(p); this }
+ def Ysourcepath = sourcepathBf.get
+ def Ysourcepath_=(p: Path): this.type = { sourcepathBf = Some(p); this }
private var sourcedirBf: Option[File] = None
def sourcedir = sourcedirBf.get
@@ -66,7 +66,7 @@ class Settings {
(if (!gBf.isEmpty) "-g:"+g :: Nil else Nil) :::
(if (uncheckedBf) "-unchecked" :: Nil else Nil) :::
(if (!classpathBf.isEmpty) "-classpath" :: classpath.toString :: Nil else Nil) :::
- (if (!sourcepathBf.isEmpty) "-sourcepath" :: sourcepath.toString :: Nil else Nil) :::
+ (if (!sourcepathBf.isEmpty) "-Ysourcepath" :: Ysourcepath.toString :: Nil else Nil) :::
(if (!sourcedirBf.isEmpty) "-Xsourcedir" :: sourcedir.toString :: Nil else Nil) :::
(if (!bootclasspathBf.isEmpty) "-bootclasspath" :: bootclasspath.toString :: Nil else Nil) :::
(if (!extdirsBf.isEmpty) "-extdirs" :: extdirs.toString :: Nil else Nil) :::
@@ -62,7 +62,15 @@ class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) {
}
/** A setting that defines a URL to be concatenated with source locations and show a link to source files.
- * If needed the sourcepath option can be used to exclude undesired initial part of the link to sources */
+ * If needed the docSourcePath option can be used to exclude undesired initial part of the link to sources */
+ val docSourcePath = PathSetting (
+ "-doc-source-path",
+ "The prefix in all source file paths. Will be stripped off all paths before URLs are generated.",
+ ""
+ )
+
+ /** A setting that defines a URL to be concatenated with source locations and show a link to source files.
+ * If needed the docSourcePath option can be used to exclude undesired initial part of the link to sources */
val docsourceurl = StringSetting (
"-doc-source-url",
"url",
Oops, something went wrong.

0 comments on commit 13213e3

Please sign in to comment.