Handle absolute source paths correctly.
Can happen if OUT_DIR is set on an absolute path.
Test: env RBE_remote_disabled=true OUT_DIR=/home_2/tmp/out m
Bug: 169048540
Fixes: 169048540
Change-Id: Ia6b91b13142d84e54d0dee8b4e04a91ad2cecc36
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 1ee096e..9d1b016 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -16,6 +16,7 @@
import (
"android/soong/android"
+ "path/filepath"
)
func init() {
@@ -360,13 +361,18 @@
sharedLibPaths = append(sharedLibPaths, deps.SharedLibs...)
sharedLibPaths = append(sharedLibPaths, deps.LateSharedLibs...)
+ var fromPath = in.String()
+ if !filepath.IsAbs(fromPath) {
+ fromPath = "$$PWD/" + fromPath
+ }
+
ctx.Build(pctx, android.BuildParams{
Rule: android.Symlink,
Output: outputFile,
Input: in,
Implicits: sharedLibPaths,
Args: map[string]string{
- "fromPath": "$$PWD/" + in.String(),
+ "fromPath": fromPath,
},
})