mirror of
https://github.com/taigrr/wails.git
synced 2026-04-09 00:21:35 -07:00
Compare commits
5 Commits
v2.0.0-alp
...
v2.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8caf277bf1 | ||
|
|
4b480bb085 | ||
|
|
c1d63aff34 | ||
|
|
5fc89c4cad | ||
|
|
5e96bb5a32 |
@@ -24,10 +24,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
|
||||
command := app.NewSubCommand("build", "Builds the application")
|
||||
|
||||
// Setup target type flag
|
||||
//description := "Type of application to build. Valid types: " + validTargetTypes.Join(",")
|
||||
//command.StringFlag("t", description, &outputType)
|
||||
|
||||
// Setup production flag
|
||||
production := false
|
||||
command.BoolFlag("production", "Build in production mode", &production)
|
||||
@@ -58,10 +54,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
tags := ""
|
||||
command.StringFlag("tags", "tags to pass to Go compiler (quoted and space separated)", &tags)
|
||||
|
||||
// Log to file
|
||||
//logFile := ""
|
||||
//command.StringFlag("l", "Log to file", &logFile)
|
||||
|
||||
// Retain assets
|
||||
keepAssets := false
|
||||
command.BoolFlag("k", "Keep generated assets", &keepAssets)
|
||||
@@ -74,11 +66,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
cleanBuildDirectory := false
|
||||
command.BoolFlag("clean", "Clean the build directory before building", &cleanBuildDirectory)
|
||||
|
||||
appleIdentity := ""
|
||||
if runtime.GOOS == "darwin" {
|
||||
command.StringFlag("sign", "Signs your app with the given identity.", &appleIdentity)
|
||||
}
|
||||
|
||||
command.Action(func() error {
|
||||
|
||||
quiet := verbosity == 0
|
||||
@@ -96,11 +83,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
app.PrintBanner()
|
||||
}
|
||||
|
||||
// Ensure package is used with apple identity
|
||||
if appleIdentity != "" && pack == false {
|
||||
return fmt.Errorf("must use `-package` flag when using `-sign`")
|
||||
}
|
||||
|
||||
// Setup mode
|
||||
mode := build.Debug
|
||||
if production {
|
||||
@@ -146,7 +128,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
LDFlags: ldflags,
|
||||
Compiler: compilerCommand,
|
||||
KeepAssets: keepAssets,
|
||||
AppleIdentity: appleIdentity,
|
||||
Verbosity: verbosity,
|
||||
Compress: compress,
|
||||
UserTags: userTags,
|
||||
|
||||
@@ -48,9 +48,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
|
||||
// Exit early if PM not found
|
||||
if info.PM == nil {
|
||||
fmt.Fprintf(w, "\n%s\t%s", "Package Manager:", "Not Found")
|
||||
w.Flush()
|
||||
println()
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(w, "%s\t%s\n", "Package Manager: ", info.PM.Name())
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/parser"
|
||||
)
|
||||
|
||||
// AddSubcommand adds the `dev` command for the Wails application
|
||||
// AddSubcommand adds the `generate` command for the Wails application
|
||||
func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
|
||||
command := app.NewSubCommand("generate", "Code Generation Tools")
|
||||
@@ -19,7 +19,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
|
||||
// Quiet Init
|
||||
quiet := false
|
||||
backendAPI.BoolFlag("q", "Supress output to console", &quiet)
|
||||
backendAPI.BoolFlag("q", "Suppress output to console", &quiet)
|
||||
|
||||
backendAPI.Action(func() error {
|
||||
|
||||
@@ -85,7 +85,4 @@ func logPackage(pkg *parser.Package, logger *clilogger.CLILogger) {
|
||||
}
|
||||
}
|
||||
logger.Println("")
|
||||
|
||||
// logger.Println(" Original Go Package Path:", pkg.Gopackage.PkgPath)
|
||||
// logger.Println(" Original Go Package Path:", pkg.Gopackage.PkgPath)
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/initialise/templates"
|
||||
|
||||
"github.com/leaanthony/clir"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/wailsapp/wails/v2/internal/templates"
|
||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||
"github.com/wailsapp/wails/v2/pkg/git"
|
||||
)
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
gofs "io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/leaanthony/debme"
|
||||
"github.com/leaanthony/gosod"
|
||||
"github.com/leaanthony/slicer"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
@@ -16,6 +18,12 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||
)
|
||||
|
||||
//go:embed templates
|
||||
var templates embed.FS
|
||||
|
||||
//go:embed ides/*
|
||||
var ides embed.FS
|
||||
|
||||
// Cahce for the templates
|
||||
// We use this because we need different views of the same data
|
||||
var templateCache []Template = nil
|
||||
@@ -59,20 +67,21 @@ type Template struct {
|
||||
HelpURL string `json:"helpurl"`
|
||||
|
||||
// Other data
|
||||
Directory string `json:"-"`
|
||||
FS gofs.FS `json:"-"`
|
||||
}
|
||||
|
||||
func parseTemplate(directory string) (Template, error) {
|
||||
templateJSON := filepath.Join(directory, "template.json")
|
||||
func parseTemplate(template gofs.FS) (Template, error) {
|
||||
var result Template
|
||||
data, err := ioutil.ReadFile(templateJSON)
|
||||
data, err := gofs.ReadFile(template, "template.json")
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
result.Directory = directory
|
||||
err = json.Unmarshal(data, &result)
|
||||
return result, err
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
result.FS = template
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// TemplateShortNames returns a slicer of short template names
|
||||
@@ -134,11 +143,13 @@ func getTemplateByShortname(shortname string) (Template, error) {
|
||||
// Loads the template cache
|
||||
func loadTemplateCache() error {
|
||||
|
||||
// Get local template directory
|
||||
templateDir := fs.RelativePath("templates")
|
||||
templatesFS, err := debme.FS(templates, "templates")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get directories
|
||||
files, err := ioutil.ReadDir(templateDir)
|
||||
files, err := templatesFS.ReadDir(".")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -148,8 +159,11 @@ func loadTemplateCache() error {
|
||||
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
templateDir := filepath.Join(templateDir, file.Name())
|
||||
template, err := parseTemplate(templateDir)
|
||||
templateFS, err := templatesFS.FS(file.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
template, err := parseTemplate(templateFS)
|
||||
if err != nil {
|
||||
// Cannot parse this template, continue
|
||||
continue
|
||||
@@ -163,7 +177,6 @@ func loadTemplateCache() error {
|
||||
|
||||
// Install the given template
|
||||
func Install(options *Options) error {
|
||||
|
||||
// Get cwd
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
@@ -211,19 +224,16 @@ func Install(options *Options) error {
|
||||
}
|
||||
|
||||
// Use Gosod to install the template
|
||||
installer, err := gosod.TemplateDir(template.Directory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
installer := gosod.New(template.FS)
|
||||
|
||||
// Ignore template.json files
|
||||
installer.IgnoreFilename("template.json")
|
||||
installer.IgnoreFile("template.json")
|
||||
|
||||
// Setup the data.
|
||||
// We use the directory name for the binary name, like Go
|
||||
BinaryName := filepath.Base(options.TargetDir)
|
||||
NPMProjectName := strings.ToLower(strings.ReplaceAll(BinaryName, " ", ""))
|
||||
localWailsDirectory := fs.RelativePath("../..")
|
||||
localWailsDirectory := fs.RelativePath("../../../../../..")
|
||||
templateData := &Data{
|
||||
ProjectName: options.ProjectName,
|
||||
BinaryName: filepath.Base(options.TargetDir),
|
||||
@@ -295,14 +305,14 @@ func generateIDEFiles(options *Options) error {
|
||||
func generateVSCodeFiles(options *Options) error {
|
||||
|
||||
targetDir := filepath.Join(options.TargetDir, ".vscode")
|
||||
sourceDir := fs.RelativePath(filepath.Join("./ides/vscode"))
|
||||
|
||||
// Use Gosod to install the template
|
||||
installer, err := gosod.TemplateDir(sourceDir)
|
||||
source, err := debme.FS(ides, "ides/vscode")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Use gosod to install the template
|
||||
installer := gosod.New(source)
|
||||
|
||||
binaryName := filepath.Base(options.TargetDir)
|
||||
if runtime.GOOS == "windows" {
|
||||
// yay windows
|
||||
@@ -11,7 +11,7 @@ type Basic struct {
|
||||
runtime *wails.Runtime
|
||||
}
|
||||
|
||||
// newBasic creates a new Basic application struct
|
||||
// NewBasic creates a new Basic application struct
|
||||
func NewBasic() *Basic {
|
||||
return &Basic{}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "{{.ProjectName}}",
|
||||
"outputfilename": "{{.BinaryName}}",
|
||||
"html": "frontend/index.html",
|
||||
"html": "frontend/src/index.html",
|
||||
"author": {
|
||||
"name": "{{.AuthorName}}",
|
||||
"email": "{{.AuthorEmail}}"
|
||||
@@ -0,0 +1,46 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/matryer/is"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
|
||||
is2 := is.New(t)
|
||||
templates, err := List()
|
||||
is2.NoErr(err)
|
||||
|
||||
println("Found these templates:")
|
||||
for _, template := range templates {
|
||||
fmt.Printf("%+v\n", template)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortname(t *testing.T) {
|
||||
|
||||
is2 := is.New(t)
|
||||
|
||||
template, err := getTemplateByShortname("vanilla")
|
||||
is2.NoErr(err)
|
||||
|
||||
println("Found this template:")
|
||||
fmt.Printf("%+v\n", template)
|
||||
}
|
||||
|
||||
func TestInstall(t *testing.T) {
|
||||
|
||||
is2 := is.New(t)
|
||||
|
||||
options := &Options{
|
||||
ProjectName: "test",
|
||||
TemplateName: "vanilla",
|
||||
AuthorName: "Lea Anthony",
|
||||
AuthorEmail: "lea.anthony@gmail.com",
|
||||
}
|
||||
|
||||
err := Install(options)
|
||||
is2.NoErr(err)
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
package main
|
||||
|
||||
var version = "v2.0.0-alpha.64"
|
||||
var version = "v2.0.0-alpha.65"
|
||||
|
||||
@@ -10,8 +10,9 @@ require (
|
||||
github.com/imdario/mergo v0.3.11
|
||||
github.com/jackmordaunt/icns v1.0.0
|
||||
github.com/leaanthony/clir v1.0.4
|
||||
github.com/leaanthony/debme v1.1.1
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1
|
||||
github.com/leaanthony/gosod v0.0.4
|
||||
github.com/leaanthony/gosod v1.0.1
|
||||
github.com/leaanthony/slicer v1.5.0
|
||||
github.com/matryer/is v1.4.0
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
|
||||
@@ -41,10 +41,12 @@ github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eT
|
||||
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/leaanthony/clir v1.0.4 h1:Dov2y9zWJmZr7CjaCe86lKa4b5CSxskGAt2yBkoDyiU=
|
||||
github.com/leaanthony/clir v1.0.4/go.mod h1:k/RBkdkFl18xkkACMCLt09bhiZnrGORoxmomeMvDpE0=
|
||||
github.com/leaanthony/debme v1.1.1 h1:2CQjJkfrjr4b2VgpDmkq2aghem5R2bNbg1Yg5cKQGBQ=
|
||||
github.com/leaanthony/debme v1.1.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQOk2DgKxGG4=
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM=
|
||||
github.com/leaanthony/gosod v0.0.4 h1:v4hepo4IyL8E8c9qzDsvYcA0KGh7Npf8As74K5ibQpI=
|
||||
github.com/leaanthony/gosod v0.0.4/go.mod h1:nGMCb1PJfXwBDbOAike78jEYlpqge+xUKFf0iBKjKxU=
|
||||
github.com/leaanthony/gosod v1.0.1 h1:F+4c3DmEBfigi7oAswCV2RpQ+k4DcNbhuCZUGdBHacQ=
|
||||
github.com/leaanthony/gosod v1.0.1/go.mod h1:W8RyeSFBXu7RpIxPGEJfW4moSyGGEjlJMLV25wEbAdU=
|
||||
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
|
||||
github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
|
||||
@@ -14,30 +14,6 @@ import (
|
||||
"github.com/leaanthony/slicer"
|
||||
)
|
||||
|
||||
const _comment = `
|
||||
|
||||
const backend = {
|
||||
main: {
|
||||
"xbarApp": {
|
||||
"GetCategories": () => {
|
||||
window.backend.main.xbarApp.GetCategories.call(arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} arg1
|
||||
*/
|
||||
"InstallPlugin": (arg1) => {
|
||||
window.backend.main.xbarApp.InstallPlugin.call(arguments);
|
||||
},
|
||||
"GetPlugins": () => {
|
||||
window.backend.main.xbarApp.GetPlugins.call(arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default backend;`
|
||||
|
||||
//go:embed assets/package.json
|
||||
var packageJSON []byte
|
||||
|
||||
@@ -100,6 +76,8 @@ const backend = {`)
|
||||
}
|
||||
returnType += ">"
|
||||
returnTypeDetails = " - Go Type: " + methodDetails.Outputs[0].TypeName
|
||||
} else {
|
||||
returnType = "Promise<void>"
|
||||
}
|
||||
output.WriteString(" * @returns {" + returnType + "} " + returnTypeDetails + "\n")
|
||||
output.WriteString(" */\n")
|
||||
@@ -125,13 +103,14 @@ const backend = {`)
|
||||
export default backend;`)
|
||||
output.WriteString("\n")
|
||||
|
||||
// TODO: Make this configurable in wails.json
|
||||
dirname, err := fs.RelativeToCwd("frontend/src/backend")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !fs.DirExists(dirname) {
|
||||
err := fs.Mkdir(dirname)
|
||||
err := fs.MkDirs(dirname)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -201,10 +201,6 @@ func GetSubdirectories(rootDir string) (*slicer.StringSlicer, error) {
|
||||
|
||||
func DirIsEmpty(dir string) (bool, error) {
|
||||
|
||||
if !DirExists(dir) {
|
||||
return false, fmt.Errorf("DirIsEmpty called with a non-existant directory: %s", dir)
|
||||
}
|
||||
|
||||
// CREDIT: https://stackoverflow.com/a/30708914/8325411
|
||||
f, err := os.Open(dir)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/matryer/is"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
|
||||
is := is.New(t)
|
||||
templates, err := List()
|
||||
is.Equal(err, nil)
|
||||
|
||||
println("Found these templates:")
|
||||
for _, template := range templates {
|
||||
fmt.Printf("%+v\n", template)
|
||||
}
|
||||
}
|
||||
181
v2/pkg/commands/build/desktop_windows.go
Normal file
181
v2/pkg/commands/build/desktop_windows.go
Normal file
@@ -0,0 +1,181 @@
|
||||
// +build windows
|
||||
|
||||
package build
|
||||
|
||||
// We will compile all tray icons found at <projectdir>/assets/trayicons/*.png into the application
|
||||
func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) error {
|
||||
//
|
||||
// var err error
|
||||
//
|
||||
// // Get all the tray icon filenames
|
||||
// trayIconDirectory := filepath.Join(options.ProjectData.AssetsDir, "tray")
|
||||
//
|
||||
// // If the directory doesn't exist, create it
|
||||
// if !fs.DirExists(trayIconDirectory) {
|
||||
// err = fs.MkDirs(trayIconDirectory)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// var trayIconFilenames []string
|
||||
// trayIconFilenames, err = filepath.Glob(trayIconDirectory + "/*.png")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// // Setup target
|
||||
// targetFilename := "trayicons"
|
||||
// targetFile := filepath.Join(assetDir, targetFilename+".h")
|
||||
// d.addFileToDelete(targetFile)
|
||||
//
|
||||
// var dataBytes []byte
|
||||
//
|
||||
// // Use a strings builder
|
||||
// var cdata strings.Builder
|
||||
//
|
||||
// // Write header
|
||||
// header := `// trayicons.h
|
||||
//// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
||||
//// This file was auto-generated. DO NOT MODIFY.
|
||||
//
|
||||
//`
|
||||
// cdata.WriteString(header)
|
||||
//
|
||||
// var variableList slicer.StringSlicer
|
||||
//
|
||||
// // Loop over icons
|
||||
// for count, filename := range trayIconFilenames {
|
||||
//
|
||||
// // Load the tray icon
|
||||
// dataBytes, err = ioutil.ReadFile(filename)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// iconname := strings.TrimSuffix(filepath.Base(filename), ".png")
|
||||
// trayIconName := fmt.Sprintf("trayIcon%dName", count)
|
||||
// variableList.Add(trayIconName)
|
||||
// cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", trayIconName, d.convertToHexLiteral([]byte(iconname))))
|
||||
//
|
||||
// trayIconLength := fmt.Sprintf("trayIcon%dLength", count)
|
||||
// variableList.Add(trayIconLength)
|
||||
// lengthAsString := strconv.Itoa(len(dataBytes))
|
||||
// cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", trayIconLength, d.convertToHexLiteral([]byte(lengthAsString))))
|
||||
//
|
||||
// trayIconData := fmt.Sprintf("trayIcon%dData", count)
|
||||
// variableList.Add(trayIconData)
|
||||
// cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { ", trayIconData))
|
||||
//
|
||||
// // Convert each byte to hex
|
||||
// for _, b := range dataBytes {
|
||||
// cdata.WriteString(fmt.Sprintf("0x%x, ", b))
|
||||
// }
|
||||
//
|
||||
// cdata.WriteString("0x00 };\n")
|
||||
// }
|
||||
//
|
||||
// // Write out main trayIcons data
|
||||
// cdata.WriteString("const unsigned char *trayIcons[] = { ")
|
||||
// cdata.WriteString(variableList.Join(", "))
|
||||
// if len(trayIconFilenames) > 0 {
|
||||
// cdata.WriteString(", ")
|
||||
// }
|
||||
// cdata.WriteString("0x00 };\n")
|
||||
//
|
||||
// err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
return nil
|
||||
}
|
||||
|
||||
// We will compile all dialog icons found at <projectdir>/icons/dialog/*.png into the application
|
||||
func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) error {
|
||||
|
||||
// var err error
|
||||
//
|
||||
// // Get all the dialog icon filenames
|
||||
// dialogIconDirectory := filepath.Join(options.ProjectData.AssetsDir, "dialog")
|
||||
// var dialogIconFilenames []string
|
||||
//
|
||||
// // If the directory does not exist, create it
|
||||
// if !fs.DirExists(dialogIconDirectory) {
|
||||
// err = fs.MkDirs(dialogIconDirectory)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// dialogIconFilenames, err = filepath.Glob(dialogIconDirectory + "/*.png")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// // Setup target
|
||||
// targetFilename := "userdialogicons"
|
||||
// targetFile := filepath.Join(assetDir, targetFilename+".h")
|
||||
// d.addFileToDelete(targetFile)
|
||||
//
|
||||
// var dataBytes []byte
|
||||
//
|
||||
// // Use a strings builder
|
||||
// var cdata strings.Builder
|
||||
//
|
||||
// // Write header
|
||||
// header := `// userdialogicons.h
|
||||
//// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
||||
//// This file was auto-generated. DO NOT MODIFY.
|
||||
//
|
||||
//`
|
||||
// cdata.WriteString(header)
|
||||
//
|
||||
// var variableList slicer.StringSlicer
|
||||
//
|
||||
// // Loop over icons
|
||||
// for count, filename := range dialogIconFilenames {
|
||||
//
|
||||
// // Load the tray icon
|
||||
// dataBytes, err = ioutil.ReadFile(filename)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// iconname := strings.TrimSuffix(filepath.Base(filename), ".png")
|
||||
// dialogIconName := fmt.Sprintf("userDialogIcon%dName", count)
|
||||
// variableList.Add(dialogIconName)
|
||||
// cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", dialogIconName, d.convertToHexLiteral([]byte(iconname))))
|
||||
//
|
||||
// dialogIconLength := fmt.Sprintf("userDialogIcon%dLength", count)
|
||||
// variableList.Add(dialogIconLength)
|
||||
// lengthAsString := strconv.Itoa(len(dataBytes))
|
||||
// cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", dialogIconLength, d.convertToHexLiteral([]byte(lengthAsString))))
|
||||
//
|
||||
// dialogIconData := fmt.Sprintf("userDialogIcon%dData", count)
|
||||
// variableList.Add(dialogIconData)
|
||||
// cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { ", dialogIconData))
|
||||
//
|
||||
// // Convert each byte to hex
|
||||
// for _, b := range dataBytes {
|
||||
// cdata.WriteString(fmt.Sprintf("0x%x, ", b))
|
||||
// }
|
||||
//
|
||||
// cdata.WriteString("0x00 };\n")
|
||||
// }
|
||||
//
|
||||
// // Write out main dialogIcons data
|
||||
// cdata.WriteString("const unsigned char *userDialogIcons[] = { ")
|
||||
// cdata.WriteString(variableList.Join(", "))
|
||||
// if len(dialogIconFilenames) > 0 {
|
||||
// cdata.WriteString(", ")
|
||||
// }
|
||||
// cdata.WriteString("0x00 };\n")
|
||||
//
|
||||
// err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user