Enable toc optimization for host builds

The toc optimization had been disabled for host builds to ensure that
the timestamp of the final binary changed whenever its implementation
changed, in order to support rerunning host tools that were modified
during incremental builds.  However, only the final install rule must be
re-run to update the timestamp, and not the link rule.

Update the shared library install dependencies to use normal
dependencies instead of order-only dependencies for host modules, and
then enable the the toc optimization for host modules.  If the
implementation of a library changes it will be reinstalled, and
libraries or binaries that depend on it will also be reinstalled.

Also move toc generation to happen on the packed, stripped library,
which is what will be used for linking, to ensure that it is available
at link time when depending only on the toc file.

Bug: 26015464
Test: m -j; touch system/tools/hidl/Annotation.cpp; m -j, verify
      out/soong/host/linux-x86/bin/hidl-gen is updated
Change-Id: I8953261d2209376f3dccbf0b1a93f7af4e45c4d0
diff --git a/android/module.go b/android/module.go
index 95bd9ea..f815ced 100644
--- a/android/module.go
+++ b/android/module.go
@@ -594,11 +594,22 @@
 	if a.Host() || !a.AConfig().SkipDeviceInstall() {
 		deps = append(deps, a.installDeps...)
 
+		var implicitDeps, orderOnlyDeps Paths
+
+		if a.Host() {
+			// Installed host modules might be used during the build, depend directly on their
+			// dependencies so their timestamp is updated whenever their dependency is updated
+			implicitDeps = deps
+		} else {
+			orderOnlyDeps = deps
+		}
+
 		a.ModuleBuild(pctx, ModuleBuildParams{
 			Rule:      Cp,
 			Output:    fullInstallPath,
 			Input:     srcPath,
-			OrderOnly: Paths(deps),
+			Implicits: implicitDeps,
+			OrderOnly: orderOnlyDeps,
 			Default:   !a.AConfig().EmbeddedInMake(),
 		})