2016-01-13 08:20:28 +01: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 05:29:05 +02:00
|
|
|
"sort"
|
2016-01-13 08:20:28 +01:00
|
|
|
"strings"
|
2017-11-14 23:09:14 +01:00
|
|
|
"sync"
|
2016-01-13 08:20:28 +01:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2016-07-29 22:44:28 +02:00
|
|
|
"android/soong/cc/config"
|
2016-01-13 08:20:28 +01:00
|
|
|
)
|
|
|
|
|
2019-02-04 20:22:08 +01:00
|
|
|
var (
|
2022-05-19 14:11:10 +02:00
|
|
|
modulesWarningsAllowedKey = android.NewOnceKey("ModulesWarningsAllowed")
|
2019-02-04 20:22:08 +01:00
|
|
|
modulesUsingWnoErrorKey = android.NewOnceKey("ModulesUsingWnoError")
|
|
|
|
modulesMissingProfileFileKey = android.NewOnceKey("ModulesMissingProfileFile")
|
2024-05-07 07:47:35 +02:00
|
|
|
sanitizerVariables = map[string]string{
|
|
|
|
"ADDRESS_SANITIZER_RUNTIME_LIBRARY": config.AddressSanitizerRuntimeLibrary(),
|
|
|
|
"HWADDRESS_SANITIZER_RUNTIME_LIBRARY": config.HWAddressSanitizerRuntimeLibrary(),
|
|
|
|
"HWADDRESS_SANITIZER_STATIC_LIBRARY": config.HWAddressSanitizerStaticLibrary(),
|
|
|
|
"UBSAN_RUNTIME_LIBRARY": config.UndefinedBehaviorSanitizerRuntimeLibrary(),
|
|
|
|
"UBSAN_MINIMAL_RUNTIME_LIBRARY": config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(),
|
|
|
|
"TSAN_RUNTIME_LIBRARY": config.ThreadSanitizerRuntimeLibrary(),
|
|
|
|
"SCUDO_RUNTIME_LIBRARY": config.ScudoRuntimeLibrary(),
|
|
|
|
"SCUDO_MINIMAL_RUNTIME_LIBRARY": config.ScudoMinimalRuntimeLibrary(),
|
|
|
|
}
|
2017-11-14 23:09:14 +01:00
|
|
|
)
|
|
|
|
|
2016-01-13 08:20:28 +01:00
|
|
|
func init() {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.RegisterMakeVarsProvider(pctx, makeVarsProvider)
|
2016-01-13 08:20:28 +01:00
|
|
|
}
|
|
|
|
|
2019-02-04 20:22:08 +01:00
|
|
|
func getNamedMapForConfig(config android.Config, key android.OnceKey) *sync.Map {
|
|
|
|
return config.Once(key, func() interface{} {
|
2017-11-14 23:09:14 +01:00
|
|
|
return &sync.Map{}
|
|
|
|
}).(*sync.Map)
|
|
|
|
}
|
|
|
|
|
2019-02-04 20:22:08 +01:00
|
|
|
func makeStringOfKeys(ctx android.MakeVarsContext, key android.OnceKey) string {
|
|
|
|
set := getNamedMapForConfig(ctx.Config(), key)
|
2017-11-14 23:09:14 +01: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...)
|
|
|
|
sort.Strings(allProjects)
|
|
|
|
// Makefile rules use pattern "path/%" to match module paths.
|
|
|
|
if len(allProjects) > 0 {
|
|
|
|
return strings.Join(allProjects, "% ") + "%"
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 15:06:23 +02:00
|
|
|
type notOnHostContext struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *notOnHostContext) Host() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func makeVarsProvider(ctx android.MakeVarsContext) {
|
2016-12-15 00:50:54 +01:00
|
|
|
ctx.Strict("LLVM_RELEASE_VERSION", "${config.ClangShortVersion}")
|
2016-07-29 22:44:28 +02: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-04 19:37:43 +02:00
|
|
|
ctx.Strict("LLVM_OBJCOPY", "${config.ClangBin}/llvm-objcopy")
|
|
|
|
ctx.Strict("LLVM_STRIP", "${config.ClangBin}/llvm-strip")
|
2016-09-27 00:45:04 +02:00
|
|
|
ctx.Strict("PATH_TO_CLANG_TIDY", "${config.ClangBin}/clang-tidy")
|
2016-07-29 22:44:28 +02:00
|
|
|
ctx.StrictSorted("CLANG_CONFIG_UNKNOWN_CFLAGS", strings.Join(config.ClangUnknownCflags, " "))
|
|
|
|
|
2017-02-02 04:19:52 +01: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 15:53:59 +02:00
|
|
|
ctx.Strict("RS_LLVM_INCLUDES", "${config.RSIncludePath}")
|
2017-02-02 04:19:52 +01: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")
|
|
|
|
|
2021-07-15 03:45:05 +02:00
|
|
|
ctx.Strict("CLANG_EXTERNAL_CFLAGS", "${config.ExternalCflags}")
|
|
|
|
ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${config.NoOverrideGlobalCflags}")
|
2023-01-12 08:26:20 +01:00
|
|
|
ctx.Strict("GLOBAL_CLANG_CFLAGS_64_NO_OVERRIDE", "${config.NoOverride64GlobalCflags}")
|
2016-05-28 00:23:38 +02:00
|
|
|
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
|
2021-12-15 00:07:08 +01:00
|
|
|
ctx.Strict("GLOBAL_CLANG_EXTERNAL_CFLAGS_NO_OVERRIDE", "${config.NoOverrideExternalGlobalCflags}")
|
2016-05-28 00:23:38 +02: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 10:23:01 +01:00
|
|
|
// Filter vendor_public_library that are exported to make
|
|
|
|
exportedVendorPublicLibraries := []string{}
|
2019-02-07 23:25:51 +01:00
|
|
|
ctx.VisitAllModules(func(module android.Module) {
|
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 10:23:01 +01:00
|
|
|
if ccModule, ok := module.(*Module); ok {
|
|
|
|
baseName := ccModule.BaseModuleName()
|
2021-04-27 22:06:04 +02:00
|
|
|
if ccModule.IsVendorPublicLibrary() && module.ExportedToMake() {
|
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 10:23:01 +01:00
|
|
|
if !inList(baseName, exportedVendorPublicLibraries) {
|
|
|
|
exportedVendorPublicLibraries = append(exportedVendorPublicLibraries, baseName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
sort.Strings(exportedVendorPublicLibraries)
|
|
|
|
ctx.Strict("VENDOR_PUBLIC_LIBRARIES", strings.Join(exportedVendorPublicLibraries, " "))
|
|
|
|
|
2018-02-24 01:43:23 +01:00
|
|
|
sort.Strings(lsdumpPaths)
|
|
|
|
ctx.Strict("LSDUMP_PATHS", strings.Join(lsdumpPaths, " "))
|
|
|
|
|
2017-11-14 23:09:14 +01:00
|
|
|
ctx.Strict("ANDROID_WARNING_ALLOWED_PROJECTS", makeStringOfWarningAllowedProjects())
|
2022-05-19 14:11:10 +02:00
|
|
|
ctx.Strict("SOONG_MODULES_WARNINGS_ALLOWED", makeStringOfKeys(ctx, modulesWarningsAllowedKey))
|
2019-02-04 20:22:08 +01:00
|
|
|
ctx.Strict("SOONG_MODULES_USING_WNO_ERROR", makeStringOfKeys(ctx, modulesUsingWnoErrorKey))
|
|
|
|
ctx.Strict("SOONG_MODULES_MISSING_PGO_PROFILE_FILE", makeStringOfKeys(ctx, modulesMissingProfileFileKey))
|
2017-11-14 23:09:14 +01:00
|
|
|
|
2024-04-04 02:56:15 +02:00
|
|
|
ctx.Strict("CLANG_COVERAGE_CONFIG_CFLAGS", strings.Join(clangCoverageCFlags, " "))
|
|
|
|
ctx.Strict("CLANG_COVERAGE_CONFIG_COMMFLAGS", strings.Join(clangCoverageCommonFlags, " "))
|
|
|
|
ctx.Strict("CLANG_COVERAGE_HOST_LDFLAGS", strings.Join(clangCoverageHostLdFlags, " "))
|
|
|
|
ctx.Strict("CLANG_COVERAGE_INSTR_PROFILE", profileInstrFlag)
|
|
|
|
ctx.Strict("CLANG_COVERAGE_CONTINUOUS_FLAGS", strings.Join(clangContinuousCoverageFlags, " "))
|
|
|
|
ctx.Strict("CLANG_COVERAGE_HWASAN_FLAGS", strings.Join(clangCoverageHWASanFlags, " "))
|
2023-12-01 05:29:44 +01:00
|
|
|
|
2017-06-15 23:45:18 +02:00
|
|
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(asanCflags, " "))
|
|
|
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", strings.Join(asanLdflags, " "))
|
2016-10-14 01:44:07 +02:00
|
|
|
|
2018-08-28 22:51:05 +02:00
|
|
|
ctx.Strict("HWADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(hwasanCflags, " "))
|
2018-10-04 03:22:57 +02:00
|
|
|
ctx.Strict("HWADDRESS_SANITIZER_GLOBAL_OPTIONS", strings.Join(hwasanGlobalOptions, ","))
|
2018-08-28 22:51:05 +02:00
|
|
|
|
2017-06-15 23:45:18 +02:00
|
|
|
ctx.Strict("CFI_EXTRA_CFLAGS", strings.Join(cfiCflags, " "))
|
2018-08-31 21:54:33 +02:00
|
|
|
ctx.Strict("CFI_EXTRA_ASFLAGS", strings.Join(cfiAsflags, " "))
|
2017-06-15 23:45:18 +02:00
|
|
|
ctx.Strict("CFI_EXTRA_LDFLAGS", strings.Join(cfiLdflags, " "))
|
2017-02-14 16:59:33 +01:00
|
|
|
|
2017-06-28 18:10:48 +02:00
|
|
|
ctx.Strict("INTEGER_OVERFLOW_EXTRA_CFLAGS", strings.Join(intOverflowCflags, " "))
|
|
|
|
|
2016-10-17 23:19:06 +02:00
|
|
|
ctx.Strict("DEFAULT_C_STD_VERSION", config.CStdVersion)
|
|
|
|
ctx.Strict("DEFAULT_CPP_STD_VERSION", config.CppStdVersion)
|
2017-02-04 01:13:38 +01:00
|
|
|
ctx.Strict("EXPERIMENTAL_C_STD_VERSION", config.ExperimentalCStdVersion)
|
|
|
|
ctx.Strict("EXPERIMENTAL_CPP_STD_VERSION", config.ExperimentalCppStdVersion)
|
2016-10-17 23:19:06 +02:00
|
|
|
|
2016-09-27 00:45:04 +02: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}")
|
2018-09-22 00:12:44 +02:00
|
|
|
ctx.Strict("WITH_TIDY_FLAGS", "${config.TidyWithTidyFlags}")
|
2016-09-27 00:45:04 +02:00
|
|
|
|
2016-11-03 22:28:51 +01:00
|
|
|
ctx.Strict("AIDL_CPP", "${aidlCmd}")
|
2019-11-26 19:32:50 +01:00
|
|
|
ctx.Strict("ALLOWED_MANUAL_INTERFACE_PATHS", strings.Join(allowedManualInterfacePaths, " "))
|
2016-11-03 22:28:51 +01:00
|
|
|
|
2017-05-02 02:37:24 +02:00
|
|
|
ctx.Strict("RS_GLOBAL_INCLUDES", "${config.RsGlobalIncludes}")
|
|
|
|
|
2018-09-08 08:16:36 +02:00
|
|
|
ctx.Strict("SOONG_STRIP_PATH", "${stripPath}")
|
|
|
|
ctx.Strict("XZ", "${xzCmd}")
|
2021-04-29 22:06:47 +02:00
|
|
|
ctx.Strict("CREATE_MINIDEBUGINFO", "${createMiniDebugInfo}")
|
2018-09-08 08:16:36 +02:00
|
|
|
|
2017-05-01 02:45:07 +02:00
|
|
|
includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes}")
|
2016-07-20 21:14:19 +02: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, " "))
|
|
|
|
|
2020-10-30 04:47:22 +01:00
|
|
|
ndkKnownLibs := *getNDKKnownLibs(ctx.Config())
|
2020-06-30 21:32:51 +02:00
|
|
|
sort.Strings(ndkKnownLibs)
|
2020-06-30 21:46:21 +02:00
|
|
|
ctx.Strict("NDK_KNOWN_LIBS", strings.Join(ndkKnownLibs, " "))
|
2016-06-18 01:45:24 +02:00
|
|
|
|
2021-07-20 18:47:41 +02:00
|
|
|
hostTargets := ctx.Config().Targets[ctx.Config().BuildOS]
|
2016-06-02 02:09:44 +02:00
|
|
|
makeVarsToolchain(ctx, "", hostTargets[0])
|
|
|
|
if len(hostTargets) > 1 {
|
|
|
|
makeVarsToolchain(ctx, "2ND_", hostTargets[1])
|
2016-01-13 08:20:28 +01:00
|
|
|
}
|
|
|
|
|
2018-10-11 02:02:29 +02:00
|
|
|
deviceTargets := ctx.Config().Targets[android.Android]
|
2016-06-02 02:09:44 +02:00
|
|
|
makeVarsToolchain(ctx, "", deviceTargets[0])
|
|
|
|
if len(deviceTargets) > 1 {
|
|
|
|
makeVarsToolchain(ctx, "2ND_", deviceTargets[1])
|
2016-01-13 08:20:28 +01:00
|
|
|
}
|
2024-04-04 02:56:15 +02:00
|
|
|
|
|
|
|
makeLlndkVars(ctx)
|
2016-01-13 08:20:28 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
2016-06-02 02:09:44 +02:00
|
|
|
target android.Target) {
|
2016-01-13 08:20:28 +01:00
|
|
|
var typePrefix string
|
2016-06-02 02:09:44 +02:00
|
|
|
switch target.Os.Class {
|
|
|
|
case android.Host:
|
|
|
|
typePrefix = "HOST_"
|
|
|
|
case android.Device:
|
2016-01-13 08:20:28 +01:00
|
|
|
typePrefix = "TARGET_"
|
|
|
|
}
|
|
|
|
makePrefix := secondPrefix + typePrefix
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
toolchain := config.FindToolchain(target.Os, target.Arch)
|
2016-01-13 08:20:28 +01:00
|
|
|
|
2016-05-18 01:35:02 +02:00
|
|
|
var productExtraCflags string
|
|
|
|
var productExtraLdflags string
|
2016-06-02 02:09:44 +02:00
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
hod := "Host"
|
2016-06-02 02:09:44 +02:00
|
|
|
if target.Os.Class == android.Device {
|
2016-07-29 22:44:28 +02:00
|
|
|
hod = "Device"
|
2016-06-02 02:09:44 +02:00
|
|
|
}
|
|
|
|
|
2018-03-12 23:30:26 +01:00
|
|
|
if target.Os.Class == android.Host && ctx.Config().HostStaticBinaries() {
|
2016-05-18 01:35:02 +02:00
|
|
|
productExtraLdflags += "-static"
|
2016-05-17 04:32:33 +02:00
|
|
|
}
|
|
|
|
|
2016-05-20 01:58:46 +02:00
|
|
|
includeFlags, err := ctx.Eval(toolchain.IncludeFlags())
|
2016-06-02 02:09:44 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-07-20 21:14:19 +02: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 01:58:46 +02:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
if target.Arch.ArchType == android.Arm {
|
2021-07-15 02:03:16 +02:00
|
|
|
flags, err := toolchain.InstructionSetFlags("arm")
|
2016-06-02 02:09:44 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-05-20 01:58:46 +02:00
|
|
|
ctx.Strict(makePrefix+"arm_CFLAGS", flags)
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
flags, err = toolchain.InstructionSetFlags("thumb")
|
2016-06-02 02:09:44 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-05-20 01:58:46 +02:00
|
|
|
ctx.Strict(makePrefix+"thumb_CFLAGS", flags)
|
|
|
|
}
|
2016-01-13 08:20:28 +01:00
|
|
|
|
2018-09-05 07:25:59 +02:00
|
|
|
clangPrefix := secondPrefix + "CLANG_" + typePrefix
|
2016-05-20 01:58:46 +02:00
|
|
|
|
2019-07-23 01:36:06 +02:00
|
|
|
ctx.Strict(clangPrefix+"TRIPLE", toolchain.ClangTriple())
|
2018-09-05 07:25:59 +02:00
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_CFLAGS", strings.Join([]string{
|
2021-07-15 02:03:16 +02:00
|
|
|
toolchain.Cflags(),
|
2021-07-15 03:45:05 +02:00
|
|
|
"${config.CommonGlobalCflags}",
|
|
|
|
fmt.Sprintf("${config.%sGlobalCflags}", hod),
|
2021-07-15 02:03:16 +02:00
|
|
|
toolchain.ToolchainCflags(),
|
2018-09-05 07:25:59 +02:00
|
|
|
productExtraCflags,
|
|
|
|
}, " "))
|
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_CPPFLAGS", strings.Join([]string{
|
2021-07-15 03:45:05 +02:00
|
|
|
"${config.CommonGlobalCppflags}",
|
2018-09-05 07:25:59 +02:00
|
|
|
fmt.Sprintf("${config.%sGlobalCppflags}", hod),
|
2021-07-15 02:03:16 +02:00
|
|
|
toolchain.Cppflags(),
|
2018-09-05 07:25:59 +02:00
|
|
|
}, " "))
|
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
|
|
|
|
fmt.Sprintf("${config.%sGlobalLdflags}", hod),
|
2021-07-15 02:03:16 +02:00
|
|
|
toolchain.Ldflags(),
|
|
|
|
toolchain.ToolchainLdflags(),
|
2018-09-05 07:25:59 +02:00
|
|
|
productExtraLdflags,
|
|
|
|
}, " "))
|
|
|
|
ctx.Strict(clangPrefix+"GLOBAL_LLDFLAGS", strings.Join([]string{
|
|
|
|
fmt.Sprintf("${config.%sGlobalLldflags}", hod),
|
2021-07-15 02:03:16 +02:00
|
|
|
toolchain.Lldflags(),
|
|
|
|
toolchain.ToolchainLdflags(),
|
2018-09-05 07:25:59 +02:00
|
|
|
productExtraLdflags,
|
|
|
|
}, " "))
|
2017-11-30 05:48:03 +01:00
|
|
|
|
2018-09-05 07:25:59 +02:00
|
|
|
if target.Os.Class == android.Device {
|
2022-02-17 20:16:08 +01:00
|
|
|
for variable, value := range sanitizerVariables {
|
|
|
|
ctx.Strict(secondPrefix+variable, value)
|
|
|
|
}
|
2016-01-13 08:20:28 +01:00
|
|
|
}
|
|
|
|
|
2018-09-05 07:25:59 +02:00
|
|
|
// This is used by external/gentoo/...
|
|
|
|
ctx.Strict("CLANG_CONFIG_"+target.Arch.ArchType.Name+"_"+typePrefix+"TRIPLE",
|
|
|
|
toolchain.ClangTriple())
|
2016-01-13 08:20:28 +01:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
if target.Os == android.Darwin {
|
2016-07-29 22:44:28 +02:00
|
|
|
ctx.Strict(makePrefix+"AR", "${config.MacArPath}")
|
2018-06-04 01:13:40 +02:00
|
|
|
ctx.Strict(makePrefix+"NM", "${config.MacToolPath}/nm")
|
|
|
|
ctx.Strict(makePrefix+"OTOOL", "${config.MacToolPath}/otool")
|
|
|
|
ctx.Strict(makePrefix+"STRIP", "${config.MacStripPath}")
|
2016-01-13 08:20:28 +01:00
|
|
|
} else {
|
2018-01-10 08:29:04 +01:00
|
|
|
ctx.Strict(makePrefix+"AR", "${config.ClangBin}/llvm-ar")
|
2021-04-21 19:22:55 +02:00
|
|
|
ctx.Strict(makePrefix+"READELF", "${config.ClangBin}/llvm-readelf")
|
|
|
|
ctx.Strict(makePrefix+"NM", "${config.ClangBin}/llvm-nm")
|
|
|
|
ctx.Strict(makePrefix+"STRIP", "${config.ClangBin}/llvm-strip")
|
2016-01-13 08:20:28 +01:00
|
|
|
}
|
2016-05-16 23:22:56 +02:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
if target.Os.Class == android.Device {
|
2021-05-05 07:38:05 +02:00
|
|
|
ctx.Strict(makePrefix+"OBJCOPY", "${config.ClangBin}/llvm-objcopy")
|
|
|
|
ctx.Strict(makePrefix+"LD", "${config.ClangBin}/lld")
|
2018-03-16 02:44:57 +01:00
|
|
|
ctx.Strict(makePrefix+"NDK_TRIPLE", config.NDKTriple(toolchain))
|
2021-05-07 20:55:30 +02:00
|
|
|
ctx.Strict(makePrefix+"TOOLS_PREFIX", "${config.ClangBin}/llvm-")
|
2016-05-16 23:22:56 +02:00
|
|
|
}
|
|
|
|
|
2019-01-26 02:00:45 +01:00
|
|
|
if target.Os.Class == android.Host {
|
2017-09-22 22:55:22 +02:00
|
|
|
ctx.Strict(makePrefix+"AVAILABLE_LIBRARIES", strings.Join(toolchain.AvailableLibraries(), " "))
|
|
|
|
}
|
|
|
|
|
2016-05-20 01:58:46 +02:00
|
|
|
ctx.Strict(makePrefix+"SHLIB_SUFFIX", toolchain.ShlibSuffix())
|
|
|
|
ctx.Strict(makePrefix+"EXECUTABLE_SUFFIX", toolchain.ExecutableSuffix())
|
2016-01-13 08:20:28 +01:00
|
|
|
}
|
2016-07-20 21:14:19 +02: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 00:45:04 +02: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, " ")
|
|
|
|
}
|