Merge "Add a nice install paths for module SDKs and exports."
This commit is contained in:
commit
8f20563514
|
@ -1276,8 +1276,8 @@ func pathForInstall(ctx PathContext, os OsType, partition string, debug bool,
|
|||
return ret
|
||||
}
|
||||
|
||||
func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath {
|
||||
paths = append([]string{"ndk"}, paths...)
|
||||
func pathForNdkOrSdkInstall(ctx PathContext, prefix string, paths []string) InstallPath {
|
||||
paths = append([]string{prefix}, paths...)
|
||||
path, err := validatePath(paths...)
|
||||
if err != nil {
|
||||
reportPathError(ctx, err)
|
||||
|
@ -1285,6 +1285,14 @@ func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath {
|
|||
return InstallPath{basePath{path, ctx.Config(), ""}, ""}
|
||||
}
|
||||
|
||||
func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath {
|
||||
return pathForNdkOrSdkInstall(ctx, "ndk", paths)
|
||||
}
|
||||
|
||||
func PathForMainlineSdksInstall(ctx PathContext, paths ...string) InstallPath {
|
||||
return pathForNdkOrSdkInstall(ctx, "mainline-sdks", paths)
|
||||
}
|
||||
|
||||
func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string {
|
||||
rel := Rel(ctx, PathForOutput(ctx, "target", "product", ctx.Config().DeviceName()).String(), path.String())
|
||||
|
||||
|
|
|
@ -281,7 +281,9 @@ func (s *sdk) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
}
|
||||
|
||||
// Generate the snapshot from the member info.
|
||||
s.snapshotFile = android.OptionalPathForPath(s.buildSnapshot(ctx, sdkVariants))
|
||||
p := s.buildSnapshot(ctx, sdkVariants)
|
||||
s.snapshotFile = android.OptionalPathForPath(p)
|
||||
ctx.InstallFile(android.PathForMainlineSdksInstall(ctx), s.Name()+"-current.zip", p)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,3 +205,19 @@ sdk_snapshot {
|
|||
}
|
||||
`))
|
||||
}
|
||||
|
||||
func TestSDkInstall(t *testing.T) {
|
||||
sdk := `
|
||||
sdk {
|
||||
name: "mysdk",
|
||||
}
|
||||
`
|
||||
result := testSdkWithFs(t, ``,
|
||||
map[string][]byte{
|
||||
"Android.bp": []byte(sdk),
|
||||
})
|
||||
|
||||
result.CheckSnapshot("mysdk", "",
|
||||
checkAllOtherCopyRules(`.intermediates/mysdk/common_os/mysdk-current.zip -> mysdk-current.zip`),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -188,19 +188,22 @@ func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo {
|
|||
|
||||
buildParams := sdk.BuildParamsForTests()
|
||||
copyRules := &strings.Builder{}
|
||||
otherCopyRules := &strings.Builder{}
|
||||
snapshotDirPrefix := sdk.builderForTests.snapshotDir.String() + "/"
|
||||
for _, bp := range buildParams {
|
||||
switch bp.Rule.String() {
|
||||
case android.Cp.String():
|
||||
output := bp.Output
|
||||
// Only check copies into the snapshot directory.
|
||||
if strings.HasPrefix(output.String(), snapshotDirPrefix) {
|
||||
// Get source relative to build directory.
|
||||
src := android.NormalizePathForTesting(bp.Input)
|
||||
// Get destination relative to the snapshot root
|
||||
dest := output.Rel()
|
||||
src := android.NormalizePathForTesting(bp.Input)
|
||||
// We differentiate between copy rules for the snapshot, and copy rules for the install file.
|
||||
if strings.HasPrefix(output.String(), snapshotDirPrefix) {
|
||||
// Get source relative to build directory.
|
||||
_, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest)
|
||||
info.snapshotContents = append(info.snapshotContents, dest)
|
||||
} else {
|
||||
_, _ = fmt.Fprintf(otherCopyRules, "%s -> %s\n", src, dest)
|
||||
}
|
||||
|
||||
case repackageZip.String():
|
||||
|
@ -234,6 +237,7 @@ func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo {
|
|||
}
|
||||
|
||||
info.copyRules = copyRules.String()
|
||||
info.otherCopyRules = otherCopyRules.String()
|
||||
|
||||
return info
|
||||
}
|
||||
|
@ -309,6 +313,13 @@ func checkAllCopyRules(expected string) snapshotBuildInfoChecker {
|
|||
}
|
||||
}
|
||||
|
||||
func checkAllOtherCopyRules(expected string) snapshotBuildInfoChecker {
|
||||
return func(info *snapshotBuildInfo) {
|
||||
info.r.t.Helper()
|
||||
info.r.AssertTrimmedStringEquals("Incorrect copy rules", expected, info.otherCopyRules)
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the specified path is in the list of zips to merge with the intermediate zip.
|
||||
func checkMergeZip(expected string) snapshotBuildInfoChecker {
|
||||
return func(info *snapshotBuildInfo) {
|
||||
|
@ -335,10 +346,14 @@ type snapshotBuildInfo struct {
|
|||
// snapshot.
|
||||
snapshotContents []string
|
||||
|
||||
// A formatted representation of the src/dest pairs, one pair per line, of the format
|
||||
// src -> dest
|
||||
// A formatted representation of the src/dest pairs for a snapshot, one pair per line,
|
||||
// of the format src -> dest
|
||||
copyRules string
|
||||
|
||||
// A formatted representation of the src/dest pairs for files not in a snapshot, one pair
|
||||
// per line, of the format src -> dest
|
||||
otherCopyRules string
|
||||
|
||||
// The path to the intermediate zip, which is a zip created from the source files copied
|
||||
// into the snapshot directory and which will be merged with other zips to form the final output.
|
||||
// Is am empty string if there is no intermediate zip because there are no zips to merge in.
|
||||
|
|
Loading…
Reference in New Issue