Fix writedocs.
This probably got broken by aosp/1609473 because soong_build is now
invoked in two different ways:
- By its absolute path during building out/soong/build.ninja
- By its path relative to the source root when generating documentation
Bug: 182347000
Test: Manual (the long incantation on b/182347000)
Change-Id: I0a3a97e4865ffde4a450a3f7baf3980b5a2016c8
diff --git a/android/writedocs.go b/android/writedocs.go
index 6cb2f10..67b9aa3 100644
--- a/android/writedocs.go
+++ b/android/writedocs.go
@@ -35,10 +35,11 @@
func primaryBuilderPath(ctx SingletonContext) Path {
buildDir := absolutePath(ctx.Config().BuildDir())
- primaryBuilder, err := filepath.Rel(buildDir, os.Args[0])
+ binary := absolutePath(os.Args[0])
+ primaryBuilder, err := filepath.Rel(buildDir, binary)
if err != nil {
- ctx.Errorf("path to primary builder %q is not in build dir %q",
- os.Args[0], ctx.Config().BuildDir())
+ ctx.Errorf("path to primary builder %q is not in build dir %q (%q)",
+ os.Args[0], ctx.Config().BuildDir(), err)
}
return PathForOutput(ctx, primaryBuilder)