1// 2// Copyright (C) 2024 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15 16genrule { 17 name: "font-resources-public", 18 out: ["values/public.xml"], 19 cmd: "mkdir -p $(genDir)/values; echo '<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 20 " <resources>" + 21 " <public type=\"string\" name=\"config_bodyFontFamily\" id=\"0x010401fe\" /> " + 22 " <public type=\"string\" name=\"config_headlineFontFamily\" id=\"0x01040274\" /> " + 23 " </resources>' > $(out)", 24} 25 26genrule { 27 name: "font-resources-compile-public", 28 tools: ["aapt2"], 29 srcs: [ 30 ":font-resources-public", 31 ], 32 out: ["values_public.arsc.flat"], 33 cmd: "$(location aapt2) compile $(in) -o $(genDir)", 34} 35 36genrule { 37 name: "font-resources-config", 38 out: ["values/config.xml"], 39 cmd: "mkdir -p $(genDir)/values; echo '<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 40 " <resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">" + 41 " <string name=\"config_headlineFontFamily\" translatable=\"false\">plh-go-sans</string>" + 42 " <string name=\"config_bodyFontFamily\" translatable=\"false\">plh-go-sans-text</string>" + 43 " </resources>' > $(out)", 44} 45 46genrule { 47 name: "font-resources-compile-config", 48 tools: ["aapt2"], 49 srcs: [ 50 ":font-resources-config", 51 ], 52 out: ["values_config.arsc.flat"], 53 cmd: "$(location aapt2) compile $(in) -o $(genDir)", 54} 55 56genrule { 57 name: "font-manifest", 58 out: ["FontAndroidManifest.xml"], 59 cmd: "echo '<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"" + 60 " package=\"android\"> <application/> </manifest>' > $(out)", 61} 62 63genrule { 64 name: "font-resources-apk", 65 tools: ["aapt2"], 66 // The first input file in the list must be the manifest 67 srcs: [ 68 ":font-manifest", 69 ":font-resources-compile-public", 70 ":font-resources-compile-config", 71 ], 72 out: ["font-resources.apk"], 73 cmd: "$(location aapt2) link -o $(out) --manifest $(in)", 74} 75 76genrule { 77 name: "font-resources-arsc", 78 srcs: [":font-resources-apk"], 79 out: ["font_resources.arsc"], 80 cmd: "mkdir -p $(genDir)/font-resources-arsc && " + 81 "unzip -x $(in) resources.arsc -d $(genDir)/font-resources-arsc && " + 82 "mkdir -p $$(dirname $(out)) && " + 83 "mv $(genDir)/font-resources-arsc/resources.arsc $(out) && " + 84 "echo 'Created $(out)'", 85} 86