1// Copyright 2022 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 allowlists
16
17const (
18	// Modules with build time of more than half a minute should have high priority.
19	DEFAULT_PRIORITIZED_WEIGHT = 1000
20	// Modules with build time of more than a few minute should have higher priority.
21	HIGH_PRIORITIZED_WEIGHT = 10 * DEFAULT_PRIORITIZED_WEIGHT
22	// Modules with inputs greater than the threshold should have high priority.
23	// Adjust this threshold if there are lots of wrong predictions.
24	INPUT_SIZE_THRESHOLD = 50
25)
26
27var (
28	// The list of module types which are expected to spend lots of build time.
29	// With `--ninja_weight_source=soong`, ninja builds these module types and deps first.
30	HugeModuleTypePrefixMap = map[string]int{
31		"rust_":       HIGH_PRIORITIZED_WEIGHT,
32		"droidstubs":  DEFAULT_PRIORITIZED_WEIGHT,
33		"art_":        DEFAULT_PRIORITIZED_WEIGHT,
34		"ndk_library": DEFAULT_PRIORITIZED_WEIGHT,
35	}
36)
37