Don't call android.PathForModuleSrc(ctx).String() to get ModuleDir
ctx.ModuleDir is much cheaper than android.PathForModuleSrc(ctx).String().
Test: builds
Change-Id: I81819088d9564b06a0336a59a45f2b110b0bd9d6
diff --git a/cc/builder.go b/cc/builder.go
index c8fa1e4..3f582fa 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -534,7 +534,7 @@
toolingCppflags += " ${config.NoOverride64GlobalCflags}"
}
- modulePath := android.PathForModuleSrc(ctx).String()
+ modulePath := ctx.ModuleDir()
if android.IsThirdPartyPath(modulePath) {
cflags += " ${config.NoOverrideExternalGlobalCflags}"
toolingCflags += " ${config.NoOverrideExternalGlobalCflags}"
diff --git a/cc/compiler.go b/cc/compiler.go
index 5bed8a7..490d3cc 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -339,7 +339,7 @@
// per-target values, module type values, and per-module Blueprints properties
func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
tc := ctx.toolchain()
- modulePath := android.PathForModuleSrc(ctx).String()
+ modulePath := ctx.ModuleDir()
compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 87588f3..f7d7de6 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -303,7 +303,7 @@
}
flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
- flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
+ flags = append(flags, "-I"+ctx.ModuleDir())
if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
flags = append(flags, "-I"+src.String())
}
diff --git a/rust/builder.go b/rust/builder.go
index 72e5be1..162d1aa 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -288,7 +288,7 @@
}
// Disallow experimental features
- modulePath := android.PathForModuleSrc(ctx).String()
+ modulePath := ctx.ModuleDir()
if !(android.IsThirdPartyPath(modulePath) || strings.HasPrefix(modulePath, "prebuilts")) {
rustcFlags = append(rustcFlags, "-Zallow-features=\"\"")
}
@@ -436,7 +436,7 @@
docTimestampFile := android.PathForModuleOut(ctx, "rustdoc.timestamp")
// Silence warnings about renamed lints for third-party crates
- modulePath := android.PathForModuleSrc(ctx).String()
+ modulePath := ctx.ModuleDir()
if android.IsThirdPartyPath(modulePath) {
rustdocFlags = append(rustdocFlags, " -A warnings")
}