Switch PackageContext functions to take a ctx am: 54daaf0371
am: f34acc112e
Change-Id: I11d13250bbe1b40179b764799ca607b2bacc607b
This commit is contained in:
@@ -197,10 +197,10 @@ var (
|
||||
_ = pctx.SourcePathVariable("sAbiDiffer", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-diff")
|
||||
|
||||
sAbiDiff = pctx.AndroidRuleFunc("sAbiDiff",
|
||||
func(config android.Config) (blueprint.RuleParams, error) {
|
||||
func(ctx android.PackageRuleContext) blueprint.RuleParams {
|
||||
|
||||
commandStr := "($sAbiDiffer $allowFlags -lib $libName -arch $arch -check-all-apis -o ${out} -new $in -old $referenceDump)"
|
||||
distDir := config.ProductVariables.DistDir
|
||||
distDir := ctx.Config().ProductVariables.DistDir
|
||||
if distDir != nil && *distDir != "" {
|
||||
distAbiDiffDir := *distDir + "/abidiffs/"
|
||||
commandStr += " || (mkdir -p " + distAbiDiffDir + " && cp ${out} " + distAbiDiffDir + " && exit 1)"
|
||||
@@ -208,7 +208,7 @@ var (
|
||||
return blueprint.RuleParams{
|
||||
Command: commandStr,
|
||||
CommandDeps: []string{"$sAbiDiffer"},
|
||||
}, nil
|
||||
}
|
||||
},
|
||||
"allowFlags", "referenceDump", "libName", "arch")
|
||||
|
||||
|
@@ -180,26 +180,26 @@ func init() {
|
||||
[]string{"libnativehelper/include_jni"})
|
||||
|
||||
pctx.SourcePathVariable("ClangDefaultBase", ClangDefaultBase)
|
||||
pctx.VariableFunc("ClangBase", func(config android.Config) (string, error) {
|
||||
if override := config.Getenv("LLVM_PREBUILTS_BASE"); override != "" {
|
||||
return override, nil
|
||||
pctx.VariableFunc("ClangBase", func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv("LLVM_PREBUILTS_BASE"); override != "" {
|
||||
return override
|
||||
}
|
||||
return "${ClangDefaultBase}", nil
|
||||
return "${ClangDefaultBase}"
|
||||
})
|
||||
pctx.VariableFunc("ClangVersion", func(config android.Config) (string, error) {
|
||||
if override := config.Getenv("LLVM_PREBUILTS_VERSION"); override != "" {
|
||||
return override, nil
|
||||
pctx.VariableFunc("ClangVersion", func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv("LLVM_PREBUILTS_VERSION"); override != "" {
|
||||
return override
|
||||
}
|
||||
return ClangDefaultVersion, nil
|
||||
return ClangDefaultVersion
|
||||
})
|
||||
pctx.StaticVariable("ClangPath", "${ClangBase}/${HostPrebuiltTag}/${ClangVersion}")
|
||||
pctx.StaticVariable("ClangBin", "${ClangPath}/bin")
|
||||
|
||||
pctx.VariableFunc("ClangShortVersion", func(config android.Config) (string, error) {
|
||||
if override := config.Getenv("LLVM_RELEASE_VERSION"); override != "" {
|
||||
return override, nil
|
||||
pctx.VariableFunc("ClangShortVersion", func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv("LLVM_RELEASE_VERSION"); override != "" {
|
||||
return override
|
||||
}
|
||||
return ClangDefaultShortVersion, nil
|
||||
return ClangDefaultShortVersion
|
||||
})
|
||||
pctx.StaticVariable("ClangAsanLibDir", "${ClangBase}/linux-x86/${ClangVersion}/lib64/clang/${ClangShortVersion}/lib/linux")
|
||||
if runtime.GOOS == "darwin" {
|
||||
@@ -222,11 +222,11 @@ func init() {
|
||||
"frameworks/rs/script_api/include",
|
||||
})
|
||||
|
||||
pctx.VariableFunc("CcWrapper", func(config android.Config) (string, error) {
|
||||
if override := config.Getenv("CC_WRAPPER"); override != "" {
|
||||
return override + " ", nil
|
||||
pctx.VariableFunc("CcWrapper", func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv("CC_WRAPPER"); override != "" {
|
||||
return override + " "
|
||||
}
|
||||
return "", nil
|
||||
return ""
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -15,9 +15,8 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -25,9 +24,9 @@ func init() {
|
||||
// Global tidy checks include only google*, performance*,
|
||||
// and misc-macro-parentheses, but not google-readability*
|
||||
// or google-runtime-references.
|
||||
pctx.VariableFunc("TidyDefaultGlobalChecks", func(config android.Config) (string, error) {
|
||||
if override := config.Getenv("DEFAULT_GLOBAL_TIDY_CHECKS"); override != "" {
|
||||
return override, nil
|
||||
pctx.VariableFunc("TidyDefaultGlobalChecks", func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv("DEFAULT_GLOBAL_TIDY_CHECKS"); override != "" {
|
||||
return override
|
||||
}
|
||||
return strings.Join([]string{
|
||||
"-*",
|
||||
@@ -36,14 +35,14 @@ func init() {
|
||||
"performance*",
|
||||
"-google-readability*",
|
||||
"-google-runtime-references",
|
||||
}, ","), nil
|
||||
}, ",")
|
||||
})
|
||||
|
||||
// There are too many clang-tidy warnings in external and vendor projects.
|
||||
// Enable only some google checks for these projects.
|
||||
pctx.VariableFunc("TidyExternalVendorChecks", func(config android.Config) (string, error) {
|
||||
if override := config.Getenv("DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS"); override != "" {
|
||||
return override, nil
|
||||
pctx.VariableFunc("TidyExternalVendorChecks", func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv("DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS"); override != "" {
|
||||
return override
|
||||
}
|
||||
return strings.Join([]string{
|
||||
"-*",
|
||||
@@ -54,7 +53,7 @@ func init() {
|
||||
"-google-readability*",
|
||||
"-google-runtime-int",
|
||||
"-google-runtime-references",
|
||||
}, ","), nil
|
||||
}, ",")
|
||||
})
|
||||
|
||||
// Give warnings to header files only in selected directories.
|
||||
|
@@ -15,7 +15,6 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -107,26 +106,28 @@ const (
|
||||
)
|
||||
|
||||
func init() {
|
||||
pctx.VariableFunc("macSdkPath", func(config android.Config) (string, error) {
|
||||
xcodeselect := config.HostSystemTool("xcode-select")
|
||||
pctx.VariableFunc("macSdkPath", func(ctx android.PackageVarContext) string {
|
||||
xcodeselect := ctx.Config().HostSystemTool("xcode-select")
|
||||
bytes, err := exec.Command(xcodeselect, "--print-path").Output()
|
||||
return strings.TrimSpace(string(bytes)), err
|
||||
if err != nil {
|
||||
ctx.Errorf("xcode-select failed with: %q", err.Error())
|
||||
}
|
||||
return strings.TrimSpace(string(bytes))
|
||||
})
|
||||
pctx.VariableFunc("macSdkRoot", func(config android.Config) (string, error) {
|
||||
return xcrunSdk(config, "--show-sdk-path")
|
||||
pctx.VariableFunc("macSdkRoot", func(ctx android.PackageVarContext) string {
|
||||
return xcrunSdk(ctx, "--show-sdk-path")
|
||||
})
|
||||
pctx.StaticVariable("macMinVersion", "10.8")
|
||||
pctx.VariableFunc("MacArPath", func(config android.Config) (string, error) {
|
||||
return xcrun(config, "--find", "ar")
|
||||
pctx.VariableFunc("MacArPath", func(ctx android.PackageVarContext) string {
|
||||
return xcrun(ctx, "--find", "ar")
|
||||
})
|
||||
|
||||
pctx.VariableFunc("MacStripPath", func(config android.Config) (string, error) {
|
||||
return xcrun(config, "--find", "strip")
|
||||
pctx.VariableFunc("MacStripPath", func(ctx android.PackageVarContext) string {
|
||||
return xcrun(ctx, "--find", "strip")
|
||||
})
|
||||
|
||||
pctx.VariableFunc("MacToolPath", func(config android.Config) (string, error) {
|
||||
path, err := xcrun(config, "--find", "ld")
|
||||
return filepath.Dir(path), err
|
||||
pctx.VariableFunc("MacToolPath", func(ctx android.PackageVarContext) string {
|
||||
return filepath.Dir(xcrun(ctx, "--find", "ld"))
|
||||
})
|
||||
|
||||
pctx.StaticVariable("DarwinGccVersion", darwinGccVersion)
|
||||
@@ -156,33 +157,38 @@ func init() {
|
||||
pctx.StaticVariable("DarwinX8664YasmFlags", "-f macho -m amd64")
|
||||
}
|
||||
|
||||
func xcrun(config android.Config, args ...string) (string, error) {
|
||||
xcrun := config.HostSystemTool("xcrun")
|
||||
func xcrun(ctx android.PackageVarContext, args ...string) string {
|
||||
xcrun := ctx.Config().HostSystemTool("xcrun")
|
||||
bytes, err := exec.Command(xcrun, args...).Output()
|
||||
return strings.TrimSpace(string(bytes)), err
|
||||
if err != nil {
|
||||
ctx.Errorf("xcrun failed with: %q", err.Error())
|
||||
}
|
||||
return strings.TrimSpace(string(bytes))
|
||||
}
|
||||
|
||||
func xcrunSdk(config android.Config, arg string) (string, error) {
|
||||
xcrun := config.HostSystemTool("xcrun")
|
||||
if selected := config.Getenv("MAC_SDK_VERSION"); selected != "" {
|
||||
func xcrunSdk(ctx android.PackageVarContext, arg string) string {
|
||||
xcrun := ctx.Config().HostSystemTool("xcrun")
|
||||
if selected := ctx.Config().Getenv("MAC_SDK_VERSION"); selected != "" {
|
||||
if !inList(selected, darwinSupportedSdkVersions) {
|
||||
return "", fmt.Errorf("MAC_SDK_VERSION %s isn't supported: %q", selected, darwinSupportedSdkVersions)
|
||||
ctx.Errorf("MAC_SDK_VERSION %s isn't supported: %q", selected, darwinSupportedSdkVersions)
|
||||
return ""
|
||||
}
|
||||
|
||||
bytes, err := exec.Command(xcrun, "--sdk", "macosx"+selected, arg).Output()
|
||||
if err == nil {
|
||||
return strings.TrimSpace(string(bytes)), err
|
||||
if err != nil {
|
||||
ctx.Errorf("MAC_SDK_VERSION %s is not installed", selected)
|
||||
}
|
||||
return "", fmt.Errorf("MAC_SDK_VERSION %s is not installed", selected)
|
||||
return strings.TrimSpace(string(bytes))
|
||||
}
|
||||
|
||||
for _, sdk := range darwinSupportedSdkVersions {
|
||||
bytes, err := exec.Command(xcrun, "--sdk", "macosx"+sdk, arg).Output()
|
||||
if err == nil {
|
||||
return strings.TrimSpace(string(bytes)), err
|
||||
return strings.TrimSpace(string(bytes))
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("Could not find a supported mac sdk: %q", darwinSupportedSdkVersions)
|
||||
ctx.Errorf("Could not find a supported mac sdk: %q", darwinSupportedSdkVersions)
|
||||
return ""
|
||||
}
|
||||
|
||||
type toolchainDarwin struct {
|
||||
|
Reference in New Issue
Block a user