1// Copyright (C) 2024 The Android Open Source Project 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 { 16 // See: http://go/android-license-faq 17 // A large-scale-change added 'default_applicable_licenses' to import 18 // all of the 'license_kinds' from "frameworks_base_license" 19 // to get the below license kinds: 20 // SPDX-license-identifier-Apache-2.0 21 default_applicable_licenses: ["frameworks_base_license"], 22 default_team: "trendy_team_android_resources", 23} 24 25genrule { 26 name: "resource-flagging-test-app-compile", 27 tools: ["aapt2"], 28 srcs: [ 29 "res/values/bools.xml", 30 "res/values/bools2.xml", 31 "res/values/ints.xml", 32 "res/values/strings.xml", 33 "res/values/styles.xml", 34 "res/layout/layout1.xml", 35 "res/layout/layout3.xml", 36 "res/flag(test.package.falseFlag)/values/bools.xml", 37 "res/flag(test.package.falseFlag)/layout/layout2.xml", 38 "res/flag(test.package.falseFlag)/drawable/removedpng.png", 39 "res/flag(test.package.trueFlag)/layout/layout3.xml", 40 "res/values/flag(test.package.trueFlag)/bools.xml", 41 "res/values/flag(!test.package.trueFlag)/bools.xml", 42 "res/values/flag(!test.package.falseFlag)/bools.xml", 43 ], 44 out: [ 45 "drawable_removedpng.(test.package.falseFlag).png.flat", 46 "values_bools.arsc.flat", 47 "values_bools.(test.package.falseFlag).arsc.flat", 48 "values_bools.(test.package.trueFlag).arsc.flat", 49 "values_bools.(!test.package.falseFlag).arsc.flat", 50 "values_bools.(!test.package.trueFlag).arsc.flat", 51 "values_bools2.arsc.flat", 52 "values_ints.arsc.flat", 53 "values_strings.arsc.flat", 54 "values_styles.arsc.flat", 55 "layout_layout1.xml.flat", 56 "layout_layout2.(test.package.falseFlag).xml.flat", 57 "layout_layout3.xml.flat", 58 "layout_layout3.(test.package.trueFlag).xml.flat", 59 ], 60 cmd: "$(location aapt2) compile $(in) -o $(genDir) " + 61 "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", 62} 63 64genrule { 65 name: "resource-flagging-test-app-apk", 66 tools: ["aapt2"], 67 // The first input file in the list must be the manifest 68 srcs: [ 69 "AndroidManifest.xml", 70 ":resource-flagging-test-app-compile", 71 ], 72 out: [ 73 "resapp.apk", 74 ], 75 cmd: "$(location aapt2) link -o $(out) --manifest $(in) " + 76 "-I $(location :current_android_jar) " + 77 "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", 78 tool_files: [":current_android_jar"], 79} 80 81genrule { 82 name: "resource-flagging-test-app-r-java", 83 tools: ["aapt2"], 84 // The first input file in the list must be the manifest 85 srcs: [ 86 "AndroidManifest.xml", 87 ":resource-flagging-test-app-compile", 88 ], 89 out: [ 90 "resource-flagging-java/com/android/intenal/flaggedresources/R.java", 91 ], 92 cmd: "$(location aapt2) link -o $(genDir)/resapp.apk --java $(genDir)/resource-flagging-java --manifest $(in) " + 93 "-I $(location :current_android_jar) " + 94 "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", 95 tool_files: [":current_android_jar"], 96} 97 98java_genrule { 99 name: "resource-flagging-test-app-apk-as-resource", 100 srcs: [ 101 ":resource-flagging-test-app-apk", 102 ], 103 out: ["apks_as_resources.res.zip"], 104 tools: ["soong_zip"], 105 106 cmd: "mkdir -p $(genDir)/res/raw && " + 107 "cp $(in) $(genDir)/res/raw/$$(basename $(in)) && " + 108 "$(location soong_zip) -o $(out) -C $(genDir)/res -D $(genDir)/res", 109} 110