Reland "Use cp instead of install for ndk_headers"

This relands aosp/3026027 with fixes for ndk_library. ndk_library
uses ctx.InstallFile to copy the stubs from an intermediate dir to
out/soong/ndk/sysroot/. The copy rule was created in
out/soong/installs-<product>.mk. This would cause issues when soong_ui
is run in `--soong-only` mode

To fix this, the cp rule is created entirely in soong. The stub library
is marked uninstallable to prevent creation of duplicate rules when
`--soong-only` mode is not used

Test: presubmits
Test: lunch ndk-trunk_staging-userdebug &&
ALLOW_MISSING_DEPENDENCIES=true build/soong/soong_ui.bash --soong-only
out/soong/ndk.timestamp

Change-Id: I6f8b87d88d8ca5ec9a3327e1f11e9aa654f8cdce
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 567cb7c..57a3b3a 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -15,7 +15,6 @@
 package cc
 
 import (
-	"fmt"
 	"path/filepath"
 
 	"android/soong/android"
@@ -45,7 +44,7 @@
 }
 
 // Returns the NDK base include path for use with sdk_version current. Usable with -I.
-func getCurrentIncludePath(ctx android.ModuleContext) android.InstallPath {
+func getCurrentIncludePath(ctx android.ModuleContext) android.OutputPath {
 	return getNdkSysrootBase(ctx).Join(ctx, "usr/include")
 }
 
@@ -87,7 +86,7 @@
 }
 
 func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string,
-	to string) android.InstallPath {
+	to string) android.OutputPath {
 	// Output path is the sysroot base + "usr/include" + to directory + directory component
 	// of the file without the leading from directory stripped.
 	//
@@ -129,13 +128,12 @@
 	for _, header := range m.srcPaths {
 		installDir := getHeaderInstallDir(ctx, header, String(m.properties.From),
 			String(m.properties.To))
-		installedPath := ctx.InstallFile(installDir, header.Base(), header)
 		installPath := installDir.Join(ctx, header.Base())
-		if installPath != installedPath {
-			panic(fmt.Sprintf(
-				"expected header install path (%q) not equal to actual install path %q",
-				installPath, installedPath))
-		}
+		ctx.Build(pctx, android.BuildParams{
+			Rule:   android.Cp,
+			Input:  header,
+			Output: installPath,
+		})
 		m.installPaths = append(m.installPaths, installPath)
 	}