-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
713 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
cd "$(dirname "$0")/.." | ||
|
||
if [ $# -gt 1 ]; then | ||
echo "Usage: $0 [<scala ver>]" | ||
echo "" | ||
echo "Where" | ||
echo " <scala ver> = 2 or 3" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
case "${1:-}" in | ||
"") | ||
"$0" 2 | ||
echo | ||
echo | ||
"$0" 3 | ||
exit 0 | ||
;; | ||
2|3) | ||
SCALA_VER="$(bin/get_scala_version $1)" | ||
echo "Scala version: $SCALA_VER" | ||
;; | ||
*) | ||
echo "Unrecognised version: $1" >&2 | ||
exit 2 | ||
;; | ||
esac | ||
|
||
dryrun= | ||
# dryrun=-n | ||
|
||
# See how much memory is available | ||
free -h | ||
echo | ||
|
||
# Test upstream | ||
rm -rf */target/scala-*/{,test-}classes | ||
cmd=( | ||
sbt | ||
-J-Xmx3G | ||
-J-XX:+UseG1GC | ||
++$SCALA_VER | ||
'set ThisBuild / parallelExecution := false' | ||
'set Global / concurrentRestrictions += Tags.limit(ScalaJSTags.Link, 1)' | ||
test # Test development-mode | ||
'set ThisBuild / scalaJSStage := FullOptStage' test # Test production-mode | ||
publishLocal # For downstream tests | ||
) | ||
echo "> $(printf "%s\n " "${cmd[@]}")" | ||
[[ $dryrun == "-n" ]] || "${cmd[@]}" | ||
|
||
# Test downstream | ||
SCALA_MAJOR_VER="${SCALA_VER:0:1}" | ||
downstream-tests/run -$SCALA_MAJOR_VER $dryrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
cd "$(dirname "$0")/.." | ||
tmp="$(fgrep " scala$1 " project/Dependencies.scala)" | ||
r='[^"]*"([^"]*)"[^"]*' | ||
if [[ "$tmp" =~ $r ]]; then | ||
echo "${BASH_REMATCH[1]}" | ||
else | ||
echo "Unable to determine Scala $1 version" >&2 | ||
exit 3 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
core/js/src/main/scala-2/scalacss/internal/ModeMacros.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package scalacss.internal | ||
|
||
import scala.reflect.macros.whitebox.Context | ||
import scalacss.defaults._ | ||
|
||
// ========================== | ||
// ==== ==== | ||
// ==== Scala 2 / JS ==== | ||
// ==== ==== | ||
// ========================== | ||
|
||
object ModeMacros { | ||
|
||
private def readConfig(key: String): Option[String] = | ||
(Option(System.getProperty(key, null)) orElse Option(System.getenv(key))) | ||
.map(_.trim.toLowerCase) | ||
.filter(_.nonEmpty) | ||
|
||
trait DevOrProdDefaults { | ||
def devOrProdDefaults: Exports with mutable.Settings = | ||
macro ModeMacros.devOrProdDefaults | ||
} | ||
|
||
def devOrProdDefaults(c: Context): c.Expr[Exports with mutable.Settings] = { | ||
import c.universe._ | ||
|
||
def fail(msg: String): Nothing = | ||
c.abort(c.enclosingPosition, msg) | ||
|
||
c.Expr[Exports with mutable.Settings]( | ||
readConfig("scalacss.mode") match { | ||
|
||
case None => | ||
q""" | ||
if (_root_.scala.scalajs.LinkingInfo.developmentMode) | ||
_root_.scalacss.DevDefaults | ||
else | ||
_root_.scalacss.ProdDefaults | ||
""" | ||
|
||
case Some("dev") => | ||
q"_root_.scalacss.DevDefaults" | ||
|
||
case Some("prod") => | ||
q"_root_.scalacss.ProdDefaults" | ||
|
||
case Some(x) => | ||
fail(s"Unrecognise option for scalacss.mode: $x. Legal values are 'dev' and 'prod'.") | ||
} | ||
) | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
core/js/src/main/scala-3/scalacss/internal/ModeMacros.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package scalacss.internal | ||
|
||
import scalacss.defaults._ | ||
import scala.language.`3.0` | ||
import scala.quoted._ | ||
|
||
// ========================== | ||
// ==== ==== | ||
// ==== Scala 3 / JS ==== | ||
// ==== ==== | ||
// ========================== | ||
|
||
object ModeMacros { | ||
|
||
private def readConfig(key: String): Option[String] = | ||
(Option(System.getProperty(key, null)) orElse Option(System.getenv(key))) | ||
.map(_.trim.toLowerCase) | ||
.filter(_.nonEmpty) | ||
|
||
trait DevOrProdDefaults { | ||
transparent inline def devOrProdDefaults: Exports with mutable.Settings = | ||
${ ModeMacros.devOrProdDefaults } | ||
} | ||
|
||
def devOrProdDefaults(using Quotes): Expr[Exports with mutable.Settings] = { | ||
import quotes.reflect._ | ||
|
||
def fail(msg: String): Nothing = | ||
report.throwError(msg) | ||
|
||
type S = Exports with mutable.Settings | ||
val expr: Expr[S] = | ||
readConfig("scalacss.mode") match { | ||
|
||
case None => | ||
'{ | ||
if (_root_.scala.scalajs.LinkingInfo.developmentMode) | ||
_root_.scalacss.DevDefaults | ||
else | ||
_root_.scalacss.ProdDefaults | ||
} | ||
|
||
case Some("dev") => | ||
'{ scalacss.DevDefaults } | ||
|
||
case Some("prod") => | ||
'{ scalacss.ProdDefaults } | ||
|
||
case Some(x) => | ||
fail(s"Unrecognise option for scalacss.mode: $x. Legal values are 'dev' and 'prod'.") | ||
} | ||
|
||
Inlined(None, Nil, expr.asTerm).asExprOf[S] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
core/jvm/src/main/scala-2/scalacss/internal/ModeMacros.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package scalacss.internal | ||
|
||
import scala.reflect.macros.whitebox.Context | ||
import scalacss.defaults._ | ||
|
||
// =========================== | ||
// ==== ==== | ||
// ==== Scala 2 / JVM ==== | ||
// ==== ==== | ||
// =========================== | ||
|
||
object ModeMacros { | ||
|
||
private def readConfig(key: String): Option[String] = | ||
(Option(System.getProperty(key, null)) orElse Option(System.getenv(key))) | ||
.map(_.trim.toLowerCase) | ||
.filter(_.nonEmpty) | ||
|
||
trait DevOrProdDefaults { | ||
def devOrProdDefaults: Exports with mutable.Settings = | ||
macro ModeMacros.devOrProdDefaults | ||
} | ||
|
||
def devOrProdDefaults(c: Context): c.Expr[Exports with mutable.Settings] = { | ||
import c.universe._ | ||
|
||
def fail(msg: String): Nothing = | ||
c.abort(c.enclosingPosition, msg) | ||
|
||
c.Expr[Exports with mutable.Settings]( | ||
readConfig("scalacss.mode") match { | ||
|
||
case Some("dev") | None => | ||
q"_root_.scalacss.DevDefaults" | ||
|
||
case Some("prod") => | ||
q"_root_.scalacss.ProdDefaults" | ||
|
||
case Some(x) => | ||
fail(s"Unrecognise option for scalacss.mode: $x. Legal values are 'dev' and 'prod'.") | ||
} | ||
) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
core/jvm/src/main/scala-3/scalacss/internal/ModeMacros.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package scalacss.internal | ||
|
||
import scalacss.defaults._ | ||
import scala.language.`3.0` | ||
import scala.quoted._ | ||
|
||
// =========================== | ||
// ==== ==== | ||
// ==== Scala 3 / JVM ==== | ||
// ==== ==== | ||
// =========================== | ||
|
||
object ModeMacros { | ||
|
||
private def readConfig(key: String): Option[String] = | ||
(Option(System.getProperty(key, null)) orElse Option(System.getenv(key))) | ||
.map(_.trim.toLowerCase) | ||
.filter(_.nonEmpty) | ||
|
||
trait DevOrProdDefaults { | ||
transparent inline def devOrProdDefaults: Exports with mutable.Settings = | ||
${ ModeMacros.devOrProdDefaults } | ||
} | ||
|
||
def devOrProdDefaults(using Quotes): Expr[Exports with mutable.Settings] = { | ||
import quotes.reflect._ | ||
|
||
def fail(msg: String): Nothing = | ||
report.throwError(msg) | ||
|
||
type S = Exports with mutable.Settings | ||
val expr: Expr[S] = | ||
readConfig("scalacss.mode") match { | ||
|
||
case Some("dev") | None => | ||
'{ scalacss.DevDefaults } | ||
|
||
case Some("prod") => | ||
'{ scalacss.ProdDefaults } | ||
|
||
case Some(x) => | ||
fail(s"Unrecognise option for scalacss.mode: $x. Legal values are 'dev' and 'prod'.") | ||
} | ||
|
||
Inlined(None, Nil, expr.asTerm).asExprOf[S] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.