Skip to content

Commit 45a78f9

Browse files
Support Scala Native (#6)
* Bump cats-parse 0.3.8 * Release native executable with scala-native
1 parent d808200 commit 45a78f9

File tree

6 files changed

+23
-25
lines changed

6 files changed

+23
-25
lines changed

.github/scripts/package.sc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using scala "3.1.2"
1+
//> using scala "3.1.3"
22
//> using lib "com.lihaoyi::os-lib:0.8.0"
33

44
import scala.util.Properties
@@ -12,14 +12,22 @@ val platformSuffix: String = {
1212
os
1313
}
1414
val artifactsPath = os.Path("artifacts", os.pwd)
15-
val destPath =
16-
if (Properties.isWin) artifactsPath / s"ulc-$platformSuffix.exe"
17-
else artifactsPath / s"ulc-$platformSuffix"
15+
16+
def destPath(prefix: String) =
17+
if (Properties.isWin) artifactsPath / s"$prefix-ulc-$platformSuffix.exe"
18+
else artifactsPath / s"$prefix-ulc-$platformSuffix"
19+
1820
val scalaCLILauncher =
1921
if (Properties.isWin) "scala-cli.bat" else "scala-cli"
2022

2123
os.makeDir(artifactsPath)
22-
os.proc(scalaCLILauncher, "package", "./ulc", "-o", destPath, "--native-image")
24+
os.proc(scalaCLILauncher, "package", "./ulc", "-o", destPath("graal"), "--native-image")
25+
.call(cwd = os.pwd)
26+
.out
27+
.text()
28+
.trim
29+
30+
os.proc(scalaCLILauncher, "package", "./ulc", "-o", destPath("native"), "--native", "--native-version", "0.4.5")
2331
.call(cwd = os.pwd)
2432
.out
2533
.text()

.github/workflows/publish.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,11 @@ on:
66

77
jobs:
88
publish:
9-
name: Publish for ${{ matrix.os }}
10-
runs-on: ${{ matrix.os }}
9+
name: Publish for ${{ matrix.OS }}
10+
runs-on: ${{ matrix.OS }}
1111
strategy:
1212
matrix:
13-
include:
14-
- os: ubuntu-latest
15-
artifact_name: ulc-pc-linux
16-
asset_name: ulc-linux
17-
- os: windows-latest
18-
artifact_name: ulc-pc-win32.exe
19-
asset_name: ulc-pc-win32.exe
20-
- os: macos-latest
21-
artifact_name: ulc-apple-darwin
22-
asset_name: ulc-apple
23-
13+
OS: ["ubuntu-latest", "macos-latest", "windows-latest"]
2414
steps:
2515
- uses: actions/checkout@v3
2616
- uses: coursier/[email protected]
@@ -31,6 +21,6 @@ jobs:
3121
uses: svenstaro/upload-release-action@v2
3222
with:
3323
repo_token: ${{ secrets.GITHUB_TOKEN }}
34-
file: ./artifacts/${{ matrix.artifact_name }}
35-
asset_name: ${{ matrix.asset_name }}
24+
file: './artifacts/**'
3625
tag: ${{ github.ref }}
26+
file_glob: true

ulc/FileReader.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object FileReader:
99
def read(path: String): Either[String, String] =
1010
Try {
1111
val bufferedSource = Source.fromFile(path)
12-
val content = bufferedSource.getLines.map(_.strip).filter(!_.isEmpty).mkString("\n")
12+
val content = bufferedSource.getLines.filter(!_.isEmpty).mkString("\n")
1313
bufferedSource.close
1414
content
1515
} match {

ulc/Interpreter.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
//> using scala "3.1.3"
2-
//> using lib "org.typelevel::cats-core:2.8.0"
3-
//> using lib "org.typelevel::cats-parse:0.3.7"
2+
//> using lib "org.typelevel::cats-core::2.8.0"
3+
//> using lib "org.typelevel::cats-parse::0.3.8"
44

55
package ulc
66

77
import cats.*
88
import cats.syntax.all.*
99
import cats.instances.all.*
1010
import cats.data.NonEmptyList
11-
import scala.annotation.tailrec
1211

1312
type Env = Map[String, Parser.Term]
1413

ulc/Parser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//> using scala "3.1.3"
2-
//> using lib "org.typelevel::cats-core:2.8.0"
2+
//> using lib "org.typelevel::cats-core::2.8.0"
33

44
package parser
55

ulc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ We show the final result in de Bruijn form, which is not easy to read. I can imp
8787
- Better error messages
8888
- Recursion scheme
8989
- Fully functional for repl/main
90+
- Location information merger seems wrong

0 commit comments

Comments
 (0)