From 9b478b083197297f7a08b795e1d392aa12d1c493 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 10 Dec 2019 13:41:51 +0000 Subject: Generate .srcjar for prebuilt_stubs_sources Changes prebuilt_stubs_sources to generate a .srcjar from its input instead of just exposing the srcs it is given. This ensures that it can be used as a drop in replacement for a droidstubs module. Updates the test for prebuilt_stubs_sources to be more representative of the actual use made of it by sdk snapshot which outputs a directory not a glob pattern. Added some documentation of the prebuilts_stubs_sources srcs property to make it clear that it is supposed to be a set of directories. Extracts common code from sdk/testing.go for normalizing path/paths for testing. Bug: 143678475 Test: m conscrypt-module-sdk conscrypt-module-host-sdk conscrypt-module-test-sdk unzip those in place of external/conscrypt build core-current-stubs-source which expects it to provide a .srcjar. Change-Id: I8204a022557a9b0b45e19eac79ecba98ff95213d --- sdk/testing.go | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'sdk/testing.go') diff --git a/sdk/testing.go b/sdk/testing.go index eec7f0198..09d0247c0 100644 --- a/sdk/testing.go +++ b/sdk/testing.go @@ -185,7 +185,7 @@ func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo { switch bp.Rule.String() { case android.Cp.String(): // Get source relative to build directory. - src := r.pathRelativeToBuildDir(bp.Input) + src := android.NormalizePathForTesting(bp.Input) // Get destination relative to the snapshot root dest := bp.Output.Rel() _, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest) @@ -201,12 +201,12 @@ func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo { // This could be an intermediate zip file and not the actual output zip. // In that case this will be overridden when the rule to merge the zips // is processed. - info.outputZip = r.pathRelativeToBuildDir(bp.Output) + info.outputZip = android.NormalizePathForTesting(bp.Output) case mergeZips.String(): // Copy the current outputZip to the intermediateZip. info.intermediateZip = info.outputZip - mergeInput := r.pathRelativeToBuildDir(bp.Input) + mergeInput := android.NormalizePathForTesting(bp.Input) if info.intermediateZip != mergeInput { r.t.Errorf("Expected intermediate zip %s to be an input to merge zips but found %s instead", info.intermediateZip, mergeInput) @@ -214,10 +214,10 @@ func (r *testSdkResult) getSdkSnapshotBuildInfo(sdk *sdk) *snapshotBuildInfo { // Override output zip (which was actually the intermediate zip file) with the actual // output zip. - info.outputZip = r.pathRelativeToBuildDir(bp.Output) + info.outputZip = android.NormalizePathForTesting(bp.Output) // Save the zips to be merged into the intermediate zip. - info.mergeZips = r.pathsRelativeToBuildDir(bp.Inputs) + info.mergeZips = android.NormalizePathsForTesting(bp.Inputs) } } @@ -234,19 +234,6 @@ func (r *testSdkResult) ModuleForTests(name string, variant string) android.Test return r.ctx.ModuleForTests(name, variant) } -func (r *testSdkResult) pathRelativeToBuildDir(path android.Path) string { - buildDir := filepath.Clean(r.config.BuildDir()) + "/" - return strings.TrimPrefix(filepath.Clean(path.String()), buildDir) -} - -func (r *testSdkResult) pathsRelativeToBuildDir(paths android.Paths) []string { - var result []string - for _, path := range paths { - result = append(result, r.pathRelativeToBuildDir(path)) - } - return result -} - // Check the snapshot build rules. // // Takes a list of functions which check different facets of the snapshot build rules. -- cgit v1.2.3-59-g8ed1b