Remove unused directories + tidy up

This commit is contained in:
Lea Anthony
2022-03-29 21:47:26 +11:00
parent a5bf76b30f
commit 1da68cfc7c
144 changed files with 1 additions and 18455 deletions
-53
View File
@@ -18,9 +18,7 @@ import (
"github.com/pkg/errors"
"github.com/leaanthony/slicer"
"github.com/wailsapp/wails/v2/internal/assetdb"
"github.com/wailsapp/wails/v2/internal/fs"
"github.com/wailsapp/wails/v2/internal/html"
"github.com/wailsapp/wails/v2/internal/project"
"github.com/wailsapp/wails/v2/internal/shell"
"github.com/wailsapp/wails/v2/pkg/clilogger"
@@ -65,49 +63,6 @@ func (b *BaseBuilder) fileExists(path string) bool {
return true
}
// buildCustomAssets will iterate through the projects static directory and add all files
// to the application wide asset database.
func (b *BaseBuilder) buildCustomAssets(projectData *project.Project) error {
// Add trailing slash to Asset directory
customAssetsDir := filepath.Join(projectData.Path, "assets", "custom") + "/"
if !b.fileExists(customAssetsDir) {
err := fs.MkDirs(customAssetsDir)
if err != nil {
return err
}
}
assets := assetdb.NewAssetDB()
err := filepath.Walk(customAssetsDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
normalisedPath := filepath.ToSlash(path)
localPath := strings.TrimPrefix(normalisedPath, customAssetsDir)
if len(localPath) == 0 {
return nil
}
if data, err := os.ReadFile(filepath.Join(customAssetsDir, localPath)); err == nil {
assets.AddAsset(localPath, data)
}
return nil
})
if err != nil {
return err
}
// Write assetdb out to root directory
assetsDbFilename := fs.RelativePath("../../../assetsdb.go")
b.addFileToDelete(assetsDbFilename)
err = os.WriteFile(assetsDbFilename, []byte(assets.Serialize("assets", "wails")), 0644)
if err != nil {
return err
}
return nil
}
func (b *BaseBuilder) convertFileToIntegerString(filename string) (string, error) {
rawData, err := os.ReadFile(filename)
if err != nil {
@@ -601,14 +556,6 @@ func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error {
return nil
}
// ExtractAssets gets the assets from the index.html file
func (b *BaseBuilder) ExtractAssets() (*html.AssetBundle, error) {
// Read in html
//return html.NewAssetBundle(b.projectData.HTML)
return nil, nil
}
func upsertEnv(env []string, key string, update func(v string) string) []string {
newEnv := make([]string, len(env), len(env)+1)
found := false
-10
View File
@@ -93,10 +93,6 @@ func Build(options *Options) (string, error) {
switch projectData.OutputType {
case "desktop":
builder = newDesktopBuilder(options)
case "hybrid":
builder = newHybridBuilder(options)
case "server":
builder = newServerBuilder(options)
case "dev":
builder = newDesktopBuilder(options)
default:
@@ -208,12 +204,6 @@ func Build(options *Options) (string, error) {
outputLogger.Println("Done.")
}
// Post compilation tasks
err = builder.PostCompilation(options)
if err != nil {
return "", err
}
compileBinary := options.CompiledBinary
hookArgs := map[string]string{
"${platform}": options.Platform + "/" + options.Arch,
-2
View File
@@ -10,9 +10,7 @@ type Builder interface {
SetProjectData(projectData *project.Project)
BuildAssets(*Options) error
BuildFrontend(*clilogger.CLILogger) error
BuildRuntime(*Options) error
CompileProject(*Options) error
OutputFilename(*Options) string
PostCompilation(*Options) error
CleanUp()
}
-128
View File
@@ -1,11 +1,7 @@
package build
import (
"fmt"
"os"
"github.com/wailsapp/wails/v2/internal/fs"
"github.com/wailsapp/wails/v2/internal/html"
"github.com/wailsapp/wails/v2/pkg/buildassets"
)
@@ -32,129 +28,5 @@ func (d *DesktopBuilder) BuildAssets(options *Options) error {
}
}
// We only build assets for cgo builds
//userTags := slicer.String(options.UserTags)
//if userTags.Contains("cgo") {
// // Get a list of assets from the HTML
// assets, err := d.BaseBuilder.ExtractAssets()
// if err != nil {
// return err
// }
//
// // Build base assets (HTML/JS/CSS/etc)
// err = d.BuildBaseAssets(assets, options)
// if err != nil {
// return err
// }
//}
return nil
}
// BuildBaseAssets builds the assets for the desktop application
func (d *DesktopBuilder) BuildBaseAssets(assets *html.AssetBundle, options *Options) error {
var err error
outputLogger := options.Logger
outputLogger.Print("Building assets: ")
// Get target asset directory
assetDir, err := fs.RelativeToCwd("build")
if err != nil {
return err
}
// Make dir if it doesn't exist
if !fs.DirExists(assetDir) {
err := fs.Mkdir(assetDir)
if err != nil {
return err
}
}
// Dump assets as C
assetsFile, err := assets.WriteToCFile(assetDir)
if err != nil {
return err
}
d.addFileToDelete(assetsFile)
// Process Icon
err = d.processApplicationIcon(assetDir, options)
if err != nil {
return err
}
// Process Tray Icons
err = d.processTrayIcons(assetDir, options)
if err != nil {
return err
}
// Process Dialog Icons
err = d.processDialogIcons(assetDir, options)
if err != nil {
return err
}
outputLogger.Println("Done.")
return nil
}
// processApplicationIcon will copy a default icon if one doesn't exist, then, if
// needed, will compile the icon
func (d *DesktopBuilder) processApplicationIcon(assetDir string, options *Options) error {
iconFile, err := buildassets.ReadFile(options.ProjectData, "appicon.png")
if err != nil {
return err
}
// Compile Icon
return d.compileIcon(assetDir, iconFile)
}
// BuildRuntime builds the Wails javascript runtime and then converts it into a C file
func (d *DesktopBuilder) BuildRuntime(options *Options) error {
outputLogger := options.Logger
sourceDir := fs.RelativePath("../../../internal/runtime/js")
if err := d.NpmInstall(sourceDir, options.Verbosity == VERBOSE); err != nil {
return err
}
outputLogger.Print("Embedding Runtime: ")
envvars := []string{"WAILSPLATFORM=" + options.Platform}
if err := d.NpmRunWithEnvironment(sourceDir, "build:desktop", false, envvars); err != nil {
return err
}
wailsJS := fs.RelativePath("../../../internal/runtime/assets/desktop.js")
runtimeData, err := os.ReadFile(wailsJS)
if err != nil {
return err
}
outputLogger.Println("done.")
// Convert to C structure
runtimeC := `
// runtime.c (c) 2019-Present Lea Anthony.
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file was auto-generated. DO NOT MODIFY.
const unsigned char runtime[]={`
for _, b := range runtimeData {
runtimeC += fmt.Sprintf("0x%x, ", b)
}
runtimeC += "0x00};"
// Save file
outputFile := fs.RelativePath("../../../internal/ffenestri/runtime.c")
if err := os.WriteFile(outputFile, []byte(runtimeC), 0600); err != nil {
return err
}
return nil
}
-212
View File
@@ -1,212 +0,0 @@
//go:build darwin
// +build darwin
package build
import (
"fmt"
"log"
"os"
"path/filepath"
"strconv"
"strings"
"github.com/leaanthony/slicer"
"github.com/wailsapp/wails/v2/internal/fs"
)
func (d *DesktopBuilder) convertToHexLiteral(bytes []byte) string {
result := ""
for _, b := range bytes {
result += fmt.Sprintf("0x%x, ", b)
}
return result
}
// compileIcon will compile the icon found at <projectdir>/icon.png into the application
func (d *DesktopBuilder) compileIcon(assetDir string, iconFile []byte) error {
return nil
}
// 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.BuildDir, "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 = os.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 = os.WriteFile(targetFile, []byte(cdata.String()), 0600)
if err != nil {
return err
}
return nil
}
// PostCompilation is called after the compilation step, if successful
func (d *DesktopBuilder) PostCompilation(options *Options) error {
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.BuildDir, "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 = os.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 = os.WriteFile(targetFile, []byte(cdata.String()), 0600)
if err != nil {
return err
}
return nil
}
-232
View File
@@ -1,232 +0,0 @@
//go:build linux
// +build linux
package build
// compileIcon will compile the icon found at <projectdir>/icon.png into the application
func (d *DesktopBuilder) compileIcon(assetDir string, iconFile []byte) error {
//
//// Load icon into a databuffer
//targetFilename := "icon"
//targetFile := filepath.Join(assetDir, targetFilename+".h")
//
//d.addFileToDelete(targetFile)
//
//// Create a new XPM encoder
//enc := xpm.NewEncoder(targetFilename)
//
//// Open the PNG file
//f, err := os.Open(iconFile)
//if err != nil {
// return err
//}
//m, err := png.Decode(f)
//if err != nil {
// return err
//}
//err = f.Close()
//if err != nil {
// return err
//}
//
//var buf strings.Builder
//
//// Generate and output the XPM data
//err = enc.Encode(&buf, m)
//if err != nil {
// return err
//}
//
//// Massage the output so we can extern reference it
//output := buf.String()
//output = strings.Replace(output, "static char", "const char", 1)
//
//// save icon.c
//err = os.WriteFile(targetFile, []byte(output), 0755)
//
//return err
return nil
}
// 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.BuildDir, "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.BuildDir, "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
}
// PostCompilation is called after the compilation step, if successful
func (d *DesktopBuilder) PostCompilation(options *Options) error {
return nil
}
-200
View File
@@ -1,200 +0,0 @@
//go:build windows
// +build windows
package build
// PostCompilation is called after the compilation step, if successful
func (d *DesktopBuilder) PostCompilation(options *Options) error {
// Dump the DLLs
//userTags := slicer.String(options.UserTags)
//if userTags.Contains("cgo") {
// err := os.WriteFile(filepath.Join(options.BuildDirectory, "WebView2Loader.dll"), x64.WebView2Loader, 0755)
// if err != nil {
// return err
// }
//}
return nil
}
// 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.BuildDir, "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
}
// compileIcon will compile the icon found at <projectdir>/icon.png into the application
func (d *DesktopBuilder) compileIcon(assetDir string, iconFile []byte) error {
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.BuildDir, "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
}
-95
View File
@@ -1,95 +0,0 @@
package build
import (
"github.com/wailsapp/wails/v2/internal/project"
"github.com/wailsapp/wails/v2/pkg/clilogger"
)
// HybridBuilder builds applications as a server
type HybridBuilder struct {
*BaseBuilder
desktop *DesktopBuilder
server *ServerBuilder
}
func newHybridBuilder(options *Options) Builder {
result := &HybridBuilder{
BaseBuilder: NewBaseBuilder(options),
desktop: newDesktopBuilder(options),
server: newServerBuilder(options),
}
return result
}
// BuildAssets builds the assets for the desktop application
func (b *HybridBuilder) BuildAssets(options *Options) error {
var err error
// Build base assets (HTML/JS/CSS/etc)
err = b.BuildBaseAssets(options)
if err != nil {
return err
}
return nil
}
// BuildFrontend builds the assets for the desktop application
func (b *HybridBuilder) BuildFrontend(_ *clilogger.CLILogger) error {
panic("To be implemented")
return nil
}
// BuildAssets builds the assets for the desktop application
func (b *HybridBuilder) BuildBaseAssets(options *Options) error {
assets, err := b.BaseBuilder.ExtractAssets()
if err != nil {
return err
}
err = b.desktop.BuildBaseAssets(assets, options)
if err != nil {
return err
}
err = b.server.BuildBaseAssets(assets)
if err != nil {
return err
}
return nil
}
func (b *HybridBuilder) BuildRuntime(options *Options) error {
err := b.desktop.BuildRuntime(options)
if err != nil {
return err
}
err = b.server.BuildRuntime(options)
if err != nil {
return err
}
return nil
}
func (b *HybridBuilder) SetProjectData(projectData *project.Project) {
b.BaseBuilder.SetProjectData(projectData)
b.desktop.SetProjectData(projectData)
b.server.SetProjectData(projectData)
}
func (b *HybridBuilder) CompileProject(options *Options) error {
return b.BaseBuilder.CompileProject(options)
}
func (b *HybridBuilder) CleanUp() {
b.desktop.CleanUp()
b.server.CleanUp()
}
// PostCompilation is called after the compilation step, if successful
func (s *HybridBuilder) PostCompilation(_ *Options) error {
return nil
}
@@ -1,3 +0,0 @@
# Default Dialog Icons
This directory contains the default dialog icons. These are pre-compiled into a single C file (`defaultDialogIcons.c`) which resides in the `ffenestri` directory. If these icons are ever updated, then there is a need to run: `go run build.go` in this directory. This will generate a new `defaultDialogIcons.c` file in the `ffenestri` directory.
@@ -1,100 +0,0 @@
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"strconv"
"strings"
"github.com/leaanthony/slicer"
)
func convertToHexLiteral(bytes []byte) string {
result := ""
for _, b := range bytes {
result += fmt.Sprintf("0x%x, ", b)
}
return result
}
func main() {
dialogIconFilenames, err := filepath.Glob("*.png")
if err != nil {
log.Fatal(err)
}
// Build icons for Mac
err = buildMacIcons(dialogIconFilenames)
if err != nil {
log.Fatal(err)
}
}
func buildMacIcons(dialogIconFilenames []string) error {
// Setup target
targetFile := "../../../../../../../internal/ffenestri/defaultdialogicons_darwin.c"
var dataBytes []byte
var err error
// Use a strings builder
var cdata strings.Builder
// Write header
header := `// defaultdialogicons_darwin.c
// 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 = os.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
iconname := strings.TrimSuffix(filepath.Base(filename), ".png")
dialogIconName := fmt.Sprintf("defaultDialogIcon%dName", count)
variableList.Add(dialogIconName)
cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", dialogIconName, convertToHexLiteral([]byte(iconname))))
dialogIconLength := fmt.Sprintf("defaultDialogIcon%dLength", count)
variableList.Add(dialogIconLength)
lengthAsString := strconv.Itoa(len(dataBytes))
cdata.WriteString(fmt.Sprintf("const unsigned char %s[] = { %s0x00 };\n", dialogIconLength, convertToHexLiteral([]byte(lengthAsString))))
dialogIconData := fmt.Sprintf("defaultDialogIcon%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 *defaultDialogIcons[] = { ")
cdata.WriteString(variableList.Join(", "))
if len(dialogIconFilenames) > 0 {
cdata.WriteString(", ")
}
cdata.WriteString("0x00 };\n")
err = os.WriteFile(targetFile, []byte(cdata.String()), 0600)
if err != nil {
log.Fatal(err)
}
return nil
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Some files were not shown because too many files have changed in this diff Show More