2016-01-13 15:20:28 +08: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.
|
|
|
|
|
|
|
|
package cc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-09-15 11:29:05 +08:00
|
|
|
"sort"
|
2016-01-13 15:20:28 +08:00
|
|
|
"strings"
|
2017-11-15 06:09:14 +08:00
|
|
|
"sync"
|
2016-01-13 15:20:28 +08:00
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
"android/soong/android"
|
2016-07-30 04:44:28 +08:00
|
|
|
"android/soong/cc/config"
|
2016-01-13 15:20:28 +08:00
|
|
|
)
|
|
|
|
|
2017-11-15 06:09:14 +08:00
|
|
|
const (
|
2018-01-30 01:18:45 +08:00
|
|
|
modulesAddedWall = "ModulesAddedWall"
|
|
|
|
modulesUsingWnoError = "ModulesUsingWnoError"
|
|
|
|
modulesMissingProfileFile = "ModulesMissingProfileFile"
|
2017-11-15 06:09:14 +08:00
|
|
|
)
|
|
|
|
|
2016-01-13 15:20:28 +08:00
|
|
|
func init() {
|
2016-05-19 06:37:25 +08:00
|
|
|
android.RegisterMakeVarsProvider(pctx, makeVarsProvider)
|
2016-01-13 15:20:28 +08:00
|
|
|
}
|
|
|
|
|
2018-01-30 01:18:45 +08:00
|
|
|
func getNamedMapForConfig(config android.Config, name string) *sync.Map {
|
2017-11-15 06:09:14 +08:00
|
|
|
return config.Once(name, func() interface{} {
|
|
|
|
return &sync.Map{}
|
|
|
|
}).(*sync.Map)
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeStringOfKeys(ctx android.MakeVarsContext, setName string) string {
|
2018-01-30 01:18:45 +08:00
|
|
|
set := getNamedMapForConfig(ctx.Config(), setName)
|
2017-11-15 06:09:14 +08:00
|
|
|
keys := []string{}
|
|
|
|
set.Range(func(key interface{}, value interface{}) bool {
|
|
|
|
keys = append(keys, key.(string))
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
sort.Strings(keys)
|
|
|
|
return strings.Join(keys, " ")
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeStringOfWarningAllowedProjects() string {
|
|
|
|
allProjects := append([]string{}, config.WarningAllowedProjects...)
|
|
|
|
allProjects = append(allProjects, config.WarningAllowedOldProjects...)
|
|
|
|
sort.Strings(allProjects)
|
|
|
|
// Makefile rules use pattern "path/%" to match module paths.
|
|
|
|
if len(allProjects) > 0 {
|
|
|
|
return strings.Join(allProjects, "% ") + "%"
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func makeVarsProvider(ctx android.MakeVarsContext) {
|
2016-12-15 07:50:54 +08:00
|
|
|
ctx.Strict("LLVM_RELEASE_VERSION", "${config.ClangShortVersion}")
|
2016-07-30 04:44:28 +08:00
|
|
|
ctx.Strict("LLVM_PREBUILTS_VERSION", "${config.ClangVersion}")
|
|
|
|
ctx.Strict("LLVM_PREBUILTS_BASE", "${config.ClangBase}")
|
|
|
|
ctx.Strict("LLVM_PREBUILTS_PATH", "${config.ClangBin}")
|
|
|
|
ctx.Strict("CLANG", "${config.ClangBin}/clang")
|
|
|
|
ctx.Strict("CLANG_CXX", "${config.ClangBin}/clang++")
|
|
|
|
ctx.Strict("LLVM_AS", "${config.ClangBin}/llvm-as")
|
|
|
|
ctx.Strict("LLVM_LINK", "${config.ClangBin}/llvm-link")
|
2018-06-05 01:37:43 +08:00
|
|
|
ctx.Strict("LLVM_OBJCOPY", "${config.ClangBin}/llvm-objcopy")
|
|
|
|
ctx.Strict("LLVM_STRIP", "${config.ClangBin}/llvm-strip")
|
2016-09-27 06:45:04 +08:00
|
|
|
ctx.Strict("PATH_TO_CLANG_TIDY", "${config.ClangBin}/clang-tidy")
|
2018-08-28 07:19:59 +08:00
|
|
|
ctx.Strict("PATH_TO_CLANG_TIDY_SHELL", "${config.ClangTidyShellPath}")
|
2016-07-30 04:44:28 +08:00
|
|
|
ctx.StrictSorted("CLANG_CONFIG_UNKNOWN_CFLAGS", strings.Join(config.ClangUnknownCflags, " "))
|
|
|
|
|
2017-02-02 11:19:52 +08:00
|
|
|
ctx.Strict("RS_LLVM_PREBUILTS_VERSION", "${config.RSClangVersion}")
|
|
|
|
ctx.Strict("RS_LLVM_PREBUILTS_BASE", "${config.RSClangBase}")
|
|
|
|
ctx.Strict("RS_LLVM_PREBUILTS_PATH", "${config.RSLLVMPrebuiltsPath}")
|
2017-04-20 21:53:59 +08:00
|
|
|
ctx.Strict("RS_LLVM_INCLUDES", "${config.RSIncludePath}")
|
2017-02-02 11:19:52 +08:00
|
|
|
ctx.Strict("RS_CLANG", "${config.RSLLVMPrebuiltsPath}/clang")
|
|
|
|
ctx.Strict("RS_LLVM_AS", "${config.RSLLVMPrebuiltsPath}/llvm-as")
|
|
|
|
ctx.Strict("RS_LLVM_LINK", "${config.RSLLVMPrebuiltsPath}/llvm-link")
|
|
|
|
|
2018-06-07 05:42:44 +08:00
|
|
|
ctx.Strict("CLANG_EXTERNAL_CFLAGS", "${config.ClangExternalCflags}")
|
2016-07-30 04:44:28 +08:00
|
|
|
ctx.Strict("GLOBAL_CFLAGS_NO_OVERRIDE", "${config.NoOverrideGlobalCflags}")
|
|
|
|
ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${config.ClangExtraNoOverrideCflags}")
|
2016-05-28 06:23:38 +08:00
|
|
|
ctx.Strict("GLOBAL_CPPFLAGS_NO_OVERRIDE", "")
|
|
|
|
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
|
2016-07-08 12:40:39 +08:00
|
|
|
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
|
2016-05-28 06:23:38 +08:00
|
|
|
|
2018-03-13 06:30:26 +08:00
|
|
|
ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
|
2016-11-19 06:54:24 +08:00
|
|
|
|
2017-08-03 20:22:50 +08:00
|
|
|
ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(vndkCoreLibraries, " "))
|
|
|
|
ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(vndkSpLibraries, " "))
|
|
|
|
ctx.Strict("LLNDK_LIBRARIES", strings.Join(llndkLibraries, " "))
|
2017-08-16 13:05:54 +08:00
|
|
|
ctx.Strict("VNDK_PRIVATE_LIBRARIES", strings.Join(vndkPrivateLibraries, " "))
|
2017-08-03 20:22:50 +08:00
|
|
|
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
// Filter vendor_public_library that are exported to make
|
|
|
|
exportedVendorPublicLibraries := []string{}
|
|
|
|
ctx.SingletonContext().VisitAllModules(func(module android.Module) {
|
|
|
|
if ccModule, ok := module.(*Module); ok {
|
|
|
|
baseName := ccModule.BaseModuleName()
|
|
|
|
if inList(baseName, vendorPublicLibraries) && module.ExportedToMake() {
|
|
|
|
if !inList(baseName, exportedVendorPublicLibraries) {
|
|
|
|
exportedVendorPublicLibraries = append(exportedVendorPublicLibraries, baseName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
sort.Strings(exportedVendorPublicLibraries)
|
|
|
|
ctx.Strict("VENDOR_PUBLIC_LIBRARIES", strings.Join(exportedVendorPublicLibraries, " "))
|
|
|
|
|
2018-02-24 08:43:23 +08:00
|
|
|
sort.Strings(lsdumpPaths)
|
|
|
|
ctx.Strict("LSDUMP_PATHS", strings.Join(lsdumpPaths, " "))
|
|
|
|
|
2017-11-15 06:09:14 +08:00
|
|
|
ctx.Strict("ANDROID_WARNING_ALLOWED_PROJECTS", makeStringOfWarningAllowedProjects())
|
|
|
|
ctx.Strict("SOONG_MODULES_ADDED_WALL", makeStringOfKeys(ctx, modulesAddedWall))
|
|
|
|
ctx.Strict("SOONG_MODULES_USING_WNO_ERROR", makeStringOfKeys(ctx, modulesUsingWnoError))
|
2018-01-30 01:18:45 +08:00
|
|
|
ctx.Strict("SOONG_MODULES_MISSING_PGO_PROFILE_FILE", makeStringOfKeys(ctx, modulesMissingProfileFile))
|
2017-11-15 06:09:14 +08:00
|
|
|
|
2017-06-16 05:45:18 +08:00
|
|
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(asanCflags, " "))
|
|
|
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", strings.Join(asanLdflags, " "))
|
|
|
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", strings.Join(asanLibs, " "))
|
2016-10-14 07:44:07 +08:00
|
|
|
|
2018-08-29 04:51:05 +08:00
|
|
|
ctx.Strict("HWADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(hwasanCflags, " "))
|
|
|
|
|
2017-06-16 05:45:18 +08:00
|
|
|
ctx.Strict("CFI_EXTRA_CFLAGS", strings.Join(cfiCflags, " "))
|
2018-09-01 03:54:33 +08:00
|
|
|
ctx.Strict("CFI_EXTRA_ASFLAGS", strings.Join(cfiAsflags, " "))
|
2017-06-16 05:45:18 +08:00
|
|
|
ctx.Strict("CFI_EXTRA_LDFLAGS", strings.Join(cfiLdflags, " "))
|
2017-02-14 23:59:33 +08:00
|
|
|
|
2017-06-29 00:10:48 +08:00
|
|
|
ctx.Strict("INTEGER_OVERFLOW_EXTRA_CFLAGS", strings.Join(intOverflowCflags, " "))
|
|
|
|
|
2016-10-18 05:19:06 +08:00
|
|
|
ctx.Strict("DEFAULT_C_STD_VERSION", config.CStdVersion)
|
|
|
|
ctx.Strict("DEFAULT_CPP_STD_VERSION", config.CppStdVersion)
|
2017-02-04 08:13:38 +08:00
|
|
|
ctx.Strict("EXPERIMENTAL_C_STD_VERSION", config.ExperimentalCStdVersion)
|
|
|
|
ctx.Strict("EXPERIMENTAL_CPP_STD_VERSION", config.ExperimentalCppStdVersion)
|
2016-10-18 05:19:06 +08:00
|
|
|
|
2016-09-27 06:45:04 +08:00
|
|
|
ctx.Strict("DEFAULT_GLOBAL_TIDY_CHECKS", "${config.TidyDefaultGlobalChecks}")
|
|
|
|
ctx.Strict("DEFAULT_LOCAL_TIDY_CHECKS", joinLocalTidyChecks(config.DefaultLocalTidyChecks))
|
|
|
|
ctx.Strict("DEFAULT_TIDY_HEADER_DIRS", "${config.TidyDefaultHeaderDirs}")
|
|
|
|
|
2016-11-04 05:28:51 +08:00
|
|
|
ctx.Strict("AIDL_CPP", "${aidlCmd}")
|
|
|
|
|
2017-05-02 08:37:24 +08:00
|
|
|
ctx.Strict("RS_GLOBAL_INCLUDES", "${config.RsGlobalIncludes}")
|
|
|
|
|
2017-07-19 04:29:35 +08:00
|
|
|
nativeHelperIncludeFlags, err := ctx.Eval("${config.CommonNativehelperInclude}")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
nativeHelperIncludes, nativeHelperSystemIncludes := splitSystemIncludes(ctx, nativeHelperIncludeFlags)
|
|
|
|
if len(nativeHelperSystemIncludes) > 0 {
|
|
|
|
panic("native helper may not have any system includes")
|
|
|
|
}
|
|
|
|
ctx.Strict("JNI_H_INCLUDE", strings.Join(nativeHelperIncludes, " "))
|
|
|
|
|
2017-05-01 08:45:07 +08:00
|
|
|
includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes}")
|
2016-07-21 03:14:19 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
includes, systemIncludes := splitSystemIncludes(ctx, includeFlags)
|
|
|
|
ctx.StrictRaw("SRC_HEADERS", strings.Join(includes, " "))
|
|
|
|
ctx.StrictRaw("SRC_SYSTEM_HEADERS", strings.Join(systemIncludes, " "))
|
|
|
|
|
2016-09-15 11:29:05 +08:00
|
|
|
sort.Strings(ndkMigratedLibs)
|
2016-06-18 07:45:24 +08:00
|
|
|
ctx.Strict("NDK_MIGRATED_LIBS", strings.Join(ndkMigratedLibs, " "))
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
hostTargets := ctx.Config().Targets[android.Host]
|
|
|
|
makeVarsToolchain(ctx, "", hostTargets[0])
|
|
|
|
if len(hostTargets) > 1 {
|
|
|
|
makeVarsToolchain(ctx, "2ND_", hostTargets[1])
|
2016-01-13 15:20:28 +08:00
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
crossTargets := ctx.Config().Targets[android.HostCross]
|
|
|
|
if len(crossTargets) > 0 {
|
|
|
|
makeVarsToolchain(ctx, "", crossTargets[0])
|
|
|
|
if len(crossTargets) > 1 {
|
|
|
|
makeVarsToolchain(ctx, "2ND_", crossTargets[1])
|
2016-01-13 15:20:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
deviceTargets := ctx.Config().Targets[android.Device]
|
|
|
|
makeVarsToolchain(ctx, "", deviceTargets[0])
|
|
|
|
if len(deviceTargets) > 1 {
|
|
|
|
makeVarsToolchain(ctx, "2ND_", deviceTargets[1])
|
2016-01-13 15:20:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
2016-06-02 08:09:44 +08:00
|
|
|
target android.Target) {
|
2016-01-13 15:20:28 +08:00
|
|
|
var typePrefix string
|
2016-06-02 08:09:44 +08:00
|
|
|
switch target.Os.Class {
|
|
|
|
case android.Host:
|
|
|
|
typePrefix = "HOST_"
|
|
|
|
case android.HostCross:
|
|
|
|
typePrefix = "HOST_CROSS_"
|
|
|
|
case android.Device:
|
2016-01-13 15:20:28 +08:00
|
|
|
typePrefix = "TARGET_"
|
|
|
|
}
|
|
|
|
makePrefix := secondPrefix + typePrefix
|
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
toolchain := config.FindToolchain(target.Os, target.Arch)
|
2016-01-13 15:20:28 +08:00
|
|
|
|
2016-05-18 07:35:02 +08:00
|
|
|
var productExtraCflags string
|
|
|
|
var productExtraLdflags string
|
2016-06-02 08:09:44 +08:00
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
hod := "Host"
|
2016-06-02 08:09:44 +08:00
|
|
|
if target.Os.Class == android.Device {
|
2016-07-30 04:44:28 +08:00
|
|
|
hod = "Device"
|
2016-06-02 08:09:44 +08:00
|
|
|
}
|
|
|
|
|
2018-03-13 06:30:26 +08:00
|
|
|
if target.Os.Class == android.Host && ctx.Config().HostStaticBinaries() {
|
2016-05-18 07:35:02 +08:00
|
|
|
productExtraLdflags += "-static"
|
2016-05-17 10:32:33 +08:00
|
|
|
}
|
|
|
|
|
2016-05-20 07:58:46 +08:00
|
|
|
includeFlags, err := ctx.Eval(toolchain.IncludeFlags())
|
2016-06-02 08:09:44 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-07-21 03:14:19 +08:00
|
|
|
includes, systemIncludes := splitSystemIncludes(ctx, includeFlags)
|
|
|
|
ctx.StrictRaw(makePrefix+"C_INCLUDES", strings.Join(includes, " "))
|
|
|
|
ctx.StrictRaw(makePrefix+"C_SYSTEM_INCLUDES", strings.Join(systemIncludes, " "))
|
2016-05-20 07:58:46 +08:00
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
if target.Arch.ArchType == android.Arm {
|
2016-05-20 07:58:46 +08:00
|
|
|
flags, err := toolchain.InstructionSetFlags("arm")
|
2016-06-02 08:09:44 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-05-20 07:58:46 +08:00
|
|
|
ctx.Strict(makePrefix+"arm_CFLAGS", flags)
|
|
|
|
|
|
|
|
flags, err = toolchain.InstructionSetFlags("thumb")
|
2016-06-02 08:09:44 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-05-20 07:58:46 +08:00
|
|
|
ctx.Strict(makePrefix+"thumb_CFLAGS", flags)
|
|
|
|
}
|
2016-01-13 15:20:28 +08:00
|
|
|
|
2018-09-05 13:25:59 +08:00
|
|
|
clangPrefix := secondPrefix + "CLANG_" + typePrefix
|
|
|
|
clangExtras := "-target " + toolchain.ClangTriple()
|
|
|
|
clangExtras += " -B" + config.ToolPath(toolchain)
|
2016-05-20 07:58:46 +08:00
|
|
|
|
2018-09-05 13:25:59 +08:00
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_CFLAGS", strings.Join([]string{
|
|
|
|
toolchain.ClangCflags(),
|
|
|
|
"${config.CommonClangGlobalCflags}",
|
|
|
|
fmt.Sprintf("${config.%sClangGlobalCflags}", hod),
|
|
|
|
toolchain.ToolchainClangCflags(),
|
|
|
|
clangExtras,
|
|
|
|
productExtraCflags,
|
|
|
|
}, " "))
|
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_CPPFLAGS", strings.Join([]string{
|
|
|
|
"${config.CommonClangGlobalCppflags}",
|
|
|
|
fmt.Sprintf("${config.%sGlobalCppflags}", hod),
|
|
|
|
toolchain.ClangCppflags(),
|
|
|
|
}, " "))
|
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
|
|
|
|
fmt.Sprintf("${config.%sGlobalLdflags}", hod),
|
|
|
|
toolchain.ClangLdflags(),
|
|
|
|
toolchain.ToolchainClangLdflags(),
|
|
|
|
productExtraLdflags,
|
|
|
|
clangExtras,
|
|
|
|
}, " "))
|
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_LLDFLAGS", strings.Join([]string{
|
|
|
|
fmt.Sprintf("${config.%sGlobalLldflags}", hod),
|
|
|
|
toolchain.ClangLldflags(),
|
|
|
|
toolchain.ToolchainClangLdflags(),
|
|
|
|
productExtraLdflags,
|
|
|
|
clangExtras,
|
|
|
|
}, " "))
|
2017-11-30 12:48:03 +08:00
|
|
|
|
2018-09-05 13:25:59 +08:00
|
|
|
if target.Os.Class == android.Device {
|
|
|
|
ctx.Strict(secondPrefix+"ADDRESS_SANITIZER_RUNTIME_LIBRARY", strings.TrimSuffix(config.AddressSanitizerRuntimeLibrary(toolchain), ".so"))
|
|
|
|
ctx.Strict(secondPrefix+"HWADDRESS_SANITIZER_RUNTIME_LIBRARY", strings.TrimSuffix(config.HWAddressSanitizerRuntimeLibrary(toolchain), ".so"))
|
|
|
|
ctx.Strict(secondPrefix+"HWADDRESS_SANITIZER_STATIC_LIBRARY", strings.TrimSuffix(config.HWAddressSanitizerStaticLibrary(toolchain), ".a"))
|
|
|
|
ctx.Strict(secondPrefix+"UBSAN_RUNTIME_LIBRARY", strings.TrimSuffix(config.UndefinedBehaviorSanitizerRuntimeLibrary(toolchain), ".so"))
|
|
|
|
ctx.Strict(secondPrefix+"UBSAN_MINIMAL_RUNTIME_LIBRARY", strings.TrimSuffix(config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(toolchain), ".a"))
|
|
|
|
ctx.Strict(secondPrefix+"TSAN_RUNTIME_LIBRARY", strings.TrimSuffix(config.ThreadSanitizerRuntimeLibrary(toolchain), ".so"))
|
|
|
|
ctx.Strict(secondPrefix+"SCUDO_RUNTIME_LIBRARY", strings.TrimSuffix(config.ScudoRuntimeLibrary(toolchain), ".so"))
|
2016-01-13 15:20:28 +08:00
|
|
|
}
|
|
|
|
|
2018-09-05 13:25:59 +08:00
|
|
|
// This is used by external/gentoo/...
|
|
|
|
ctx.Strict("CLANG_CONFIG_"+target.Arch.ArchType.Name+"_"+typePrefix+"TRIPLE",
|
|
|
|
toolchain.ClangTriple())
|
2016-01-13 15:20:28 +08:00
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
if target.Os == android.Darwin {
|
2016-07-30 04:44:28 +08:00
|
|
|
ctx.Strict(makePrefix+"AR", "${config.MacArPath}")
|
2018-06-04 07:13:40 +08:00
|
|
|
ctx.Strict(makePrefix+"NM", "${config.MacToolPath}/nm")
|
|
|
|
ctx.Strict(makePrefix+"OTOOL", "${config.MacToolPath}/otool")
|
|
|
|
ctx.Strict(makePrefix+"STRIP", "${config.MacStripPath}")
|
2016-01-13 15:20:28 +08:00
|
|
|
} else {
|
2018-01-10 15:29:04 +08:00
|
|
|
ctx.Strict(makePrefix+"AR", "${config.ClangBin}/llvm-ar")
|
2016-01-13 15:20:28 +08:00
|
|
|
ctx.Strict(makePrefix+"READELF", gccCmd(toolchain, "readelf"))
|
|
|
|
ctx.Strict(makePrefix+"NM", gccCmd(toolchain, "nm"))
|
2018-06-04 07:13:40 +08:00
|
|
|
ctx.Strict(makePrefix+"STRIP", gccCmd(toolchain, "strip"))
|
2016-01-13 15:20:28 +08:00
|
|
|
}
|
2016-05-17 05:22:56 +08:00
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
if target.Os == android.Windows {
|
2016-05-17 05:22:56 +08:00
|
|
|
ctx.Strict(makePrefix+"OBJDUMP", gccCmd(toolchain, "objdump"))
|
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
if target.Os.Class == android.Device {
|
2016-05-17 05:22:56 +08:00
|
|
|
ctx.Strict(makePrefix+"OBJCOPY", gccCmd(toolchain, "objcopy"))
|
|
|
|
ctx.Strict(makePrefix+"LD", gccCmd(toolchain, "ld"))
|
2016-05-20 07:58:46 +08:00
|
|
|
ctx.Strict(makePrefix+"GCC_VERSION", toolchain.GccVersion())
|
|
|
|
ctx.Strict(makePrefix+"NDK_GCC_VERSION", toolchain.GccVersion())
|
2018-03-16 09:44:57 +08:00
|
|
|
ctx.Strict(makePrefix+"NDK_TRIPLE", config.NDKTriple(toolchain))
|
2016-05-17 05:22:56 +08:00
|
|
|
}
|
|
|
|
|
2017-09-23 04:55:22 +08:00
|
|
|
if target.Os.Class == android.Host || target.Os.Class == android.HostCross {
|
|
|
|
ctx.Strict(makePrefix+"AVAILABLE_LIBRARIES", strings.Join(toolchain.AvailableLibraries(), " "))
|
|
|
|
}
|
|
|
|
|
2016-05-27 06:23:07 +08:00
|
|
|
ctx.Strict(makePrefix+"TOOLCHAIN_ROOT", toolchain.GccRoot())
|
2016-05-17 05:22:56 +08:00
|
|
|
ctx.Strict(makePrefix+"TOOLS_PREFIX", gccCmd(toolchain, ""))
|
2016-05-20 07:58:46 +08:00
|
|
|
ctx.Strict(makePrefix+"SHLIB_SUFFIX", toolchain.ShlibSuffix())
|
|
|
|
ctx.Strict(makePrefix+"EXECUTABLE_SUFFIX", toolchain.ExecutableSuffix())
|
2016-01-13 15:20:28 +08:00
|
|
|
}
|
2016-07-21 03:14:19 +08:00
|
|
|
|
|
|
|
func splitSystemIncludes(ctx android.MakeVarsContext, val string) (includes, systemIncludes []string) {
|
|
|
|
flags, err := ctx.Eval(val)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
extract := func(flags string, dirs []string, prefix string) (string, []string, bool) {
|
|
|
|
if strings.HasPrefix(flags, prefix) {
|
|
|
|
flags = strings.TrimPrefix(flags, prefix)
|
|
|
|
flags = strings.TrimLeft(flags, " ")
|
|
|
|
s := strings.SplitN(flags, " ", 2)
|
|
|
|
dirs = append(dirs, s[0])
|
|
|
|
if len(s) > 1 {
|
|
|
|
return strings.TrimLeft(s[1], " "), dirs, true
|
|
|
|
}
|
|
|
|
return "", dirs, true
|
|
|
|
} else {
|
|
|
|
return flags, dirs, false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = strings.TrimLeft(flags, " ")
|
|
|
|
for flags != "" {
|
|
|
|
found := false
|
|
|
|
flags, includes, found = extract(flags, includes, "-I")
|
|
|
|
if !found {
|
|
|
|
flags, systemIncludes, found = extract(flags, systemIncludes, "-isystem ")
|
|
|
|
}
|
|
|
|
if !found {
|
|
|
|
panic(fmt.Errorf("Unexpected flag in %q", flags))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return includes, systemIncludes
|
|
|
|
}
|
2016-09-27 06:45:04 +08:00
|
|
|
|
|
|
|
func joinLocalTidyChecks(checks []config.PathBasedTidyCheck) string {
|
|
|
|
rets := make([]string, len(checks))
|
|
|
|
for i, check := range config.DefaultLocalTidyChecks {
|
|
|
|
rets[i] = check.PathPrefix + ":" + check.Checks
|
|
|
|
}
|
|
|
|
return strings.Join(rets, " ")
|
|
|
|
}
|