blob: 9d5154ce28b80e5b77860a11f02952e06eccf400 [file] [log] [blame]
Ivan Lozanod7586b62021-04-01 09:49:36 -04001// 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
15package rust
16
17import (
18 "android/soong/android"
19)
20
Ivan Lozano1921e802021-05-20 13:39:16 -040021// snapshotLibraryInterface is an interface for libraries captured to VNDK / vendor snapshots.
22type 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 Lozanod7586b62021-04-01 09:49:36 -040035func (mod *Module) ExcludeFromVendorSnapshot() bool {
Ivan Lozano1921e802021-05-20 13:39:16 -040036 return Bool(mod.Properties.Exclude_from_vendor_snapshot)
Ivan Lozanod7586b62021-04-01 09:49:36 -040037}
38
39func (mod *Module) ExcludeFromRecoverySnapshot() bool {
Ivan Lozano1921e802021-05-20 13:39:16 -040040 return Bool(mod.Properties.Exclude_from_recovery_snapshot)
Ivan Lozanod7586b62021-04-01 09:49:36 -040041}
42
43func (mod *Module) IsSnapshotLibrary() bool {
Ivan Lozano1921e802021-05-20 13:39:16 -040044 if lib, ok := mod.compiler.(libraryInterface); ok {
45 // Rust-native dylibs and rlibs are not snapshot supported yet, so only
46 // return true if this module produces a C shared or static library.
47 return lib.shared() || lib.static()
48 }
Ivan Lozanod7586b62021-04-01 09:49:36 -040049 return false
50}
51
52func (mod *Module) SnapshotRuntimeLibs() []string {
53 // TODO Rust does not yet support a runtime libs notion similar to CC
54 return []string{}
55}
56
57func (mod *Module) SnapshotSharedLibs() []string {
Ivan Lozano1921e802021-05-20 13:39:16 -040058 return mod.Properties.SnapshotSharedLibs
Ivan Lozanod7586b62021-04-01 09:49:36 -040059}
60
61func (mod *Module) Symlinks() []string {
62 // TODO update this to return the list of symlinks when Rust supports defining symlinks
63 return nil
64}
65
66func (m *Module) SnapshotHeaders() android.Paths {
Ivan Lozano1921e802021-05-20 13:39:16 -040067 if l, ok := m.compiler.(snapshotLibraryInterface); ok {
68 return l.snapshotHeaders()
69 }
Ivan Lozanod7586b62021-04-01 09:49:36 -040070 return android.Paths{}
71}