blob: 903a424dae3319c19e13032512dc1e5413fa9f89 [file] [log] [blame]
Ivan Lozanoffee3342019-08-27 12:03:00 -07001// 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
15package config
16
17import (
18 "android/soong/android"
19 _ "android/soong/cc/config"
20)
21
22var pctx = android.NewPackageContext("android/soong/rust/config")
23
24var (
Matthew Maurer43f697e2019-09-09 16:17:33 -070025 RustDefaultVersion = "1.37.0"
Ivan Lozanoffee3342019-08-27 12:03:00 -070026 RustDefaultBase = "prebuilts/rust/"
27 DefaultEdition = "2018"
28 Stdlibs = []string{
Ivan Lozanoffee3342019-08-27 12:03:00 -070029 "libstd",
Ivan Lozanoffee3342019-08-27 12:03:00 -070030 "libterm",
Ivan Lozano6d9e7122019-09-20 10:59:56 -070031 "libtest",
Ivan Lozanoffee3342019-08-27 12:03:00 -070032 }
33)
34
35func 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}