1*67e74705SXin Li// Copyright (C) 2016 The Android Open Source Project 2*67e74705SXin Li// 3*67e74705SXin Li// Licensed under the Apache License, Version 2.0 (the "License"); 4*67e74705SXin Li// you may not use this file except in compliance with the License. 5*67e74705SXin Li// You may obtain a copy of the License at 6*67e74705SXin Li// 7*67e74705SXin Li// http://www.apache.org/licenses/LICENSE-2.0 8*67e74705SXin Li// 9*67e74705SXin Li// Unless required by applicable law or agreed to in writing, software 10*67e74705SXin Li// distributed under the License is distributed on an "AS IS" BASIS, 11*67e74705SXin Li// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*67e74705SXin Li// See the License for the specific language governing permissions and 13*67e74705SXin Li// limitations under the License. 14*67e74705SXin Li 15*67e74705SXin Lipackage clang 16*67e74705SXin Li 17*67e74705SXin Liimport ( 18*67e74705SXin Li "android/soong/android" 19*67e74705SXin Li "android/soong/cc" 20*67e74705SXin Li 21*67e74705SXin Li "github.com/google/blueprint/proptools" 22*67e74705SXin Li) 23*67e74705SXin Li 24*67e74705SXin Li// Clang binaries (clang, clang-check, clang-format) need to be compiled for both 32-bit and 64-bit, 25*67e74705SXin Li// but only when FORCE_BUILD_LLVM_COMPONENTS is set 26*67e74705SXin Li 27*67e74705SXin Lifunc init() { 28*67e74705SXin Li android.RegisterModuleType("clang_binary_host", clangBinaryHostFactory) 29*67e74705SXin Li} 30*67e74705SXin Li 31*67e74705SXin Lifunc clangForceBuildLlvmComponents(ctx android.LoadHookContext) { 32*67e74705SXin Li type props struct { 33*67e74705SXin Li Target struct { 34*67e74705SXin Li Host struct { 35*67e74705SXin Li Compile_multilib *string 36*67e74705SXin Li } 37*67e74705SXin Li } 38*67e74705SXin Li Multilib struct { 39*67e74705SXin Li Lib32 struct { 40*67e74705SXin Li Suffix *string 41*67e74705SXin Li } 42*67e74705SXin Li } 43*67e74705SXin Li } 44*67e74705SXin Li p := &props{} 45*67e74705SXin Li 46*67e74705SXin Li if ctx.Config().IsEnvTrue("FORCE_BUILD_LLVM_COMPONENTS") { 47*67e74705SXin Li p.Target.Host.Compile_multilib = proptools.StringPtr("both") 48*67e74705SXin Li p.Multilib.Lib32.Suffix = proptools.StringPtr("_32") 49*67e74705SXin Li } 50*67e74705SXin Li 51*67e74705SXin Li ctx.AppendProperties(p) 52*67e74705SXin Li} 53*67e74705SXin Li 54*67e74705SXin Lifunc clangBinaryHostFactory() android.Module { 55*67e74705SXin Li module, _ := cc.NewBinary(android.HostSupported) 56*67e74705SXin Li android.AddLoadHook(module, clangForceBuildLlvmComponents) 57*67e74705SXin Li 58*67e74705SXin Li return module.Init() 59*67e74705SXin Li} 60