Kaynağa Gözat

Propagate shared library destination path through FilesToZip

Shared libraries in fuzz zip files may have a different filename than
their source file, for example when the source file is a prebuilt in
the source tree.  Propagate the computed library name through
FilesToZip to soong_zip to use the correct name in the zip file.

Bug: 254867347
Test: builds
Change-Id: Ib0def8decdbec7842b8e1a9056fac373d743bac0
Colin Cross 1 yıl önce
ebeveyn
işleme
80462dc040
3 değiştirilmiş dosya ile 17 ekleme ve 9 silme
  1. 6 2
      cc/fuzz.go
  2. 9 5
      fuzz/fuzz_common.go
  3. 2 2
      java/fuzz.go

+ 6 - 2
cc/fuzz.go

@@ -423,7 +423,7 @@ func (s *ccRustFuzzPackager) GenerateBuildActions(ctx android.SingletonContext)
 		files = append(files, GetSharedLibsToZip(ccModule.FuzzSharedLibraries(), ccModule, &s.FuzzPackager, archString, sharedLibsInstallDirPrefix, &sharedLibraryInstalled)...)
 
 		// The executable.
-		files = append(files, fuzz.FileToZip{android.OutputFileForModule(ctx, ccModule, "unstripped"), ""})
+		files = append(files, fuzz.FileToZip{SourceFilePath: android.OutputFileForModule(ctx, ccModule, "unstripped")})
 
 		archDirs[archOs], ok = s.BuildZipFile(ctx, module, fpm, files, builder, archDir, archString, hostOrTargetString, archOs, archDirs)
 		if !ok {
@@ -462,7 +462,11 @@ func GetSharedLibsToZip(sharedLibraries android.RuleBuilderInstalls, module Link
 	for _, ruleBuilderInstall := range sharedLibraries {
 		library := ruleBuilderInstall.From
 		install := ruleBuilderInstall.To
-		files = append(files, fuzz.FileToZip{library, destinationPathPrefix})
+		files = append(files, fuzz.FileToZip{
+			SourceFilePath:        library,
+			DestinationPathPrefix: destinationPathPrefix,
+			DestinationPath:       install,
+		})
 
 		// For each architecture-specific shared library dependency, we need to
 		// install it to the output directory. Setup the install destination here,

+ 9 - 5
fuzz/fuzz_common.go

@@ -61,6 +61,7 @@ type FuzzPackager struct {
 type FileToZip struct {
 	SourceFilePath        android.Path
 	DestinationPathPrefix string
+	DestinationPath       string
 }
 
 type ArchOs struct {
@@ -443,7 +444,7 @@ func (s *FuzzPackager) PackageArtifacts(ctx android.SingletonContext, module and
 			FlagWithOutput("-o ", corpusZip)
 		rspFile := corpusZip.ReplaceExtension(ctx, "rsp")
 		command.FlagWithRspFileInputList("-r ", rspFile, fuzzModule.Corpus)
-		files = append(files, FileToZip{corpusZip, ""})
+		files = append(files, FileToZip{SourceFilePath: corpusZip})
 	}
 
 	// Package the data into a zipfile.
@@ -456,17 +457,17 @@ func (s *FuzzPackager) PackageArtifacts(ctx android.SingletonContext, module and
 			command.FlagWithArg("-C ", intermediateDir)
 			command.FlagWithInput("-f ", f)
 		}
-		files = append(files, FileToZip{dataZip, ""})
+		files = append(files, FileToZip{SourceFilePath: dataZip})
 	}
 
 	// The dictionary.
 	if fuzzModule.Dictionary != nil {
-		files = append(files, FileToZip{fuzzModule.Dictionary, ""})
+		files = append(files, FileToZip{SourceFilePath: fuzzModule.Dictionary})
 	}
 
 	// Additional fuzz config.
 	if fuzzModule.Config != nil && IsValidConfig(fuzzModule, module.Name()) {
-		files = append(files, FileToZip{fuzzModule.Config, ""})
+		files = append(files, FileToZip{SourceFilePath: fuzzModule.Config})
 	}
 
 	return files
@@ -485,6 +486,9 @@ func (s *FuzzPackager) BuildZipFile(ctx android.SingletonContext, module android
 		} else {
 			command.Flag("-P ''")
 		}
+		if file.DestinationPath != "" {
+			command.FlagWithArg("-e ", file.DestinationPath)
+		}
 		command.FlagWithInput("-f ", file.SourceFilePath)
 	}
 
@@ -502,7 +506,7 @@ func (s *FuzzPackager) BuildZipFile(ctx android.SingletonContext, module android
 	}
 
 	s.FuzzTargets[module.Name()] = true
-	archDirs[archOs] = append(archDirs[archOs], FileToZip{fuzzZip, ""})
+	archDirs[archOs] = append(archDirs[archOs], FileToZip{SourceFilePath: fuzzZip})
 
 	return archDirs[archOs], true
 }

+ 2 - 2
java/fuzz.go

@@ -250,11 +250,11 @@ func generateBuildActions(s *fuzz.FuzzPackager, hostOrTargetString string, ctx a
 		files = s.PackageArtifacts(ctx, module, javaFuzzModule.fuzzPackagedModule, archDir, builder)
 
 		// Add .jar
-		files = append(files, fuzz.FileToZip{javaFuzzModule.implementationJarFile, ""})
+		files = append(files, fuzz.FileToZip{SourceFilePath: javaFuzzModule.implementationJarFile})
 
 		// Add jni .so files
 		for _, fPath := range javaFuzzModule.jniFilePaths {
-			files = append(files, fuzz.FileToZip{fPath, ""})
+			files = append(files, fuzz.FileToZip{SourceFilePath: fPath})
 		}
 
 		archDirs[archOs], ok = s.BuildZipFile(ctx, module, javaFuzzModule.fuzzPackagedModule, files, builder, archDir, archString, hostOrTargetString, archOs, archDirs)