blob: 1d9765053f933fee4caee5b748c49aa65dd10297 [file] [log] [blame]
Ivan Lozanoffee3342019-08-27 12:03:00 -07001// Copyright 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
15package rust
16
17import (
18 "android/soong/android"
19)
20
21func init() {
22 android.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
23}
24
25type PrebuiltProperties struct {
26 // path to the prebuilt file
27 Srcs []string `android:"path,arch_variant"`
28}
29
30type prebuiltLibraryDecorator struct {
31 *libraryDecorator
32 Properties PrebuiltProperties
33}
34
35var _ compiler = (*prebuiltLibraryDecorator)(nil)
36
37func PrebuiltDylibFactory() android.Module {
38 module, _ := NewPrebuiltDylib(android.HostAndDeviceSupported)
39 return module.Init()
40}
41
42func NewPrebuiltDylib(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibraryDecorator) {
43 module, library := NewRustLibrary(hod)
44 library.BuildOnlyDylib()
Matthew Maurer99020b02019-10-31 10:44:40 -070045 library.setNoStdlibs()
Ivan Lozanoffee3342019-08-27 12:03:00 -070046 library.setDylib()
47 prebuilt := &prebuiltLibraryDecorator{
48 libraryDecorator: library,
49 }
50 module.compiler = prebuilt
51 module.AddProperties(&library.Properties)
52 return module, prebuilt
53}
54
55func (prebuilt *prebuiltLibraryDecorator) compilerProps() []interface{} {
56 return append(prebuilt.baseCompiler.compilerProps(),
57 &prebuilt.Properties)
58}
59
60func (prebuilt *prebuiltLibraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
61 srcPath := srcPathFromModuleSrcs(ctx, prebuilt.Properties.Srcs)
62
63 prebuilt.unstrippedOutputFile = srcPath
64
65 return srcPath
66}
Ivan Lozanof1c84332019-09-20 11:00:37 -070067
68func (prebuilt *prebuiltLibraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
69 deps = prebuilt.baseCompiler.compilerDeps(ctx, deps)
70 return deps
71}
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -040072
73func (prebuilt *prebuiltLibraryDecorator) nativeCoverage() bool {
74 return false
75}