diff --git a/cc/cc.go b/cc/cc.go index a92831223..61e256847 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -404,6 +404,9 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha } // Include dir cflags + common.CheckSrcDirsExist(ctx, c.Properties.Include_dirs, "include_dirs") + common.CheckModuleSrcDirsExist(ctx, c.Properties.Local_include_dirs, "local_include_dirs") + rootIncludeDirs := pathtools.PrefixPaths(c.Properties.Include_dirs, ctx.AConfig().SrcDir()) localIncludeDirs := pathtools.PrefixPaths(c.Properties.Local_include_dirs, common.ModuleSrcDir(ctx)) flags.GlobalFlags = append(flags.GlobalFlags, @@ -1096,6 +1099,8 @@ func (c *CCLibrary) compileStaticLibrary(ctx common.AndroidModuleContext, c.objFiles = objFiles c.out = outputFile + + common.CheckModuleSrcDirsExist(ctx, c.Properties.Export_include_dirs, "export_include_dirs") includeDirs := pathtools.PrefixPaths(c.Properties.Export_include_dirs, common.ModuleSrcDir(ctx)) c.exportFlags = []string{includeDirsToFlags(includeDirs)} diff --git a/common/paths.go b/common/paths.go index bcd6d8c73..070662adb 100644 --- a/common/paths.go +++ b/common/paths.go @@ -16,6 +16,7 @@ package common import ( "path/filepath" + "os" ) // ModuleOutDir returns the path to the module-specific output directory. @@ -74,3 +75,33 @@ func ModuleProtoDir(ctx AndroidModuleContext) string { func ModuleJSCompiledDir(ctx AndroidModuleContext) string { return filepath.Join(ModuleOutDir(ctx), "js") } + +// CheckModuleSrcDirsExist logs an error on a property if any of the directories relative to the +// Blueprints file don't exist. +func CheckModuleSrcDirsExist(ctx AndroidModuleContext, dirs []string, prop string) { + for _, dir := range dirs { + fullDir := filepath.Join(ModuleSrcDir(ctx), dir) + if _, err := os.Stat(fullDir); err != nil { + if os.IsNotExist(err) { + ctx.PropertyErrorf(prop, "module source directory %q does not exist", dir) + } else { + ctx.PropertyErrorf(prop, "%s", err.Error()) + } + } + } +} + +// CheckModuleSrcDirsExist logs an error on a property if any of the directories relative to the +// top of the source tree don't exist. +func CheckSrcDirsExist(ctx AndroidModuleContext, dirs []string, prop string) { + for _, dir := range dirs { + fullDir := filepath.Join(ctx.AConfig().SrcDir(), dir) + if _, err := os.Stat(fullDir); err != nil { + if os.IsNotExist(err) { + ctx.PropertyErrorf(prop, "top-level source directory %q does not exist", dir) + } else { + ctx.PropertyErrorf(prop, "%s", err.Error()) + } + } + } +}