Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 1 | // Copyright (C) 2019 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 | |
Tobias Thierer | adeea59 | 2019-09-27 20:27:29 +0100 | [diff] [blame^] | 15 | |
| 16 | java_defaults { |
| 17 | name: "mimemap-defaults", |
| 18 | srcs: [ |
| 19 | "java/android/content/type/DefaultMimeMapFactory.java", |
| 20 | ], |
| 21 | sdk_version: "core_platform", |
| 22 | } |
| 23 | |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 24 | java_library { |
| 25 | name: "mimemap", |
Tobias Thierer | adeea59 | 2019-09-27 20:27:29 +0100 | [diff] [blame^] | 26 | defaults: ["mimemap-defaults"], |
| 27 | static_libs: ["mimemap-res.jar"], |
| 28 | visibility: [ |
| 29 | "//frameworks/base:__subpackages__", |
| 30 | ], |
| 31 | } |
| 32 | |
| 33 | java_library { |
| 34 | name: "mimemap-testing", |
| 35 | defaults: ["mimemap-defaults"], |
| 36 | static_libs: ["mimemap-testing-res.jar"], |
| 37 | jarjar_rules: "jarjar-rules.txt", |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 38 | visibility: [ |
| 39 | "//cts/tests/tests/mimemap:__subpackages__", |
| 40 | "//frameworks/base:__subpackages__", |
| 41 | ], |
Tobias Thierer | adeea59 | 2019-09-27 20:27:29 +0100 | [diff] [blame^] | 42 | } |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 43 | |
Tobias Thierer | adeea59 | 2019-09-27 20:27:29 +0100 | [diff] [blame^] | 44 | // The mimemap-res.jar and mimemap-testing-res.jar genrules produce a .jar that |
| 45 | // has the resource file in a subdirectory res/ and testres/, respectively. |
| 46 | // Those paths need to They need to be in different paths because one of them |
| 47 | // ends up on a bootclasspath jar whereas the other one ends up in a test jar. |
| 48 | // Bootclasspath resources hide test or application resources under the same |
| 49 | // path because ClassLoader.getResource(String) consults the parent ClassLoader |
| 50 | // first. |
| 51 | // |
| 52 | // Further notes: |
| 53 | // - the "cp" command will flatten any directory paths that occur in $(in), |
| 54 | // but here they happen to already be in the root directory. If we needed |
| 55 | // to preserve sub paths then we might want to zip the files first and then |
| 56 | // unzip them below the new parent directory. |
| 57 | // - the path names "res/" and "testres/" and duplicated in .java source files |
| 58 | // (DefaultMimeMapFactory.java and MimeMapTest.java, as of October 2019). |
| 59 | java_genrule { |
| 60 | name: "mimemap-res.jar", |
| 61 | tools: [ |
| 62 | "soong_zip", |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 63 | ], |
Tobias Thierer | adeea59 | 2019-09-27 20:27:29 +0100 | [diff] [blame^] | 64 | srcs: [":mime.types"], |
| 65 | out: ["mimemap-res.jar"], |
| 66 | cmd: "mkdir $(genDir)/res/ && cp $(in) $(genDir)/res/ && $(location soong_zip) -C $(genDir) -o $(out) -D $(genDir)/res/", |
| 67 | } |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 68 | |
Tobias Thierer | adeea59 | 2019-09-27 20:27:29 +0100 | [diff] [blame^] | 69 | // The same as mimemap-res.jar except that the resources are placed in a different directory. |
| 70 | // They get bundled with CTS so that CTS can compare a device's MimeMap implementation vs. |
| 71 | // the stock Android one from when CTS was built. |
| 72 | java_genrule { |
| 73 | name: "mimemap-testing-res.jar", |
| 74 | tools: [ |
| 75 | "soong_zip", |
| 76 | ], |
| 77 | srcs: [":mime.types"], |
| 78 | out: ["mimemap-testing-res.jar"], |
| 79 | cmd: "mkdir $(genDir)/testres/ && cp $(in) $(genDir)/testres/ && $(location soong_zip) -C $(genDir) -o $(out) -D $(genDir)/testres/", |
| 80 | } |
| 81 | |
| 82 | // Combination of all *mime.types resources. |
| 83 | filegroup { |
| 84 | name: "mime.types", |
| 85 | visibility: [ |
| 86 | "//visibility:private", |
| 87 | ], |
| 88 | srcs: [ |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 89 | ":debian.mime.types", |
| 90 | ":android.mime.types", |
Tobias Thierer | 3243491 | 2019-09-27 19:22:39 +0100 | [diff] [blame] | 91 | ":vendor.mime.types", |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 92 | ], |
Tobias Thierer | 878c77b | 2019-08-18 15:19:45 +0100 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | filegroup { |
| 96 | name: "android.mime.types", |
| 97 | visibility: [ |
| 98 | "//visibility:private", |
| 99 | ], |
| 100 | path: "java-res/", |
| 101 | srcs: [ |
| 102 | "java-res/android.mime.types", |
| 103 | ], |
| 104 | } |
Tobias Thierer | 3243491 | 2019-09-27 19:22:39 +0100 | [diff] [blame] | 105 | |
| 106 | filegroup { |
| 107 | name: "vendor.mime.types", |
| 108 | visibility: [ |
| 109 | "//visibility:private", |
| 110 | ], |
| 111 | path: "java-res/", |
| 112 | srcs: [ |
| 113 | "java-res/vendor.mime.types", |
| 114 | ], |
| 115 | } |