blob: aeefcf2cb104e51686d115fa6a36cd30aface6a7 [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,
Dan Willemsen16dbb392018-06-06 11:02:42 -070062 "bc": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070063 "bzip2": Allowed,
64 "cat": Allowed,
65 "chmod": Allowed,
66 "cmp": Allowed,
67 "comm": Allowed,
68 "cp": Allowed,
69 "cut": Allowed,
70 "date": Allowed,
71 "dd": Allowed,
72 "diff": Allowed,
73 "dirname": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -070074 "du": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070075 "echo": Allowed,
76 "egrep": Allowed,
77 "env": Allowed,
78 "expr": Allowed,
79 "find": Allowed,
80 "getconf": Allowed,
81 "getopt": Allowed,
82 "git": Allowed,
83 "grep": Allowed,
84 "gzip": Allowed,
85 "head": Allowed,
86 "hexdump": Allowed,
87 "hostname": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -070088 "id": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070089 "jar": Allowed,
90 "java": Allowed,
91 "javap": Allowed,
92 "ln": Allowed,
93 "ls": Allowed,
Dan Willemsen42740f22018-08-15 10:14:40 -070094 "lsof": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070095 "m4": Allowed,
96 "make": Allowed,
97 "md5sum": Allowed,
98 "mkdir": Allowed,
99 "mktemp": Allowed,
100 "mv": Allowed,
101 "openssl": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700102 "paste": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700103 "patch": Allowed,
104 "perl": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700105 "pgrep": Allowed,
106 "pkill": Allowed,
Dan Willemsen42740f22018-08-15 10:14:40 -0700107 "ps": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700108 "pstree": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700109 "pwd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700110 "python": Allowed,
111 "python2.7": Allowed,
112 "python3": Allowed,
113 "readlink": Allowed,
114 "realpath": Allowed,
115 "rm": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700116 "rmdir": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700117 "rsync": Allowed,
118 "runalarm": Allowed,
119 "sed": Allowed,
120 "setsid": Allowed,
121 "sh": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700122 "sha1sum": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700123 "sha256sum": Allowed,
124 "sha512sum": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700125 "sleep": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700126 "sort": Allowed,
127 "stat": Allowed,
128 "sum": Allowed,
129 "tar": Allowed,
130 "tail": Allowed,
131 "touch": Allowed,
132 "tr": Allowed,
133 "true": Allowed,
134 "uname": Allowed,
135 "uniq": Allowed,
136 "unzip": Allowed,
137 "wc": Allowed,
138 "which": Allowed,
139 "whoami": Allowed,
140 "xargs": Allowed,
141 "xmllint": Allowed,
Dan Willemsen14eae192018-08-14 23:02:11 -0700142 "xxd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700143 "xz": Allowed,
144 "zip": Allowed,
145 "zipinfo": Allowed,
146
147 // Host toolchain is removed. In-tree toolchain should be used instead.
148 // GCC also can't find cc1 with this implementation.
149 "ar": Forbidden,
150 "as": Forbidden,
151 "cc": Forbidden,
152 "clang": Forbidden,
153 "clang++": Forbidden,
154 "gcc": Forbidden,
155 "g++": Forbidden,
156 "ld": Forbidden,
157 "ld.bfd": Forbidden,
158 "ld.gold": Forbidden,
159 "pkg-config": Forbidden,
160
161 // We've got prebuilts of these
162 //"dtc": Forbidden,
163 //"lz4": Forbidden,
164 //"lz4c": Forbidden,
165}
166
167func init() {
168 if runtime.GOOS == "darwin" {
169 Configuration["md5"] = Allowed
170 Configuration["sw_vers"] = Allowed
171 Configuration["xcrun"] = Allowed
172 }
173}