2016-07-29 21:48:20 +02:00
|
|
|
// Copyright 2016 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
package config
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Flags used by lots of devices. Putting them in package static variables will save bytes in
|
|
|
|
// build.ninja so they aren't repeated for every file
|
|
|
|
var (
|
|
|
|
commonGlobalCflags = []string{
|
|
|
|
"-DANDROID",
|
|
|
|
"-fmessage-length=0",
|
|
|
|
"-W",
|
|
|
|
"-Wall",
|
|
|
|
"-Wno-unused",
|
|
|
|
"-Winit-self",
|
|
|
|
"-Wpointer-arith",
|
|
|
|
|
|
|
|
// COMMON_RELEASE_CFLAGS
|
|
|
|
"-DNDEBUG",
|
|
|
|
"-UDEBUG",
|
|
|
|
}
|
|
|
|
|
|
|
|
deviceGlobalCflags = []string{
|
|
|
|
"-fdiagnostics-color",
|
|
|
|
|
|
|
|
// TARGET_ERROR_FLAGS
|
|
|
|
"-Werror=return-type",
|
|
|
|
"-Werror=non-virtual-dtor",
|
|
|
|
"-Werror=address",
|
|
|
|
"-Werror=sequence-point",
|
|
|
|
"-Werror=date-time",
|
|
|
|
}
|
|
|
|
|
|
|
|
hostGlobalCflags = []string{}
|
|
|
|
|
|
|
|
commonGlobalCppflags = []string{
|
|
|
|
"-Wsign-promo",
|
|
|
|
}
|
|
|
|
|
|
|
|
noOverrideGlobalCflags = []string{
|
|
|
|
"-Werror=int-to-pointer-cast",
|
|
|
|
"-Werror=pointer-to-int-cast",
|
|
|
|
}
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
IllegalFlags = []string{
|
2016-07-29 21:48:20 +02:00
|
|
|
"-w",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
var pctx = android.NewPackageContext("android/soong/cc/config")
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
func init() {
|
|
|
|
if android.BuildOs == android.Linux {
|
|
|
|
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
|
|
|
|
}
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("CommonGlobalCflags", strings.Join(commonGlobalCflags, " "))
|
|
|
|
pctx.StaticVariable("DeviceGlobalCflags", strings.Join(deviceGlobalCflags, " "))
|
|
|
|
pctx.StaticVariable("HostGlobalCflags", strings.Join(hostGlobalCflags, " "))
|
|
|
|
pctx.StaticVariable("NoOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " "))
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("CommonGlobalCppflags", strings.Join(commonGlobalCppflags, " "))
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("CommonClangGlobalCflags",
|
|
|
|
strings.Join(append(ClangFilterUnknownCflags(commonGlobalCflags), "${ClangExtraCflags}"), " "))
|
|
|
|
pctx.StaticVariable("DeviceClangGlobalCflags",
|
|
|
|
strings.Join(append(ClangFilterUnknownCflags(deviceGlobalCflags), "${ClangExtraTargetCflags}"), " "))
|
|
|
|
pctx.StaticVariable("HostClangGlobalCflags",
|
|
|
|
strings.Join(ClangFilterUnknownCflags(hostGlobalCflags), " "))
|
|
|
|
pctx.StaticVariable("NoOverrideClangGlobalCflags",
|
|
|
|
strings.Join(append(ClangFilterUnknownCflags(noOverrideGlobalCflags), "${ClangExtraNoOverrideCflags}"), " "))
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("CommonClangGlobalCppflags",
|
|
|
|
strings.Join(append(ClangFilterUnknownCflags(commonGlobalCppflags), "${ClangExtraCppflags}"), " "))
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-09-15 18:30:46 +02:00
|
|
|
// Everything in these lists is a crime against abstraction and dependency tracking.
|
2016-07-29 21:48:20 +02:00
|
|
|
// Do not add anything to this list.
|
2016-09-15 18:30:46 +02:00
|
|
|
pctx.PrefixedPathsForOptionalSourceVariable("CommonGlobalIncludes", "-I",
|
2016-09-23 00:29:50 +02:00
|
|
|
[]string{
|
2016-09-23 17:48:51 +02:00
|
|
|
"system/core/include",
|
2016-09-23 21:20:54 +02:00
|
|
|
})
|
|
|
|
pctx.PrefixedPathsForOptionalSourceVariable("CommonGlobalSystemIncludes", "-isystem ",
|
|
|
|
[]string{
|
2016-07-29 21:48:20 +02:00
|
|
|
"system/media/audio/include",
|
|
|
|
"hardware/libhardware/include",
|
|
|
|
"hardware/libhardware_legacy/include",
|
|
|
|
"hardware/ril/include",
|
|
|
|
"libnativehelper/include",
|
|
|
|
"frameworks/native/include",
|
|
|
|
"frameworks/native/opengl/include",
|
|
|
|
"frameworks/av/include",
|
|
|
|
"frameworks/base/include",
|
|
|
|
})
|
|
|
|
// This is used by non-NDK modules to get jni.h. export_include_dirs doesn't help
|
|
|
|
// with this, since there is no associated library.
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.PrefixedPathsForOptionalSourceVariable("CommonNativehelperInclude", "-I",
|
2016-07-29 21:48:20 +02:00
|
|
|
[]string{"libnativehelper/include/nativehelper"})
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.SourcePathVariable("ClangDefaultBase", "prebuilts/clang/host")
|
|
|
|
pctx.VariableFunc("ClangBase", func(config interface{}) (string, error) {
|
2016-07-29 21:48:20 +02:00
|
|
|
if override := config.(android.Config).Getenv("LLVM_PREBUILTS_BASE"); override != "" {
|
|
|
|
return override, nil
|
|
|
|
}
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${ClangDefaultBase}", nil
|
2016-07-29 21:48:20 +02:00
|
|
|
})
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.VariableFunc("ClangVersion", func(config interface{}) (string, error) {
|
2016-07-29 21:48:20 +02:00
|
|
|
if override := config.(android.Config).Getenv("LLVM_PREBUILTS_VERSION"); override != "" {
|
|
|
|
return override, nil
|
|
|
|
}
|
2016-08-24 18:44:55 +02:00
|
|
|
return "clang-3217047", nil
|
2016-07-29 21:48:20 +02:00
|
|
|
})
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("ClangPath", "${ClangBase}/${HostPrebuiltTag}/${ClangVersion}")
|
|
|
|
pctx.StaticVariable("ClangBin", "${ClangPath}/bin")
|
|
|
|
|
|
|
|
pctx.StaticVariable("ClangAsanLibDir", "${ClangPath}/lib64/clang/3.8/lib/linux")
|
2016-08-26 21:55:49 +02:00
|
|
|
|
|
|
|
pctx.VariableFunc("CcWrapper", func(config interface{}) (string, error) {
|
|
|
|
if override := config.(android.Config).Getenv("CC_WRAPPER"); override != "" {
|
|
|
|
return override + " ", nil
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
})
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
|
|
|
|
|
|
|
|
func bionicHeaders(bionicArch, kernelArch string) string {
|
|
|
|
return strings.Join([]string{
|
|
|
|
"-isystem bionic/libc/arch-" + bionicArch + "/include",
|
|
|
|
"-isystem bionic/libc/include",
|
|
|
|
"-isystem bionic/libc/kernel/uapi",
|
|
|
|
"-isystem bionic/libc/kernel/uapi/asm-" + kernelArch,
|
|
|
|
"-isystem bionic/libc/kernel/android/uapi",
|
|
|
|
}, " ")
|
|
|
|
}
|