Skip to content

Commit

Permalink
Merge branch 'main' into update/svm-22.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski authored Sep 21, 2023
2 parents 69bc36a + 5a0fcd7 commit 58196ef
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 111 deletions.
41 changes: 14 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on:
push:
branches:
- master
- main
tags:
- "v*"
pull_request:
Expand All @@ -21,7 +21,7 @@ jobs:
with:
jvm: "temurin:17"
- name: Test CLI
run: ./mill -i 'tests[_].test'
run: ./mill -i 'tests.test'

publish:
needs: test
Expand Down Expand Up @@ -51,7 +51,6 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
scalaJsVersion: ["1.9.0", "1.10.0", "1.10.1", "1.11.0", "1.12.0", "1.13.1"]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -62,22 +61,18 @@ jobs:
with:
jvm: temurin:17
- run: |
./mill -i "native[$scalaJsVersion].writeNativeImageScript" generate.sh "" && \
./mill -i "native.writeNativeImageScript" generate.sh "" && \
./generate.sh && \
./mill -i "tests[$scalaJsVersion].test.native" && \
./mill -i "native[$scalaJsVersion].copyToArtifacts" artifacts/
./mill -i "tests.test.native" && \
./mill -i "native.copyToArtifacts" artifacts/
if: runner.os != 'Windows'
env:
scalaJsVersion: ${{ matrix.scalaJsVersion }}
- run: |
@call ./mill.bat -i "native[%scalaJsVersion%].writeNativeImageScript" generate.bat ""
@call ./mill.bat -i "native.writeNativeImageScript" generate.bat ""
@call generate.bat
@call ./mill.bat -i "tests[%scalaJsVersion%].test.native"
@call ./mill.bat -i "native[%scalaJsVersion%].copyToArtifacts" artifacts/
@call ./mill.bat -i "tests.test.native"
@call ./mill.bat -i "native.copyToArtifacts" artifacts/
shell: cmd
if: runner.os == 'Windows'
env:
scalaJsVersion: ${{ matrix.scalaJsVersion }}
- uses: actions/[email protected]
with:
name: launcher-${{ matrix.os }}
Expand All @@ -94,8 +89,6 @@ jobs:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
scalaJsVersion: ["1.9.0", "1.10.0", "1.10.1", "1.11.0", "1.12.0", "1.13.1"]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -106,12 +99,10 @@ jobs:
with:
jvm: temurin:17
- run: |
./mill -i "native-static[$scalaJsVersion].writeNativeImageScript" generate.sh "" && \
./mill -i "native-static.writeNativeImageScript" generate.sh "" && \
./generate.sh && \
./mill -i "tests[$scalaJsVersion].test.nativeStatic" && \
./mill -i "native-static[$scalaJsVersion].copyToArtifacts" artifacts/
env:
scalaJsVersion: ${{ matrix.scalaJsVersion }}
./mill -i "tests.test.nativeStatic" && \
./mill -i "native-static.copyToArtifacts" artifacts/
- uses: actions/[email protected]
with:
name: launcher-${{ matrix.os }}-static
Expand All @@ -128,8 +119,6 @@ jobs:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
scalaJsVersion: ["1.9.0", "1.10.0", "1.10.1", "1.11.0", "1.12.0", "1.13.1"]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -140,12 +129,10 @@ jobs:
with:
jvm: temurin:17
- run: |
./mill -i "native-mostly-static[$scalaJsVersion].writeNativeImageScript" generate.sh "" && \
./mill -i "native-mostly-static.writeNativeImageScript" generate.sh "" && \
./generate.sh && \
./mill -i "tests[$scalaJsVersion].test.nativeStatic" && \
./mill -i "native-mostly-static[$scalaJsVersion].copyToArtifacts" artifacts/
env:
scalaJsVersion: ${{ matrix.scalaJsVersion }}
./mill -i "tests.test.nativeStatic" && \
./mill -i "native-mostly-static.copyToArtifacts" artifacts/
- uses: actions/[email protected]
with:
name: launcher-${{ matrix.os }}-mostly-static
Expand Down
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.12
0.11.1
91 changes: 30 additions & 61 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.3.0`
import $ivy.`io.github.alexarchambault.mill::mill-native-image::0.1.23`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`io.github.alexarchambault.mill::mill-native-image::0.1.25`
import $ivy.`io.github.alexarchambault.mill::mill-native-image-upload:0.1.19`
import $ivy.`io.get-coursier::coursier-launcher:2.1.0-M2`

Expand All @@ -17,30 +17,18 @@ import scala.util.Properties.isWin


def scalaJsCliVersion = "1.1.1-sc5"
def scala213 = "2.13.10"
def latestScalaJsVersion = "1.13.1"
def scalaJsVersions = Seq("1.9.0", "1.10.0", "1.10.1", "1.11.0", "1.12.0", latestScalaJsVersion)

object cli extends Cross[Cli](scalaJsVersions: _*)

class Cli(val scalaJsVersion0: String) extends ScalaModule with ScalaJsCliPublishModule {
def scala213 = "2.13.12"
def scalaJsVersion = "1.13.2"
object cli extends Cli
trait Cli extends ScalaModule with ScalaJsCliPublishModule {
def scalaVersion = scala213
def artifactName = "scalajs" + super.artifactName()
def ivyDeps = super.ivyDeps() ++ Seq(
ivy"org.scala-js::scalajs-linker:$scalaJsVersion0",
ivy"org.scala-js::scalajs-linker:$scalaJsVersion",
ivy"com.github.scopt::scopt:4.1.0"
)
def millSourcePath = super.millSourcePath / os.up

def mainClass = Some("org.scalajs.cli.Scalajsld")

def sources = T.sources {
val extra =
if (Version(scalaJsVersion0) == Version("1.9.0")) millSourcePath / "scala-js-1.9"
else millSourcePath / "scala-js-1.10+"
super.sources() ++ Seq(PathRef(extra))
}

def transitiveJars: T[Agg[PathRef]] = {

def allModuleDeps(todo: List[JavaModule]): List[JavaModule] = {
Expand Down Expand Up @@ -73,7 +61,6 @@ class Cli(val scalaJsVersion0: String) extends ScalaModule with ScalaJsCliPublis
else None

import coursier.launcher.{
AssemblyGenerator,
BootstrapGenerator,
ClassPathEntry,
Parameters,
Expand Down Expand Up @@ -107,9 +94,8 @@ class Cli(val scalaJsVersion0: String) extends ScalaModule with ScalaJsCliPublis
}
}

class ScalaJsCliNativeImage(val scalaJsVersion0: String) extends ScalaModule with NativeImage {
trait ScalaJsCliNativeImage extends ScalaModule with NativeImage {
def scalaVersion = scala213
def scalaJsVersion = scalaJsVersion0

def nativeImageClassPath = T{
runClasspath()
Expand All @@ -127,7 +113,7 @@ class ScalaJsCliNativeImage(val scalaJsVersion0: String) extends ScalaModule wit
def nativeImageGraalVmJvmId = s"graalvm-java17:$graalVmVersion"
def nativeImageName = "scala-js-ld"
def moduleDeps() = Seq(
cli(scalaJsVersion0)
cli
)
def compileIvyDeps = super.compileIvyDeps() ++ Seq(
ivy"org.graalvm.nativeimage:svm:$graalVmVersion"
Expand All @@ -139,20 +125,20 @@ class ScalaJsCliNativeImage(val scalaJsVersion0: String) extends ScalaModule wit
val _ = Upload.copyLauncher(
nativeImage().path,
directory,
s"scala-js-ld-$scalaJsVersion",
s"scala-js-ld",
compress = true,
suffix = nameSuffix
)
}
}

object native extends Cross[ScalaJsCliNativeImage](scalaJsVersions: _*)
object native extends ScalaJsCliNativeImage

def native0 = native

def csDockerVersion = "2.1.0-M5-18-gfebf9838c"

class ScalaJsCliStaticNativeImage(scalaJsVersion0: String) extends ScalaJsCliNativeImage(scalaJsVersion0) {
trait ScalaJsCliStaticNativeImage extends ScalaJsCliNativeImage {
def nameSuffix = "-static"
def buildHelperImage = T {
os.proc("docker", "build", "-t", "scala-cli-base-musl:latest", ".")
Expand All @@ -173,9 +159,9 @@ class ScalaJsCliStaticNativeImage(scalaJsVersion0: String) extends ScalaJsCliNat
super.writeNativeImageScript(scriptDest, imageDest)()
}
}
object `native-static` extends Cross[ScalaJsCliStaticNativeImage](scalaJsVersions: _*)
object `native-static` extends ScalaJsCliStaticNativeImage

class ScalaJsCliMostlyStaticNativeImage(scalaJsVersion0: String) extends ScalaJsCliNativeImage(scalaJsVersion0) {
trait ScalaJsCliMostlyStaticNativeImage extends ScalaJsCliNativeImage {
def nameSuffix = "-mostly-static"
def nativeImageDockerParams = Some(
NativeImage.linuxMostlyStaticParams(
Expand All @@ -184,16 +170,15 @@ class ScalaJsCliMostlyStaticNativeImage(scalaJsVersion0: String) extends ScalaJs
)
)
}
object `native-mostly-static` extends Cross[ScalaJsCliMostlyStaticNativeImage](scalaJsVersions: _*)
object `native-mostly-static` extends ScalaJsCliMostlyStaticNativeImage

object tests extends Cross[Tests](scalaJsVersions: _*)
class Tests(val scalaJsVersion0: String) extends ScalaModule {
object tests extends ScalaModule {
def scalaVersion = scala213

object test extends Tests {
object test extends ScalaTests {
def ivyDeps = super.ivyDeps() ++ Seq(
ivy"org.scalameta::munit:0.7.29",
ivy"com.lihaoyi::os-lib:0.9.0",
ivy"com.lihaoyi::os-lib:0.9.1",
ivy"com.lihaoyi::pprint:0.8.1"
)
def testFramework = "munit.Framework"
Expand All @@ -206,7 +191,7 @@ class Tests(val scalaJsVersion0: String) extends ScalaModule {
val launcher = launcherTask().path
val extraArgs = Seq(
s"-Dtest.scala-js-cli.path=$launcher",
s"-Dtest.scala-js-cli.scala-js-version=$scalaJsVersion0"
s"-Dtest.scala-js-cli.scala-js-version=$scalaJsVersion"
)
args ++ extraArgs
}
Expand All @@ -219,41 +204,23 @@ class Tests(val scalaJsVersion0: String) extends ScalaModule {
def test(args: String*) =
jvm(args: _*)
def jvm(args: String*) =
new TestHelper(cli(scalaJsVersion0).standaloneLauncher).test(args: _*)
new TestHelper(cli.standaloneLauncher).test(args: _*)
def native(args: String*) =
new TestHelper(native0(scalaJsVersion0).nativeImage).test(args: _*)
new TestHelper(native0.nativeImage).test(args: _*)
def nativeStatic(args: String*) =
new TestHelper(`native-static`(scalaJsVersion0).nativeImage).test(args: _*)
new TestHelper(`native-static`.nativeImage).test(args: _*)
def nativeMostlyStatic(args: String*) =
new TestHelper(`native-mostly-static`(scalaJsVersion0).nativeImage).test(args: _*)

private def updateRef(ref: PathRef): PathRef = {
val rawPath = ref.path.toString.replace(
File.separator + scalaJsVersion0 + File.separator,
File.separator
)
PathRef(os.Path(rawPath))
}
def sources = T.sources {
super.sources().flatMap { ref =>
Seq(updateRef(ref), ref)
}
}
def resources = T.sources {
super.resources().flatMap { ref =>
Seq(updateRef(ref), ref)
}
}
new TestHelper(`native-mostly-static`.nativeImage).test(args: _*)
}
}

def ghOrg = "scala-cli"
def ghOrg = "virtuslab"
def ghName = "scala-js-cli"
trait ScalaJsCliPublishModule extends PublishModule {
import mill.scalalib.publish._
def pomSettings = PomSettings(
description = artifactName(),
organization = "io.github.alexarchambault.tmp",
organization = "org.virtuslab.scala-cli",
url = s"https://github.com/$ghOrg/$ghName",
licenses = Seq(License.`BSD-3-Clause`),
versionControl = VersionControl.github(ghOrg, ghName),
Expand Down Expand Up @@ -357,8 +324,8 @@ object ci extends Module {
set.head
}
val publisher = new scalalib.publish.SonatypePublisher(
uri = "https://s01.oss.sonatype.org/service/local",
snapshotUri = "https://s01.oss.sonatype.org/content/repositories/snapshots",
uri = "https://oss.sonatype.org/service/local",
snapshotUri = "https://oss.sonatype.org/content/repositories/snapshots",
credentials = credentials,
signed = true,
// format: off
Expand Down Expand Up @@ -395,7 +362,9 @@ object ci extends Module {
if (version.endsWith("-SNAPSHOT")) ("launchers", true)
else ("v" + version, false)

Upload.upload("scala-cli", "scala-js-cli", ghToken, tag, dryRun = false, overwrite = overwriteAssets)(launchers: _*)
Upload.upload(ghOrg, ghName, ghToken, tag, dryRun = false, overwrite = overwriteAssets)(launchers: _*)
if(version != scalaJsVersion && !version.endsWith("-SNAPSHOT")) // when we release `0.13.0.1` we should also update native launchers in tag `0.13.0`
Upload.upload(ghOrg, ghName, ghToken, s"v$scalaJsVersion", dryRun = false, overwrite = true)(launchers: _*)
}
}

Expand Down

This file was deleted.

5 changes: 4 additions & 1 deletion cli/src/org/scalajs/cli/Scalajsld.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import java.io.File
import java.net.URI
import java.nio.file.Path
import java.lang.NoClassDefFoundError
import org.scalajs.cli.internal.ModuleSplitStyleParser
import org.scalajs.cli.internal.{EsVersionParser, ModuleSplitStyleParser}

object Scalajsld {

Expand Down Expand Up @@ -153,6 +153,9 @@ object Scalajsld {
opt[Unit]("es2015")
.action { (_, c) => c.copy(esFeatures = c.esFeatures.withESVersion(ESVersion.ES2015)) }
.text("Use ECMAScript 2015")
opt[String]("esVersion")
.action { (esV, c) => c.copy(esFeatures = c.esFeatures.withESVersion(EsVersionParser.parse(esV))) }
.text("EsVersion " + EsVersionParser.All.mkString("(", ", ", ")"))
opt[ModuleKind]('k', "moduleKind")
.action { (kind, c) => c.copy(moduleKind = kind) }
.text("Module kind " + ModuleKind.All.mkString("(", ", ", ")"))
Expand Down
23 changes: 23 additions & 0 deletions cli/src/org/scalajs/cli/internal/EsVersionParser.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.scalajs.cli.internal

import org.scalajs.linker.interface.ESVersion

import java.util.Locale

object EsVersionParser {
def parse(esVersion: String): ESVersion =
esVersion.trim.toLowerCase(Locale.ROOT) match {
case "es5_1" => ESVersion.ES5_1
case "es2015" => ESVersion.ES2015
case "es2016" => ESVersion.ES2016
case "es2017" => ESVersion.ES2017
case "es2018" => ESVersion.ES2018
case "es2019" => ESVersion.ES2019
case "es2020" => ESVersion.ES2020
case "es2021" => ESVersion.ES2021
case unknown => throw new IllegalArgumentException(s"Warning: unrecognized argument: $unknown for --esVersion parameter")
}

val All: List[ESVersion] =
List(ESVersion.ES5_1, ESVersion.ES2015, ESVersion.ES2016, ESVersion.ES2017, ESVersion.ES2018, ESVersion.ES2019, ESVersion.ES2020, ESVersion.ES2021)
}

0 comments on commit 58196ef

Please sign in to comment.