blob: 427560179f754960c40b65223a5dda0299fcf89a [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,
74 "echo": Allowed,
75 "egrep": Allowed,
76 "env": Allowed,
77 "expr": Allowed,
78 "find": Allowed,
79 "getconf": Allowed,
80 "getopt": Allowed,
81 "git": Allowed,
82 "grep": Allowed,
83 "gzip": Allowed,
84 "head": Allowed,
85 "hexdump": Allowed,
86 "hostname": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -070087 "id": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -070088 "jar": Allowed,
89 "java": Allowed,
90 "javap": Allowed,
91 "ln": Allowed,
92 "ls": Allowed,
93 "m4": Allowed,
94 "make": Allowed,
95 "md5sum": Allowed,
96 "mkdir": Allowed,
97 "mktemp": Allowed,
98 "mv": Allowed,
99 "openssl": Allowed,
100 "patch": Allowed,
101 "perl": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700102 "pgrep": Allowed,
103 "pkill": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700104 "pstree": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700105 "pwd": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700106 "python": Allowed,
107 "python2.7": Allowed,
108 "python3": Allowed,
109 "readlink": Allowed,
110 "realpath": Allowed,
111 "rm": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700112 "rmdir": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700113 "rsync": Allowed,
114 "runalarm": Allowed,
115 "sed": Allowed,
116 "setsid": Allowed,
117 "sh": Allowed,
Dan Willemsenf6d30062018-06-01 10:58:58 -0700118 "sha1sum": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700119 "sha256sum": Allowed,
120 "sha512sum": Allowed,
Dan Willemsen16dbb392018-06-06 11:02:42 -0700121 "sleep": Allowed,
Dan Willemsen18490112018-05-25 16:30:04 -0700122 "sort": Allowed,
123 "stat": Allowed,
124 "sum": Allowed,
125 "tar": Allowed,
126 "tail": Allowed,
127 "touch": Allowed,
128 "tr": Allowed,
129 "true": Allowed,
130 "uname": Allowed,
131 "uniq": Allowed,
132 "unzip": Allowed,
133 "wc": Allowed,
134 "which": Allowed,
135 "whoami": Allowed,
136 "xargs": Allowed,
137 "xmllint": Allowed,
138 "xz": Allowed,
139 "zip": Allowed,
140 "zipinfo": Allowed,
141
142 // Host toolchain is removed. In-tree toolchain should be used instead.
143 // GCC also can't find cc1 with this implementation.
144 "ar": Forbidden,
145 "as": Forbidden,
146 "cc": Forbidden,
147 "clang": Forbidden,
148 "clang++": Forbidden,
149 "gcc": Forbidden,
150 "g++": Forbidden,
151 "ld": Forbidden,
152 "ld.bfd": Forbidden,
153 "ld.gold": Forbidden,
154 "pkg-config": Forbidden,
155
156 // We've got prebuilts of these
157 //"dtc": Forbidden,
158 //"lz4": Forbidden,
159 //"lz4c": Forbidden,
160}
161
162func init() {
163 if runtime.GOOS == "darwin" {
164 Configuration["md5"] = Allowed
165 Configuration["sw_vers"] = Allowed
166 Configuration["xcrun"] = Allowed
167 }
168}