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 | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 29 | DefaultLibraries = []string{"core-oj", "core-libart", "ext", "framework", "okhttp"} |
| 30 | ) |
| 31 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 32 | func init() { |
| 33 | pctx.Import("github.com/google/blueprint/bootstrap") |
| 34 | |
| 35 | pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{ |
| 36 | `-J-Xmx2048M`, |
| 37 | `-Xmaxerrs 9999999`, |
| 38 | `-encoding UTF-8`, |
| 39 | `-sourcepath ""`, |
| 40 | `-g`, |
| 41 | }, " ")) |
| 42 | |
| 43 | pctx.StaticVariable("DefaultJavaVersion", "1.8") |
| 44 | |
| 45 | pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS) |
| 46 | |
| 47 | pctx.SourcePathVariableWithEnvOverride("JavaHome", |
| 48 | "prebuilts/jdk/jdk8/${hostPrebuiltTag}", "OVERRIDE_ANDROID_JAVA_HOME") |
| 49 | pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin") |
| 50 | pctx.SourcePathVariableWithEnvOverride("JavacCmd", |
| 51 | "${JavaToolchain}/javac", "ALTERNATE_JAVAC") |
| 52 | pctx.SourcePathVariable("JavaCmd", "${JavaToolchain}/java") |
| 53 | pctx.SourcePathVariable("JarCmd", "${JavaToolchain}/jar") |
| 54 | pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc") |
| 55 | |
| 56 | pctx.StaticVariable("SoongZipCmd", filepath.Join("${bootstrap.ToolDir}", "soong_zip")) |
| 57 | pctx.HostBinToolVariable("DxCmd", "dx") |
| 58 | pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar") |
| 59 | |
| 60 | pctx.VariableFunc("JavacWrapper", func(config interface{}) (string, error) { |
| 61 | if override := config.(android.Config).Getenv("JAVAC_WRAPPER"); override != "" { |
| 62 | return override + " ", nil |
| 63 | } |
| 64 | return "", nil |
| 65 | }) |
| 66 | } |