blob: 7886466105c39e5086d07a209c325559df6fde56 [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.
Dan Willemsen8125d2a2018-08-15 15:26:39 -070043// Currently this will create the symlink, but log and error when it's used. In
44// the future, I expect the symlink to be removed, and this will be equivalent
45// to Forbidden.
Dan Willemsen18490112018-05-25 16:30:04 -070046var Missing = PathConfig{
47 Symlink: true,
48 Log: true,
Dan Willemsen8125d2a2018-08-15 15:26:39 -070049 Error: true,
Dan Willemsen18490112018-05-25 16:30:04 -070050}
51
52func GetConfig(name string) PathConfig {
53 if config, ok := Configuration[name]; ok {
54 return config
55 }
56 return Missing
57}
58
59var Configuration = map[string]PathConfig{
60 "awk": Allowed,
61 "basename": Allowed,
62 "bash": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -070063 "bc": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070064 "bzip2": Allowed,
65 "cat": Allowed,
66 "chmod": Allowed,
67 "cmp": Allowed,
68 "comm": Allowed,
69 "cp": Allowed,
70 "cut": Allowed,
71 "date": Allowed,
72 "dd": Allowed,
73 "diff": Allowed,
74 "dirname": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -070075 "du": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070076 "echo": Allowed,
77 "egrep": Allowed,
78 "env": Allowed,
79 "expr": Allowed,
80 "find": Allowed,
Dan Willemsenb4d01442018-08-27 16:14:23 -070081 "fuser": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070082 "getconf": Allowed,
83 "getopt": Allowed,
84 "git": Allowed,
85 "grep": Allowed,
86 "gzip": Allowed,
87 "head": Allowed,
88 "hexdump": Allowed,
89 "hostname": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -070090 "id": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070091 "jar": Allowed,
92 "java": Allowed,
93 "javap": Allowed,
94 "ln": Allowed,
95 "ls": Allowed,
Dan Willemsen42740f22018-08-15 10:14:40 -070096 "lsof": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070097 "m4": Allowed,
98 "make": Allowed,
99 "md5sum": Allowed,
100 "mkdir": Allowed,
101 "mktemp": Allowed,
102 "mv": Allowed,
Dan Willemsen2d31ace2018-08-30 16:51:42 -0700103 "od": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700104 "openssl": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700105 "paste": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700106 "patch": Allowed,
107 "perl": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700108 "pgrep": Allowed,
109 "pkill": Allowed,
Dan Willemsen42740f22018-08-15 10:14:40 -0700110 "ps": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700111 "pstree": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700112 "pwd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700113 "python": Allowed,
114 "python2.7": Allowed,
115 "python3": Allowed,
116 "readlink": Allowed,
117 "realpath": Allowed,
118 "rm": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700119 "rmdir": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700120 "rsync": Allowed,
121 "runalarm": Allowed,
122 "sed": Allowed,
123 "setsid": Allowed,
124 "sh": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700125 "sha1sum": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700126 "sha256sum": Allowed,
127 "sha512sum": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700128 "sleep": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700129 "sort": Allowed,
130 "stat": Allowed,
131 "sum": Allowed,
132 "tar": Allowed,
133 "tail": Allowed,
Dan Willemsen090ec582018-08-31 08:12:22 +0000134 "tee": Allowed,
Dan Willemsen7a08bc52018-08-28 00:18:02 -0700135 "todos": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700136 "touch": Allowed,
137 "tr": Allowed,
138 "true": Allowed,
139 "uname": Allowed,
140 "uniq": Allowed,
Dan Willemsen6fa18f42018-08-29 10:26:47 -0700141 "unix2dos": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700142 "unzip": Allowed,
143 "wc": Allowed,
144 "which": Allowed,
145 "whoami": Allowed,
146 "xargs": Allowed,
147 "xmllint": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700148 "xxd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700149 "xz": Allowed,
150 "zip": Allowed,
151 "zipinfo": Allowed,
152
153 // Host toolchain is removed. In-tree toolchain should be used instead.
154 // GCC also can't find cc1 with this implementation.
155 "ar": Forbidden,
156 "as": Forbidden,
157 "cc": Forbidden,
158 "clang": Forbidden,
159 "clang++": Forbidden,
160 "gcc": Forbidden,
161 "g++": Forbidden,
162 "ld": Forbidden,
163 "ld.bfd": Forbidden,
164 "ld.gold": Forbidden,
165 "pkg-config": Forbidden,
166
167 // We've got prebuilts of these
168 //"dtc": Forbidden,
169 //"lz4": Forbidden,
170 //"lz4c": Forbidden,
171}
172
173func init() {
174 if runtime.GOOS == "darwin" {
175 Configuration["md5"] = Allowed
176 Configuration["sw_vers"] = Allowed
177 Configuration["xcrun"] = Allowed
178 }
179}