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

Maintenance toolchain update 2023 #159

Merged
merged 8 commits into from
Nov 18, 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ project/metals.sbt
# for personal trials / tests that shall be ignored but stay on your disk
ztest/
.bsp/

# OS specific
.DS_Store

7 changes: 7 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules = [
ProcedureSyntax,
ExplicitResultTypes,
NoAutoTupling,
OrganizeImports,
RemoveUnused
]
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 3.0.6
version = 3.7.15
runner.dialect = scala213
20 changes: 17 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import sbtassembly.AssemblyPlugin.defaultUniversalScript

ThisBuild / scalaVersion := "2.13.6"
ThisBuild / scalaVersion := "2.12.18"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional, 2.13 brings 100 + deprecations,
so first, get a clean 2.12 state, and then move on

ThisBuild / organization := "com.github.cross-language-cpp"

ThisBuild / semanticdbEnabled := true // enable SemanticDB
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version

// Keep this as a reminder, we will use that later
// ThisBuild / scalacOptions += "-Ywarn-unused"
// us: sbt 'set ThisBuild / scalacOptions += "-Ywarn-unused"' scalafix
// until the last 2 unused warnings are fixed
ThisBuild / scalacOptions ++= Seq("-deprecation", "-unchecked")

val binExt = if (System.getProperty("os.name").startsWith("Windows")) ".bat" else ""
lazy val djinni = (project in file("."))
.configs(IntegrationTest)
.enablePlugins(ScalafixPlugin) // enable Scalafix for this project
.settings(
name := "djinni",
Defaults.itSettings,
Expand All @@ -15,8 +25,12 @@ lazy val djinni = (project in file("."))
libraryDependencies += "org.yaml" % "snakeyaml" % "1.29",
libraryDependencies += "com.github.scopt" %% "scopt" % "4.0.1",
libraryDependencies += "commons-io" % "commons-io" % "2.11.0",
assembly / assemblyOutputPath := { file("target/bin") / s"${(assembly / assemblyJarName).value}${binExt}" },
assembly / assemblyOutputPath := {
val dir = file("target/bin")
IO.createDirectory(dir)
dir / s"${(assembly / assemblyJarName).value}${binExt}"
},
assembly / assemblyJarName := s"${name.value}",
assembly / assemblyOption := (assembly / assemblyOption).value.copy(prependShellScript = Some(defaultUniversalScript(shebang = false))),
assembly / assemblyPrependShellScript := Some(defaultUniversalScript(shebang = false)),
assembly / test := {}
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.9.7
8 changes: 5 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.4")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.4")
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3")
10 changes: 5 additions & 5 deletions src/it/scala/djinni/GeneratorIntegrationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -732,23 +732,23 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen {
}

it(s"skip-generate should not generate any files") {
var idlFile = "all_datatypes"
var outputPath = "src/it/resources/result/skip_generate"
val idlFile = "all_datatypes"
val outputPath = "src/it/resources/result/skip_generate"
Given(s"`$idlFile.djinni`")
When(s"passing skip-generation true")

djinni(djinniParams(idlFile, outputPath) + " --skip-generation true")

Then(s"`$outputPath` should have been created")
var dir = new java.io.File(outputPath, idlFile)
val dir = new java.io.File(outputPath, idlFile)
dir.exists should be(true)

Then(s"genreated-files.txt should have been generated")
val gen = new java.io.File(dir, "generated-files.txt")
gen.exists should be(true)

Then(s"only the generated-files.txt should be generated")
var files = dir.listFiles()
val files = dir.listFiles()
files should contain only (gen)
}

Expand Down Expand Up @@ -815,7 +815,7 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen {
When(
"calling the generator with `--cpp-namespace custom_namespace, --cpp-json-serialization nlohmann_json and --cpp-out`"
)
val output = djinni(
val _ = djinni(
s"--idl src/it/resources/${idlFile}.djinni --cpp-namespace custom_namespace --cpp-json-serialization nlohmann_json --cpp-out $outputPath/cpp --cpp-header-out $outputPath/cpp-headers"
)
Then(
Expand Down
2 changes: 1 addition & 1 deletion src/it/scala/djinni/IntegrationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.sys.process._

import scala.reflect.io.Directory
import java.io.File
import java.nio.file.Paths
//import java.nio.file.Paths

// Base class for integration tests, providing a few handy helper functions
class IntegrationTest extends AnyFunSpec {
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/djinni/BaseObjcGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class BaseObjcGenerator(spec: Spec) extends Generator(spec) {
consts: Seq[Const],
selfName: String,
genType: ObjcConstantType.Value
) = {
): Unit = {
def boxedPrimitive(ty: TypeRef): String = {
val (_, needRef) = marshal.toObjcType(ty)
if (needRef) "@" else ""
Expand Down Expand Up @@ -78,16 +78,16 @@ abstract class BaseObjcGenerator(spec: Spec) extends Generator(spec) {
}
}

def writeObjcConstMethImpl(c: Const, w: IndentWriter) {
def writeObjcConstMethImpl(c: Const, w: IndentWriter): Unit = {
val label = "+"
val nullability = marshal.nullability(c.ty.resolved).fold("")(" __" + _)
val ret = marshal.fqFieldType(c.ty) + nullability
val decl = s"$label ($ret)${idObjc.method(c.ident)}"
writeAlignedObjcCall(w, decl, List(), "", p => ("", ""))
writeAlignedObjcCall(w, decl, List(), "", _ => ("", ""))
w.wl

w.braced {
var static_var = s"s_${idObjc.method(c.ident)}"
val static_var = s"s_${idObjc.method(c.ident)}"
w.w(s"static ${marshal.fqFieldType(c.ty)} const ${static_var} = ")
writeObjcConstValue(w, c.ty, c.value)
w.wl(";")
Expand Down
Loading
Loading