-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apollo-ast] Turn into a mpp module and move jmh benchmark to an inte…
…gration test (#5072) * turn apollo-ast into a mpp module and move jmh benchmark to an integration test * stick with okio 3.2.0 until we bump our Kotlin requirements * Update libraries/apollo-ast/src/appleMain/kotlin/com/apollographql/apollo3/ast/antlr.apple.kt Co-authored-by: Benoit Lubek <[email protected]> * Update libraries/apollo-ast/src/jsMain/kotlin/com/apollographql/apollo3/ast/antlr.js.kt Co-authored-by: Benoit Lubek <[email protected]> * Update libraries/apollo-ast/src/linuxMain/kotlin/com/apollographql/apollo3/ast/antlr.linux.kt Co-authored-by: Benoit Lubek <[email protected]> --------- Co-authored-by: Benoit Lubek <[email protected]>
- Loading branch information
1 parent
6ef957f
commit 18963c3
Showing
88 changed files
with
750 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,68 @@ | ||
plugins { | ||
antlr | ||
id("org.jetbrains.kotlin.jvm") | ||
id("org.jetbrains.kotlin.multiplatform") | ||
id("apollo.library") | ||
id("org.jetbrains.kotlin.plugin.serialization") | ||
id("org.jetbrains.kotlinx.benchmark") | ||
} | ||
|
||
apolloLibrary { | ||
javaModuleName("com.apollographql.apollo3.ast") | ||
mpp {} | ||
} | ||
|
||
sourceSets.create("jmh") | ||
kotlin { | ||
jvm { | ||
withJava() | ||
} | ||
sourceSets { | ||
getByName("commonMain") { | ||
dependencies { | ||
api(golatac.lib("okio")) | ||
api(project(":apollo-annotations")) | ||
implementation(golatac.lib("kotlinx.serialization.json")) | ||
} | ||
} | ||
|
||
benchmark { | ||
targets { | ||
register("jmh") | ||
getByName("jsMain") { | ||
dependencies { | ||
implementation(golatac.lib("okio.nodefilesystem")) | ||
} | ||
} | ||
getByName("jvmMain") { | ||
dependencies { | ||
implementation(golatac.lib("antlr.runtime")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
antlr(golatac.lib("antlr")) | ||
implementation(golatac.lib("antlr.runtime")) | ||
api(okio()) | ||
api(project(":apollo-annotations")) | ||
|
||
implementation(golatac.lib("kotlinx.serialization.json")) | ||
|
||
testImplementation(golatac.lib("kotlin.test.junit")) | ||
|
||
add("jmhImplementation", golatac.lib("kotlinx.benchmark.runtime")) | ||
add("jmhImplementation", sourceSets.main.get().output + sourceSets.main.get().runtimeClasspath) | ||
} | ||
|
||
// Only expose the antlr runtime dependency | ||
// See https://github.com/gradle/gradle/issues/820#issuecomment-288838412 | ||
configurations[JavaPlugin.API_CONFIGURATION_NAME].let { apiConfiguration -> | ||
apiConfiguration.setExtendsFrom(apiConfiguration.extendsFrom.filter { it.name != "antlr" }) | ||
configurations["jvmMainApi"].apply { | ||
setExtendsFrom(extendsFrom.filter { it.name != "antlr" }) | ||
} | ||
|
||
/** | ||
* By default, antlr doesn't know about MPP, so we wire everything manually | ||
*/ | ||
kotlin.sourceSets.getByName("jvmMain").kotlin.srcDir(file("build/generated-src/antlr/main")) | ||
sourceSets.getByName("main").java.srcDir(file("build/generated-src/antlr/main")) | ||
|
||
// See https://github.com/gradle/gradle/issues/19555 | ||
tasks.named("compileKotlin") { | ||
tasks.named("compileKotlinJvm") { | ||
dependsOn("generateGrammarSource") | ||
} | ||
tasks.named("compileTestKotlin") { | ||
// See https://github.com/gradle/gradle/issues/19555 | ||
tasks.named("compileJava") { | ||
dependsOn("generateGrammarSource") | ||
} | ||
tasks.named("compileKotlinJvm") { | ||
dependsOn("generateTestGrammarSource") | ||
} | ||
tasks.named("compileJmhKotlin") { | ||
dependsOn("generateJmhGrammarSource") | ||
tasks.named("jvmSourcesJar") { | ||
dependsOn("generateGrammarSource") | ||
} |
31 changes: 31 additions & 0 deletions
31
libraries/apollo-ast/src/appleMain/kotlin/com/apollographql/apollo3/ast/antlr.apple.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.apollographql.apollo3.ast | ||
|
||
import okio.BufferedSource | ||
|
||
internal actual fun parseDocumentWithAntlr( | ||
source: BufferedSource, | ||
filePath: String?, | ||
): GQLResult<GQLDocument> { | ||
throw UnsupportedOperationException("Antlr parser implementation is for the JVM") | ||
} | ||
|
||
internal actual fun parseValueWithAntlr( | ||
source: BufferedSource, | ||
filePath: String?, | ||
): GQLResult<GQLValue> { | ||
throw UnsupportedOperationException("Antlr parser implementation is for the JVM") | ||
} | ||
|
||
internal actual fun parseTypeWithAntlr( | ||
source: BufferedSource, | ||
filePath: String?, | ||
): GQLResult<GQLType> { | ||
throw UnsupportedOperationException("Antlr parser implementation is for the JVM") | ||
} | ||
|
||
internal actual fun parseSelectionsWithAntlr( | ||
source: BufferedSource, | ||
filePath: String?, | ||
): GQLResult<List<GQLSelection>> { | ||
throw UnsupportedOperationException("Antlr parser implementation is for the JVM") | ||
} |
6 changes: 6 additions & 0 deletions
6
libraries/apollo-ast/src/appleMain/kotlin/com/apollographql/apollo3/ast/host.apple.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.apollographql.apollo3.ast | ||
|
||
import okio.FileSystem | ||
|
||
internal actual val HOST_FILESYSTEM: FileSystem | ||
get() = FileSystem.SYSTEM |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 4 additions & 7 deletions
11
.../com/apollographql/apollo3/ast/gqlnode.kt → .../com/apollographql/apollo3/ast/gqlnode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...hql/apollo3/ast/gqloperationdefinition.kt → ...hql/apollo3/ast/gqloperationdefinition.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.