blob: 4a5a2dd07db8738ea2db94ac8c2d942d33327dae [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 Cross3203dde2017-08-28 17:23:21 -070029 JavacHeapSize = "2048M"
30
Colin Cross3e3e72d2017-06-22 17:20:19 -070031 DefaultLibraries = []string{"core-oj", "core-libart", "ext", "framework", "okhttp"}
32)
33
Colin Cross64162712017-08-08 13:17:59 -070034func init() {
35 pctx.Import("github.com/google/blueprint/bootstrap")
36
Colin Cross3203dde2017-08-28 17:23:21 -070037 pctx.StaticVariable("JavacHeapFlags", "-J-Xmx"+JavacHeapSize)
38
Colin Cross64162712017-08-08 13:17:59 -070039 pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{
Colin Cross64162712017-08-08 13:17:59 -070040 `-Xmaxerrs 9999999`,
41 `-encoding UTF-8`,
42 `-sourcepath ""`,
43 `-g`,
44 }, " "))
45
46 pctx.StaticVariable("DefaultJavaVersion", "1.8")
47
48 pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS)
49
50 pctx.SourcePathVariableWithEnvOverride("JavaHome",
51 "prebuilts/jdk/jdk8/${hostPrebuiltTag}", "OVERRIDE_ANDROID_JAVA_HOME")
52 pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin")
53 pctx.SourcePathVariableWithEnvOverride("JavacCmd",
54 "${JavaToolchain}/javac", "ALTERNATE_JAVAC")
55 pctx.SourcePathVariable("JavaCmd", "${JavaToolchain}/java")
56 pctx.SourcePathVariable("JarCmd", "${JavaToolchain}/jar")
57 pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc")
Tobias Thierer77d0b412017-08-31 16:08:39 +010058 pctx.SourcePathVariable("JlinkCmd", "${JavaToolchain}/jlink")
59 pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod")
Colin Cross64162712017-08-08 13:17:59 -070060
Colin Crossb852a582017-08-10 17:58:12 -070061 pctx.StaticVariable("Zip2ZipCmd", filepath.Join("${bootstrap.ToolDir}", "zip2zip"))
62 pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
Colin Cross64162712017-08-08 13:17:59 -070063 pctx.HostBinToolVariable("DxCmd", "dx")
64 pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar")
65
66 pctx.VariableFunc("JavacWrapper", func(config interface{}) (string, error) {
67 if override := config.(android.Config).Getenv("JAVAC_WRAPPER"); override != "" {
68 return override + " ", nil
69 }
70 return "", nil
71 })
72}