diff --git a/compiler/bindata.go b/compiler/bindata.go index 2abf1c3..c3d7671 100644 --- a/compiler/bindata.go +++ b/compiler/bindata.go @@ -71,7 +71,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _templatesEmbedGoTmpl = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x8e\xc1\x4a\x04\x31\x10\x44\xef\xf3\x15\x75\x98\x43\x02\xbb\xf9\x00\xc1\x83\xa2\xe0\xc5\x45\x14\xbd\x88\x2c\x59\xd3\xa3\x0d\x33\x19\xed\x24\xab\x12\xf2\xef\xd2\xe3\x9c\x44\x6f\xa9\x74\xd5\xab\xaa\x75\x0b\xf1\xf1\x85\xd0\xef\x37\xe8\xdf\x84\x71\x72\x8a\xde\xdd\x47\x7e\xbf\x11\x9e\x85\x33\x53\x42\x6b\xdd\x2f\xe7\x71\x52\xa3\xe1\x18\xe8\x13\xbd\xbb\x9b\x25\x53\x78\xb8\x4e\x0b\xc3\xfe\x11\xa0\xe9\x40\x61\x81\x1f\x27\x77\xa9\x62\xc1\x0e\x25\x3e\xa3\xd6\xf5\xee\x76\x7e\xa2\x2b\x9f\x5e\xd1\x9a\xb1\x78\x7c\x3a\x7c\x65\x42\xed\x80\xb4\xc1\x5e\xd3\x3c\x97\xcc\xa3\xbb\x25\x1f\xce\xc6\xd1\x0c\xa3\xcf\xe4\x76\xf4\xa1\x1f\x24\x46\xfd\x49\xf5\x79\x19\x06\x12\xf3\x43\x50\x00\xa0\x83\xd6\x9a\x0b\x9f\xbd\xb6\x03\xcd\x5a\xdb\x01\x42\xb9\x48\x44\xea\x74\x37\x28\x06\x6c\xdb\x3f\xcf\xef\x00\x00\x00\xff\xff\xf0\x23\xa3\xa9\x33\x01\x00\x00" +var _templatesEmbedGoTmpl = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x8e\x4d\x4a\x04\x31\x10\x85\xf7\x7d\x8a\xc7\x90\x45\x02\x33\x39\x80\xe0\x42\x50\x70\xe3\x20\x8a\x6e\x44\x86\x8c\x29\xdb\x82\x4e\x7a\xac\xa4\xc7\x9f\x90\xbb\x4b\x9a\x06\x45\x74\x57\x55\xef\x7b\x1f\x55\xca\x06\xe2\x62\x4f\x50\xbb\x35\xd4\x41\x18\x27\xa7\x50\xf6\x2e\xf2\xeb\xb5\xf0\x28\x9c\x99\x12\x6a\xed\x7e\x91\xc7\xd0\x40\xcd\xd1\xd3\x3b\x94\xbd\x1d\x25\x93\xbf\xbf\x4a\xb3\xc3\xfc\x51\xa0\xb0\x27\x3f\xcb\x8f\xc1\x5e\xb4\x65\xd6\x3e\x4f\xf1\x09\xa5\x2c\xb9\xdd\xba\x40\x97\x2e\xbd\xa0\x56\x6d\xf0\xf0\xb8\xff\xc8\x84\xd2\x01\xb2\xc6\xae\xb5\xfb\x4f\x3e\xd8\x2d\xbd\xdd\x90\xf3\x24\x3a\x65\xe1\xd8\xa7\x1f\x97\xd5\xb7\xec\xdc\x65\x87\x5a\x57\xc6\x74\x40\x5a\x04\x3c\x4e\x99\x07\xdb\xe8\xb3\x61\xd0\xd2\x32\xa1\x3c\x49\x44\xea\xda\xd7\xa0\xe8\xb1\xa9\xff\x8c\x5f\x01\x00\x00\xff\xff\xd5\xe3\xa7\x72\x31\x01\x00\x00" func templatesEmbedGoTmplBytes() ([]byte, error) { return bindataRead( @@ -86,12 +86,12 @@ func templatesEmbedGoTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "templates/embed.go.tmpl", size: 307, mode: os.FileMode(420), modTime: time.Unix(1520115917, 0)} + info := bindataFileInfo{name: "templates/embed.go.tmpl", size: 305, mode: os.FileMode(420), modTime: time.Unix(1520146058, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _templatesEntrypointGoTmpl = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x53\x41\x4f\xe3\x3a\x10\xbe\xe7\x57\x8c\xa2\xea\x29\x11\xc5\xe5\x71\x44\xea\x01\x3d\x0a\x0f\x09\x58\xa4\x2e\x70\x40\x2c\x72\x92\xa9\xb1\x9a\xd8\xe9\xd8\x6e\x41\x55\xfe\xfb\x6a\x9c\x14\x28\x1c\x76\x2f\x95\x67\xf2\xcd\x37\xdf\x7c\x33\x6d\x65\xb9\x94\x0a\xa1\x91\xda\x24\x89\x6e\x5a\x4b\x1e\xb2\x04\x20\x2d\xde\x3c\xba\x94\x5f\xa5\x6d\x5a\x42\xe7\x26\x8b\x5a\x7a\x8c\x29\x6d\x27\xda\x06\xaf\xeb\x18\xb9\x37\x53\xf6\x0f\x4f\xa5\x35\xeb\x34\xe1\x40\x69\xff\x12\x0a\x51\xda\x66\xa2\xd0\x1c\x95\xba\xc2\x89\x72\x25\xe9\xd6\x4f\xd0\x28\x6d\x22\xd5\x76\x7b\x08\x7a\x01\xb8\x82\x91\x98\x19\x59\xd4\x78\x65\x95\xd2\x46\x81\xa7\x80\xd0\x75\x7f\xa2\xaa\x7b\x78\xfa\x05\xe7\x34\x85\xd6\xa1\xe1\xef\x14\x5c\xdf\x0a\xd0\x54\x4c\x99\x27\xc9\x22\x98\x32\x4e\x9d\xe5\xb0\x4d\x00\xd6\x92\x60\xa3\x80\x47\x11\x0f\x52\xfb\x0b\xb2\xa1\x1d\xf4\x91\x34\x0a\x61\xf4\x3c\x86\x51\x4b\x1a\x4e\xa6\x30\x12\x77\x46\xaf\x6e\x49\x5b\xd2\x5e\xa3\xeb\x75\x7e\xc1\xae\x1b\x86\x66\xda\x54\xf8\x0a\x23\x31\xb7\xe4\xb1\xba\xbf\x76\x91\x25\xef\x4b\x36\x4a\x9c\x56\x55\xf6\x6f\x9e\x00\x28\x0b\xac\x6a\x10\x04\x50\xe1\x02\x59\x94\x38\xb3\x06\xb3\x3c\xe6\x94\x43\x26\xed\xfd\x13\x37\xb8\xc9\xd2\xed\x96\x5b\x89\xcb\x33\xe8\xba\xb4\x47\xfd\x8d\xa9\x91\x4b\x70\x1e\x49\x9c\x5b\x6a\xa4\xf7\x48\x30\x85\x7f\x06\x47\xc5\xc5\x7c\xf6\x9e\xdf\x7e\x2b\xf9\x11\x3c\x4c\x61\x87\xbd\xb2\xea\x81\x34\x03\x6f\x64\x83\x27\xb0\xaf\xea\x5b\xf1\x15\xae\xb1\xee\xcb\x29\x38\x71\x86\x45\x50\x31\xf7\x2e\x7f\xd8\xd4\xae\xee\x3f\x42\xe9\xf1\xfe\xfa\xc3\x06\x31\x47\xff\x53\x37\x68\x83\xcf\x86\x66\x43\x08\x5d\xb7\xb3\xe1\xf3\x3a\xb0\x29\xb0\x8a\xcb\x5b\x37\x62\xc6\x81\x83\xc3\x4f\x2d\x4e\xab\xea\x32\xde\x7f\x6f\x69\x84\x8b\x73\x5d\xa3\x91\x0d\x7b\x96\x8e\xe1\x23\xcf\x53\xfe\x2f\xdd\xcb\xe7\x5e\x2c\xf9\x70\xcf\x5b\x59\xcd\xe3\x91\x66\x1c\xf6\xe4\xee\x71\xcf\x1a\xa1\x5c\xfa\x94\xe5\x1f\x53\xcd\x5e\xb1\x0c\x1e\x6f\x6b\x69\xe2\xac\x5d\xfc\xdd\x63\xdf\xa8\x78\xa1\x5f\x3f\x74\xc3\x51\xab\x6c\x09\x14\x0c\x8e\xa1\x80\xc7\x27\x7e\xe5\xe0\x3c\xf1\xf6\xf9\xae\x16\x96\x40\x8f\xe1\x99\x9d\xe8\xdd\x29\x86\x7b\x2b\x1e\xf5\x13\xfc\x9a\xc2\x32\x46\x4b\x7e\x72\x8a\x45\x24\x00\x2b\x2e\xe8\x79\xb2\xa3\xd7\xe3\x63\xee\xee\x06\x9e\xe1\x7f\x2f\xee\xcc\x2a\x58\x8f\xd9\x0a\x0e\x76\xd0\x22\x87\x03\x58\x31\x98\xd0\x07\x32\xe0\x92\x2e\xf9\x1d\x00\x00\xff\xff\xb1\x82\xe2\x8d\x76\x04\x00\x00" +var _templatesEntrypointGoTmpl = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x54\x4d\x4f\xdb\x40\x10\xbd\xfb\x57\x8c\xac\xa8\xb2\x45\xd8\x50\x8e\x48\x39\xa0\x12\x28\x12\x50\xa4\x14\x38\x20\x8a\xd6\xf6\x64\x19\x25\xde\x75\xf6\x23\xa1\x8d\xfc\xdf\xab\x59\x3b\x40\xc2\xa1\xbd\x44\x3b\xe3\x37\x6f\xde\xbc\x9d\x4d\x23\xcb\xb9\x54\x08\xb5\x24\x9d\x24\x54\x37\xc6\x7a\xc8\x12\x80\xb4\x34\x75\x63\xd1\xb9\x91\xfa\x43\x4d\xca\x19\x32\x23\x32\xc1\xd3\x22\x46\xee\xb7\x2e\xbb\x83\xb7\xa5\xd1\xab\xed\x99\xb4\x72\x69\xc2\x81\x22\xff\x12\x0a\x51\x9a\x7a\xa4\x50\x1f\x95\x54\xe1\x48\xb9\xd2\x52\xe3\x47\xa8\x15\x69\xe4\x9a\xcd\xe6\x10\x68\x06\xb8\x84\x81\x98\x68\x59\x2c\xf0\xca\x28\x45\x5a\x81\xb7\x01\xa1\x6d\xff\x45\xb5\xe8\xe0\xe9\x1e\xce\x91\x0d\x8d\x43\xcd\xdf\x6d\x70\x5d\x2b\x40\x5d\x31\x65\x9e\x24\xb3\xa0\xcb\x38\x76\x96\xc3\x26\x01\x58\x49\x0b\x6b\x05\x3c\x96\x78\x90\xe4\x2f\xac\x09\x4d\xaf\xcf\x4a\xad\x10\x06\xcf\x43\x18\x34\x96\xe0\x64\x0c\x03\x71\xa7\x69\x79\x6b\xc9\x58\xf2\x84\xae\xd3\xb9\x87\x5d\xd5\x0c\xcd\x48\x57\xf8\x0a\x03\x31\x35\xd6\x63\x75\x7f\xed\x22\x4b\xde\x95\xac\x95\x38\xad\xaa\xec\x6b\x9e\x00\x28\x03\xac\xaa\x17\x04\x50\xe1\x0c\x59\x94\x38\x33\x1a\xb3\x3c\xe6\x94\x43\x26\xed\xfc\x13\x37\xb8\xce\xd2\xcd\x86\x5b\x89\xcb\x33\x68\xdb\xb4\x43\xfd\x8f\xa9\x91\x4b\x70\x1e\xad\x38\x37\xb6\x96\xde\xa3\x85\x31\x7c\xe9\x1d\x15\x17\xd3\xc9\x5b\x7e\xf3\xa9\xe4\x47\xf0\x30\x86\x2d\xf6\xca\xa8\x07\x4b\x0c\xbc\x91\x35\x9e\xc0\xae\xaa\x4f\xc5\x57\xb8\xc2\x45\x57\x6e\x83\x13\x67\x58\x04\x15\x73\x6f\xf2\xfb\x9b\xda\xd6\x7d\xb3\x28\x3d\xde\x5f\xbf\xdb\x20\xa6\xe8\x7f\x52\x8d\x26\xf8\xac\x6f\xd6\x87\xd0\xb6\x5b\x1b\x3e\x5e\x07\xd6\x05\x56\xf1\xf2\x56\xb5\x98\x70\xe0\xe0\xf0\x43\x8b\xd3\xaa\xba\x8c\x0f\xa0\xb3\x34\xc2\xc5\x39\x2d\x50\xcb\x9a\x3d\x4b\x87\xf0\x9e\xe7\x29\xbf\x4b\xf7\xf2\xb1\x17\x4b\x3e\xdc\xf1\x56\x56\xd3\xb8\xa4\x19\x87\x1d\xb9\x7b\xdc\xb1\x46\x28\x97\x3e\x65\xf9\xfb\x54\x93\x57\x2c\x83\xc7\xdb\x85\xd4\x71\xd6\x36\xfe\xee\xb0\xaf\x55\xdc\xd0\xfd\x0f\x6d\xbf\xd4\x2a\x9b\x83\x0d\x1a\x87\x50\xc0\xe3\x13\x9f\x72\xe8\x1e\x66\xdc\xab\x99\xb1\x40\x43\x78\x66\x27\x3a\x77\x8a\x7e\xdf\x8a\x47\x7a\x82\x5f\x63\x98\xc7\x68\xce\x47\x4e\xb1\x88\x04\x60\xc9\x05\x1d\x4f\x76\xf4\x7a\x7c\xcc\xdd\x5d\xcf\xd3\xff\x07\x88\x3b\xbd\x0c\xc6\x63\xb6\x84\x83\x2d\xb4\xc8\xe1\x00\x96\x0c\xb6\xe8\x83\xd5\xe0\x92\x36\xf9\x1b\x00\x00\xff\xff\x90\x4b\x40\x84\x77\x04\x00\x00" func templatesEntrypointGoTmplBytes() ([]byte, error) { return bindataRead( @@ -106,7 +106,7 @@ func templatesEntrypointGoTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "templates/entrypoint.go.tmpl", size: 1142, mode: os.FileMode(420), modTime: time.Unix(1520112101, 0)} + info := bindataFileInfo{name: "templates/entrypoint.go.tmpl", size: 1143, mode: os.FileMode(420), modTime: time.Unix(1520146076, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -146,7 +146,7 @@ func templatesObfstringGoTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "templates/obfstring.go.tmpl", size: 159, mode: os.FileMode(420), modTime: time.Unix(1511857680, 0)} + info := bindataFileInfo{name: "templates/obfstring.go.tmpl", size: 159, mode: os.FileMode(420), modTime: time.Unix(1520144733, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/compiler/embedder.go b/compiler/embedder.go index 3534f63..c4b602d 100644 --- a/compiler/embedder.go +++ b/compiler/embedder.go @@ -2,7 +2,7 @@ package compiler import ( "bytes" - "compress/flate" + "compress/gzip" "fmt" "io/ioutil" "math/rand" @@ -54,24 +54,22 @@ func (e *EmbeddedFile) Data() string { } func (e *EmbeddedFile) GenerateEmbedData() { - for idx, b := range e.Compressed { - if idx%12 == 0 { - e.EmbedData.WriteString("\n ") - } - e.EmbedData.WriteString(fmt.Sprintf("0x%02x, ", b)) + for _, b := range e.Compressed { + e.EmbedData.WriteString(fmt.Sprintf("\\x%02x", b)) } } func BytesToCompressed(b []byte) []byte { buf := new(bytes.Buffer) - w, _ := flate.NewWriter(buf, flate.BestCompression) + w, _ := gzip.NewWriterLevel(buf, gzip.BestCompression) w.Write(b) w.Close() return buf.Bytes() } func CompressedToBytes(b []byte) []byte { - buf, _ := ioutil.ReadAll(flate.NewReader(bytes.NewBuffer(b))) + r, _ := gzip.NewReader(bytes.NewBuffer(b)) + buf, _ := ioutil.ReadAll(r) return buf } diff --git a/gscript.go b/gscript.go index e45776f..220b43a 100644 --- a/gscript.go +++ b/gscript.go @@ -1,4 +1,4 @@ package gscript // Version defines the version of gscript -const Version = "v0.0.15" +const Version = "v0.0.16" diff --git a/spec/large_file.gs b/spec/large_file.gs new file mode 100644 index 0000000..eafe201 --- /dev/null +++ b/spec/large_file.gs @@ -0,0 +1,16 @@ +//import:/Users/flint/Downloads/e200.tar + +function BeforeDeploy() { + LogInfo("BeforeDeploy()"); + return true; +} + +function Deploy() { + WriteFile("/Users/flint/Downloads/e301.tar", Asset("e200.tar"), "0644"); + return true; +} + +function AfterDeploy() { + LogInfo("AfterDeploy()"); + return true; +} diff --git a/spec/test.gs b/spec/test.gs index 12fc4a9..4a49b0e 100644 --- a/spec/test.gs +++ b/spec/test.gs @@ -1,4 +1,4 @@ -//import:/Users/flint/Downloads/tater.jpg +// //import:/Users/flint/Downloads/tater.jpg function BeforeDeploy() { LogInfo("BeforeDeploy()"); diff --git a/templates/embed.go.tmpl b/templates/embed.go.tmpl index dd0e174..e01cd37 100644 --- a/templates/embed.go.tmpl +++ b/templates/embed.go.tmpl @@ -2,9 +2,8 @@ {{- range $_, $vm := (index $.SortedVMs $pri) }} {{- range $_, $embed := $vm.Embeds }} func {{ $embed.NameHash }}() []byte { - s, _ := ioutil.ReadAll(flate.NewReader(bytes.NewBuffer([]byte{ - {{- $embed.Data }} - }))) + r, _ := gzip.NewReader(strings.NewReader("{{ $embed.Data }}")) + s, _ := ioutil.ReadAll(r) return s } {{ end -}} diff --git a/templates/entrypoint.go.tmpl b/templates/entrypoint.go.tmpl index 9c4ed9f..0c20ad9 100644 --- a/templates/entrypoint.go.tmpl +++ b/templates/entrypoint.go.tmpl @@ -1,11 +1,11 @@ package main import ( - "bytes" - "compress/flate" + "compress/gzip" "io/ioutil" "sync" "strconv" + "strings" "github.com/gen0cide/gscript/engine" {{- if eq $.EnableLogging true }}