syso

package module
v0.0.0-...-43d74b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 12 Imported by: 1

README

syso

Build Status codecov godoc goreportcard

syso - tool for embedding various type of resources in go Windows executable

Table of contents:

Features

Feature rsrc goversioninfo syso(this project)
Embedding icons
Embedding manifest
Configuration through a file
Embedding version info
Embedding multilingual version info
Fixed resource identifier
Why fixed resource identifier matters?

Because you can easily load your resource in runtime. Other tools do not guarantee your resource to have same id across builds.

Installation

$ go get -u github.com/hallazzang/syso/...

Usage

Write a configuration file in JSON, which tells syso what resources you want to embed. Here's an example:

{
  "Icons": [
    {
      "ID": 1,
      "Path": "icon.ico"
    }
  ],
  "Manifest": {
    "ID": 2,
    "Path": "App.exe.manifest"
  }
}

You can specify name instead of id:

...
    {
      "Name": "MyIcon",
      "Path": "icon.ico"
    }
...

Save it as syso.json in project's directory and run the tool:

$ syso

This will generate out.syso in your current directory. You can now go build to actually include the resources in your executable.

Configuration

Configuration file is written in JSON format. Top-level configuration is an object that has three optional fields: Icon, Manifest, VersionInfos.

Here are details about configuration object types.

Icon
Field Type Description
ID Number
Name String
Path String Icon file path
Manifest
Field Type Description
ID Number
Name String
Path String Manifest file path
VersionInfo
Field Type Description
ID Number
Name String
Fixed VersionInfoFixed Language-independent information
StringTables []VersionInfoStringTable Language-specific string information
Translations []VersionInfoTranslation Language and charset pairs which application supports
VersionInfoFixed
Field Type Description
FileVersion String Format: "Major.Minor.Patch.Build"
ProductVersion String Format: "Major.Minor.Patch.Build"
VersionInfoStringTable
Field Type Description
Language String (Required) String table's language, in hex
Charset String (Required) String table's charset, in hex
Strings VersionInfoStrings (Required) Actual string table
VersionInfoStrings
Field Type Description
Comments String
CompanyName String
FileDescription String
FileVersion String
InternalName String
LegalCopyright String
LegalTradeMarks String
OriginalFilename String
PrivateBuild String
ProductName String
ProductVersion String
SpecialBuild String
VersionInfoTranslation
Field Type Description
Language String (Required) Supported language, in hex
Charset String (Required) Supported charset, in hex

Here's an example configuration:

{
  "Icons": [
    {
      "ID": 1,
      "Path": "icon.ico"
    },
    {
      "Name": "Icon",
      "Path": "icon2.ico"
    }
  ],
  "Manifest": {
    "ID": 1,
    "Path": "App.exe.manifest"
  },
  "VersionInfos": [
    {
      "ID": 1,
      "Fixed": {
        "FileVersion": "10.0.14393.0",
        "ProductVersion": "10.0.14393.0"
      },
      "StringTables": [
        {
          "Language": "0409",
          "Charset": "04b0",
          "Strings": {
            "CompanyName": "Microsoft Corporation",
            "FileDescription": "Windows Command Processor",
            "FileVersion": "10.0.14393.0 (rs1_release.160715-1616)",
            "InternalName": "cmd",
            "LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
            "OriginalFilename": "Cmd.Exe",
            "ProductName": "Microsoft\u00ae Windows\u00ae Operating System",
            "ProductVersion": "10.0.14393.0"
          }
        }
      ],
      "Translations": [
        {
          "Language": "0409",
          "Charset": "04b0"
        }
      ]
    }
  ]
}

Note that keys are case-insensitive. You can use both "companyName" and "CompanyName", or even "companyname" for key.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmbedIcon

func EmbedIcon(c *coff.File, icon *FileResource) error

EmbedIcon embeds an icon into c.

func EmbedManifest

func EmbedManifest(c *coff.File, manifest *FileResource) error

EmbedManifest embeds a manifest into c.

func EmbedVersionInfo

func EmbedVersionInfo(c *coff.File, v *VersionInfoResource) error

EmbedVersionInfo embeds a version info resource.

Types

type Config

type Config struct {
	Icons        []*FileResource
	Manifest     *FileResource
	VersionInfos []*VersionInfoResource
}

Config is a syso config data.

func ParseConfig

func ParseConfig(r io.Reader) (*Config, error)

ParseConfig reads JSON-formatted syso config from r and returns Config object.

type FileResource

type FileResource struct {
	ID   int
	Name string
	Path string
}

FileResource represents a file resource that can be found at Path.

func (*FileResource) Validate

func (r *FileResource) Validate() error

Validate returns an error if the resource is invalid.

type VersionInfoFixed

type VersionInfoFixed struct {
	FileVersion    *string
	ProductVersion *string
}

VersionInfoFixed holds fixed information that is language and codepage independent, like file version or product version.

func (*VersionInfoFixed) Validate

func (f *VersionInfoFixed) Validate() error

Validate returns data validation result.

type VersionInfoResource

type VersionInfoResource struct {
	ID           *int
	Name         *string
	Fixed        *VersionInfoFixed
	StringTables []*VersionInfoStringTable
	Translations []*VersionInfoTranslation
}

VersionInfoResource represents a version info resource.

func (*VersionInfoResource) Validate

func (r *VersionInfoResource) Validate() error

Validate returns an error if the resource is invalid.

type VersionInfoStringTable

type VersionInfoStringTable struct {
	Language *string
	Charset  *string
	Strings  *VersionInfoStrings
}

VersionInfoStringTable holds string table associated with language and charset pair. See https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource#remarks for details about language and charset.

func (*VersionInfoStringTable) Validate

func (st *VersionInfoStringTable) Validate() error

Validate returns data validation result.

type VersionInfoStrings

type VersionInfoStrings struct {
	Comments         *string
	CompanyName      *string
	FileDescription  *string
	FileVersion      *string
	InternalName     *string
	LegalCopyright   *string
	LegalTradeMarks  *string
	OriginalFilename *string
	PrivateBuild     *string
	ProductName      *string
	ProductVersion   *string
	SpecialBuild     *string
}

VersionInfoStrings holds strings which describes the application.

type VersionInfoTranslation

type VersionInfoTranslation struct {
	Language *string
	Charset  *string
}

VersionInfoTranslation holds language-codepage pairs that application supports.

func (*VersionInfoTranslation) Validate

func (t *VersionInfoTranslation) Validate() error

Validate returns data validation result.

Directories

Path Synopsis
cmd
pkg
coff
Package coff provides COFF(Common Object File Format)-related functionalities.
Package coff provides COFF(Common Object File Format)-related functionalities.
common
Package common provides common utilities used by syso tool.
Package common provides common utilities used by syso tool.
ico

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL