Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-build for Native #1180

Merged
merged 8 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
os: [ubuntu-latest]
scala: [2.13.8, 3.1.2]
java: [temurin@8, temurin@11, temurin@17]
project: [rootJS, rootJVM]
project: [rootJS, rootJVM, rootNative]
exclude:
- scala: 2.13.8
java: temurin@11
Expand All @@ -40,6 +40,10 @@ jobs:
java: temurin@11
- project: rootJS
java: temurin@17
- project: rootNative
java: temurin@11
- project: rootNative
java: temurin@17
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -118,6 +122,10 @@ jobs:
if: matrix.project == 'rootJS'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult

- name: nativeLink
if: matrix.project == 'rootNative'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink

- name: Test
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test

Expand All @@ -131,11 +139,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p data/.jvm/target legacy/.jvm/target extras/.js/target examples/target target platform/js/target macros/.jvm/target .js/target site/target core/.js/target macros/.js/target laws/.js/target legacy/.js/target core/.jvm/target tests/js/target .jvm/target .native/target platform/jvm/target util/.js/target data/.js/target util/.jvm/target laws/.jvm/target tests/jvm/target extras/.jvm/target benchmark/target project/target
run: mkdir -p data/.jvm/target legacy/.jvm/target extras/.js/target examples/target util/.native/target extras/.native/target target platform/js/target macros/.jvm/target legacy/.native/target .js/target core/.native/target site/target macros/.native/target laws/.native/target core/.js/target macros/.js/target laws/.js/target legacy/.js/target core/.jvm/target tests/js/target .jvm/target .native/target platform/jvm/target util/.js/target platform/native/target data/.js/target util/.jvm/target laws/.jvm/target tests/jvm/target extras/.jvm/target data/.native/target benchmark/target tests/native/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar data/.jvm/target legacy/.jvm/target extras/.js/target examples/target target platform/js/target macros/.jvm/target .js/target site/target core/.js/target macros/.js/target laws/.js/target legacy/.js/target core/.jvm/target tests/js/target .jvm/target .native/target platform/jvm/target util/.js/target data/.js/target util/.jvm/target laws/.jvm/target tests/jvm/target extras/.jvm/target benchmark/target project/target
run: tar cf targets.tar data/.jvm/target legacy/.jvm/target extras/.js/target examples/target util/.native/target extras/.native/target target platform/js/target macros/.jvm/target legacy/.native/target .js/target core/.native/target site/target macros/.native/target laws/.native/target core/.js/target macros/.js/target laws/.js/target legacy/.js/target core/.jvm/target tests/js/target .jvm/target .native/target platform/jvm/target util/.js/target platform/native/target data/.js/target util/.jvm/target laws/.jvm/target tests/jvm/target extras/.jvm/target data/.native/target benchmark/target tests/native/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand Down Expand Up @@ -240,6 +248,16 @@ jobs:
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13.8, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative

- name: Inflate target directories (2.13.8, rootNative)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (3.1.2, rootJS)
uses: actions/download-artifact@v2
with:
Expand All @@ -260,6 +278,16 @@ jobs:
tar xf targets.tar
rm targets.tar

- name: Download target directories (3.1.2, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.2-rootNative

- name: Inflate target directories (3.1.2, rootNative)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (3.1.2, rootJVM)
uses: actions/download-artifact@v2
with:
Expand Down
25 changes: 12 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import scala.language.existentials

lazy val scalaCheckVersion = "1.16.0"

lazy val munit = "0.7.29"
lazy val munitDiscipline = "1.0.9"
lazy val munit = "1.0.0-M5"
lazy val munitDiscipline = "2.0.0-M2"

lazy val algebraVersion = "2.7.0"
lazy val algebraVersion = "2.8.0"

lazy val apfloatVersion = "1.10.1"
lazy val jscienceVersion = "4.3.1"
Expand Down Expand Up @@ -62,14 +62,14 @@ lazy val root = tlCrossRootProject
.settings(unidocSettings)
.enablePlugins(ScalaUnidocPlugin)

lazy val platform = crossProject(JSPlatform, JVMPlatform)
lazy val platform = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(moduleName := "spire-platform")
.settings(spireSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(macros, util)

lazy val macros = crossProject(JSPlatform, JVMPlatform)
lazy val macros = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-macros")
.settings(spireSettings: _*)
Expand All @@ -78,29 +78,29 @@ lazy val macros = crossProject(JSPlatform, JVMPlatform)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)

lazy val data = crossProject(JSPlatform, JVMPlatform)
lazy val data = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-data")
.settings(spireSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)

lazy val legacy = crossProject(JSPlatform, JVMPlatform)
lazy val legacy = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-legacy")
.settings(spireSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)

lazy val util = crossProject(JSPlatform, JVMPlatform)
lazy val util = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-util")
.settings(spireSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(macros)

lazy val core = crossProject(JSPlatform, JVMPlatform)
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire")
.settings(spireSettings: _*)
Expand All @@ -109,7 +109,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
.jsSettings(commonJsSettings: _*)
.dependsOn(macros, platform, util)

lazy val extras = crossProject(JSPlatform, JVMPlatform)
lazy val extras = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-extras")
.settings(spireSettings: _*)
Expand Down Expand Up @@ -140,7 +140,7 @@ lazy val examples = project
.settings(commonJvmSettings)
.dependsOn(core.jvm, extras.jvm)

lazy val laws = crossProject(JSPlatform, JVMPlatform)
lazy val laws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-laws")
.settings(spireSettings: _*)
Expand All @@ -154,7 +154,7 @@ lazy val laws = crossProject(JSPlatform, JVMPlatform)
.jsSettings(commonJsSettings: _*)
.dependsOn(core, extras)

lazy val tests = crossProject(JSPlatform, JVMPlatform)
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Full)
.settings(moduleName := "spire-tests")
.settings(spireSettings: _*)
Expand Down Expand Up @@ -196,7 +196,6 @@ lazy val commonDeps = Seq(
)

lazy val commonSettings = Seq(
resolvers += Resolver.sonatypeRepo("snapshots"),
headerLicense := Some(HeaderLicense.Custom(header))
) ++ scalaMacroDependencies

Expand Down
5 changes: 1 addition & 4 deletions core/src/main/scala/spire/math/poly/Term.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ object Term {

// call Regex constructor directly to get rid of compiler warning
// replace with "".r once SI-6723 is fixed
private val superscriptRegex =
new scala.util.matching.Regex(
"[\\u2070\\u2071\\u2072\\u2073\\u2074\\u2075\\u2076\\u2077\\u2078\\u2079\\u207B\\u00B9\\u00B2\\u00B3]+"
)
private val superscriptRegex = "[⁰¹²³⁴⁵⁶⁷⁸⁹⁻ⁱ]+".r

private[spire] def removeSuperscript(text: String): String =
superscriptRegex.replaceAllIn(text, "^" + _.group(0).map(removeSuperscript))
Expand Down
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ val sbtTypelevelVersion = "0.4.12"
addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion)
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion)

addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")

addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ class SafeLongScalaCheckSuite extends munit.ScalaCheckSuite {
}
}

property("x >> k") {
forAll { (x: BigInt, k: Byte) =>
intercept[RuntimeException] { SafeLong(x) >> Int.MinValue }
invariant(SafeLong(x) >> k) == SafeLong(x >> k)
if (!sys.props.get("java.vm.name").contains("Scala Native"))
property("x >> k") {
forAll { (x: BigInt, k: Byte) =>
intercept[RuntimeException] { SafeLong(x) >> Int.MinValue }
invariant(SafeLong(x) >> k) == SafeLong(x >> k)
}
}
}

property("long safelongs") {
forAll { (x: Long) =>
Expand Down