Merge changes from topic "glob_escapes"
* changes: Revert "soong_zip: support globs in -f and -D arguments" Revert "Add a --symlinks argument to soong_zip"
This commit is contained in:
@@ -103,10 +103,10 @@ var buildAAR = pctx.AndroidStaticRule("buildAAR",
|
||||
`cp ${manifest} ${outDir}/AndroidManifest.xml && ` +
|
||||
`cp ${classesJar} ${outDir}/classes.jar && ` +
|
||||
`cp ${rTxt} ${outDir}/R.txt && ` +
|
||||
`${config.SoongZipCmd} -jar -o $out -C ${outDir} -D ${outDir}`,
|
||||
`${config.SoongZipCmd} -jar -o $out -C ${outDir} -D ${outDir} ${resArgs}`,
|
||||
CommandDeps: []string{"${config.SoongZipCmd}"},
|
||||
},
|
||||
"manifest", "classesJar", "rTxt", "outDir")
|
||||
"manifest", "classesJar", "rTxt", "resArgs", "outDir")
|
||||
|
||||
func BuildAAR(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
classesJar, manifest, rTxt android.Path, res android.Paths) {
|
||||
|
||||
@@ -321,7 +321,7 @@ func TransformResourcesToJar(ctx android.ModuleContext, outputFile android.Writa
|
||||
Output: outputFile,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"jarArgs": strings.Join(proptools.NinjaAndShellEscape(jarArgs), " "),
|
||||
"jarArgs": strings.Join(proptools.NinjaEscape(jarArgs), " "),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
|
||||
"github.com/google/blueprint/pathtools"
|
||||
)
|
||||
|
||||
var resourceExcludes = []string{
|
||||
@@ -66,7 +64,7 @@ func ResourceDirsToJarArgs(ctx android.ModuleContext,
|
||||
if !strings.HasPrefix(path, dir.String()) {
|
||||
panic(fmt.Errorf("path %q does not start with %q", path, dir))
|
||||
}
|
||||
args = append(args, "-f", pathtools.MatchEscape(path))
|
||||
args = append(args, "-f", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +107,7 @@ func resourceFilesToJarArgs(ctx android.ModuleContext,
|
||||
if i == 0 || dir != lastDir {
|
||||
args = append(args, "-C", dir)
|
||||
}
|
||||
args = append(args, "-f", pathtools.MatchEscape(path))
|
||||
args = append(args, "-f", path)
|
||||
lastDir = dir
|
||||
}
|
||||
|
||||
|
||||
@@ -186,8 +186,6 @@ func main() {
|
||||
emulateJar := flags.Bool("jar", false, "modify the resultant .zip to emulate the output of 'jar'")
|
||||
writeIfChanged := flags.Bool("write_if_changed", false, "only update resultant .zip if it has changed")
|
||||
|
||||
symlinks := flags.Bool("symlinks", true, "store symbolic links in zip instead of following them")
|
||||
|
||||
parallelJobs := flags.Int("parallel", runtime.NumCPU(), "number of parallel threads to use")
|
||||
cpuProfile := flags.String("cpuprofile", "", "write cpu profile to file")
|
||||
traceFile := flags.String("trace", "", "write trace to file")
|
||||
@@ -201,11 +199,6 @@ func main() {
|
||||
|
||||
flags.Parse(expandedArgs[1:])
|
||||
|
||||
if flags.NArg() > 0 {
|
||||
fmt.Fprintf(os.Stderr, "unexpected arguments %s\n", strings.Join(flags.Args(), " "))
|
||||
usage()
|
||||
}
|
||||
|
||||
err := zip.Run(zip.ZipArgs{
|
||||
FileArgs: fArgs,
|
||||
OutputFilePath: *out,
|
||||
@@ -218,10 +211,9 @@ func main() {
|
||||
NumParallelJobs: *parallelJobs,
|
||||
NonDeflatedFiles: nonDeflatedFiles,
|
||||
WriteIfChanged: *writeIfChanged,
|
||||
StoreSymlinks: *symlinks,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "error:", err.Error())
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
41
zip/zip.go
41
zip/zip.go
@@ -107,7 +107,6 @@ type ZipWriter struct {
|
||||
|
||||
compressorPool sync.Pool
|
||||
compLevel int
|
||||
followSymlinks pathtools.ShouldFollowSymlinks
|
||||
}
|
||||
|
||||
type zipEntry struct {
|
||||
@@ -133,7 +132,6 @@ type ZipArgs struct {
|
||||
NumParallelJobs int
|
||||
NonDeflatedFiles map[string]bool
|
||||
WriteIfChanged bool
|
||||
StoreSymlinks bool
|
||||
}
|
||||
|
||||
const NOQUOTE = '\x00'
|
||||
@@ -214,36 +212,21 @@ func Run(args ZipArgs) (err error) {
|
||||
args.AddDirectoryEntriesToZip = true
|
||||
}
|
||||
|
||||
// Have Glob follow symlinks if they are not being stored as symlinks in the zip file.
|
||||
followSymlinks := pathtools.ShouldFollowSymlinks(!args.StoreSymlinks)
|
||||
|
||||
w := &ZipWriter{
|
||||
time: jar.DefaultTime,
|
||||
createdDirs: make(map[string]string),
|
||||
createdFiles: make(map[string]string),
|
||||
directories: args.AddDirectoryEntriesToZip,
|
||||
compLevel: args.CompressionLevel,
|
||||
followSymlinks: followSymlinks,
|
||||
time: jar.DefaultTime,
|
||||
createdDirs: make(map[string]string),
|
||||
createdFiles: make(map[string]string),
|
||||
directories: args.AddDirectoryEntriesToZip,
|
||||
compLevel: args.CompressionLevel,
|
||||
}
|
||||
pathMappings := []pathMapping{}
|
||||
|
||||
noCompression := args.CompressionLevel == 0
|
||||
|
||||
for _, fa := range args.FileArgs {
|
||||
var srcs []string
|
||||
for _, s := range fa.SourceFiles {
|
||||
globbed, _, err := pathtools.Glob(s, nil, followSymlinks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
srcs = append(srcs, globbed...)
|
||||
}
|
||||
srcs := fa.SourceFiles
|
||||
if fa.GlobDir != "" {
|
||||
globbed, _, err := pathtools.Glob(filepath.Join(fa.GlobDir, "**/*"), nil, followSymlinks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
srcs = append(srcs, globbed...)
|
||||
srcs = append(srcs, recursiveGlobFiles(fa.GlobDir)...)
|
||||
}
|
||||
for _, src := range srcs {
|
||||
err := fillPathPairs(fa, src, &pathMappings, args.NonDeflatedFiles, noCompression)
|
||||
@@ -478,15 +461,7 @@ func (z *ZipWriter) addFile(dest, src string, method uint16, emulateJar bool) er
|
||||
var fileSize int64
|
||||
var executable bool
|
||||
|
||||
var s os.FileInfo
|
||||
var err error
|
||||
if z.followSymlinks {
|
||||
s, err = os.Stat(src)
|
||||
} else {
|
||||
s, err = os.Lstat(src)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if s, err := os.Lstat(src); err != nil {
|
||||
return err
|
||||
} else if s.IsDir() {
|
||||
if z.directories {
|
||||
|
||||
Reference in New Issue
Block a user