APEX respects relative_install_path

relative_install_path for cc_library is respected by APEX.

relative_install_path for cc_binary is not yet respected because doing
it will break the path to the dynamic linker in the runtime APEX.
That change should be done along with changes in init, bionic, etc.

Bug: 123721777
Test: m (apex_test.go amended)
Change-Id: I855f8eda0d4255d563861ac96d0d3e2c669e9a2a
diff --git a/apex/apex.go b/apex/apex.go
index f6daf9b..eb791d9 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -540,6 +540,7 @@
 	case "lib64":
 		dirInApex = "lib64"
 	}
+	dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
 	if !cc.Arch().Native {
 		dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
 	}
@@ -564,6 +565,8 @@
 }
 
 func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
+	// TODO(b/123721777) respect relative_install_path also for binaries
+	// dirInApex = filepath.Join("bin", cc.RelativeInstallPath())
 	dirInApex = "bin"
 	fileToCopy = cc.OutputFile().Path()
 	return