blob: 7d1fa29bfb76153c7a66c36eb6cf55f81bdfc0a7 [file] [log] [blame]
Colin Cross3e3e72d2017-06-22 17:20:19 -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 Cross64162712017-08-08 13:17:59 -070017import (
18 "path/filepath"
19 "strings"
20
21 _ "github.com/google/blueprint/bootstrap"
22
23 "android/soong/android"
24)
Colin Cross3e3e72d2017-06-22 17:20:19 -070025
26var (
Colin Cross64162712017-08-08 13:17:59 -070027 pctx = android.NewPackageContext("android/soong/java/config")
28
Colin Crosscb2c9292017-09-23 19:57:16 -070029 DefaultBootclasspathLibraries = []string{"core-oj", "core-libart"}
Colin Cross1369cdb2017-09-29 17:58:17 -070030 DefaultSystemModules = "core-system-modules"
Colin Crosscb2c9292017-09-23 19:57:16 -070031 DefaultLibraries = []string{"ext", "framework", "okhttp"}
Colin Cross3e3e72d2017-06-22 17:20:19 -070032)
33
Colin Cross64162712017-08-08 13:17:59 -070034func init() {
35 pctx.Import("github.com/google/blueprint/bootstrap")
36
Colin Crossfee57cb2017-09-05 13:16:45 -070037 pctx.StaticVariable("JavacHeapSize", "2048M")
38 pctx.StaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}")
Colin Cross3203dde2017-08-28 17:23:21 -070039
Colin Cross64162712017-08-08 13:17:59 -070040 pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{
Colin Cross64162712017-08-08 13:17:59 -070041 `-Xmaxerrs 9999999`,
42 `-encoding UTF-8`,
43 `-sourcepath ""`,
44 `-g`,
Colin Cross945c0002017-09-19 10:52:23 -070045 // Turbine leaves out bridges which can cause javac to unnecessarily insert them into
46 // subclasses (b/65645120). Setting this flag causes our custom javac to assume that
47 // the missing bridges will exist at runtime and not recreate them in subclasses.
48 // If a different javac is used the flag will be ignored and extra bridges will be inserted.
49 // The flag is implemented by https://android-review.googlesource.com/c/486427
50 `-XDskipDuplicateBridges=true`,
Colin Cross64162712017-08-08 13:17:59 -070051
Colin Cross1369cdb2017-09-29 17:58:17 -070052 // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9
53 `-XDstringConcat=inline`,
54 }, " "))
Colin Cross64162712017-08-08 13:17:59 -070055
56 pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS)
57
Colin Crosse2ad2302017-10-05 16:48:56 -070058 pctx.VariableFunc("JavaHome", func(config interface{}) (string, error) {
59 if override := config.(android.Config).Getenv("OVERRIDE_ANDROID_JAVA_HOME"); override != "" {
60 return override, nil
61 }
Colin Cross1369cdb2017-09-29 17:58:17 -070062 if config.(android.Config).UseOpenJDK9() {
Colin Crosse2ad2302017-10-05 16:48:56 -070063 return "prebuilts/jdk/jdk9/${hostPrebuiltTag}", nil
64 }
65 return "prebuilts/jdk/jdk8/${hostPrebuiltTag}", nil
66 })
67
Colin Cross64162712017-08-08 13:17:59 -070068 pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin")
69 pctx.SourcePathVariableWithEnvOverride("JavacCmd",
70 "${JavaToolchain}/javac", "ALTERNATE_JAVAC")
71 pctx.SourcePathVariable("JavaCmd", "${JavaToolchain}/java")
72 pctx.SourcePathVariable("JarCmd", "${JavaToolchain}/jar")
73 pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc")
Tobias Thierer77d0b412017-08-31 16:08:39 +010074 pctx.SourcePathVariable("JlinkCmd", "${JavaToolchain}/jlink")
75 pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod")
Colin Cross1369cdb2017-09-29 17:58:17 -070076 pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar")
Colin Cross64162712017-08-08 13:17:59 -070077
Colin Crossb852a582017-08-10 17:58:12 -070078 pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
Colin Cross0a6e0072017-08-30 14:24:55 -070079 pctx.StaticVariable("SoongZipCmd", filepath.Join("${bootstrap.ToolDir}", "soong_zip"))
80 pctx.StaticVariable("MergeZipsCmd", filepath.Join("${bootstrap.ToolDir}", "merge_zips"))
Colin Cross64162712017-08-08 13:17:59 -070081 pctx.HostBinToolVariable("DxCmd", "dx")
82 pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar")
Colin Cross6ade34f2017-09-15 13:00:47 -070083 pctx.HostJavaToolVariable("DesugarJar", "desugar.jar")
Colin Cross64162712017-08-08 13:17:59 -070084
85 pctx.VariableFunc("JavacWrapper", func(config interface{}) (string, error) {
86 if override := config.(android.Config).Getenv("JAVAC_WRAPPER"); override != "" {
87 return override + " ", nil
88 }
89 return "", nil
90 })
91}