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

Prepare for release 0.5.0 #31

Merged
merged 17 commits into from
Oct 10, 2023
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
9 changes: 6 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ jobs:
fail-fast: false
matrix:
OS: [ubuntu-22.04, windows-2022]
scala: [2.12.17, 2.13.10, 3.2.1]
scala: [2.12.18, 2.13.12, 3.3.1]
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v13
- uses: actions/checkout@v3
- uses: coursier/cache-action@v6
- uses: coursier/setup-action@v1
with:
jvm: adopt:8
- name: Set env Linux
if: ${{ startsWith(matrix.OS, 'ubuntu') }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ jobs:
check-cla:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/check-cla.sh
2 changes: 1 addition & 1 deletion .github/workflows/check-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ jobs:
check-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./scripts/check-lint.sh
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish
on:
push:
tags:
- 'v0.5.*'
workflow_dispatch:
repository_dispatch:
types: [nightly-published]

jobs:
publish:
name: Publish
runs-on: ubuntu-22.04
if: github.repository == 'scala-native/scala-native-cli'
steps:
- uses: actions/checkout@v3
- uses: coursier/cache-action@v6
- uses: coursier/setup-action@v1
with:
jvm: adopt:8

- name: Setup PGP Key
run: |
echo -n "$PGP_SECRET" | base64 --decode | gpg --batch --import
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}

- name: Compile everything
run: sbt "+Test/compile"

- name: Publish release
env:
MAVEN_USER: "${{ secrets.SONATYPE_USER }}"
MAVEN_PASSWORD: "${{ secrets.SONATYPE_PASSWORD }}"
PGP_PASSPHRASE: "${{ secrets.PGP_PASSWORD }}"
run: sbt "clean;+cli/cliPack; +cli/publishSigned"

- name: Create release artifacts
run: |
version=$(sbt "print cli/version" | tail -n1)
echo "This build version: $version"
./scritps/dist.sh $version

- name: Archive CLI artifacts
uses: actions/upload-artifact@v3
with:
name: scala-native-cli
path: release/
116 changes: 81 additions & 35 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
val crossScalaVersions212 = (13 to 18).map("2.12." + _)
val crossScalaVersions213 = (4 to 11).map("2.13." + _)
val crossScalaVersions212 = (14 to 18).map("2.12." + _)
val crossScalaVersions213 = (8 to 12).map("2.13." + _)
val crossScalaVersions3 =
(0 to 3).map("3.1." + _) ++
(2 to 3).map("3.1." + _) ++
(0 to 2).map("3.2." + _) ++
(0 to 0).map("3.3." + _)
(0 to 1).map("3.3." + _)

val publishScalaVersions =
Seq(crossScalaVersions212, crossScalaVersions213).map(_.last) ++ Seq("3.1.3")
val scala2_12 = crossScalaVersions212.last
val scala2_13 = crossScalaVersions213.last
val scala3 = crossScalaVersions3.last
val scala3PublishVersion = "3.1.3"

val publishScalaVersions = Seq(scala2_12, scala2_13, scala3PublishVersion)

def scalaReleasesForBinaryVersion(v: String): Seq[String] = v match {
case "2.12" => crossScalaVersions212
Expand All @@ -19,27 +23,37 @@ def scalaReleasesForBinaryVersion(v: String): Seq[String] = v match {
}

def scalaStdlibForBinaryVersion(
nativeBinVer: String,
scalaBinVer: String
): Seq[String] = {
def depPattern(lib: String, v: String) =
s"${lib}_native${nativeBinVer}_${v}"
val scalalib = "scalalib"
val scala3lib = "scala3lib"
val commonLibs = Seq(
organization: String,
nativeVersion: String,
nativeBinaryVersion: String,
scalaBinaryVersion: String
): Seq[ModuleID] = {
def artifact(module: String, binV: String, version: String = nativeVersion) =
organization % s"${module}_native${nativeBinaryVersion}_$binV" % version

def scalalibVersion(scalaBinVersion: String): String = {
val scalaVersion = scalaReleasesForBinaryVersion(scalaBinaryVersion).last
s"$scalaVersion+$nativeVersion"
}
def scalalib(binV: String) = artifact("scalalib", binV, scalalibVersion(binV))
val scala3lib = artifact("scalalib", "3", scalalibVersion("3"))
val crossRuntimeLibraries = List(
"nativelib",
"clib",
"posixlib",
"windowslib",
"javalib",
"auxlib"
)
scalaBinVer match {
case "2.12" | "2.13" =>
(commonLibs :+ scalalib).map(depPattern(_, scalaBinVer))
case "3" =>
(commonLibs :+ scala3lib).map(depPattern(_, scalaBinVer)) :+
depPattern(scalalib, "2.13")
).map(artifact(_, scalaBinaryVersion))

val nonCrossRuntimeLibraries = List("javalib-intf")
.map(organization % _ % nativeVersion)

val runtimeLibraries = crossRuntimeLibraries ++ nonCrossRuntimeLibraries

scalaBinaryVersion match {
case "2.12" | "2.13" => scalalib(scalaBinaryVersion) :: runtimeLibraries
case "3" => scala3lib :: scalalib("2.13") :: runtimeLibraries
case ver =>
throw new IllegalArgumentException(
s"Unsupported binary scala version `${ver}`"
Expand All @@ -55,9 +69,9 @@ val cliAssemblyJarName = settingKey[String]("Name of created assembly jar")
inThisBuild(
Def.settings(
organization := "org.scala-native",
scalaNativeVersion := "0.4.15",
scalaNativeVersion := "0.5.0-SNAPSHOT",
version := scalaNativeVersion.value,
scalaVersion := crossScalaVersions212.last,
scalaVersion := scala3PublishVersion,
crossScalaVersions := publishScalaVersions,
homepage := Some(url("http://www.scala-native.org")),
startYear := Some(2021),
Expand All @@ -74,7 +88,7 @@ inThisBuild(
Some("scm:git:[email protected]:scala-native/scala-native-cli.git")
)
),
resolvers += Resolver.sonatypeRepo("snapshots"),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
resolvers += Resolver.mavenCentral,
resolvers += Resolver.defaultLocal
)
Expand Down Expand Up @@ -143,10 +157,33 @@ lazy val cliScriptedTests = project

def nativeBinaryVersion(version: String): String = {
val VersionPattern = raw"(\d+)\.(\d+)\.(\d+)(\-.*)?".r
val VersionPattern(major, minor, _, _) = version
s"$major.$minor"
val VersionPattern(major, minor, patch, milestone) = version
if (patch != null && milestone != null) version
else s"$major.$minor"
}

val nativeSourceExtensions = Set(".c", ".cpp", ".cxx", ".h", ".hpp", ".S")
val DeduplicateOrRename = new sbtassembly.MergeStrategy {
def name: String = "deduplicate-or-rename"
def apply(
tempDir: java.io.File,
path: String,
files: Seq[java.io.File]
): Either[String, Seq[(java.io.File, String)]] =
MergeStrategy.deduplicate(tempDir, path, files) match {
case v @ Right(_) => v
case _ => MergeStrategy.rename(tempDir, path, files)
}
}

lazy val cliPackSettings = Def.settings(
assemblyMergeStrategy := {
val default = assemblyMergeStrategy.value
file =>
if (nativeSourceExtensions.exists(file.endsWith)) DeduplicateOrRename
else if (file.endsWith("scala-native.properties")) MergeStrategy.concat
else default(file)
},
cliPackLibJars := {
val s = streams.value
val log = s.log
Expand All @@ -159,13 +196,15 @@ lazy val cliPackSettings = Def.settings(
val scalaFullVers = scalaReleasesForBinaryVersion(scalaBinVer)
val cliAssemblyJar = assembly.value

val scalaStdLibraryModuleIDs =
scalaStdlibForBinaryVersion(nativeBinVer, scalaBinVer)

// Standard modules needed for linking of Scala Native
val stdLibModuleIDs = scalaStdLibraryModuleIDs.map(
scalaNativeOrg % _ % snVer
)
val stdLibModuleIDs =
scalaStdlibForBinaryVersion(
organization = scalaNativeOrg,
nativeVersion = snVer,
nativeBinaryVersion = nativeBinVer,
scalaBinaryVersion = scalaBinVer
)

val compilerPluginModuleIDs =
scalaFullVers.map(v => scalaNativeOrg % s"nscplugin_$v" % snVer)
val allModuleIDs = (stdLibModuleIDs ++ compilerPluginModuleIDs).toVector
Expand Down Expand Up @@ -235,6 +274,10 @@ lazy val cliPackSettings = Def.settings(
"@SCALANATIVE_BIN_VER@",
nativeBinaryVersion(snVer)
)
.replaceAllLiterally(
"@SCALALIB_2_13_FOR_3_VER@",
crossScalaVersions213.last
)
val dest = trgBin / scriptFile.getName
IO.write(dest, processedContent)
if (scriptFile.canExecute)
Expand All @@ -259,11 +302,14 @@ lazy val publishSettings = Def.settings(
},
credentials ++= {
for {
realm <- sys.env.get("MAVEN_REALM")
domain <- sys.env.get("MAVEN_DOMAIN")
user <- sys.env.get("MAVEN_USER")
password <- sys.env.get("MAVEN_PASSWORD")
} yield Credentials(realm, domain, user, password)
} yield Credentials(
realm = "Sonatype Nexus Repository Manager",
host = "oss.sonatype.org",
userName = user,
passwd = password
)
}.toSeq,
developers ++= List(
Developer(
Expand Down
20 changes: 18 additions & 2 deletions cli/src/main/scala/scala/scalanative/cli/ScalaNativeLd.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package scala.scalanative.cli

import java.nio.file._
import scala.scalanative.build._
import scala.scalanative.util.Scope
import scala.scalanative.cli.utils.ConfigConverter
import scala.scalanative.cli.options._
import scala.concurrent._
import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global

object ScalaNativeLd {

Expand Down Expand Up @@ -69,9 +73,21 @@ object ScalaNativeLd {
System.err.println(thrown.getMessage())
sys.exit(1)
case Right(buildOptions) =>
Scope { implicit scope =>
Build.build(buildOptions.config, buildOptions.outpath)
val outpath = Paths.get(options.config.outpath)
val build = Scope { implicit scope =>
Build
.build(buildOptions.config)
.map(
Files.copy(
_,
outpath,
StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.COPY_ATTRIBUTES
)
)
}
Await.result(build, Duration.Inf)

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ object ScalaNativeP {
private def printNIR(defns: Seq[Defn], verbose: Boolean) =
defns
.map {
case defn @ Defn.Define(attrs, name, ty, _) if !verbose =>
case defn @ Defn.Define(attrs, name, ty, _, _) if !verbose =>
Defn.Declare(attrs, name, ty)(defn.pos)
case defn => defn
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ case class NativeConfigOptions(
dump: Boolean = false,
noOptimize: Boolean = false,
embedResources: Boolean = false,
multithreadingSupport: Boolean = true,
debugMetadata: Boolean = false,
incrementalCompilation: Boolean = false,
baseName: Option[String] = None,
ltp: List[String] = List.empty,
linkingOption: List[String] = List.empty,
compileOption: List[String] = List.empty,
Expand Down Expand Up @@ -109,6 +112,38 @@ object NativeConfigOptions {
.text(
"Shall use incremental compilation mode for builds? (experimental) [false]"
)
parser
.opt[Boolean]("multithreading")
.abbr("-mt")
.optional()
.action((x, c) =>
c.copy(nativeConfig = c.nativeConfig.copy(multithreadingSupport = x))
)
.text(
"Should the target enable multihreading support for builds? [true]"
)
parser
.opt[Boolean]("debug-info")
.abbr("-g")
.optional()
.action((x, c) =>
c.copy(nativeConfig = c.nativeConfig.copy(debugMetadata = x))
)
.text(
"Should the build include additional debug information? These can be used for better stacktraces or debuging support [false]"
)
parser
.opt[String]("base-name")
.optional()
.action((x, c) =>
c.copy(nativeConfig =
c.nativeConfig
.copy(baseName = Some(x).map(_.trim()).filter(_.nonEmpty))
)
)
.text(
"Base name (without extension) used to generate names for build outputs. If empty `--base-name` would be resolved from `--outpath`"
)
parser
.opt[String]("ltp")
.valueName("<keystring=value>")
Expand Down
Loading