blob: a7f6c09c8cb4e2a320182718620496218daaecfa [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
Ivan Lozanoffee3342019-08-27 12:03:00 -070051 return module, prebuilt
52}
53
54func (prebuilt *prebuiltLibraryDecorator) compilerProps() []interface{} {
Matthew Maurer128f53b2020-06-29 13:31:04 -070055 return append(prebuilt.libraryDecorator.compilerProps(),
Ivan Lozanoffee3342019-08-27 12:03:00 -070056 &prebuilt.Properties)
57}
58
59func (prebuilt *prebuiltLibraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
60 srcPath := srcPathFromModuleSrcs(ctx, prebuilt.Properties.Srcs)
61
62 prebuilt.unstrippedOutputFile = srcPath
63
64 return srcPath
65}
Ivan Lozanof1c84332019-09-20 11:00:37 -070066
67func (prebuilt *prebuiltLibraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
68 deps = prebuilt.baseCompiler.compilerDeps(ctx, deps)
69 return deps
70}
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -040071
72func (prebuilt *prebuiltLibraryDecorator) nativeCoverage() bool {
73 return false
74}