Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 1 | // Copyright 2021 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 | |
| 15 | package rust |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | ) |
| 20 | |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 21 | // snapshotLibraryInterface is an interface for libraries captured to VNDK / vendor snapshots. |
| 22 | type snapshotLibraryInterface interface { |
| 23 | libraryInterface |
| 24 | |
| 25 | // collectHeadersForSnapshot is called in GenerateAndroidBuildActions for snapshot aware |
| 26 | // modules (See isSnapshotAware below). |
| 27 | // This function should gather all headers needed for snapshot. |
| 28 | collectHeadersForSnapshot(ctx android.ModuleContext, deps PathDeps) |
| 29 | |
| 30 | // snapshotHeaders should return collected headers by collectHeadersForSnapshot. |
| 31 | // Calling snapshotHeaders before collectHeadersForSnapshot is an error. |
| 32 | snapshotHeaders() android.Paths |
| 33 | } |
| 34 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 35 | func (mod *Module) ExcludeFromVendorSnapshot() bool { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 36 | return Bool(mod.Properties.Exclude_from_vendor_snapshot) |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | func (mod *Module) ExcludeFromRecoverySnapshot() bool { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 40 | return Bool(mod.Properties.Exclude_from_recovery_snapshot) |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | func (mod *Module) IsSnapshotLibrary() bool { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 44 | if lib, ok := mod.compiler.(libraryInterface); ok { |
Ivan Lozano | add122a | 2023-07-13 11:01:41 -0400 | [diff] [blame] | 45 | return lib.shared() || lib.static() || lib.rlib() || lib.dylib() |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 46 | } |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 47 | return false |
| 48 | } |
| 49 | |
| 50 | func (mod *Module) SnapshotRuntimeLibs() []string { |
| 51 | // TODO Rust does not yet support a runtime libs notion similar to CC |
| 52 | return []string{} |
| 53 | } |
| 54 | |
| 55 | func (mod *Module) SnapshotSharedLibs() []string { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 56 | return mod.Properties.SnapshotSharedLibs |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 57 | } |
| 58 | |
Justin Yun | 5e03586 | 2021-06-29 20:50:37 +0900 | [diff] [blame] | 59 | func (mod *Module) SnapshotStaticLibs() []string { |
| 60 | return mod.Properties.SnapshotStaticLibs |
| 61 | } |
| 62 | |
Ivan Lozano | add122a | 2023-07-13 11:01:41 -0400 | [diff] [blame] | 63 | func (mod *Module) SnapshotRlibs() []string { |
| 64 | return mod.Properties.SnapshotRlibs |
| 65 | } |
| 66 | |
| 67 | func (mod *Module) SnapshotDylibs() []string { |
| 68 | return mod.Properties.SnapshotDylibs |
| 69 | } |
| 70 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 71 | func (mod *Module) Symlinks() []string { |
| 72 | // TODO update this to return the list of symlinks when Rust supports defining symlinks |
| 73 | return nil |
| 74 | } |
| 75 | |
| 76 | func (m *Module) SnapshotHeaders() android.Paths { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 77 | if l, ok := m.compiler.(snapshotLibraryInterface); ok { |
| 78 | return l.snapshotHeaders() |
| 79 | } |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 80 | return android.Paths{} |
| 81 | } |