blob: 5d40ec389122648d8eb360e44eaf090a8984ebcb [file] [log] [blame]
Paul Duffin9a89a2a2020-10-28 19:20:06 +00001// 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
Martin Stjernholm1dc0d6d2021-01-17 21:05:12 +000021// 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 }
Paul Duffine1d38372021-04-02 10:35:24 +010028 return android.IsModulePreferred(module)
Martin Stjernholm1dc0d6d2021-01-17 21:05:12 +000029}
30
Paul Duffinc8ead412021-06-07 19:28:15 +010031// buildRuleForBootJarsPackageCheck generates the build rule to perform the boot jars package
32// check.
33func buildRuleForBootJarsPackageCheck(ctx android.ModuleContext, bootDexJarByModule bootDexJarByModule) {
Paul Duffin9ffbecc2021-06-22 14:48:12 +010034 bootDexJars := bootDexJarByModule.bootDexJarsWithoutCoverage()
35 if len(bootDexJars) == 0 {
36 return
37 }
38
Paul Duffin9a89a2a2020-10-28 19:20:06 +000039 timestamp := android.PathForOutput(ctx, "boot-jars-package-check/stamp")
40
Colin Crossf1a035e2020-11-16 17:32:30 -080041 rule := android.NewRuleBuilder(pctx, ctx)
Paul Duffinc8ead412021-06-07 19:28:15 +010042 rule.Command().BuiltTool("check_boot_jars").
Paul Duffin2d8e1a72020-10-29 12:56:09 +000043 Input(ctx.Config().HostToolPath(ctx, "dexdump")).
Paul Duffinc8ead412021-06-07 19:28:15 +010044 Input(android.PathForSource(ctx, "build/soong/scripts/check_boot_jars/package_allowed_list.txt")).
Paul Duffin9ffbecc2021-06-22 14:48:12 +010045 Inputs(bootDexJars).
Paul Duffinc8ead412021-06-07 19:28:15 +010046 Text("&& touch").Output(timestamp)
Colin Crossf1a035e2020-11-16 17:32:30 -080047 rule.Build("boot_jars_package_check", "check boot jar packages")
Paul Duffin9a89a2a2020-10-28 19:20:06 +000048
49 // The check-boot-jars phony target depends on the timestamp created if the check succeeds.
50 ctx.Phony("check-boot-jars", timestamp)
51
52 // The droidcore phony target depends on the check-boot-jars phony target
53 ctx.Phony("droidcore", android.PathForPhony(ctx, "check-boot-jars"))
54}