Skip to content

Commit

Permalink
Scala 3.5.0 + Reworking the sandbox build
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Sep 12, 2024
1 parent a2cc972 commit 34ff7ea
Show file tree
Hide file tree
Showing 70 changed files with 880 additions and 172 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ metals.sbt
.bsp/
.ammonite
.coursier
*.semanticdb

# Direnv
.direnv
Expand Down
1 change: 1 addition & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rules = [

OrganizeImports {
removeUnused = false
targetDialect = Scala3
}

DisableSyntax {
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.3.0
version = 3.8.3
runner.dialect = scala3
style = defaultWithAlign
maxColumn = 120
Expand Down
30 changes: 4 additions & 26 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import scala.language.postfixOps
import Misc._
import Dependencies._
import org.typelevel.scalacoptions.ScalacOptions
import indigoplugin.IndigoOptions

Global / onChangedBuildSource := ReloadOnSourceChanges
Global / semanticdbEnabled := true

val scala3Version = "3.4.1"
val scala3Version = "3.5.0"

ThisBuild / versionScheme := Some("early-semver")
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0"
ThisBuild / scalaVersion := scala3Version
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / scalaVersion := scala3Version

lazy val ultravioletVersion = "0.3.1-SNAPSHOT"

Expand All @@ -23,7 +21,6 @@ lazy val commonSettings: Seq[sbt.Def.Setting[_]] = Seq(
scalacOptions ++= Seq("-language:strictEquality"),
scalafixOnCompile := true,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
autoAPIMappings := true,
logo := name.value,
Test / tpolecatExcludeOptions ++= Set(
Expand Down Expand Up @@ -68,26 +65,7 @@ lazy val ultravioletProject =
usefulTasks := customTasksAliases,
presentationSettings(version)
)
.aggregate(ultraviolet.js, ultraviolet.jvm, sandbox)

// Testing

lazy val sandbox =
project
.enablePlugins(ScalaJSPlugin, SbtIndigo)
.dependsOn(ultraviolet.js)
.settings(
neverPublish,
commonSettings,
name := "sandbox",
libraryDependencies ++= Shared.indigo.value,
libraryDependencies ++= Shared.indigoExtras.value,
libraryDependencies ++= Shared.indigoJson.value,
indigoOptions :=
IndigoOptions.defaults
.withTitle("Sandbox")
.withAssetDirectory(os.RelPath.rel / "sandbox" / "assets")
)
.aggregate(ultraviolet.js, ultraviolet.jvm)

// Shader
lazy val ultraviolet =
Expand Down
42 changes: 3 additions & 39 deletions commands.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// TODO: This is overkill at this point. Should be able to simplify this.

lazy val releaseProjects: List[String] =
List(
"ultravioletJS",
"ultravioletJVM"
)

lazy val coreProjects: List[String] =
releaseProjects ++ List(
"sandbox"
)
releaseProjects

val allProjects = List("ultravioletProject") // the aggregate

Expand Down Expand Up @@ -110,42 +110,6 @@ addCommandAlias(
).mkString(";", ";", "")
)

addCommandAlias(
"sandboxBuild",
List(
"buildAllNoClean",
"sandbox/fastOptJS",
"sandbox/indigoBuild"
).mkString(";", ";", "")
)

addCommandAlias(
"sandboxBuildFull",
List(
"buildAllNoClean",
"sandbox/fullOptJS",
"sandbox/indigoBuildFull"
).mkString(";", ";", "")
)

addCommandAlias(
"sandboxRun",
List(
"buildAllNoClean",
"sandbox/fastOptJS",
"sandbox/indigoRun"
).mkString(";", ";", "")
)

addCommandAlias(
"sandboxRunFull",
List(
"buildAllNoClean",
"sandbox/fullOptJS",
"sandbox/indigoRunFull"
).mkString(";", ";", "")
)

addCommandAlias(
"ultravioletPublishAllSigned",
applyToAllReleaseable("publishSigned")
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"electron": "^32.1.0"
}
}
8 changes: 2 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ import sbt.{Def, _}
object Dependencies {

object Versions {
val munit = "0.7.29"
val indigo = "0.16.0"
val munit = "0.7.29"
}

object Shared {
val munit = Def.setting(Seq("org.scalameta" %%% "munit" % Versions.munit % Test))
val indigo = Def.setting(Seq("io.indigoengine" %%% "indigo" % Versions.indigo))
val indigoExtras = Def.setting(Seq("io.indigoengine" %%% "indigo-extras" % Versions.indigo))
val indigoJson = Def.setting(Seq("io.indigoengine" %%% "indigo-json-circe" % Versions.indigo))
val munit = Def.setting(Seq("org.scalameta" %%% "munit" % Versions.munit % Test))
}

}
39 changes: 9 additions & 30 deletions project/ShaderDSLGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ object ShaderDSLGen {
val vec4 = List("x", "y", "z", "w")
val vec4RGBA = List("r", "g", "b", "a")

def swizzles1(input: List[String]): List[List[String]] =
input.map(c => List(c))

def swizzles2(input: List[String]): List[List[String]] = {
val res =
for {
Expand Down Expand Up @@ -89,11 +86,9 @@ object ShaderDSLGen {
"",
"Float",
"vec2",
swizzles1(vec2) ++
swizzles2(vec2) ++
swizzles2(vec2) ++
swizzles3(vec2) ++
swizzles4(vec2) ++
swizzles1(vec2RGBA) ++
swizzles2(vec2RGBA) ++
swizzles3(vec2RGBA) ++
swizzles4(vec2RGBA),
Expand All @@ -112,11 +107,9 @@ object ShaderDSLGen {
"",
"Float",
"vec3",
swizzles1(vec3) ++
swizzles2(vec3) ++
swizzles2(vec3) ++
swizzles3(vec3) ++
swizzles4(vec3) ++
swizzles1(vec3RGBA) ++
swizzles2(vec3RGBA) ++
swizzles3(vec3RGBA) ++
swizzles4(vec3RGBA),
Expand All @@ -135,11 +128,9 @@ object ShaderDSLGen {
"",
"Float",
"vec4",
swizzles1(vec4) ++
swizzles2(vec4) ++
swizzles2(vec4) ++
swizzles3(vec4) ++
swizzles4(vec4) ++
swizzles1(vec4RGBA) ++
swizzles2(vec4RGBA) ++
swizzles3(vec4RGBA) ++
swizzles4(vec4RGBA),
Expand All @@ -158,11 +149,9 @@ object ShaderDSLGen {
"b",
"Boolean",
"bvec2",
swizzles1(vec2) ++
swizzles2(vec2) ++
swizzles2(vec2) ++
swizzles3(vec2) ++
swizzles4(vec2) ++
swizzles1(vec2RGBA) ++
swizzles2(vec2RGBA) ++
swizzles3(vec2RGBA) ++
swizzles4(vec2RGBA),
Expand All @@ -181,11 +170,9 @@ object ShaderDSLGen {
"b",
"Boolean",
"bvec3",
swizzles1(vec3) ++
swizzles2(vec3) ++
swizzles2(vec3) ++
swizzles3(vec3) ++
swizzles4(vec3) ++
swizzles1(vec3RGBA) ++
swizzles2(vec3RGBA) ++
swizzles3(vec3RGBA) ++
swizzles4(vec3RGBA),
Expand All @@ -204,11 +191,9 @@ object ShaderDSLGen {
"b",
"Boolean",
"bvec4",
swizzles1(vec4) ++
swizzles2(vec4) ++
swizzles2(vec4) ++
swizzles3(vec4) ++
swizzles4(vec4) ++
swizzles1(vec4RGBA) ++
swizzles2(vec4RGBA) ++
swizzles3(vec4RGBA) ++
swizzles4(vec4RGBA),
Expand All @@ -227,11 +212,9 @@ object ShaderDSLGen {
"i",
"Int",
"ivec2",
swizzles1(vec2) ++
swizzles2(vec2) ++
swizzles2(vec2) ++
swizzles3(vec2) ++
swizzles4(vec2) ++
swizzles1(vec2RGBA) ++
swizzles2(vec2RGBA) ++
swizzles3(vec2RGBA) ++
swizzles4(vec2RGBA),
Expand All @@ -250,11 +233,9 @@ object ShaderDSLGen {
"i",
"Int",
"ivec3",
swizzles1(vec3) ++
swizzles2(vec3) ++
swizzles2(vec3) ++
swizzles3(vec3) ++
swizzles4(vec3) ++
swizzles1(vec3RGBA) ++
swizzles2(vec3RGBA) ++
swizzles3(vec3RGBA) ++
swizzles4(vec3RGBA),
Expand All @@ -273,11 +254,9 @@ object ShaderDSLGen {
"i",
"Int",
"ivec4",
swizzles1(vec4) ++
swizzles2(vec4) ++
swizzles2(vec4) ++
swizzles3(vec4) ++
swizzles4(vec4) ++
swizzles1(vec4RGBA) ++
swizzles2(vec4RGBA) ++
swizzles3(vec4RGBA) ++
swizzles4(vec4RGBA),
Expand Down
11 changes: 6 additions & 5 deletions project/ShaderTypeOfArrayGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ object ShaderTypeOfArrayGen {
Seq(file)
}

def makeContents(): String = {
(0 to 4096).map { i =>
s""" given array$i[A](using sto: ShaderTypeOf[A]): ShaderTypeOf[array[$i, A]] with
def makeContents(): String =
(0 to 4096)
.map { i =>
s""" given array$i[A](using sto: ShaderTypeOf[A]): ShaderTypeOf[array[$i, A]] with
| def typeOf: String = s"$${sto.typeOf}[$i]"
|"""
}.mkString("\n")
}
}
.mkString("\n")

}
7 changes: 3 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "1.16.0")
addSbtPlugin("io.indigoengine" %% "sbt-indigo" % "0.16.0")
addSbtPlugin("org.xerial.sbt" %% "sbt-sonatype" % "3.9.7")
addSbtPlugin("com.jsuereth" %% "sbt-pgp" % "2.0.1")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31")
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.3.1")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1")
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.4.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
5 changes: 2 additions & 3 deletions project/project/SbtIndigoVersion.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

object SbtIndigoVersion {
def getVersion: String = {
def rec(path: String, levels: Int, version: Option[String]): String = {
val msg = "ERROR: Couldn't find indigo version."
version match {
case Some(v) =>
case Some(v) =>
println(s"""SBT Indigo version set to '$v'""")
v

Expand All @@ -22,7 +21,7 @@ object SbtIndigoVersion {
throw new Exception(msg)
}
}

rec(".indigo-version", 0, None)
}
}
27 changes: 27 additions & 0 deletions sandbox/.scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
rules = [
DisableSyntax,
OrganizeImports
]

OrganizeImports {
removeUnused = false
targetDialect = Scala3
}

DisableSyntax {
noVars = true
noThrows = true
noNulls = true
noReturns = true
noWhileLoops = true
noAsInstanceOf = false # Doesn't seem to work correctly
noIsInstanceOf = false # Doesn't seem to work correctly
noXml = true
noDefaultArgs = true
noFinalVal = true
noFinalize = true
noValPatterns = true
# noUniversalEquality = false # handled by scala 3
# noUniversalEqualityMessage = "== and != are unsafe since they allow comparing two unrelated types"
# regex = []
}
6 changes: 6 additions & 0 deletions sandbox/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version = 3.7.17
runner.dialect = scala3
style = defaultWithAlign
maxColumn = 80
rewrite.rules = [RedundantBraces,RedundantParens,PreferCurlyFors]
danglingParentheses.preset = true
7 changes: 7 additions & 0 deletions sandbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# UV Sandbox

## Getting started with sbt

Type `sbt` into you command line to enter the sbt console. There you will be presented with a welcome screen a list of useful commands.

You can also use `sbt runGame`, to compile and run the game immediately.
Loading

0 comments on commit 34ff7ea

Please sign in to comment.