aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-11-29 21:39:59 -0800
committerDan Willemsen <dwillemsen@google.com>2019-02-15 14:33:59 -0800
commit707542f2989751e9a834e5d0bd30dc23cbcc8d16 (patch)
tree7a817e7fb8bdf60abfb85d3d8f4194839f7a5528 /cmd
parent7b88d7c9f6a1b5c8c50a581bb16e685be4ecd0d6 (diff)
downloadbuild_soong-707542f2989751e9a834e5d0bd30dc23cbcc8d16.tar.gz
build_soong-707542f2989751e9a834e5d0bd30dc23cbcc8d16.tar.bz2
build_soong-707542f2989751e9a834e5d0bd30dc23cbcc8d16.zip
Simplify python launcher, use __main__.py
Uses more python rather than C++, and skips less of Py_Main. Test: build/soong/python/tests/runtests.sh Change-Id: I03997d88e2e16047c96bb4e00e530229c42b3325
Diffstat (limited to 'cmd')
-rw-r--r--cmd/merge_zips/merge_zips.go27
-rw-r--r--cmd/merge_zips/merge_zips_test.go2
2 files changed, 4 insertions, 25 deletions
diff --git a/cmd/merge_zips/merge_zips.go b/cmd/merge_zips/merge_zips.go
index c21da44b..68fe2592 100644
--- a/cmd/merge_zips/merge_zips.go
+++ b/cmd/merge_zips/merge_zips.go
@@ -66,7 +66,6 @@ var (
stripDirEntries = flag.Bool("D", false, "strip directory entries from the output zip file")
manifest = flag.String("m", "", "manifest file to insert in jar")
pyMain = flag.String("pm", "", "__main__.py file to insert in par")
- entrypoint = flag.String("e", "", "par entrypoint file to insert in par")
prefix = flag.String("prefix", "", "A file to prefix to the zip file")
ignoreDuplicates = flag.Bool("ignore-duplicates", false, "take each entry from the first zip it exists in and don't warn")
)
@@ -79,7 +78,7 @@ func init() {
func main() {
flag.Usage = func() {
- fmt.Fprintln(os.Stderr, "usage: merge_zips [-jpsD] [-m manifest] [--prefix script] [-e entrypoint] [-pm __main__.py] output [inputs...]")
+ fmt.Fprintln(os.Stderr, "usage: merge_zips [-jpsD] [-m manifest] [--prefix script] [-pm __main__.py] output [inputs...]")
flag.PrintDefaults()
}
@@ -139,16 +138,12 @@ func main() {
log.Fatal(errors.New("must specify -j when specifying a manifest via -m"))
}
- if *entrypoint != "" && !*emulatePar {
- log.Fatal(errors.New("must specify -p when specifying a entrypoint via -e"))
- }
-
if *pyMain != "" && !*emulatePar {
log.Fatal(errors.New("must specify -p when specifying a Python __main__.py via -pm"))
}
// do merge
- err = mergeZips(readers, writer, *manifest, *entrypoint, *pyMain, *sortEntries, *emulateJar, *emulatePar,
+ err = mergeZips(readers, writer, *manifest, *pyMain, *sortEntries, *emulateJar, *emulatePar,
*stripDirEntries, *ignoreDuplicates, []string(stripFiles), []string(stripDirs), map[string]bool(zipsToNotStrip))
if err != nil {
log.Fatal(err)
@@ -249,7 +244,7 @@ type fileMapping struct {
source zipSource
}
-func mergeZips(readers []namedZipReader, writer *zip.Writer, manifest, entrypoint, pyMain string,
+func mergeZips(readers []namedZipReader, writer *zip.Writer, manifest, pyMain string,
sortEntries, emulateJar, emulatePar, stripDirEntries, ignoreDuplicates bool,
stripFiles, stripDirs []string, zipsToNotStrip map[string]bool) error {
@@ -289,22 +284,6 @@ func mergeZips(readers []namedZipReader, writer *zip.Writer, manifest, entrypoin
addMapping(jar.ManifestFile, fileSource)
}
- if entrypoint != "" {
- buf, err := ioutil.ReadFile(entrypoint)
- if err != nil {
- return err
- }
- fh := &zip.FileHeader{
- Name: "entry_point.txt",
- Method: zip.Store,
- UncompressedSize64: uint64(len(buf)),
- }
- fh.SetMode(0700)
- fh.SetModTime(jar.DefaultTime)
- fileSource := bufferEntry{fh, buf}
- addMapping("entry_point.txt", fileSource)
- }
-
if pyMain != "" {
buf, err := ioutil.ReadFile(pyMain)
if err != nil {
diff --git a/cmd/merge_zips/merge_zips_test.go b/cmd/merge_zips/merge_zips_test.go
index 19fa5edd..dbde2705 100644
--- a/cmd/merge_zips/merge_zips_test.go
+++ b/cmd/merge_zips/merge_zips_test.go
@@ -221,7 +221,7 @@ func TestMergeZips(t *testing.T) {
out := &bytes.Buffer{}
writer := zip.NewWriter(out)
- err := mergeZips(readers, writer, "", "", "",
+ err := mergeZips(readers, writer, "", "",
test.sort, test.jar, false, test.stripDirEntries, test.ignoreDuplicates,
test.stripFiles, test.stripDirs, test.zipsToNotStrip)