blob: 742d1c1799a3fc692623e6536327e80e20c84305 [file] [log] [blame]
Colin Crossb916a382016-07-29 17:28:03 -07001// Copyright 2016 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
15package cc
16
17import (
Colin Crossb916a382016-07-29 17:28:03 -070018 "android/soong/android"
19)
20
21//
22// Device libraries shipped with gcc
23//
24
25func init() {
Colin Crosse40b4ea2018-10-02 22:25:58 -070026 android.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
Colin Crossb916a382016-07-29 17:28:03 -070027}
28
Dan Willemsenfeea4df2018-10-07 18:16:48 -070029type toolchainLibraryProperties struct {
30 // the prebuilt toolchain library, as a path from the top of the source tree
31 Src *string `android:"arch_variant"`
32}
33
Colin Crossb916a382016-07-29 17:28:03 -070034type toolchainLibraryDecorator struct {
35 *libraryDecorator
Dan Willemsenfeea4df2018-10-07 18:16:48 -070036
37 Properties toolchainLibraryProperties
Colin Crossb916a382016-07-29 17:28:03 -070038}
39
Colin Cross37047f12016-12-13 17:06:13 -080040func (*toolchainLibraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -070041 // toolchain libraries can't have any dependencies
42 return deps
43}
44
Dan Willemsenfeea4df2018-10-07 18:16:48 -070045func (library *toolchainLibraryDecorator) linkerProps() []interface{} {
46 var props []interface{}
47 props = append(props, library.libraryDecorator.linkerProps()...)
48 return append(props, &library.Properties)
49}
50
Colin Crosse40b4ea2018-10-02 22:25:58 -070051func ToolchainLibraryFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -080052 module, library := NewLibrary(android.HostAndDeviceSupported)
53 library.BuildOnlyStatic()
Colin Crossb916a382016-07-29 17:28:03 -070054 toolchainLibrary := &toolchainLibraryDecorator{
55 libraryDecorator: library,
56 }
57 module.compiler = toolchainLibrary
58 module.linker = toolchainLibrary
Dan Willemsen742a5452018-07-23 17:19:36 -070059 module.Properties.Gcc = true
Colin Crossb916a382016-07-29 17:28:03 -070060 module.stl = nil
61 module.sanitize = nil
62 module.installer = nil
63 return module.Init()
64}
65
66func (library *toolchainLibraryDecorator) compile(ctx ModuleContext, flags Flags,
Dan Willemsen5cb580f2016-09-26 17:33:01 -070067 deps PathDeps) Objects {
68 return Objects{}
Colin Crossb916a382016-07-29 17:28:03 -070069}
70
71func (library *toolchainLibraryDecorator) link(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -070072 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Crossb916a382016-07-29 17:28:03 -070073
Dan Willemsenfeea4df2018-10-07 18:16:48 -070074 if library.Properties.Src == nil {
75 ctx.PropertyErrorf("src", "No library source specified")
76 return android.PathForSource(ctx, "")
Colin Crossb916a382016-07-29 17:28:03 -070077 }
78
Dan Willemsenfeea4df2018-10-07 18:16:48 -070079 return android.PathForSource(ctx, *library.Properties.Src)
Colin Crossb916a382016-07-29 17:28:03 -070080}