1 // Copyright (C) 2016 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 15 package clang 16 17 import ( 18 "android/soong/android" 19 "android/soong/cc" 20 21 "github.com/google/blueprint" 22 ) 23 24 // Clang binaries (clang, clang-check, clang-format) need to be compiled for both 32-bit and 64-bit, 25 // but only when FORCE_BUILD_LLVM_COMPONENTS is set 26 27 func init() { 28 android.RegisterModuleType("clang_binary_host", clangBinaryHostFactory) 29 } 30 31 func clangForceBuildLlvmComponents(ctx android.LoadHookContext) { 32 if ctx.AConfig().IsEnvTrue("FORCE_BUILD_LLVM_COMPONENTS") { 33 type props struct { 34 Target struct { 35 Host struct { 36 Compile_multilib string 37 } 38 } 39 Multilib struct { 40 Lib32 struct { 41 Suffix string 42 } 43 } 44 } 45 p := &props{} 46 p.Target.Host.Compile_multilib = "both" 47 p.Multilib.Lib32.Suffix = "_32" 48 ctx.AppendProperties(p) 49 } 50 } 51 52 func clangBinaryHostFactory() (blueprint.Module, []interface{}) { 53 module, _ := cc.NewBinary(android.HostSupported) 54 android.AddLoadHook(module, clangForceBuildLlvmComponents) 55 56 return module.Init() 57 } 58