blob: ef6fd5f67772a46f8158339075a4d9f659faec6b [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
Dan Willemsen3eec9c52018-10-04 23:21:40 +000042var Log = PathConfig{
43 Symlink: true,
44 Log: true,
45 Error: false,
46}
47
Dan Willemsen18490112018-05-25 16:30:04 -070048// The configuration used if the tool is not listed in the config below.
Dan Willemsen8125d2a2018-08-15 15:26:39 -070049// Currently this will create the symlink, but log and error when it's used. In
50// the future, I expect the symlink to be removed, and this will be equivalent
51// to Forbidden.
Dan Willemsen18490112018-05-25 16:30:04 -070052var Missing = PathConfig{
53 Symlink: true,
54 Log: true,
Dan Willemsen8125d2a2018-08-15 15:26:39 -070055 Error: true,
Dan Willemsen18490112018-05-25 16:30:04 -070056}
57
58func GetConfig(name string) PathConfig {
59 if config, ok := Configuration[name]; ok {
60 return config
61 }
62 return Missing
63}
64
65var Configuration = map[string]PathConfig{
66 "awk": Allowed,
67 "basename": Allowed,
68 "bash": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -070069 "bc": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070070 "bzip2": Allowed,
71 "cat": Allowed,
72 "chmod": Allowed,
73 "cmp": Allowed,
74 "comm": Allowed,
75 "cp": Allowed,
76 "cut": Allowed,
77 "date": Allowed,
78 "dd": Allowed,
79 "diff": Allowed,
80 "dirname": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -070081 "du": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070082 "echo": Allowed,
83 "egrep": Allowed,
84 "env": Allowed,
85 "expr": Allowed,
86 "find": Allowed,
Dan Willemsenb4d01442018-08-27 16:14:23 -070087 "fuser": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070088 "getconf": Allowed,
89 "getopt": Allowed,
90 "git": Allowed,
91 "grep": Allowed,
92 "gzip": Allowed,
93 "head": Allowed,
94 "hexdump": Allowed,
95 "hostname": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -070096 "id": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070097 "jar": Allowed,
98 "java": Allowed,
99 "javap": Allowed,
100 "ln": Allowed,
101 "ls": Allowed,
Dan Willemsen42740f22018-08-15 10:14:40 -0700102 "lsof": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700103 "m4": Allowed,
104 "make": Allowed,
105 "md5sum": Allowed,
106 "mkdir": Allowed,
107 "mktemp": Allowed,
108 "mv": Allowed,
Dan Willemsen2d31ace2018-08-30 16:51:42 -0700109 "od": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700110 "openssl": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700111 "paste": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700112 "patch": Allowed,
Dan Willemsen3eec9c52018-10-04 23:21:40 +0000113 "perl": Log,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700114 "pgrep": Allowed,
115 "pkill": Allowed,
Dan Willemsen42740f22018-08-15 10:14:40 -0700116 "ps": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700117 "pstree": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700118 "pwd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700119 "python": Allowed,
120 "python2.7": Allowed,
121 "python3": Allowed,
122 "readlink": Allowed,
123 "realpath": Allowed,
124 "rm": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700125 "rmdir": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700126 "rsync": Allowed,
127 "runalarm": Allowed,
128 "sed": Allowed,
129 "setsid": Allowed,
130 "sh": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700131 "sha1sum": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700132 "sha256sum": Allowed,
133 "sha512sum": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700134 "sleep": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700135 "sort": Allowed,
136 "stat": Allowed,
137 "sum": Allowed,
138 "tar": Allowed,
139 "tail": Allowed,
Dan Willemsen090ec582018-08-31 08:12:22 +0000140 "tee": Allowed,
Dan Willemsen7a08bc52018-08-28 00:18:02 -0700141 "todos": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700142 "touch": Allowed,
143 "tr": Allowed,
144 "true": Allowed,
145 "uname": Allowed,
146 "uniq": Allowed,
Dan Willemsen6fa18f42018-08-29 10:26:47 -0700147 "unix2dos": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700148 "unzip": Allowed,
149 "wc": Allowed,
150 "which": Allowed,
151 "whoami": Allowed,
152 "xargs": Allowed,
153 "xmllint": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700154 "xxd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700155 "xz": Allowed,
156 "zip": Allowed,
157 "zipinfo": Allowed,
158
159 // Host toolchain is removed. In-tree toolchain should be used instead.
160 // GCC also can't find cc1 with this implementation.
161 "ar": Forbidden,
162 "as": Forbidden,
163 "cc": Forbidden,
164 "clang": Forbidden,
165 "clang++": Forbidden,
166 "gcc": Forbidden,
167 "g++": Forbidden,
168 "ld": Forbidden,
169 "ld.bfd": Forbidden,
170 "ld.gold": Forbidden,
171 "pkg-config": Forbidden,
172
173 // We've got prebuilts of these
174 //"dtc": Forbidden,
175 //"lz4": Forbidden,
176 //"lz4c": Forbidden,
177}
178
179func init() {
180 if runtime.GOOS == "darwin" {
181 Configuration["md5"] = Allowed
182 Configuration["sw_vers"] = Allowed
183 Configuration["xcrun"] = Allowed
184 }
185}