Merge changes from topic "api_library_missing_deps"
* changes: Do not register missing deps Skip existence check for stub library files
This commit is contained in:
@@ -1139,6 +1139,21 @@ func PathForSource(ctx PathContext, pathComponents ...string) SourcePath {
|
||||
return path
|
||||
}
|
||||
|
||||
// MaybeExistentPathForSource joins the provided path components and validates that the result
|
||||
// neither escapes the source dir nor is in the out dir.
|
||||
// It does not validate whether the path exists.
|
||||
func MaybeExistentPathForSource(ctx PathContext, pathComponents ...string) SourcePath {
|
||||
path, err := pathForSource(ctx, pathComponents...)
|
||||
if err != nil {
|
||||
reportPathError(ctx, err)
|
||||
}
|
||||
|
||||
if pathtools.IsGlob(path.String()) {
|
||||
ReportPathErrorf(ctx, "path may not contain a glob: %s", path.String())
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// ExistentPathForSource returns an OptionalPath with the SourcePath, rooted from SrcDir, *not*
|
||||
// rooted from the module's local source directory, if the path exists, or an empty OptionalPath if
|
||||
// it doesn't exist. Dependencies are added so that the ninja file will be regenerated if the state
|
||||
|
@@ -77,6 +77,19 @@ func (d *apiLibraryDecorator) Name(basename string) string {
|
||||
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.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), dir))
|
||||
}
|
||||
// system headers
|
||||
for _, dir := range exporterProps.Export_system_include_dirs {
|
||||
d.systemDirs = append(d.systemDirs, android.MaybeExistentPathForSource(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) {
|
||||
@@ -87,7 +100,7 @@ func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps
|
||||
}
|
||||
|
||||
// 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...)
|
||||
@@ -95,7 +108,13 @@ func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps
|
||||
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.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), *d.properties.Src)
|
||||
|
||||
d.unstrippedOutputFile = in
|
||||
libName := d.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
|
||||
|
@@ -241,3 +241,41 @@ func TestApiHeadersShouldNotReplaceWithoutApiImport(t *testing.T) {
|
||||
android.AssertBoolEquals(t, "original header should be used for original library", true, hasDirectDependency(t, ctx, libfoo, libfooHeader))
|
||||
android.AssertBoolEquals(t, "Header from API surface should not be used for original library", false, hasDirectDependency(t, ctx, libfoo, libfooHeaderApiImport))
|
||||
}
|
||||
|
||||
func TestExportDirFromStubLibrary(t *testing.T) {
|
||||
bp := `
|
||||
cc_library {
|
||||
name: "libfoo",
|
||||
export_include_dirs: ["source_include_dir"],
|
||||
export_system_include_dirs: ["source_system_include_dir"],
|
||||
vendor_available: true,
|
||||
}
|
||||
cc_api_library {
|
||||
name: "libfoo",
|
||||
export_include_dirs: ["stub_include_dir"],
|
||||
export_system_include_dirs: ["stub_system_include_dir"],
|
||||
vendor_available: true,
|
||||
src: "libfoo.so",
|
||||
}
|
||||
api_imports {
|
||||
name: "api_imports",
|
||||
shared_libs: [
|
||||
"libfoo",
|
||||
],
|
||||
header_libs: [],
|
||||
}
|
||||
// vendor binary
|
||||
cc_binary {
|
||||
name: "vendorbin",
|
||||
vendor: true,
|
||||
srcs: ["vendor.cc"],
|
||||
shared_libs: ["libfoo"],
|
||||
}
|
||||
`
|
||||
ctx := prepareForCcTest.RunTestWithBp(t, bp)
|
||||
vendorCFlags := ctx.ModuleForTests("vendorbin", "android_vendor.29_arm64_armv8-a").Rule("cc").Args["cFlags"]
|
||||
android.AssertStringDoesContain(t, "Vendor binary should compile using headers provided by stub", vendorCFlags, "-Istub_include_dir")
|
||||
android.AssertStringDoesNotContain(t, "Vendor binary should not compile using headers of source", vendorCFlags, "-Isource_include_dir")
|
||||
android.AssertStringDoesContain(t, "Vendor binary should compile using system headers provided by stub", vendorCFlags, "-isystem stub_system_include_dir")
|
||||
android.AssertStringDoesNotContain(t, "Vendor binary should not compile using system headers of source", vendorCFlags, "-isystem source_system_include_dir")
|
||||
}
|
||||
|
Reference in New Issue
Block a user