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
This commit is contained in:
Lukacs T. Berki
2021-03-10 18:11:57 +01:00
parent 282671d696
commit 81a6983dc2

View File

@@ -35,10 +35,11 @@ type docsSingleton struct{}
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)