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
This commit is contained in:
parent
767a1fe663
commit
f280b23fe5
5 changed files with 23 additions and 22 deletions
|
@ -1831,17 +1831,13 @@ func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string,
|
||||||
return base.Join(ctx, pathComponents...)
|
return base.Join(ctx, pathComponents...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pathForNdkOrSdkInstall(ctx PathContext, prefix string, paths []string) InstallPath {
|
func PathForNdkInstall(ctx PathContext, paths ...string) OutputPath {
|
||||||
base := pathForPartitionInstallDir(ctx, "", prefix, false)
|
return PathForOutput(ctx, append([]string{"ndk"}, paths...)...)
|
||||||
return base.Join(ctx, paths...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath {
|
|
||||||
return pathForNdkOrSdkInstall(ctx, "ndk", paths)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func PathForMainlineSdksInstall(ctx PathContext, paths ...string) InstallPath {
|
func PathForMainlineSdksInstall(ctx PathContext, paths ...string) InstallPath {
|
||||||
return pathForNdkOrSdkInstall(ctx, "mainline-sdks", paths)
|
base := pathForPartitionInstallDir(ctx, "", "mainline-sdks", false)
|
||||||
|
return base.Join(ctx, paths...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string {
|
func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string {
|
||||||
|
|
|
@ -448,6 +448,7 @@ func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.
|
||||||
if c.parsedCoverageXmlPath.String() != "" {
|
if c.parsedCoverageXmlPath.String() != "" {
|
||||||
entries.SetString("SOONG_NDK_API_XML", "$(SOONG_NDK_API_XML) "+c.parsedCoverageXmlPath.String())
|
entries.SetString("SOONG_NDK_API_XML", "$(SOONG_NDK_API_XML) "+c.parsedCoverageXmlPath.String())
|
||||||
}
|
}
|
||||||
|
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) // Stubs should not be installed
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
@ -45,7 +44,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the NDK base include path for use with sdk_version current. Usable with -I.
|
// 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")
|
return getNdkSysrootBase(ctx).Join(ctx, "usr/include")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ type headerModule struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string,
|
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
|
// Output path is the sysroot base + "usr/include" + to directory + directory component
|
||||||
// of the file without the leading from directory stripped.
|
// of the file without the leading from directory stripped.
|
||||||
//
|
//
|
||||||
|
@ -129,13 +128,12 @@ func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
for _, header := range m.srcPaths {
|
for _, header := range m.srcPaths {
|
||||||
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From),
|
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From),
|
||||||
String(m.properties.To))
|
String(m.properties.To))
|
||||||
installedPath := ctx.InstallFile(installDir, header.Base(), header)
|
|
||||||
installPath := installDir.Join(ctx, header.Base())
|
installPath := installDir.Join(ctx, header.Base())
|
||||||
if installPath != installedPath {
|
ctx.Build(pctx, android.BuildParams{
|
||||||
panic(fmt.Sprintf(
|
Rule: android.Cp,
|
||||||
"expected header install path (%q) not equal to actual install path %q",
|
Input: header,
|
||||||
installPath, installedPath))
|
Output: installPath,
|
||||||
}
|
})
|
||||||
m.installPaths = append(m.installPaths, installPath)
|
m.installPaths = append(m.installPaths, installPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -518,19 +518,25 @@ func (stub *stubDecorator) nativeCoverage() bool {
|
||||||
|
|
||||||
// Returns the install path for unversioned NDK libraries (currently only static
|
// Returns the install path for unversioned NDK libraries (currently only static
|
||||||
// libraries).
|
// libraries).
|
||||||
func getUnversionedLibraryInstallPath(ctx ModuleContext) android.InstallPath {
|
func getUnversionedLibraryInstallPath(ctx ModuleContext) android.OutputPath {
|
||||||
return getNdkSysrootBase(ctx).Join(ctx, "usr/lib", config.NDKTriple(ctx.toolchain()))
|
return getNdkSysrootBase(ctx).Join(ctx, "usr/lib", config.NDKTriple(ctx.toolchain()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the install path for versioned NDK libraries. These are most often
|
// Returns the install path for versioned NDK libraries. These are most often
|
||||||
// stubs, but the same paths are used for CRT objects.
|
// stubs, but the same paths are used for CRT objects.
|
||||||
func getVersionedLibraryInstallPath(ctx ModuleContext, apiLevel android.ApiLevel) android.InstallPath {
|
func getVersionedLibraryInstallPath(ctx ModuleContext, apiLevel android.ApiLevel) android.OutputPath {
|
||||||
return getUnversionedLibraryInstallPath(ctx).Join(ctx, apiLevel.String())
|
return getUnversionedLibraryInstallPath(ctx).Join(ctx, apiLevel.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) {
|
func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) {
|
||||||
installDir := getVersionedLibraryInstallPath(ctx, stub.apiLevel)
|
installDir := getVersionedLibraryInstallPath(ctx, stub.apiLevel)
|
||||||
stub.installPath = ctx.InstallFile(installDir, path.Base(), path)
|
out := installDir.Join(ctx, path.Base())
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: android.Cp,
|
||||||
|
Input: path,
|
||||||
|
Output: out,
|
||||||
|
})
|
||||||
|
stub.installPath = out
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStubLibrary() *Module {
|
func newStubLibrary() *Module {
|
||||||
|
|
|
@ -69,12 +69,12 @@ func RegisterNdkModuleTypes(ctx android.RegistrationContext) {
|
||||||
ctx.RegisterParallelSingletonType("ndk", NdkSingleton)
|
ctx.RegisterParallelSingletonType("ndk", NdkSingleton)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNdkInstallBase(ctx android.PathContext) android.InstallPath {
|
func getNdkInstallBase(ctx android.PathContext) android.OutputPath {
|
||||||
return android.PathForNdkInstall(ctx)
|
return android.PathForNdkInstall(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the main install directory for the NDK sysroot. Usable with --sysroot.
|
// Returns the main install directory for the NDK sysroot. Usable with --sysroot.
|
||||||
func getNdkSysrootBase(ctx android.PathContext) android.InstallPath {
|
func getNdkSysrootBase(ctx android.PathContext) android.OutputPath {
|
||||||
return getNdkInstallBase(ctx).Join(ctx, "sysroot")
|
return getNdkInstallBase(ctx).Join(ctx, "sysroot")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue