blob: ed44cedd5a46b60f63ff9bc4c2af16f04fb4ade6 [file] [log] [blame]
Dan Willemsena14704c2017-10-28 22:57:22 -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
17type PathConfig struct {
18 // Whether to create the symlink in the new PATH for this tool.
19 Symlink bool
20
21 // Whether to log about usages of this tool to the soong.log
22 Log bool
23
24 // Whether to exit with an error instead of invoking the underlying tool.
25 Error bool
26}
27
28var Allowed = PathConfig{
29 Symlink: true,
30 Log: false,
31 Error: false,
32}
33
34var Forbidden = PathConfig{
35 Symlink: false,
36 Log: true,
37 Error: true,
38}
39
40// The configuration used if the tool is not listed in the config below.
41// Currently this will create the symlink, but log a warning. In the future,
42// I expect this to move closer to Forbidden.
43var Missing = PathConfig{
44 Symlink: true,
45 Log: true,
46 Error: false,
47}
48
49func GetConfig(name string) PathConfig {
50 if config, ok := Configuration[name]; ok {
51 return config
52 }
53 return Missing
54}
55
56var Configuration = map[string]PathConfig{
57 "awk": Allowed,
58 "basename": Allowed,
59 "bash": Allowed,
60 "bzip2": Allowed,
61 "cat": Allowed,
62 "chmod": Allowed,
63 "cmp": Allowed,
64 "comm": Allowed,
65 "cp": Allowed,
66 "cut": Allowed,
67 "date": Allowed,
68 "dd": Allowed,
69 "diff": Allowed,
70 "dirname": Allowed,
71 "echo": Allowed,
72 "egrep": Allowed,
73 "env": Allowed,
74 "expr": Allowed,
75 "find": Allowed,
76 "getconf": Allowed,
77 "getopt": Allowed,
78 "git": Allowed,
79 "grep": Allowed,
80 "gzip": Allowed,
81 "head": Allowed,
82 "hexdump": Allowed,
83 "hostname": Allowed,
84 "jar": Allowed,
85 "java": Allowed,
86 "javap": Allowed,
87 "ln": Allowed,
88 "ls": Allowed,
89 "m4": Allowed,
90 "make": Allowed,
91 "md5sum": Allowed,
92 "mkdir": Allowed,
93 "mktemp": Allowed,
94 "mv": Allowed,
95 "openssl": Allowed,
96 "patch": Allowed,
97 "perl": Allowed,
98 "pstree": Allowed,
99 "python": Allowed,
100 "python2.7": Allowed,
101 "python3": Allowed,
102 "readlink": Allowed,
103 "realpath": Allowed,
104 "rm": Allowed,
105 "rsync": Allowed,
106 "runalarm": Allowed,
107 "sed": Allowed,
108 "setsid": Allowed,
109 "sh": Allowed,
110 "sha256sum": Allowed,
111 "sha512sum": Allowed,
112 "sort": Allowed,
113 "stat": Allowed,
114 "sum": Allowed,
115 "tar": Allowed,
116 "tail": Allowed,
117 "touch": Allowed,
118 "tr": Allowed,
119 "true": Allowed,
120 "uname": Allowed,
121 "uniq": Allowed,
122 "unzip": Allowed,
123 "wc": Allowed,
124 "which": Allowed,
125 "whoami": Allowed,
126 "xargs": Allowed,
127 "xmllint": Allowed,
128 "xz": Allowed,
129 "zip": Allowed,
130 "zipinfo": Allowed,
131
132 // Host toolchain is removed. In-tree toolchain should be used instead.
133 // GCC also can't find cc1 with this implementation.
134 "ar": Forbidden,
135 "as": Forbidden,
136 "cc": Forbidden,
137 "clang": Forbidden,
138 "clang++": Forbidden,
139 "gcc": Forbidden,
140 "g++": Forbidden,
141 "ld": Forbidden,
142 "ld.bfd": Forbidden,
143 "ld.gold": Forbidden,
144 "pkg-config": Forbidden,
145
146 // We've got prebuilts of these
147 //"dtc": Forbidden,
148 //"lz4": Forbidden,
149 //"lz4c": Forbidden,
150}