Check that local, top level, and exported include paths exist
Require directories listed in the include_dirs, local_include_dirs, and
exported_include_dirs properties to exist.
Change-Id: I5b079bd2c607839bb28dae43801cd7345bde2299
diff --git a/common/paths.go b/common/paths.go
index bcd6d8c..070662a 100644
--- a/common/paths.go
+++ b/common/paths.go
@@ -16,6 +16,7 @@
import (
"path/filepath"
+ "os"
)
// ModuleOutDir returns the path to the module-specific output directory.
@@ -74,3 +75,33 @@
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())
+ }
+ }
+ }
+}