• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2020 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 java
16
17import (
18	"android/soong/android"
19)
20
21// isActiveModule returns true if the given module should be considered for boot
22// jars, i.e. if it's enabled and the preferred one in case of source and
23// prebuilt alternatives.
24func isActiveModule(module android.Module) bool {
25	if !module.Enabled() {
26		return false
27	}
28	return android.IsModulePreferred(module)
29}
30
31// buildRuleForBootJarsPackageCheck generates the build rule to perform the boot jars package
32// check.
33func buildRuleForBootJarsPackageCheck(ctx android.ModuleContext, bootDexJarByModule bootDexJarByModule) {
34	timestamp := android.PathForOutput(ctx, "boot-jars-package-check/stamp")
35
36	rule := android.NewRuleBuilder(pctx, ctx)
37	rule.Command().BuiltTool("check_boot_jars").
38		Input(ctx.Config().HostToolPath(ctx, "dexdump")).
39		Input(android.PathForSource(ctx, "build/soong/scripts/check_boot_jars/package_allowed_list.txt")).
40		Inputs(bootDexJarByModule.bootDexJarsWithoutCoverage()).
41		Text("&& touch").Output(timestamp)
42	rule.Build("boot_jars_package_check", "check boot jar packages")
43
44	// The check-boot-jars phony target depends on the timestamp created if the check succeeds.
45	ctx.Phony("check-boot-jars", timestamp)
46
47	// The droidcore phony target depends on the check-boot-jars phony target
48	ctx.Phony("droidcore", android.PathForPhony(ctx, "check-boot-jars"))
49}
50