Add missing os.MkdirAll to WriteFileToOutputDir
Fix tests when out/soong doesn't already exist by adding os.MkdirAll
to WriteFileToOutputDir.
Test: soong tests
Change-Id: I2a2b10e43b967d0c61d0dbe6a3f8bf381babe73c
diff --git a/android/paths.go b/android/paths.go
index 82c8a24..dceaac1 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -2058,7 +2058,12 @@
// Writes a file to the output directory. Attempting to write directly to the output directory
// will fail due to the sandbox of the soong_build process.
func WriteFileToOutputDir(path WritablePath, data []byte, perm os.FileMode) error {
- return ioutil.WriteFile(absolutePath(path.String()), data, perm)
+ absPath := absolutePath(path.String())
+ err := os.MkdirAll(filepath.Dir(absPath), 0777)
+ if err != nil {
+ return err
+ }
+ return ioutil.WriteFile(absPath, data, perm)
}
func RemoveAllOutputDir(path WritablePath) error {