blob: 9b83f1818d51a23c241c172787a7cc6ec6970460 [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 "github.com/google/blueprint/proptools"
19
Colin Crossb916a382016-07-29 17:28:03 -070020 "android/soong/android"
21)
22
23//
24// Device libraries shipped with gcc
25//
26
27func init() {
Colin Cross798bfce2016-10-12 14:28:16 -070028 android.RegisterModuleType("toolchain_library", toolchainLibraryFactory)
Colin Crossb916a382016-07-29 17:28:03 -070029}
30
31type toolchainLibraryDecorator struct {
32 *libraryDecorator
33}
34
Colin Cross37047f12016-12-13 17:06:13 -080035func (*toolchainLibraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -070036 // toolchain libraries can't have any dependencies
37 return deps
38}
39
Colin Cross36242852017-06-23 15:06:31 -070040func toolchainLibraryFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -080041 module, library := NewLibrary(android.HostAndDeviceSupported)
42 library.BuildOnlyStatic()
Colin Crossb916a382016-07-29 17:28:03 -070043 toolchainLibrary := &toolchainLibraryDecorator{
44 libraryDecorator: library,
45 }
46 module.compiler = toolchainLibrary
47 module.linker = toolchainLibrary
48 module.Properties.Clang = proptools.BoolPtr(false)
49 module.stl = nil
50 module.sanitize = nil
51 module.installer = nil
52 return module.Init()
53}
54
55func (library *toolchainLibraryDecorator) compile(ctx ModuleContext, flags Flags,
Dan Willemsen5cb580f2016-09-26 17:33:01 -070056 deps PathDeps) Objects {
57 return Objects{}
Colin Crossb916a382016-07-29 17:28:03 -070058}
59
60func (library *toolchainLibraryDecorator) link(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -070061 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Crossb916a382016-07-29 17:28:03 -070062
63 libName := ctx.ModuleName() + staticLibraryExtension
64 outputFile := android.PathForModuleOut(ctx, libName)
65
66 if flags.Clang {
67 ctx.ModuleErrorf("toolchain_library must use GCC, not Clang")
68 }
69
70 CopyGccLib(ctx, libName, flagsToBuilderFlags(flags), outputFile)
71
72 ctx.CheckbuildFile(outputFile)
73
74 return outputFile
75}