Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 1 | // Copyright 2019 The Android Open Source Project |
| 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 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | _ "android/soong/cc/config" |
| 20 | ) |
| 21 | |
| 22 | var pctx = android.NewPackageContext("android/soong/rust/config") |
| 23 | |
| 24 | var ( |
Matthew Maurer | 43f697e | 2019-09-09 16:17:33 -0700 | [diff] [blame] | 25 | RustDefaultVersion = "1.37.0" |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 26 | RustDefaultBase = "prebuilts/rust/" |
| 27 | DefaultEdition = "2018" |
| 28 | Stdlibs = []string{ |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 29 | "libstd", |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 30 | "libterm", |
Ivan Lozano | 6d9e712 | 2019-09-20 10:59:56 -0700 | [diff] [blame^] | 31 | "libtest", |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 32 | } |
| 33 | ) |
| 34 | |
| 35 | func init() { |
| 36 | pctx.SourcePathVariable("RustDefaultBase", RustDefaultBase) |
| 37 | pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS) |
| 38 | |
| 39 | pctx.VariableFunc("RustBase", func(ctx android.PackageVarContext) string { |
| 40 | if override := ctx.Config().Getenv("RUST_PREBUILTS_BASE"); override != "" { |
| 41 | return override |
| 42 | } |
| 43 | return "${RustDefaultBase}" |
| 44 | }) |
| 45 | |
| 46 | pctx.VariableFunc("RustVersion", func(ctx android.PackageVarContext) string { |
| 47 | if override := ctx.Config().Getenv("RUST_PREBUILTS_VERSION"); override != "" { |
| 48 | return override |
| 49 | } |
| 50 | return RustDefaultVersion |
| 51 | }) |
| 52 | |
| 53 | pctx.StaticVariable("RustPath", "${RustBase}/${HostPrebuiltTag}/${RustVersion}") |
| 54 | pctx.StaticVariable("RustBin", "${RustPath}/bin") |
| 55 | |
| 56 | pctx.ImportAs("ccConfig", "android/soong/cc/config") |
| 57 | pctx.StaticVariable("RustLinker", "${ccConfig.ClangBin}/clang++") |
| 58 | pctx.StaticVariable("RustLinkerArgs", "-B ${ccConfig.ClangBin} -fuse-ld=lld") |
| 59 | } |