published to our maven
This commit is contained in:
parent
185aa4e0cf
commit
8c6a1979ed
37
README.md
37
README.md
@ -9,6 +9,10 @@ class Point(x,y) {
|
|||||||
fun dist() { sqrt(x*x + y*y) }
|
fun dist() { sqrt(x*x + y*y) }
|
||||||
}
|
}
|
||||||
Point(3,4).dist() //< 5
|
Point(3,4).dist() //< 5
|
||||||
|
|
||||||
|
fun swapEnds(first, args..., last, f) {
|
||||||
|
f( last, ...args, first)
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- extremely simple Kotlin integration on any platform
|
- extremely simple Kotlin integration on any platform
|
||||||
@ -31,16 +35,37 @@ and it is multithreaded on platforms supporting it (automatically, no code chang
|
|||||||
|
|
||||||
## Integration in Kotlin multiplatform
|
## Integration in Kotlin multiplatform
|
||||||
|
|
||||||
### Add library
|
### Add dependency to your project
|
||||||
|
|
||||||
TBD
|
```kotlin
|
||||||
|
// update to current please:
|
||||||
|
val lyngVersion = "0.6.1-SNAPSHOT"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// ...
|
||||||
|
maven("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
And add dependency to the proper place in your project, it could look like:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
comminMain by getting {
|
||||||
|
dependencies {
|
||||||
|
// ...
|
||||||
|
implementation("net.sergeych:lynglib:$lyngVersion")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can import lyng and use it:
|
||||||
|
|
||||||
### Execute script:
|
### Execute script:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
assertEquals("hello, world", eval("""
|
import net.sergeyh.lyng.*
|
||||||
"hello, " + "world"
|
|
||||||
""").toString())
|
println(eval(""" "hello, " + "Lyng" """))
|
||||||
```
|
```
|
||||||
|
|
||||||
### Exchanging information
|
### Exchanging information
|
||||||
@ -49,6 +74,8 @@ Script is executed over some `Context`. Create instance of the context,
|
|||||||
add your specific vars and functions to it, an call over it:
|
add your specific vars and functions to it, an call over it:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
|
import new.sergeych.lyng.*
|
||||||
|
|
||||||
// simple function
|
// simple function
|
||||||
val context = Context().apply {
|
val context = Context().apply {
|
||||||
addFn("addArgs") {
|
addFn("addArgs") {
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package net.sergeych.lyng
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Symbols(
|
|
||||||
unitType: UnitType,
|
|
||||||
val name: String,
|
|
||||||
val x: TypeDecl
|
|
||||||
) {
|
|
||||||
enum class UnitType {
|
|
||||||
Module, Function, Lambda
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package net.sergeych.lyng
|
|
||||||
|
|
||||||
sealed class TypeDecl {
|
|
||||||
// ??
|
|
||||||
data class Fn(val argTypes: List<ArgsDeclaration.Item>, val retType: TypeDecl) : TypeDecl()
|
|
||||||
object Obj : TypeDecl()
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
To use in the compiler, we need symbol information when:
|
|
||||||
|
|
||||||
- declaring a class: the only way to export its public/protected symbols is to know it in compiler time
|
|
||||||
- importing a module: actually, we cam try to do it in a more efficient way.
|
|
||||||
|
|
||||||
Importing module:
|
|
||||||
|
|
||||||
The moudule is efficiently a statement, that initializes it with all its symbols modifying some context.
|
|
||||||
|
|
||||||
The thing is, we need only
|
|
||||||
|
|
||||||
*/
|
|
@ -29,7 +29,7 @@ kotlin {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":library"))
|
implementation(project(":lynglib"))
|
||||||
implementation(libs.okio)
|
implementation(libs.okio)
|
||||||
|
|
||||||
implementation(libs.clikt)
|
implementation(libs.clikt)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
|
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
|
||||||
import com.vanniktech.maven.publish.SonatypeHost
|
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
@ -20,9 +19,10 @@ buildscript {
|
|||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.kotlinMultiplatform)
|
alias(libs.plugins.kotlinMultiplatform)
|
||||||
alias(libs.plugins.androidLibrary)
|
alias(libs.plugins.androidLibrary)
|
||||||
alias(libs.plugins.vanniktech.mavenPublish)
|
// alias(libs.plugins.vanniktech.mavenPublish)
|
||||||
kotlin("plugin.serialization") version "2.1.20"
|
kotlin("plugin.serialization") version "2.1.20"
|
||||||
id("com.codingfeline.buildkonfig") version "0.17.1"
|
id("com.codingfeline.buildkonfig") version "0.17.1"
|
||||||
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
buildkonfig {
|
buildkonfig {
|
||||||
@ -62,7 +62,7 @@ kotlin {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
all {
|
all {
|
||||||
languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
|
languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
|
||||||
languageSettings.optIn("kotlin.contracts.ExperimentalContracts::class")
|
languageSettings.optIn("kotlin.contracts.ExperimentalContracts")
|
||||||
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
|
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
|
||||||
languageSettings.optIn("kotlin.coroutines.DelicateCoroutinesApi")
|
languageSettings.optIn("kotlin.coroutines.DelicateCoroutinesApi")
|
||||||
}
|
}
|
||||||
@ -101,73 +101,54 @@ dependencies {
|
|||||||
implementation(libs.firebase.crashlytics.buildtools)
|
implementation(libs.firebase.crashlytics.buildtools)
|
||||||
}
|
}
|
||||||
|
|
||||||
mavenPublishing {
|
publishing {
|
||||||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
|
val mavenToken by lazy {
|
||||||
|
File("${System.getProperty("user.home")}/.gitea_token").readText()
|
||||||
signAllPublications()
|
}
|
||||||
|
repositories {
|
||||||
coordinates(group.toString(), "library", version.toString())
|
maven {
|
||||||
|
credentials(HttpHeaderCredentials::class) {
|
||||||
pom {
|
name = "Authorization"
|
||||||
name = "Lyng language"
|
value = mavenToken
|
||||||
description = "Kotlin-bound scripting loanguage"
|
|
||||||
inceptionYear = "2025"
|
|
||||||
// url = "https://sergeych.net"
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name = "XXX"
|
|
||||||
url = "YYY"
|
|
||||||
distribution = "ZZZ"
|
|
||||||
}
|
}
|
||||||
}
|
url = uri("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
|
||||||
developers {
|
authentication {
|
||||||
developer {
|
create("Authorization", HttpHeaderAuthentication::class)
|
||||||
id = "XXX"
|
|
||||||
name = "YYY"
|
|
||||||
url = "ZZZ"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scm {
|
|
||||||
url = "XXX"
|
|
||||||
connection = "YYY"
|
|
||||||
developerConnection = "ZZZ"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mavenPublishing {
|
||||||
|
// publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
|
||||||
//
|
//
|
||||||
//val projectVersion by project.extra(provider {
|
// signAllPublications()
|
||||||
// // Compute value lazily
|
|
||||||
// (version as String)
|
|
||||||
//})
|
|
||||||
//
|
//
|
||||||
//val generateBuildConfig by tasks.registering {
|
// coordinates(group.toString(), "library", version.toString())
|
||||||
// // Declare outputs safely
|
|
||||||
// val outputDir = layout.buildDirectory.dir("generated/buildConfig/commonMain/kotlin")
|
|
||||||
// outputs.dir(outputDir)
|
|
||||||
//
|
//
|
||||||
// val version = projectVersion.get()
|
// pom {
|
||||||
//
|
// name = "Lyng language"
|
||||||
// // Inputs: Version is tracked as an input
|
// description = "Kotlin-bound scripting loanguage"
|
||||||
// inputs.property("version", version)
|
// inceptionYear = "2025"
|
||||||
//
|
//// url = "https://sergeych.net"
|
||||||
// doLast {
|
// licenses {
|
||||||
// val packageName = "net.sergeych.lyng.buildconfig"
|
// license {
|
||||||
// val packagePath = packageName.replace('.', '/')
|
// name = "XXX"
|
||||||
// val buildConfigFile = outputDir.get().file("$packagePath/BuildConfig.kt").asFile
|
// url = "YYY"
|
||||||
//
|
// distribution = "ZZZ"
|
||||||
// buildConfigFile.parentFile?.mkdirs()
|
// }
|
||||||
// buildConfigFile.writeText(
|
// }
|
||||||
// """
|
// developers {
|
||||||
// |package $packageName
|
// developer {
|
||||||
// |
|
// id = "XXX"
|
||||||
// |object BuildConfig {
|
// name = "YYY"
|
||||||
// | const val VERSION = "$version"
|
// url = "ZZZ"
|
||||||
// |}
|
// }
|
||||||
// """.trimMargin()
|
// }
|
||||||
// )
|
// scm {
|
||||||
|
// url = "XXX"
|
||||||
|
// connection = "YYY"
|
||||||
|
// developerConnection = "ZZZ"
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
|
||||||
//tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
|
||||||
// dependsOn(generateBuildConfig)
|
|
||||||
//}
|
|
@ -96,6 +96,7 @@ internal class CompilerContext(val tokens: List<Token>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun addBreak() {
|
inline fun addBreak() {
|
||||||
breakFound = true
|
breakFound = true
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ data class Pos(val source: Source, val line: Int, val column: Int) {
|
|||||||
return "${source.fileName}:${line+1}:${column}"
|
return "${source.fileName}:${line+1}:${column}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
fun back(): Pos =
|
fun back(): Pos =
|
||||||
if( column > 0) Pos(source, line, column-1)
|
if( column > 0) Pos(source, line, column-1)
|
||||||
else if( line > 0) Pos(source, line-1, source.lines[line-1].length - 1)
|
else if( line > 0) Pos(source, line-1, source.lines[line-1].length - 1)
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.sergeych.lyng
|
||||||
|
|
||||||
|
// this is highly experimental and subject to complete redesign
|
||||||
|
// very soon
|
||||||
|
sealed class TypeDecl {
|
||||||
|
// ??
|
||||||
|
// data class Fn(val argTypes: List<ArgsDeclaration.Item>, val retType: TypeDecl) : TypeDecl()
|
||||||
|
object Obj : TypeDecl()
|
||||||
|
}
|
@ -18,5 +18,5 @@ dependencyResolutionManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = "lyng"
|
rootProject.name = "lyng"
|
||||||
include(":library")
|
include(":lynglib")
|
||||||
include(":lyng")
|
include(":lyng")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user