summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/paths.go15
-rw-r--r--cc/library_stub.go6
2 files changed, 18 insertions, 3 deletions
diff --git a/android/paths.go b/android/paths.go
index dbcdb23e9..375297f6a 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -1139,6 +1139,21 @@ func PathForSource(ctx PathContext, pathComponents ...string) SourcePath {
return path
}
+// MaybeExistentPathForSource joins the provided path components and validates that the result
+// neither escapes the source dir nor is in the out dir.
+// It does not validate whether the path exists.
+func MaybeExistentPathForSource(ctx PathContext, pathComponents ...string) SourcePath {
+ path, err := pathForSource(ctx, pathComponents...)
+ if err != nil {
+ reportPathError(ctx, err)
+ }
+
+ if pathtools.IsGlob(path.String()) {
+ ReportPathErrorf(ctx, "path may not contain a glob: %s", path.String())
+ }
+ return path
+}
+
// ExistentPathForSource returns an OptionalPath with the SourcePath, rooted from SrcDir, *not*
// rooted from the module's local source directory, if the path exists, or an empty OptionalPath if
// it doesn't exist. Dependencies are added so that the ninja file will be regenerated if the state
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 1597a6f1f..80c48ad8c 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -86,11 +86,11 @@ func (d *apiLibraryDecorator) Name(basename string) string {
func (d *apiLibraryDecorator) exportIncludes(ctx ModuleContext) {
exporterProps := d.flagExporter.Properties
for _, dir := range exporterProps.Export_include_dirs {
- d.dirs = append(d.dirs, android.PathForSource(ctx, ctx.ModuleDir(), dir))
+ d.dirs = append(d.dirs, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), dir))
}
// system headers
for _, dir := range exporterProps.Export_system_include_dirs {
- d.systemDirs = append(d.systemDirs, android.PathForSource(ctx, ctx.ModuleDir(), dir))
+ d.systemDirs = append(d.systemDirs, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), dir))
}
}
@@ -118,7 +118,7 @@ func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps
// Skip the existence check of the stub prebuilt file.
// The file is not guaranteed to exist during Soong analysis.
// Build orchestrator will be responsible for creating a connected ninja graph.
- in := android.PathForSource(ctx, ctx.ModuleDir(), *d.properties.Src)
+ in := android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), *d.properties.Src)
d.unstrippedOutputFile = in
libName := d.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix()