Fix java resource glob file list location
The source path was being appended to the module out directory
to create the file list file, which was resulting in .. in the
source path moving the file list file up the directory tree.
Use SrcDirRelPath to convert the globbed resource directories
to be relatiave to $srcDir before appending them.
Also do the same fix to generated aidl, logtags, yacc, and lex
files.
Change-Id: I2e636bd30abf03bc1d80a897951a9812cc3e09ef
diff --git a/common/paths.go b/common/paths.go
index c4bdfc7..d92dcf9 100644
--- a/common/paths.go
+++ b/common/paths.go
@@ -15,6 +15,7 @@
package common
import (
+ "fmt"
"os"
"path/filepath"
)
@@ -105,3 +106,15 @@
}
}
}
+
+// Returns a path relative to the top level source directory. Panics if path is not inside the
+// top level source directory.
+func SrcDirRelPath(ctx AndroidModuleContext, path string) string {
+ srcDir := ctx.AConfig().SrcDir()
+ relPath, err := filepath.Rel(srcDir, path)
+ if err != nil {
+ panic(fmt.Errorf("%q is not inside %q: %s", path, srcDir, err.Error()))
+ }
+
+ return relPath
+}