Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 1 | // Copyright 2017 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 | |
| 15 | package cc |
| 16 | |
Kiyoung Kim | 37693d0 | 2024-04-04 09:56:15 +0900 | [diff] [blame] | 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "strings" |
| 20 | ) |
| 21 | |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 22 | var ( |
| 23 | llndkLibrarySuffix = ".llndk" |
Jiyong Park | 2a45412 | 2017-10-19 15:59:33 +0900 | [diff] [blame] | 24 | llndkHeadersSuffix = ".llndk" |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 25 | ) |
| 26 | |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 27 | // Holds properties to describe a stub shared library based on the provided version file. |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 28 | type llndkLibraryProperties struct { |
| 29 | // Relative path to the symbol map. |
| 30 | // An example file can be seen here: TODO(danalbert): Make an example. |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 31 | Symbol_file *string |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 32 | |
| 33 | // Whether to export any headers as -isystem instead of -I. Mainly for use by |
| 34 | // bionic/libc. |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 35 | Export_headers_as_system *bool |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 36 | |
| 37 | // Which headers to process with versioner. This really only handles |
| 38 | // bionic/libc/include right now. |
| 39 | Export_preprocessed_headers []string |
| 40 | |
| 41 | // Whether the system library uses symbol versions. |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 42 | Unversioned *bool |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 43 | |
Jiyong Park | 2a45412 | 2017-10-19 15:59:33 +0900 | [diff] [blame] | 44 | // list of llndk headers to re-export include directories from. |
Colin Cross | 0fb7fcd | 2021-03-02 11:00:07 -0800 | [diff] [blame] | 45 | Export_llndk_headers []string |
| 46 | |
| 47 | // list of directories relative to the Blueprints file that willbe added to the include path |
| 48 | // (using -I) for any module that links against the LLNDK variant of this module, replacing |
| 49 | // any that were listed outside the llndk clause. |
| 50 | Override_export_include_dirs []string |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 51 | |
| 52 | // whether this module can be directly depended upon by libs that are installed |
| 53 | // to /vendor and /product. |
| 54 | // When set to true, this module can only be depended on by VNDK libraries, not |
| 55 | // vendor nor product libraries. This effectively hides this module from |
| 56 | // non-system modules. Default value is false. |
| 57 | Private *bool |
Colin Cross | 1f3f130 | 2021-04-26 18:37:44 -0700 | [diff] [blame] | 58 | |
| 59 | // if true, make this module available to provide headers to other modules that set |
| 60 | // llndk.symbol_file. |
| 61 | Llndk_headers *bool |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 62 | } |
Kiyoung Kim | 37693d0 | 2024-04-04 09:56:15 +0900 | [diff] [blame] | 63 | |
| 64 | func makeLlndkVars(ctx android.MakeVarsContext) { |
| 65 | // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if |
| 66 | // they been moved to an apex. |
| 67 | movedToApexLlndkLibraries := make(map[string]bool) |
| 68 | ctx.VisitAllModules(func(module android.Module) { |
| 69 | if library := moduleLibraryInterface(module); library != nil && library.hasLLNDKStubs() { |
| 70 | // Skip bionic libs, they are handled in different manner |
| 71 | name := library.implementationModuleName(module.(*Module).BaseModuleName()) |
| 72 | if module.(android.ApexModule).DirectlyInAnyApex() && !isBionic(name) { |
| 73 | movedToApexLlndkLibraries[name] = true |
| 74 | } |
| 75 | } |
| 76 | }) |
| 77 | |
| 78 | ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", |
| 79 | strings.Join(android.SortedKeys(movedToApexLlndkLibraries), " ")) |
| 80 | } |