blob: ffb025d9cf43bbe81a7f987b21afa8542c347153 [file] [log] [blame]
Colin Cross93e85952017-08-15 13:34:18 -07001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package config
16
Colin Crossafbb1732019-01-17 15:42:52 -080017import "strings"
18
Colin Cross93e85952017-08-15 13:34:18 -070019var (
Zoran Jovanovic8736ce22018-08-21 17:10:29 +020020 KotlinStdlibJar = "external/kotlinc/lib/kotlin-stdlib.jar"
21 KotlincIllegalFlags = []string{
22 "-no-jdk",
23 "-no-stdlib",
Dave Mankoff1a7705d2025-01-08 03:06:21 +000024 "-language-version",
Zoran Jovanovic8736ce22018-08-21 17:10:29 +020025 }
Colin Cross93e85952017-08-15 13:34:18 -070026)
27
28func init() {
29 pctx.SourcePathVariable("KotlincCmd", "external/kotlinc/bin/kotlinc")
30 pctx.SourcePathVariable("KotlinCompilerJar", "external/kotlinc/lib/kotlin-compiler.jar")
Dan Willemsenaad19602019-04-07 09:44:35 -070031 pctx.SourcePathVariable("KotlinPreloaderJar", "external/kotlinc/lib/kotlin-preloader.jar")
32 pctx.SourcePathVariable("KotlinReflectJar", "external/kotlinc/lib/kotlin-reflect.jar")
33 pctx.SourcePathVariable("KotlinScriptRuntimeJar", "external/kotlinc/lib/kotlin-script-runtime.jar")
34 pctx.SourcePathVariable("KotlinTrove4jJar", "external/kotlinc/lib/trove4j.jar")
Colin Crossafbb1732019-01-17 15:42:52 -080035 pctx.SourcePathVariable("KotlinKaptJar", "external/kotlinc/lib/kotlin-annotation-processing.jar")
Dan Willemsen1cfbdbe2019-06-13 04:59:17 +000036 pctx.SourcePathVariable("KotlinAnnotationJar", "external/kotlinc/lib/annotations-13.0.jar")
Colin Cross93e85952017-08-15 13:34:18 -070037 pctx.SourcePathVariable("KotlinStdlibJar", KotlinStdlibJar)
Colin Cross220a9a12022-03-28 17:08:01 -070038 pctx.SourcePathVariable("KotlinAbiGenPluginJar", "external/kotlinc/lib/jvm-abi-gen.jar")
Colin Crossafbb1732019-01-17 15:42:52 -080039
Colin Crossd47f4ac2021-03-26 10:52:02 -070040 // These flags silence "Illegal reflective access" warnings when running kapt in OpenJDK9+
41 pctx.StaticVariable("KaptSuppressJDK9Warnings", strings.Join([]string{
Colin Crossafbb1732019-01-17 15:42:52 -080042 "-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
43 "-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
44 "-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
45 "-J--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED",
46 }, " "))
Colin Crossd47f4ac2021-03-26 10:52:02 -070047
48 // These flags silence "Illegal reflective access" warnings when running kotlinc in OpenJDK9+
49 pctx.StaticVariable("KotlincSuppressJDK9Warnings", strings.Join([]string{
50 "-J--add-opens=java.base/java.util=ALL-UNNAMED", // https://youtrack.jetbrains.com/issue/KT-43704
51 }, " "))
Colin Crossc2d50482022-03-17 12:01:27 -070052
Dave Mankoff1a7705d2025-01-08 03:06:21 +000053 pctx.StaticVariable("KotlincGlobalFlags", strings.Join([]string{}, " "))
Spandan Das3d6c6d92024-09-12 18:06:24 +000054 // Use KotlincKytheGlobalFlags to prevent kotlinc version skew issues between android and
55 // g3 kythe indexers.
56 // This is necessary because there might be instances of kotlin code in android
57 // platform that are not fully compatible with the kotlinc used in g3 kythe indexers.
58 // e.g. uninitialized variables are a warning in 1.*, but an error in 2.*
59 // https://github.com/JetBrains/kotlin/blob/master/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt#L748
Dave Mankoff1a7705d2025-01-08 03:06:21 +000060 pctx.StaticVariable("KotlincKytheGlobalFlags", strings.Join([]string{}, " "))
Colin Cross93e85952017-08-15 13:34:18 -070061}