Skip existence check for stub library files

Switch from `PathForModuleSrc` to `PathForSource`. The latter does not
check that the target path exists in the tree. This is necessary since
the prebuilt stub and header directories are not guaranteed to exist
when Soong analysis begins (Step 2a)

Build orchestrator will be responsible for putting these files in the
right place as part of Multi-tree ninja invocation (Step 4)

Test: go test ./cc
Change-Id: I27175a8440fca6bba21197b1e106a22b733da882
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 2ebb6ef..1597a6f 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -81,6 +81,19 @@
 	return basename + multitree.GetApiImportSuffix()
 }
 
+// Export include dirs without checking for existence.
+// The directories are not guaranteed to exist during Soong analysis.
+func (d *apiLibraryDecorator) exportIncludes(ctx ModuleContext) {
+	exporterProps := d.flagExporter.Properties
+	for _, dir := range exporterProps.Export_include_dirs {
+		d.dirs = append(d.dirs, android.PathForSource(ctx, ctx.ModuleDir(), dir))
+	}
+	// system headers
+	for _, dir := range exporterProps.Export_system_include_dirs {
+		d.systemDirs = append(d.systemDirs, android.PathForSource(ctx, ctx.ModuleDir(), dir))
+	}
+}
+
 func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objects Objects) android.Path {
 	// Export headers as system include dirs if specified. Mostly for libc
 	if Bool(d.libraryDecorator.Properties.Llndk.Export_headers_as_system) {
@@ -91,7 +104,7 @@
 	}
 
 	// Flags reexported from dependencies. (e.g. vndk_prebuilt_shared)
-	d.libraryDecorator.flagExporter.exportIncludes(ctx)
+	d.exportIncludes(ctx)
 	d.libraryDecorator.reexportDirs(deps.ReexportedDirs...)
 	d.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...)
 	d.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
@@ -99,7 +112,13 @@
 	d.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
 	d.libraryDecorator.flagExporter.setProvider(ctx)
 
-	in := android.PathForModuleSrc(ctx, *d.properties.Src)
+	if d.properties.Src == nil {
+		ctx.PropertyErrorf("src", "src is a required property")
+	}
+	// Skip the existence check of the stub prebuilt file.
+	// The file is not guaranteed to exist during Soong analysis.
+	// Build orchestrator will be responsible for creating a connected ninja graph.
+	in := android.PathForSource(ctx, ctx.ModuleDir(), *d.properties.Src)
 
 	d.unstrippedOutputFile = in
 	libName := d.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix()