diff options
Diffstat (limited to 'project')
-rw-r--r-- | project/GenerateAnyVals.scala | 490 | ||||
-rw-r--r-- | project/Osgi.scala | 19 | ||||
-rw-r--r-- | project/PartestUtil.scala | 2 | ||||
-rw-r--r-- | project/ScalaOptionParser.scala | 18 | ||||
-rw-r--r-- | project/ScriptCommands.scala | 4 | ||||
-rw-r--r-- | project/build.sbt | 2 | ||||
-rw-r--r-- | project/plugins.sbt | 2 |
7 files changed, 514 insertions, 23 deletions
diff --git a/project/GenerateAnyVals.scala b/project/GenerateAnyVals.scala new file mode 100644 index 0000000000..84454cb0ed --- /dev/null +++ b/project/GenerateAnyVals.scala @@ -0,0 +1,490 @@ +/** Code generation of the AnyVal types and their companions. */ +trait GenerateAnyValReps { + self: GenerateAnyVals => + + sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) + extends AnyValRep(name,repr,javaEquiv) { + + case class Op(op : String, doc : String) + + private def companionCoercions(tos: AnyValRep*) = { + tos.toList map (to => + s"implicit def @javaequiv@2${to.javaEquiv}(x: @name@): ${to.name} = x.to${to.name}" + ) + } + def coercionComment = +"""/** Language mandated coercions from @name@ to "wider" types. */ +import scala.language.implicitConversions""" + + def implicitCoercions: List[String] = { + val coercions = this match { + case B => companionCoercions(S, I, L, F, D) + case S | C => companionCoercions(I, L, F, D) + case I => companionCoercions(L, F, D) + case L => companionCoercions(F, D) + case F => companionCoercions(D) + case _ => Nil + } + if (coercions.isEmpty) Nil + else coercionComment.lines.toList ++ coercions + } + + def isCardinal: Boolean = isIntegerType(this) + def unaryOps = { + val ops = List( + Op("+", "/** Returns this value, unmodified. */"), + Op("-", "/** Returns the negation of this value. */")) + + if(isCardinal) + Op("~", "/**\n" + + " * Returns the bitwise negation of this value.\n" + + " * @example {{{\n" + + " * ~5 == -6\n" + + " * // in binary: ~00000101 ==\n" + + " * // 11111010\n" + + " * }}}\n" + + " */") :: ops + else ops + } + + def bitwiseOps = + if (isCardinal) + List( + Op("|", "/**\n" + + " * Returns the bitwise OR of this value and `x`.\n" + + " * @example {{{\n" + + " * (0xf0 | 0xaa) == 0xfa\n" + + " * // in binary: 11110000\n" + + " * // | 10101010\n" + + " * // --------\n" + + " * // 11111010\n" + + " * }}}\n" + + " */"), + Op("&", "/**\n" + + " * Returns the bitwise AND of this value and `x`.\n" + + " * @example {{{\n" + + " * (0xf0 & 0xaa) == 0xa0\n" + + " * // in binary: 11110000\n" + + " * // & 10101010\n" + + " * // --------\n" + + " * // 10100000\n" + + " * }}}\n" + + " */"), + Op("^", "/**\n" + + " * Returns the bitwise XOR of this value and `x`.\n" + + " * @example {{{\n" + + " * (0xf0 ^ 0xaa) == 0x5a\n" + + " * // in binary: 11110000\n" + + " * // ^ 10101010\n" + + " * // --------\n" + + " * // 01011010\n" + + " * }}}\n" + + " */")) + else Nil + + def shiftOps = + if (isCardinal) + List( + Op("<<", "/**\n" + + " * Returns this value bit-shifted left by the specified number of bits,\n" + + " * filling in the new right bits with zeroes.\n" + + " * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}\n" + + " */"), + + Op(">>>", "/**\n" + + " * Returns this value bit-shifted right by the specified number of bits,\n" + + " * filling the new left bits with zeroes.\n" + + " * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}}\n" + + " * @example {{{\n" + + " * -21 >>> 3 == 536870909\n" + + " * // in binary: 11111111 11111111 11111111 11101011 >>> 3 ==\n" + + " * // 00011111 11111111 11111111 11111101\n" + + " * }}}\n" + + " */"), + + Op(">>", "/**\n" + + " * Returns this value bit-shifted right by the specified number of bits,\n" + + " * filling in the left bits with the same value as the left-most bit of this.\n" + + " * The effect of this is to retain the sign of the value.\n" + + " * @example {{{\n" + + " * -21 >> 3 == -3\n" + + " * // in binary: 11111111 11111111 11111111 11101011 >> 3 ==\n" + + " * // 11111111 11111111 11111111 11111101\n" + + " * }}}\n" + + " */")) + else Nil + + def comparisonOps = List( + Op("==", "/** Returns `true` if this value is equal to x, `false` otherwise. */"), + Op("!=", "/** Returns `true` if this value is not equal to x, `false` otherwise. */"), + Op("<", "/** Returns `true` if this value is less than x, `false` otherwise. */"), + Op("<=", "/** Returns `true` if this value is less than or equal to x, `false` otherwise. */"), + Op(">", "/** Returns `true` if this value is greater than x, `false` otherwise. */"), + Op(">=", "/** Returns `true` if this value is greater than or equal to x, `false` otherwise. */")) + + def otherOps = List( + Op("+", "/** Returns the sum of this value and `x`. */"), + Op("-", "/** Returns the difference of this value and `x`. */"), + Op("*", "/** Returns the product of this value and `x`. */"), + Op("/", "/** Returns the quotient of this value and `x`. */"), + Op("%", "/** Returns the remainder of the division of this value by `x`. */")) + + // Given two numeric value types S and T , the operation type of S and T is defined as follows: + // If both S and T are subrange types then the operation type of S and T is Int. + // Otherwise the operation type of S and T is the larger of the two types wrt ranking. + // Given two numeric values v and w the operation type of v and w is the operation type + // of their run-time types. + def opType(that: AnyValNum): AnyValNum = { + val rank = IndexedSeq(I, L, F, D) + (rank indexOf this, rank indexOf that) match { + case (-1, -1) => I + case (r1, r2) => rank apply (r1 max r2) + } + } + + def mkCoercions = numeric map (x => "def to%s: %s".format(x, x)) + def mkUnaryOps = unaryOps map (x => "%s\n def unary_%s : %s".format(x.doc, x.op, this opType I)) + def mkStringOps = List("def +(x: String): String") + def mkShiftOps = ( + for (op <- shiftOps ; arg <- List(I, L)) yield + "%s\n def %s(x: %s): %s".format(op.doc, op.op, arg, this opType I) + ) + + def clumps: List[List[String]] = { + val xs1 = List(mkCoercions, mkUnaryOps, mkStringOps, mkShiftOps) map (xs => if (xs.isEmpty) xs else xs :+ "") + val xs2 = List( + mkBinOpsGroup(comparisonOps, numeric, _ => Z), + mkBinOpsGroup(bitwiseOps, cardinal, this opType _), + mkBinOpsGroup(otherOps, numeric, this opType _) + ) + xs1 ++ xs2 + } + def classLines = (clumps :+ commonClassLines).foldLeft(List[String]()) { + case (res, Nil) => res + case (res, lines) => + val xs = lines map { + case "" => "" + case s => interpolate(s) + } + res ++ xs + } + def objectLines = { + val comp = if (isCardinal) cardinalCompanion else floatingCompanion + interpolate(comp + allCompanions + "\n" + nonUnitCompanions).trim.lines.toList ++ (implicitCoercions map interpolate) + } + + /** Makes a set of binary operations based on the given set of ops, args, and resultFn. + * + * @param ops list of function names e.g. List(">>", "%") + * @param args list of types which should appear as arguments + * @param resultFn function which calculates return type based on arg type + * @return list of function definitions + */ + def mkBinOpsGroup(ops: List[Op], args: List[AnyValNum], resultFn: AnyValNum => AnyValRep): List[String] = ( + ops flatMap (op => + args.map(arg => + "%s\n def %s(x: %s): %s".format(op.doc, op.op, arg, resultFn(arg))) :+ "" + ) + ).toList + } + + sealed abstract class AnyValRep(val name: String, val repr: Option[String], val javaEquiv: String) { + def classLines: List[String] + def objectLines: List[String] + def commonClassLines = List( + "// Provide a more specific return type for Scaladoc", + "override def getClass(): Class[@name@] = ???" + ) + + def lcname = name.toLowerCase + def boxedSimpleName = this match { + case C => "Character" + case I => "Integer" + case _ => name + } + def boxedName = this match { + case U => "scala.runtime.BoxedUnit" + case _ => "java.lang." + boxedSimpleName + } + def zeroRep = this match { + case L => "0L" + case F => "0.0f" + case D => "0.0d" + case _ => "0" + } + + def representation = repr.map(", a " + _).getOrElse("") + + def indent(s: String) = if (s == "") "" else " " + s + def indentN(s: String) = s.lines map indent mkString "\n" + + def boxUnboxInterpolations = Map( + "@boxRunTimeDoc@" -> """ + * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxTo%s`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + *""".format(boxedSimpleName), + "@unboxRunTimeDoc@" -> """ + * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxTo%s`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]]. + *""".format(name), + "@unboxDoc@" -> "the %s resulting from calling %sValue() on `x`".format(name, lcname), + "@boxImpl@" -> "???", + "@unboxImpl@" -> "???" + ) + def interpolations = Map( + "@name@" -> name, + "@representation@" -> representation, + "@javaequiv@" -> javaEquiv, + "@boxed@" -> boxedName, + "@lcname@" -> lcname, + "@zero@" -> zeroRep + ) ++ boxUnboxInterpolations + + def interpolate(s: String): String = interpolations.foldLeft(s) { + case (str, (key, value)) => str.replaceAll(key, value) + } + def classDoc = interpolate(classDocTemplate) + def objectDoc = "" + def mkImports = "" + + def mkClass = assemble("final abstract class " + name + " private extends AnyVal", classLines) + def mkObject = assemble("object " + name + " extends AnyValCompanion", objectLines) + def make() = List[String]( + headerTemplate, + mkImports, + classDoc, + mkClass, + objectDoc, + mkObject + ) mkString "" + + def assemble(decl: String, lines: List[String]): String = { + val body = if (lines.isEmpty) " { }\n\n" else lines map indent mkString (" {\n", "\n", "\n}\n") + + decl + body + "\n" + } + override def toString = name + } +} + +trait GenerateAnyValTemplates { + def headerTemplate = """/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in "project/GenerateAnyVals.scala". +// Afterwards, running "sbt generateSources" regenerates this source file. + +package scala + +""" + + def classDocTemplate = (""" +/** `@name@`@representation@ (equivalent to Java's `@javaequiv@` primitive type) is a + * subtype of [[scala.AnyVal]]. Instances of `@name@` are not + * represented by an object in the underlying runtime system. + * + * There is an implicit conversion from [[scala.@name@]] => [[scala.runtime.Rich@name@]] + * which provides useful non-primitive operations. + */ +""".trim + "\n") + + def allCompanions = """ +/** Transform a value type into a boxed reference type. + *@boxRunTimeDoc@ + * @param x the @name@ to be boxed + * @return a @boxed@ offering `x` as its underlying value. + */ +def box(x: @name@): @boxed@ = @boxImpl@ + +/** Transform a boxed type into a value type. Note that this + * method is not typesafe: it accepts any Object, but will throw + * an exception if the argument is not a @boxed@. + *@unboxRunTimeDoc@ + * @param x the @boxed@ to be unboxed. + * @throws ClassCastException if the argument is not a @boxed@ + * @return @unboxDoc@ + */ +def unbox(x: java.lang.Object): @name@ = @unboxImpl@ + +/** The String representation of the scala.@name@ companion object. */ +override def toString = "object scala.@name@" +""" + + def nonUnitCompanions = "" // todo + + def cardinalCompanion = """ +/** The smallest value representable as a @name@. */ +final val MinValue = @boxed@.MIN_VALUE + +/** The largest value representable as a @name@. */ +final val MaxValue = @boxed@.MAX_VALUE +""" + + def floatingCompanion = """ +/** The smallest positive value greater than @zero@ which is + * representable as a @name@. + */ +final val MinPositiveValue = @boxed@.MIN_VALUE +final val NaN = @boxed@.NaN +final val PositiveInfinity = @boxed@.POSITIVE_INFINITY +final val NegativeInfinity = @boxed@.NEGATIVE_INFINITY + +/** The negative number with the greatest (finite) absolute value which is representable + * by a @name@. Note that it differs from [[java.lang.@name@.MIN_VALUE]], which + * is the smallest positive value representable by a @name@. In Scala that number + * is called @name@.MinPositiveValue. + */ +final val MinValue = -@boxed@.MAX_VALUE + +/** The largest finite positive number representable as a @name@. */ +final val MaxValue = @boxed@.MAX_VALUE +""" +} + +class GenerateAnyVals extends GenerateAnyValReps with GenerateAnyValTemplates { + object B extends AnyValNum("Byte", Some("8-bit signed integer"), "byte") + object S extends AnyValNum("Short", Some("16-bit signed integer"), "short") + object C extends AnyValNum("Char", Some("16-bit unsigned integer"), "char") + object I extends AnyValNum("Int", Some("32-bit signed integer"), "int") + object L extends AnyValNum("Long", Some("64-bit signed integer"), "long") + object F extends AnyValNum("Float", Some("32-bit IEEE-754 floating point number"), "float") + object D extends AnyValNum("Double", Some("64-bit IEEE-754 floating point number"), "double") + object Z extends AnyValRep("Boolean", None, "boolean") { + def classLines = """ +/** Negates a Boolean expression. + * + * - `!a` results in `false` if and only if `a` evaluates to `true` and + * - `!a` results in `true` if and only if `a` evaluates to `false`. + * + * @return the negated expression + */ +def unary_! : Boolean + +/** Compares two Boolean expressions and returns `true` if they evaluate to the same value. + * + * `a == b` returns `true` if and only if + * - `a` and `b` are `true` or + * - `a` and `b` are `false`. + */ +def ==(x: Boolean): Boolean + +/** + * Compares two Boolean expressions and returns `true` if they evaluate to a different value. + * + * `a != b` returns `true` if and only if + * - `a` is `true` and `b` is `false` or + * - `a` is `false` and `b` is `true`. + */ +def !=(x: Boolean): Boolean + +/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. + * + * `a || b` returns `true` if and only if + * - `a` is `true` or + * - `b` is `true` or + * - `a` and `b` are `true`. + * + * @note This method uses 'short-circuit' evaluation and + * behaves as if it was declared as `def ||(x: => Boolean): Boolean`. + * If `a` evaluates to `true`, `true` is returned without evaluating `b`. + */ +def ||(x: Boolean): Boolean + +/** Compares two Boolean expressions and returns `true` if both of them evaluate to true. + * + * `a && b` returns `true` if and only if + * - `a` and `b` are `true`. + * + * @note This method uses 'short-circuit' evaluation and + * behaves as if it was declared as `def &&(x: => Boolean): Boolean`. + * If `a` evaluates to `false`, `false` is returned without evaluating `b`. + */ +def &&(x: Boolean): Boolean + +// Compiler won't build with these seemingly more accurate signatures +// def ||(x: => Boolean): Boolean +// def &&(x: => Boolean): Boolean + +/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. + * + * `a | b` returns `true` if and only if + * - `a` is `true` or + * - `b` is `true` or + * - `a` and `b` are `true`. + * + * @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`. + */ +def |(x: Boolean): Boolean + +/** Compares two Boolean expressions and returns `true` if both of them evaluate to true. + * + * `a & b` returns `true` if and only if + * - `a` and `b` are `true`. + * + * @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`. + */ +def &(x: Boolean): Boolean + +/** Compares two Boolean expressions and returns `true` if they evaluate to a different value. + * + * `a ^ b` returns `true` if and only if + * - `a` is `true` and `b` is `false` or + * - `a` is `false` and `b` is `true`. + */ +def ^(x: Boolean): Boolean + +// Provide a more specific return type for Scaladoc +override def getClass(): Class[Boolean] = ??? + """.trim.lines.toList + + def objectLines = interpolate(allCompanions + "\n" + nonUnitCompanions).lines.toList + } + object U extends AnyValRep("Unit", None, "void") { + override def classDoc = """ +/** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type + * `Unit`, `()`, and it is not represented by any object in the underlying + * runtime system. A method with return type `Unit` is analogous to a Java + * method which is declared `void`. + */ +""" + def classLines = List( + "// Provide a more specific return type for Scaladoc", + "override def getClass(): Class[Unit] = ???" + ) + def objectLines = interpolate(allCompanions).lines.toList + + override def boxUnboxInterpolations = Map( + "@boxRunTimeDoc@" -> "", + "@unboxRunTimeDoc@" -> "", + "@unboxDoc@" -> "the Unit value ()", + "@boxImpl@" -> "scala.runtime.BoxedUnit.UNIT", + "@unboxImpl@" -> "x.asInstanceOf[scala.runtime.BoxedUnit]" + ) + } + + def isSubrangeType = Set(B, S, C) + def isIntegerType = Set(B, S, C, I, L) + def isFloatingType = Set(F, D) + def isWideType = Set(L, D) + + def cardinal = numeric filter isIntegerType + def numeric = List(B, S, C, I, L, F, D) + def values = List(U, Z) ++ numeric + + def make() = values map (x => (x.name, x.make())) +} + +object GenerateAnyVals { + def run(outDir: java.io.File) { + val av = new GenerateAnyVals + + av.make() foreach { case (name, code ) => + val file = new java.io.File(outDir, name + ".scala") + sbt.IO.write(file, code, java.nio.charset.Charset.forName("UTF-8"), false) + } + } +} diff --git a/project/Osgi.scala b/project/Osgi.scala index c5d4734cab..4177251aa4 100644 --- a/project/Osgi.scala +++ b/project/Osgi.scala @@ -1,10 +1,10 @@ -import aQute.lib.osgi.Builder -import aQute.lib.osgi.Constants._ +import aQute.bnd.osgi.Builder +import aQute.bnd.osgi.Constants._ import java.util.Properties import java.util.jar.Attributes import sbt._ import sbt.Keys._ -import scala.collection.JavaConversions._ +import collection.JavaConverters._ import VersionUtil.versionProperties /** OSGi packaging for the Scala build, distilled from sbt-osgi. We do not use sbt-osgi because it @@ -31,14 +31,15 @@ object Osgi { "Export-Package" -> "*;version=${ver};-split-package:=merge-first", "Import-Package" -> "scala.*;version=\"${range;[==,=+);${ver}}\",*", "Bundle-Version" -> v, - "Bundle-RequiredExecutionEnvironment" -> "JavaSE-1.6, JavaSE-1.7", + "Bundle-RequiredExecutionEnvironment" -> "JavaSE-1.8", "-eclipse" -> "false" ) }, jarlist := false, bundle <<= Def.task { + val res = (products in Compile in packageBin).value bundleTask(headers.value.toMap, jarlist.value, (products in Compile in packageBin).value, - (artifactPath in (Compile, packageBin)).value, Nil, streams.value) + (artifactPath in (Compile, packageBin)).value, res, streams.value) }, packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), bundle).identityMap, // Also create OSGi source bundles: @@ -58,16 +59,16 @@ object Osgi { headers foreach { case (k, v) => builder.setProperty(k, v) } val includeRes = resourceDirectories.filter(_.exists).map(_.getAbsolutePath).mkString(",") if(!includeRes.isEmpty) builder.setProperty(INCLUDERESOURCE, includeRes) - builder.getProperties.foreach { case (k, v) => log.debug(s"bnd: $k: $v") } + builder.getProperties.asScala.foreach { case (k, v) => log.debug(s"bnd: $k: $v") } // builder.build is not thread-safe because it uses a static SimpleDateFormat. This ensures // that all calls to builder.build are serialized. val jar = synchronized { builder.build } - builder.getWarnings.foreach(s => log.warn(s"bnd: $s")) - builder.getErrors.foreach(s => log.error(s"bnd: $s")) + builder.getWarnings.asScala.foreach(s => log.warn(s"bnd: $s")) + builder.getErrors.asScala.foreach(s => log.error(s"bnd: $s")) IO.createDirectory(artifactPath.getParentFile) if (jarlist) { val entries = jar.getManifest.getEntries - for ((name, resource) <- jar.getResources if name.endsWith(".class")) { + for ((name, resource) <- jar.getResources.asScala if name.endsWith(".class")) { entries.put(name, new Attributes) } } diff --git a/project/PartestUtil.scala b/project/PartestUtil.scala index 4b18c94b47..8793e9c0a5 100644 --- a/project/PartestUtil.scala +++ b/project/PartestUtil.scala @@ -33,7 +33,7 @@ object PartestUtil { val srcPathOption = "--srcpath" val grepOption = "--grep" - // HACK: if we parse `--srpath scaladoc`, we overwrite this var. The parser for test file paths + // HACK: if we parse `--srcpath scaladoc`, we overwrite this var. The parser for test file paths // then lazily creates the examples based on the current value. // TODO is there a cleaner way to do this with SBT's parser infrastructure? var srcPath = "files" diff --git a/project/ScalaOptionParser.scala b/project/ScalaOptionParser.scala index da8a3bf460..77c9d765e9 100644 --- a/project/ScalaOptionParser.scala +++ b/project/ScalaOptionParser.scala @@ -79,30 +79,28 @@ object ScalaOptionParser { P <~ token(OptSpace) } - // TODO retrieve this data programatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala + // TODO retrieve this data programmatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala private def booleanSettingNames = List("-X", "-Xcheckinit", "-Xdev", "-Xdisable-assertions", "-Xexperimental", "-Xfatal-warnings", "-Xfull-lubs", "-Xfuture", "-Xlog-free-terms", "-Xlog-free-types", "-Xlog-implicit-conversions", "-Xlog-implicits", "-Xlog-reflective-calls", "-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-uescape", "-Xnojline", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xstrict-inference", "-Xverify", "-Y", - "-Ybreak-cycles", "-Yclosure-elim", "-Yconst-opt", "-Ydead-code", "-Ydebug", "-Ycompact-trees", "-Ydisable-unreachable-prevention", "-YdisableFlatCpCaching", "-Ydoc-debug", - "-Yeta-expand-keeps-star", "-Yide-debug", "-Yinfer-argument-types", "-Yinfer-by-name", "-Yinfer-debug", "-Yinline", "-Yinline-handlers", - "-Yinline-warnings", "-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand", - "-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-load-impl-class", "-Yno-predef", "-Ynooptimise", - "-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypos-debug", "-Ypresentation-debug", + "-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug", + "-Yeta-expand-keeps-star", "-Yide-debug", "-Yinfer-argument-types", "-Yinfer-by-name", + "-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand", + "-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-predef", + "-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypartial-unification", "-Ypos-debug", "-Ypresentation-debug", "-Ypresentation-strict", "-Ypresentation-verbose", "-Yquasiquote-debug", "-Yrangepos", "-Yreify-copypaste", "-Yreify-debug", "-Yrepl-class-based", "-Yrepl-sync", "-Yshow-member-pos", "-Yshow-symkinds", "-Yshow-symowners", "-Yshow-syms", "-Yshow-trees", "-Yshow-trees-compact", "-Yshow-trees-stringified", "-Ytyper-debug", "-Ywarn-adapted-args", "-Ywarn-dead-code", "-Ywarn-inaccessible", "-Ywarn-infer-any", "-Ywarn-nullary-override", "-Ywarn-nullary-unit", "-Ywarn-numeric-widen", "-Ywarn-unused", "-Ywarn-unused-import", "-Ywarn-value-discard", "-deprecation", "-explaintypes", "-feature", "-help", "-no-specialization", "-nobootcp", "-nowarn", "-optimise", "-print", "-unchecked", "-uniqid", "-usejavacp", "-usemanifestcp", "-verbose", "-version") private def stringSettingNames = List("-Xgenerate-phase-graph", "-Xmain-class", "-Xpluginsdir", "-Xshow-class", "-Xshow-object", "-Xsource-reader", "-Ydump-classes", "-Ygen-asmp", - "-Ygen-javap", "-Ypresentation-log", "-Ypresentation-replay", "-Yrepl-outdir", "-d", "-dependencyfile", "-encoding", "-Xscript") + "-Ypresentation-log", "-Ypresentation-replay", "-Yrepl-outdir", "-d", "-dependencyfile", "-encoding", "-Xscript") private def pathSettingNames = List("-bootclasspath", "-classpath", "-extdirs", "-javabootclasspath", "-javaextdirs", "-sourcepath", "-toolcp") private val phases = List("all", "parser", "namer", "packageobjects", "typer", "patmat", "superaccessors", "extmethods", "pickler", "refchecks", "uncurry", "tailcalls", "specialize", "explicitouter", "erasure", "posterasure", "lazyvals", "lambdalift", "constructors", "flatten", "mixin", "cleanup", "delambdafy", "icode", "jvm", "terminal") private val phaseSettings = List("-Xprint-icode", "-Ystop-after", "-Yskip", "-Yshow", "-Ystop-before", "-Ybrowse", "-Ylog", "-Ycheck", "-Xprint") private def multiStringSettingNames = List("-Xmacro-settings", "-Xplugin", "-Xplugin-disable", "-Xplugin-require") private def intSettingNames = List("-Xmax-classfile-name", "-Xelide-below", "-Ypatmat-exhaust-depth", "-Ypresentation-delay", "-Yrecursion") private def choiceSettingNames = Map[String, List[String]]( - "-Ybackend" -> List("GenASM", "GenBCode"), "-YclasspathImpl" -> List("flat", "recursive"), "-Ydelambdafy" -> List("inline", "method"), - "-Ylinearizer" -> List("dfs", "dump", "normal", "rpo"), "-Ymacro-expand" -> List("discard", "none"), "-Yresolve-term-conflict" -> List("error", "object", "package"), "-g" -> List("line", "none", "notailcails", "source", "vars"), @@ -110,7 +108,7 @@ object ScalaOptionParser { private def multiChoiceSettingNames = Map[String, List[String]]( "-Xlint" -> List("adapted-args", "nullary-unit", "inaccessible", "nullary-override", "infer-any", "missing-interpolator", "doc-detached", "private-shadow", "type-parameter-shadow", "poly-implicit-overload", "option-implicit", "delayedinit-select", "by-name-right-associative", "package-object-classes", "unsound-match", "stars-align"), "-language" -> List("help", "_", "dynamics", "postfixOps", "reflectiveCalls", "implicitConversions", "higherKinds", "existentials", "experimental.macros"), - "-Yopt" -> List("l:none", "l:default", "l:method", "l:project", "l:classpath", "unreachable-code", "simplify-jumps", "empty-line-numbers", "empty-labels", "compact-locals", "nullness-tracking", "closure-elimination", "inline-project", "inline-global"), + "-opt" -> List("l:none", "l:default", "l:method", "l:project", "l:classpath", "unreachable-code", "simplify-jumps", "empty-line-numbers", "empty-labels", "compact-locals", "nullness-tracking", "closure-elimination", "inline-project", "inline-global"), "-Ystatistics" -> List("parser", "typer", "patmat", "erasure", "cleanup", "jvm") ) private def scalaVersionSettings = List("-Xmigration", "-Xsource") diff --git a/project/ScriptCommands.scala b/project/ScriptCommands.scala index efeac95e6d..b6565803b4 100644 --- a/project/ScriptCommands.scala +++ b/project/ScriptCommands.scala @@ -13,7 +13,7 @@ object ScriptCommands { // Append build.timestamp to Artifactory URL to get consistent build numbers (see https://github.com/sbt/sbt/issues/2088): publishTo in Global := Some("scala-pr" at url.replaceAll("/$", "") + ";build.timestamp=" + System.currentTimeMillis), publishArtifact in (Compile, packageDoc) in ThisBuild := false, - scalacOptions in Compile in ThisBuild += "-optimise", + scalacOptions in Compile in ThisBuild += "-Yopt:l:classpath", logLevel in ThisBuild := Level.Info, logLevel in update in ThisBuild := Level.Warn ), state) @@ -24,7 +24,7 @@ object ScriptCommands { //TODO When ant is gone, pass starr version as an argument to this command instead of using version.properties Project.extract(state).append(Seq( resolvers in Global += "scala-pr" at url, - scalacOptions in Compile in ThisBuild += "-optimise", + scalacOptions in Compile in ThisBuild += "-opt:l:classpath", logLevel in ThisBuild := Level.Info, logLevel in update in ThisBuild := Level.Warn ), state) diff --git a/project/build.sbt b/project/build.sbt new file mode 100644 index 0000000000..b19238f577 --- /dev/null +++ b/project/build.sbt @@ -0,0 +1,2 @@ +// Add genprod to the build; It should be moved from `src/build` to `project` once the ANT build is gone +sources in Compile += ((baseDirectory).value.getParentFile / "src" / "build" / "genprod.scala") diff --git a/project/plugins.sbt b/project/plugins.sbt index 4c0a6e7b8a..98ec8f16ed 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,7 +5,7 @@ libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.3.2" libraryDependencies += "org.pantsbuild" % "jarjar" % "1.6.3" -libraryDependencies += "biz.aQute" % "bndlib" % "1.50.0" +libraryDependencies += "biz.aQute.bnd" % "biz.aQute.bnd" % "2.4.1" enablePlugins(BuildInfoPlugin) |