blob: 2e08a8cf3cecce842fc68cc95f1d82c091661f9f [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 (
25 RustDefaultVersion = "1.35.0"
26 RustDefaultBase = "prebuilts/rust/"
27 DefaultEdition = "2018"
28 Stdlibs = []string{
29 "libarena",
30 "libfmt_macros",
31 "libgraphviz",
32 "libserialize",
33 "libstd",
34 "libsyntax",
35 "libsyntax_ext",
36 "libsyntax_pos",
37 "libterm",
38 }
39)
40
41func init() {
42 pctx.SourcePathVariable("RustDefaultBase", RustDefaultBase)
43 pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
44
45 pctx.VariableFunc("RustBase", func(ctx android.PackageVarContext) string {
46 if override := ctx.Config().Getenv("RUST_PREBUILTS_BASE"); override != "" {
47 return override
48 }
49 return "${RustDefaultBase}"
50 })
51
52 pctx.VariableFunc("RustVersion", func(ctx android.PackageVarContext) string {
53 if override := ctx.Config().Getenv("RUST_PREBUILTS_VERSION"); override != "" {
54 return override
55 }
56 return RustDefaultVersion
57 })
58
59 pctx.StaticVariable("RustPath", "${RustBase}/${HostPrebuiltTag}/${RustVersion}")
60 pctx.StaticVariable("RustBin", "${RustPath}/bin")
61
62 pctx.ImportAs("ccConfig", "android/soong/cc/config")
63 pctx.StaticVariable("RustLinker", "${ccConfig.ClangBin}/clang++")
64 pctx.StaticVariable("RustLinkerArgs", "-B ${ccConfig.ClangBin} -fuse-ld=lld")
65}