Skip to content

Commit 5b7f0e2

Browse files
committed
gRPC
1 parent 4ff7243 commit 5b7f0e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4216
-286
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
cache-read-only: ${{ github.ref != 'refs/heads/develop' && github.ref != 'ref/heads/neo' }}
3939

4040
- name: Build and run tests
41-
run: ./gradlew --scan build -x :jacodb-ets:build
41+
run: ./gradlew --scan build
4242

4343
- name: Upload coverage reports to Codecov
4444
uses: codecov/codecov-action@v3
@@ -122,11 +122,11 @@ jobs:
122122

123123
- name: Set up ArkAnalyzer
124124
run: |
125-
REPO_URL="https://gitcode.com/Lipen/arkanalyzer"
125+
REPO_URL="https://gitcode.com/Lipen/arkanalyzer.git"
126126
DEST_DIR="arkanalyzer"
127127
MAX_RETRIES=10
128-
RETRY_DELAY=3 # Delay between retries in seconds
129-
BRANCH="neo/2025-06-16"
128+
RETRY_DELAY=3 # Delay between retries in seconds
129+
BRANCH="neo/2025-06-20"
130130
131131
for ((i=1; i<=MAX_RETRIES; i++)); do
132132
git clone --depth=1 --branch $BRANCH $REPO_URL $DEST_DIR && break
@@ -147,6 +147,9 @@ jobs:
147147
npm install
148148
npm run build
149149
150+
- name: Enable ETS modules
151+
run: echo "enableEts=true" >> local.properties
152+
150153
- name: Run ETS tests
151154
run: ./gradlew --scan :jacodb-ets:generateTestResources :jacodb-ets:test
152155

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.idea/
22
.gradle/
3-
build/
43
.kotlin/
4+
build/
5+
generated/
56
idea-community
67
*.db
7-
/generated/
8+
/local.properties

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ allprojects {
147147
license {
148148
include("**/*.kt")
149149
include("**/*.java")
150+
exclude { it.file.startsWith(layout.buildDirectory.asFile.get()) }
150151
header(rootProject.file("docs/copyright/COPYRIGHT_HEADER.txt"))
151152
}
152153
}
@@ -173,7 +174,6 @@ if (!repoUrl.isNullOrEmpty()) {
173174
project(":jacodb-storage"),
174175
project(":jacodb-approximations"),
175176
project(":jacodb-taint-configuration"),
176-
project(":jacodb-ets"),
177177
)
178178
) {
179179
tasks {

buildSrc/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ plugins {
55
repositories {
66
mavenCentral()
77
}
8+
9+
dependencies {
10+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
11+
}

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ object Versions {
66
const val asm = "9.7.1"
77
const val dokka = "1.9.20" // note: must be compatible with kotlin version
88
const val gradle_download = "5.3.0"
9+
const val gradle_node = "7.1.0"
910
const val gradle_versions = "0.47.0"
10-
11-
// hikaricp version compatible with Java 8
12-
const val hikaricp = "4.0.3"
13-
11+
const val grpc = "1.72.0"
12+
const val grpc_kotlin = "1.4.3"
1413
const val guava = "31.1-jre"
14+
const val hikaricp = "4.0.3" // compatible with Java 8
1515
const val javax_activation = "1.1"
1616
const val javax_mail = "1.4.7"
1717
const val javax_servlet_api = "2.5"
@@ -24,23 +24,26 @@ object Versions {
2424
const val junit = "5.9.2"
2525
const val kotlin = "2.1.0"
2626
const val kotlin_logging = "1.8.3"
27+
const val kotlin_metadata = kotlin
2728
const val kotlinx_benchmark = "0.4.6"
2829
const val kotlinx_cli = "0.3.5"
2930
const val kotlinx_collections_immutable = "0.3.5"
3031
const val kotlinx_coroutines = "1.6.4"
31-
const val kotlin_metadata = kotlin
3232
const val kotlinx_serialization = "1.8.0"
3333
const val licenser = "0.6.1"
34+
const val lmdb_java = "0.9.0"
3435
const val mockk = "1.13.3"
36+
const val protobuf = "4.30.2"
37+
const val rocks_db = "9.1.1"
3538
const val sarif4k = "0.5.0"
3639
const val shadow = "8.1.1"
37-
const val slf4j = "1.7.36"
40+
const val slf4j = "2.0.17"
3841
const val soot_utbot_fork = "4.4.0-FORK-2"
3942
const val sootup = "1.0.0"
4043
const val sqlite = "3.41.2.2"
4144
const val xodus = "2.0.1"
42-
const val rocks_db = "9.1.1"
43-
const val lmdb_java = "0.9.0"
45+
const val wire = "5.3.1"
46+
const val wire_grpc_server = "1.0.0-alpha04"
4447

4548
// libs for tests only
4649
const val jgit_test_only_version = "5.9.0.202009080501-r"
@@ -144,11 +147,6 @@ object Libs {
144147
)
145148

146149
// https://github.com/Kotlin/kotlinx.serialization
147-
val kotlinx_serialization_core = dep(
148-
group = "org.jetbrains.kotlinx",
149-
name = "kotlinx-serialization-core",
150-
version = Versions.kotlinx_serialization
151-
)
152150
val kotlinx_serialization_json = dep(
153151
group = "org.jetbrains.kotlinx",
154152
name = "kotlinx-serialization-json",
@@ -339,6 +337,52 @@ object Libs {
339337
name = "commons-compress",
340338
version = Versions.commons_compress_test_only_version
341339
)
340+
341+
// https://github.com/grpc/grpc-java
342+
val grpc_api = dep(
343+
group = "io.grpc",
344+
name = "grpc-api",
345+
version = Versions.grpc
346+
)
347+
val grpc_protobuf = dep(
348+
group = "io.grpc",
349+
name = "grpc-protobuf",
350+
version = Versions.grpc
351+
)
352+
val grpc_services = dep(
353+
group = "io.grpc",
354+
name = "grpc-services",
355+
version = Versions.grpc
356+
)
357+
val grpc_netty_shaded = dep(
358+
group = "io.grpc",
359+
name = "grpc-netty-shaded",
360+
version = Versions.grpc
361+
)
362+
363+
// https://github.com/square/wire
364+
val wire_runtime = dep(
365+
group = "com.squareup.wire",
366+
name = "wire-runtime",
367+
version = Versions.wire
368+
)
369+
val wire_grpc_client = dep(
370+
group = "com.squareup.wire",
371+
name = "wire-grpc-client",
372+
version = Versions.wire
373+
)
374+
375+
// https://github.com/square/wire-grpc-server
376+
val wire_grpc_server = dep(
377+
group = "com.squareup.wiregrpcserver",
378+
name = "server",
379+
version = Versions.wire_grpc_server
380+
)
381+
val wire_grpc_server_generator = dep(
382+
group = "com.squareup.wiregrpcserver",
383+
name = "server-generator",
384+
version = Versions.wire_grpc_server
385+
)
342386
}
343387

344388
object Plugins {
@@ -357,6 +401,12 @@ object Plugins {
357401
id = "de.undercouch.download"
358402
)
359403

404+
// https://github.com/node-gradle/gradle-node-plugin
405+
object GradleNode : ProjectPlugin(
406+
version = Versions.gradle_node,
407+
id = "com.github.node-gradle.node"
408+
)
409+
360410
// https://github.com/ben-manes/gradle-versions-plugin
361411
object GradleVersions : ProjectPlugin(
362412
version = Versions.gradle_versions,
@@ -380,6 +430,12 @@ object Plugins {
380430
version = Versions.shadow,
381431
id = "com.github.johnrengelman.shadow"
382432
)
433+
434+
// https://github.com/square/wire
435+
object Wire : ProjectPlugin(
436+
version = Versions.wire,
437+
id = "com.squareup.wire"
438+
)
383439
}
384440

385441
fun PluginDependenciesSpec.id(plugin: Plugins.ProjectPlugin) {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import kotlinx.coroutines.CoroutineScope
2+
import kotlinx.coroutines.Dispatchers
3+
import kotlinx.coroutines.joinAll
4+
import kotlinx.coroutines.launch
5+
import kotlinx.coroutines.runBlocking
6+
import java.io.Reader
7+
import java.util.concurrent.TimeUnit
8+
import kotlin.time.Duration
9+
10+
object ProcessUtil {
11+
data class Result(
12+
val exitCode: Int,
13+
val stdout: String,
14+
val stderr: String,
15+
val isTimeout: Boolean, // true if the process was terminated due to timeout
16+
)
17+
18+
fun run(
19+
command: List<String>,
20+
input: Reader = "".reader(),
21+
timeout: Duration? = null,
22+
builder: ProcessBuilder.() -> Unit = {},
23+
): Result {
24+
val process = ProcessBuilder(command).apply(builder).start()
25+
return communicate(process, input, timeout)
26+
}
27+
28+
private fun communicate(
29+
process: Process,
30+
input: Reader,
31+
timeout: Duration? = null,
32+
): Result {
33+
val stdout = StringBuilder()
34+
val stderr = StringBuilder()
35+
36+
val scope = CoroutineScope(Dispatchers.IO)
37+
38+
// Handle process input
39+
val stdinJob = scope.launch {
40+
process.outputStream.bufferedWriter().use { writer ->
41+
input.copyTo(writer)
42+
}
43+
}
44+
45+
// Launch output capture coroutines
46+
val stdoutJob = scope.launch {
47+
process.inputStream.bufferedReader().useLines { lines ->
48+
lines.forEach { stdout.appendLine(it) }
49+
}
50+
}
51+
val stderrJob = scope.launch {
52+
process.errorStream.bufferedReader().useLines { lines ->
53+
lines.forEach { stderr.appendLine(it) }
54+
}
55+
}
56+
57+
// Wait for completion
58+
val isTimeout = if (timeout != null) {
59+
!process.waitFor(timeout.inWholeNanoseconds, TimeUnit.NANOSECONDS)
60+
} else {
61+
process.waitFor()
62+
false
63+
}
64+
65+
// Wait for all coroutines to finish
66+
runBlocking {
67+
joinAll(stdinJob, stdoutJob, stderrJob)
68+
}
69+
70+
return Result(
71+
exitCode = process.exitValue(),
72+
stdout = stdout.toString(),
73+
stderr = stderr.toString(),
74+
isTimeout = isTimeout,
75+
)
76+
}
77+
}

jacodb-ets/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
arkanalyzer
12
/src/test/resources/samples/etsir
23
/src/test/resources/projects
34

0 commit comments

Comments
 (0)