-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'valencia' into issue-2255
- Loading branch information
Showing
22 changed files
with
4,616 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
glob:*.res | ||
glob:*.exe | ||
|
||
glob:tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Mateusz Czapliński <czapkofan@gmail.com> | ||
shnmng <shnmng@gmail.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2013-2014 The rsrc Authors. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
rsrc - Tool for embedding binary resources in Go programs. | ||
|
||
INSTALL: go get github.com/akavel/rsrc | ||
|
||
PREBUILT BINARIES for Windows/Linux/MacOSX available via 3rd party site: | ||
http://gobuild.io/download/github.com/akavel/rsrc | ||
|
||
USAGE: | ||
|
||
rsrc [-manifest FILE.exe.manifest] [-ico FILE.ico[,FILE2.ico...]] -o FILE.syso | ||
Generates a .syso file with specified resources embedded in .rsrc section. | ||
The .syso file can be linked by Go linker when building Win32 executables. | ||
Icon embedded this way will show up on application's .exe instead of empty icon. | ||
Manifest file embedded this way will be recognized and detected by Windows. | ||
|
||
rsrc -data FILE.dat -o FILE.syso > FILE.c | ||
Generates a .syso file with specified opaque binary blob embedded, | ||
together with related .c file making it possible to access from Go code. | ||
Theoretically cross-platform, but reportedly cannot compile together with cgo. | ||
|
||
The generated *.syso and *.c files should get automatically recognized | ||
by 'go build' command and linked into an executable/library, as long as | ||
there are any *.go files in the same directory. | ||
|
||
NOTE: starting with Go 1.4+, *.c files reportedly won't be linkable any more, | ||
see: https://codereview.appspot.com/149720043 | ||
|
||
OPTIONS: | ||
-data="": path to raw data file to embed | ||
-ico="": comma-separated list of paths to .ico files to embed | ||
-manifest="": path to a Windows manifest file to embed | ||
-o="rsrc.syso": name of output COFF (.res or .syso) file | ||
|
||
Based on ideas presented by Minux. | ||
|
||
In case anything does not work, it'd be nice if you could report (either via Github | ||
issues, or via email to czapkofan@gmail.com), and please attach the input file(s) | ||
which resulted in a problem, plus error message & symptoms, and/or any other details. | ||
|
||
TODO MAYBE/LATER: | ||
- fix or remove FIXMEs | ||
|
||
LICENSE: MIT | ||
Copyright 2013-2014 The rsrc Authors. | ||
|
||
http://github.com/akavel/rsrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package binutil | ||
|
||
import ( | ||
"reflect" | ||
) | ||
|
||
func Plain(kind reflect.Kind) bool { | ||
switch kind { | ||
case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128: | ||
return true | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package binutil | ||
|
||
import ( | ||
"io" | ||
"os" | ||
) | ||
|
||
type SizedReader interface { | ||
io.Reader | ||
Size() int64 | ||
} | ||
|
||
type SizedFile struct { | ||
f *os.File | ||
s *io.SectionReader // helper, for Size() | ||
} | ||
|
||
func (r *SizedFile) Read(p []byte) (n int, err error) { return r.s.Read(p) } | ||
func (r *SizedFile) Size() int64 { return r.s.Size() } | ||
func (r *SizedFile) Close() error { return r.f.Close() } | ||
|
||
func SizedOpen(filename string) (*SizedFile, error) { | ||
f, err := os.Open(filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
info, err := f.Stat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &SizedFile{ | ||
f: f, | ||
s: io.NewSectionReader(f, 0, info.Size()), | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package binutil | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"path" | ||
"reflect" | ||
) | ||
|
||
var ( | ||
WALK_SKIP = errors.New("") | ||
) | ||
|
||
type Walker func(v reflect.Value, path string) error | ||
|
||
func Walk(value interface{}, walker Walker) error { | ||
err := walk(reflect.ValueOf(value), "/", walker) | ||
if err == WALK_SKIP { | ||
err = nil | ||
} | ||
return err | ||
} | ||
|
||
func stopping(err error) bool { | ||
return err != nil && err != WALK_SKIP | ||
} | ||
|
||
func walk(v reflect.Value, spath string, walker Walker) error { | ||
err := walker(v, spath) | ||
if err != nil { | ||
return err | ||
} | ||
v = reflect.Indirect(v) | ||
switch v.Kind() { | ||
case reflect.Slice, reflect.Array: | ||
for i := 0; i < v.Len(); i++ { | ||
err = walk(v.Index(i), spath+fmt.Sprintf("[%d]", i), walker) | ||
if stopping(err) { | ||
return err | ||
} | ||
} | ||
case reflect.Interface: | ||
err = walk(v.Elem(), spath, walker) | ||
if stopping(err) { | ||
return err | ||
} | ||
case reflect.Struct: | ||
//t := v.Type() | ||
for i := 0; i < v.NumField(); i++ { | ||
//f := t.Field(i) //TODO: handle unexported fields | ||
vv := v.Field(i) | ||
err = walk(vv, path.Join(spath, v.Type().Field(i).Name), walker) | ||
if stopping(err) { | ||
return err | ||
} | ||
} | ||
default: | ||
// FIXME: handle other special cases too | ||
// String | ||
return nil | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package binutil | ||
|
||
import ( | ||
"encoding/binary" | ||
"io" | ||
"reflect" | ||
) | ||
|
||
type Writer struct { | ||
W io.Writer | ||
Offset uint32 //FIXME: int64? | ||
Err error | ||
} | ||
|
||
func (w *Writer) WriteLE(v interface{}) { | ||
if w.Err != nil { | ||
return | ||
} | ||
w.Err = binary.Write(w.W, binary.LittleEndian, v) | ||
if w.Err != nil { | ||
return | ||
} | ||
w.Offset += uint32(reflect.TypeOf(v).Size()) | ||
} | ||
|
||
func (w *Writer) WriteFromSized(r SizedReader) { | ||
if w.Err != nil { | ||
return | ||
} | ||
var n int64 | ||
n, w.Err = io.CopyN(w.W, r, r.Size()) | ||
w.Offset += uint32(n) | ||
} |
Oops, something went wrong.