Home | History | Annotate | Download | only in cc
      1 // 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 
     15 package cc
     16 
     17 import (
     18 	"github.com/google/blueprint"
     19 	"github.com/google/blueprint/proptools"
     20 
     21 	"android/soong/android"
     22 )
     23 
     24 //
     25 // Device libraries shipped with gcc
     26 //
     27 
     28 func init() {
     29 	android.RegisterModuleType("toolchain_library", toolchainLibraryFactory)
     30 }
     31 
     32 type toolchainLibraryDecorator struct {
     33 	*libraryDecorator
     34 }
     35 
     36 func (*toolchainLibraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
     37 	// toolchain libraries can't have any dependencies
     38 	return deps
     39 }
     40 
     41 func toolchainLibraryFactory() (blueprint.Module, []interface{}) {
     42 	module, library := NewLibrary(android.HostAndDeviceSupported)
     43 	library.BuildOnlyStatic()
     44 	toolchainLibrary := &toolchainLibraryDecorator{
     45 		libraryDecorator: library,
     46 	}
     47 	module.compiler = toolchainLibrary
     48 	module.linker = toolchainLibrary
     49 	module.Properties.Clang = proptools.BoolPtr(false)
     50 	module.stl = nil
     51 	module.sanitize = nil
     52 	module.installer = nil
     53 	return module.Init()
     54 }
     55 
     56 func (library *toolchainLibraryDecorator) compile(ctx ModuleContext, flags Flags,
     57 	deps PathDeps) Objects {
     58 	return Objects{}
     59 }
     60 
     61 func (library *toolchainLibraryDecorator) link(ctx ModuleContext,
     62 	flags Flags, deps PathDeps, objs Objects) android.Path {
     63 
     64 	libName := ctx.ModuleName() + staticLibraryExtension
     65 	outputFile := android.PathForModuleOut(ctx, libName)
     66 
     67 	if flags.Clang {
     68 		ctx.ModuleErrorf("toolchain_library must use GCC, not Clang")
     69 	}
     70 
     71 	CopyGccLib(ctx, libName, flagsToBuilderFlags(flags), outputFile)
     72 
     73 	ctx.CheckbuildFile(outputFile)
     74 
     75 	return outputFile
     76 }
     77