blob: a87cbf286b75c8d4f74c500ca472afad221023ef [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,
103 "openssl": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700104 "paste": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700105 "patch": Allowed,
106 "perl": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700107 "pgrep": Allowed,
108 "pkill": Allowed,
Dan Willemsen42740f22018-08-15 10:14:40 -0700109 "ps": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700110 "pstree": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700111 "pwd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700112 "python": Allowed,
113 "python2.7": Allowed,
114 "python3": Allowed,
115 "readlink": Allowed,
116 "realpath": Allowed,
117 "rm": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700118 "rmdir": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700119 "rsync": Allowed,
120 "runalarm": Allowed,
121 "sed": Allowed,
122 "setsid": Allowed,
123 "sh": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700124 "sha1sum": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700125 "sha256sum": Allowed,
126 "sha512sum": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700127 "sleep": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700128 "sort": Allowed,
129 "stat": Allowed,
130 "sum": Allowed,
131 "tar": Allowed,
132 "tail": Allowed,
Dan Willemsen7a08bc52018-08-28 00:18:02 -0700133 "todos": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700134 "touch": Allowed,
135 "tr": Allowed,
136 "true": Allowed,
137 "uname": Allowed,
138 "uniq": Allowed,
Dan Willemsen6fa18f42018-08-29 10:26:47 -0700139 "unix2dos": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700140 "unzip": Allowed,
141 "wc": Allowed,
142 "which": Allowed,
143 "whoami": Allowed,
144 "xargs": Allowed,
145 "xmllint": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700146 "xxd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700147 "xz": Allowed,
148 "zip": Allowed,
149 "zipinfo": Allowed,
150
151 // Host toolchain is removed. In-tree toolchain should be used instead.
152 // GCC also can't find cc1 with this implementation.
153 "ar": Forbidden,
154 "as": Forbidden,
155 "cc": Forbidden,
156 "clang": Forbidden,
157 "clang++": Forbidden,
158 "gcc": Forbidden,
159 "g++": Forbidden,
160 "ld": Forbidden,
161 "ld.bfd": Forbidden,
162 "ld.gold": Forbidden,
163 "pkg-config": Forbidden,
164
165 // We've got prebuilts of these
166 //"dtc": Forbidden,
167 //"lz4": Forbidden,
168 //"lz4c": Forbidden,
169}
170
171func init() {
172 if runtime.GOOS == "darwin" {
173 Configuration["md5"] = Allowed
174 Configuration["sw_vers"] = Allowed
175 Configuration["xcrun"] = Allowed
176 }
177}