Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package config |
| 16 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 17 | import ( |
| 18 | "path/filepath" |
| 19 | "strings" |
| 20 | |
| 21 | _ "github.com/google/blueprint/bootstrap" |
| 22 | |
| 23 | "android/soong/android" |
| 24 | ) |
Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 25 | |
| 26 | var ( |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 27 | pctx = android.NewPackageContext("android/soong/java/config") |
| 28 | |
Colin Cross | 3203dde | 2017-08-28 17:23:21 -0700 | [diff] [blame^] | 29 | JavacHeapSize = "2048M" |
| 30 | |
Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 31 | DefaultLibraries = []string{"core-oj", "core-libart", "ext", "framework", "okhttp"} |
| 32 | ) |
| 33 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 34 | func init() { |
| 35 | pctx.Import("github.com/google/blueprint/bootstrap") |
| 36 | |
Colin Cross | 3203dde | 2017-08-28 17:23:21 -0700 | [diff] [blame^] | 37 | pctx.StaticVariable("JavacHeapFlags", "-J-Xmx"+JavacHeapSize) |
| 38 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 39 | pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{ |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 40 | `-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") |
| 58 | |
Colin Cross | b852a58 | 2017-08-10 17:58:12 -0700 | [diff] [blame] | 59 | pctx.StaticVariable("Zip2ZipCmd", filepath.Join("${bootstrap.ToolDir}", "zip2zip")) |
| 60 | pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh") |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 61 | pctx.HostBinToolVariable("DxCmd", "dx") |
| 62 | pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar") |
| 63 | |
| 64 | pctx.VariableFunc("JavacWrapper", func(config interface{}) (string, error) { |
| 65 | if override := config.(android.Config).Getenv("JAVAC_WRAPPER"); override != "" { |
| 66 | return override + " ", nil |
| 67 | } |
| 68 | return "", nil |
| 69 | }) |
| 70 | } |