Skip to content

Commit

Permalink
Merge pull request #32 from josephspurrier/windows-ci
Browse files Browse the repository at this point in the history
Fix issue with icon not closing handle
  • Loading branch information
josephspurrier committed Feb 9, 2019
2 parents 6dac909 + f050d50 commit 63e6d1a
Show file tree
Hide file tree
Showing 29 changed files with 257 additions and 159 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# IDE Settings
.vscode/

# Folders
vendor/

# Files
cmd/goversioninfo/goversioninfo
*.exe
*.syso

# OS Files
.DS_Store
thumbs.db
33 changes: 21 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
os: windows
sudo: false
language: go

go:
#- 1.0
#- 1.1
#- 1.2
#- 1.3
- 1.4
- 1.5
- 1.6
- tip

# - '1.0'
# - '1.1'
# - '1.2'
# - '1.3'
# - '1.4'
- '1.5'
- '1.6'
- '1.7'
- '1.8'
- '1.9'
- '1.10'
- '1.11'
before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
- go get github.com/akavel/rsrc/binutil
- go get github.com/akavel/rsrc/coff
- go get github.com/akavel/rsrc/ico

script:
- $HOME/gopath/bin/goveralls -repotoken lNZXr7UDQai10RBP6KAOqA6fRcs5NlKEe
# Install binary.
- go install github.com/$TRAVIS_REPO_SLUG/cmd/goversioninfo
# Test building 32 and 64 on Windows.
- bash $TRAVIS_BUILD_DIR/testdata/bash/build.sh
# Run tests and send coverage info.
- cd $TRAVIS_BUILD_DIR
- $GOPATH/bin/goveralls -service=travis-ci
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ To install, run the following command:
go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo
~~~

Copy versioninfo.json into your working directory and then modify the file with your own settings.
Copy testdata/resource/versioninfo.json into your working directory and then modify the file with your own settings.

Add a similar text to the top of your Go source code (-icon and -manifest are optional, but can also be specified in the versioninfo.json file):
~~~ go
//go:generate goversioninfo -icon=icon.ico -manifest=goversioninfo.exe.manifest
//go:generate goversioninfo -icon=testdata/resource/icon.ico -manifest=testdata/resource/goversioninfo.exe.manifest
~~~

Run the Go commands in this order so goversioninfo will create a file called resource.syso in the same directory as the Go source code.
Expand Down Expand Up @@ -94,20 +94,20 @@ If you find any other differences, let me know.

You can also use [windres](https://sourceware.org/binutils/docs/binutils/windres.html) to create the syso file. The windres executable is available in either [MinGW](http://www.mingw.org/) or [tdm-gcc](http://tdm-gcc.tdragon.net/).

Below is a sample batch file you can use to create a .syso file from a .rc file. There are sample .rc files in the rc folder.
Below is a sample batch file you can use to create a .syso file from a .rc file. There are sample .rc files in the testdata/rc folder.

~~~
@ECHO OFF
SET PATH=C:\TDM-GCC-64\bin;%PATH%
REM SET PATH=C:\mingw64\bin;%PATH%
windres -i versioninfo.rc -O coff -o versioninfo.syso
windres -i testdata/rc/versioninfo.rc -O coff -o versioninfo.syso
PAUSE
~~~

The information on how to create a .rc file is available [here](https://msdn.microsoft.com/en-us/library/windows/desktop/aa381043(v=vs.85).aspx). You can use the versioninfo.rc file to create a .syso file that contains version info, icon, and manifest.
The information on how to create a .rc file is available [here](https://msdn.microsoft.com/en-us/library/windows/desktop/aa381043(v=vs.85).aspx). You can use the testdata/rc/versioninfo.rc file to create a .syso file that contains version info, icon, and manifest.

## Issues

Expand Down
48 changes: 5 additions & 43 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,9 @@
package goversioninfo
//go:generate goversioninfo -icon=testdata/resource/icon.ico -manifest=testdata/resource/goversioninfo.exe.manifest -64

import (
"io/ioutil"
"log"
"os"
)
package goversioninfo_test

// Example
func Example() {
logic()
}

// Create the syso file
func logic() {
// Read the config file
jsonBytes, err := ioutil.ReadFile("versioninfo.json")
if err != nil {
log.Printf("Error reading versioninfo.json: %v", err)
os.Exit(1)
}

// Create a new container
vi := &VersionInfo{}

// Parse the config
if err := vi.ParseJSON(jsonBytes); err != nil {
log.Printf("Could not parse the .json file: %v", err)
os.Exit(2)
}
import "fmt"

// Fill the structures with config data
vi.Build()

// Write the data to a buffer
vi.Walk()

// Optionally, embed an icon by path
// If the icon has multiple sizes, all of the sizes will be embedded
vi.IconPath = "icon.ico"

// Create the file
if err := vi.WriteSyso("resource.syso", "386"); err != nil {
log.Printf("Error writing syso: %v", err)
os.Exit(3)
}
func Example() {
fmt.Println("Hello world")
}
2 changes: 2 additions & 0 deletions goversioninfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ type StringFileInfo struct {
// Helpers
// *****************************************************************************

// SizedReader is a *bytes.Buffer.
type SizedReader struct {
*bytes.Buffer
}

// Size returns the length of the buffer.
func (s SizedReader) Size() int64 {
return int64(s.Buffer.Len())
}
Expand Down
Loading

0 comments on commit 63e6d1a

Please sign in to comment.