blob: 548b038581ea01896c776df650af35d9c849f28f [file] [log] [blame]
Dan Willemsen18490112018-05-25 16:30:04 -07001// Copyright 2018 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
15package paths
16
17import "runtime"
18
19type PathConfig struct {
20 // Whether to create the symlink in the new PATH for this tool.
21 Symlink bool
22
23 // Whether to log about usages of this tool to the soong.log
24 Log bool
25
26 // Whether to exit with an error instead of invoking the underlying tool.
27 Error bool
28}
29
30var Allowed = PathConfig{
31 Symlink: true,
32 Log: false,
33 Error: false,
34}
35
36var Forbidden = PathConfig{
37 Symlink: false,
38 Log: true,
39 Error: true,
40}
41
42// The configuration used if the tool is not listed in the config below.
43// Currently this will create the symlink, but log a warning. In the future,
44// I expect this to move closer to Forbidden.
45var Missing = PathConfig{
46 Symlink: true,
47 Log: true,
48 Error: false,
49}
50
51func GetConfig(name string) PathConfig {
52 if config, ok := Configuration[name]; ok {
53 return config
54 }
55 return Missing
56}
57
58var Configuration = map[string]PathConfig{
59 "awk": Allowed,
60 "basename": Allowed,
61 "bash": Allowed,
62 "bzip2": Allowed,
63 "cat": Allowed,
64 "chmod": Allowed,
65 "cmp": Allowed,
66 "comm": Allowed,
67 "cp": Allowed,
68 "cut": Allowed,
69 "date": Allowed,
70 "dd": Allowed,
71 "diff": Allowed,
72 "dirname": Allowed,
73 "echo": Allowed,
74 "egrep": Allowed,
75 "env": Allowed,
76 "expr": Allowed,
77 "find": Allowed,
78 "getconf": Allowed,
79 "getopt": Allowed,
80 "git": Allowed,
81 "grep": Allowed,
82 "gzip": Allowed,
83 "head": Allowed,
84 "hexdump": Allowed,
85 "hostname": Allowed,
86 "jar": Allowed,
87 "java": Allowed,
88 "javap": Allowed,
89 "ln": Allowed,
90 "ls": Allowed,
91 "m4": Allowed,
92 "make": Allowed,
93 "md5sum": Allowed,
94 "mkdir": Allowed,
95 "mktemp": Allowed,
96 "mv": Allowed,
97 "openssl": Allowed,
98 "patch": Allowed,
99 "perl": Allowed,
100 "pstree": Allowed,
101 "python": Allowed,
102 "python2.7": Allowed,
103 "python3": Allowed,
104 "readlink": Allowed,
105 "realpath": Allowed,
106 "rm": Allowed,
107 "rsync": Allowed,
108 "runalarm": Allowed,
109 "sed": Allowed,
110 "setsid": Allowed,
111 "sh": Allowed,
112 "sha256sum": Allowed,
113 "sha512sum": Allowed,
114 "sort": Allowed,
115 "stat": Allowed,
116 "sum": Allowed,
117 "tar": Allowed,
118 "tail": Allowed,
119 "touch": Allowed,
120 "tr": Allowed,
121 "true": Allowed,
122 "uname": Allowed,
123 "uniq": Allowed,
124 "unzip": Allowed,
125 "wc": Allowed,
126 "which": Allowed,
127 "whoami": Allowed,
128 "xargs": Allowed,
129 "xmllint": Allowed,
130 "xz": Allowed,
131 "zip": Allowed,
132 "zipinfo": Allowed,
133
134 // Host toolchain is removed. In-tree toolchain should be used instead.
135 // GCC also can't find cc1 with this implementation.
136 "ar": Forbidden,
137 "as": Forbidden,
138 "cc": Forbidden,
139 "clang": Forbidden,
140 "clang++": Forbidden,
141 "gcc": Forbidden,
142 "g++": Forbidden,
143 "ld": Forbidden,
144 "ld.bfd": Forbidden,
145 "ld.gold": Forbidden,
146 "pkg-config": Forbidden,
147
148 // We've got prebuilts of these
149 //"dtc": Forbidden,
150 //"lz4": Forbidden,
151 //"lz4c": Forbidden,
152}
153
154func init() {
155 if runtime.GOOS == "darwin" {
156 Configuration["md5"] = Allowed
157 Configuration["sw_vers"] = Allowed
158 Configuration["xcrun"] = Allowed
159 }
160}