Move assets -> build dir. Bundle assets in CLI binary.
2
.gitignore
vendored
@ -28,4 +28,6 @@ v2/test/kitchensink/frontend/public
|
||||
v2/test/kitchensink/build/darwin/desktop/kitchensink
|
||||
v2/test/kitchensink/frontend/package.json.md5
|
||||
/v2/internal/ffenestri/windows/test/cmake-build-debug/
|
||||
!v2/internal/ffenestri/windows/x64/webview2.dll
|
||||
!v2/internal/ffenestri/windows/x64/WebView2Loader.dll
|
||||
.idea/
|
||||
|
13
v2/.vscode/settings.json
vendored
@ -1,13 +0,0 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"ios": "c",
|
||||
"typeinfo": "c",
|
||||
"sstream": "c",
|
||||
"__functional_03": "c",
|
||||
"functional": "c",
|
||||
"__locale": "c",
|
||||
"locale": "c",
|
||||
"chrono": "c",
|
||||
"system_error": "c"
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package initialise
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/wailsapp/wails/v2/pkg/buildassets"
|
||||
"io"
|
||||
"strings"
|
||||
"time"
|
||||
@ -40,7 +41,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
|
||||
// Quiet Init
|
||||
quiet := false
|
||||
command.BoolFlag("q", "Supress output to console", &quiet)
|
||||
command.BoolFlag("q", "Suppress output to console", &quiet)
|
||||
|
||||
initGit := false
|
||||
gitInstalled := git.IsInstalled()
|
||||
@ -129,6 +130,12 @@ func initProject(options *templates.Options) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Install the default assets
|
||||
err = buildassets.Install(options.TargetDir, options.ProjectName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if options.InitGit {
|
||||
err = initGit(options)
|
||||
if err != nil {
|
||||
|
@ -10,10 +10,11 @@ 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.2
|
||||
github.com/leaanthony/debme v1.2.0
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1
|
||||
github.com/leaanthony/gosod v1.0.1
|
||||
github.com/leaanthony/slicer v1.5.0
|
||||
github.com/leaanthony/winicon v0.0.0-20200606125418-4419cea822a0
|
||||
github.com/matryer/is v1.4.0
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.4
|
||||
|
@ -42,14 +42,16 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs
|
||||
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/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/debme v1.1.2 h1:dGeQuj0+xPIlDQzGIjmAU52+yRg85u5pWaaqrdLBjD0=
|
||||
github.com/leaanthony/debme v1.1.2/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/debme v1.2.0 h1:i7JUQhuv7PtJ/7qV+SIa5QARTGBcojUZ+2eCiV9begU=
|
||||
github.com/leaanthony/debme v1.2.0/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 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/leaanthony/winicon v0.0.0-20200606125418-4419cea822a0 h1:FPGYnfxuuxqCZhrGq8nKjthEcYHgHmFbyY953Xv9cNI=
|
||||
github.com/leaanthony/winicon v0.0.0-20200606125418-4419cea822a0/go.mod h1:en5xhijl92aphrJdmRPlh4NI1L6wq3gEm0LpXAPghjU=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
|
||||
@ -92,6 +94,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
|
@ -79,7 +79,7 @@ func (a *App) Run() error {
|
||||
// Default app options
|
||||
var port = 8080
|
||||
var ip = "localhost"
|
||||
var supressLogging = false
|
||||
var SuppressLogging = false
|
||||
var debugMode = false
|
||||
|
||||
// Create CLI
|
||||
@ -89,7 +89,7 @@ func (a *App) Run() error {
|
||||
cli.IntFlag("p", "Port to serve on", &port)
|
||||
cli.StringFlag("i", "IP to serve on", &ip)
|
||||
cli.BoolFlag("d", "Debug mode", &debugMode)
|
||||
cli.BoolFlag("q", "Supress logging", &supressLogging)
|
||||
cli.BoolFlag("q", "Suppress logging", &SuppressLogging)
|
||||
|
||||
// Setup main action
|
||||
cli.Action(func() error {
|
||||
@ -98,8 +98,8 @@ func (a *App) Run() error {
|
||||
a.webserver.SetPort(port)
|
||||
a.webserver.SetIP(ip)
|
||||
a.webserver.SetBindings(a.bindings)
|
||||
// Log information (if we aren't supressing it)
|
||||
if !supressLogging {
|
||||
// Log information (if we aren't Suppressing it)
|
||||
if !SuppressLogging {
|
||||
cli.PrintBanner()
|
||||
a.logger.Info("Running server at %s", a.webserver.URL())
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
project(test C)
|
||||
project(test)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(SOURCES ../../ffenestri_windows.cpp)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
add_executable(test ${SOURCES} main.c)
|
||||
add_executable(test main.cpp)
|
@ -1 +0,0 @@
|
||||
g++ main.c ..\..\ffenestri_windows.cpp -lgdi32 -std=c++11
|
@ -25,8 +25,8 @@ type Project struct {
|
||||
// The path to the project directory
|
||||
Path string
|
||||
|
||||
// Assets directory
|
||||
AssetsDir string `json:"assetsdir"`
|
||||
// Build directory
|
||||
BuildDir string `json:"builddir"`
|
||||
|
||||
// The output filename
|
||||
OutputFilename string `json:"outputfilename"`
|
||||
@ -76,8 +76,8 @@ func Load(projectPath string) (*Project, error) {
|
||||
}
|
||||
|
||||
// Set default assets directory if none given
|
||||
if result.AssetsDir == "" {
|
||||
result.AssetsDir = filepath.Join(result.Path, "assets")
|
||||
if result.BuildDir == "" {
|
||||
result.BuildDir = filepath.Join(result.Path, "build")
|
||||
}
|
||||
|
||||
// Fix up OutputFilename
|
||||
|
52
v2/pkg/buildassets/build/README.md
Normal file
@ -0,0 +1,52 @@
|
||||
# Assets Directory
|
||||
|
||||
The assets directory is used to house all the assets of your application.
|
||||
|
||||
The structure is:
|
||||
|
||||
* dialog - Icons for dialogs
|
||||
* tray - Icons for the system tray
|
||||
* mac - MacOS specific files
|
||||
* linux - Linux specific files
|
||||
* windows - Windows specific files
|
||||
|
||||
## Dialog Icons
|
||||
|
||||
Place any PNG file in this directory to be able to use them in message dialogs.
|
||||
The files should have names in the following format: `name[-(light|dark)][2x].png`
|
||||
|
||||
Examples:
|
||||
|
||||
* `mypic.png` - Standard definition icon with ID `mypic`
|
||||
* `mypic-light.png` - Standard definition icon with ID `mypic`, used when system theme is light
|
||||
* `mypic-dark.png` - Standard definition icon with ID `mypic`, used when system theme is dark
|
||||
* `mypic2x.png` - High definition icon with ID `mypic`
|
||||
* `mypic-light2x.png` - High definition icon with ID `mypic`, used when system theme is light
|
||||
* `mypic-dark2x.png` - High definition icon with ID `mypic`, used when system theme is dark
|
||||
|
||||
### Order of preference
|
||||
|
||||
Icons are selected with the following order of preference:
|
||||
|
||||
For High Definition displays:
|
||||
* name-(theme)2x.png
|
||||
* name2x.png
|
||||
* name-(theme).png
|
||||
* name.png
|
||||
|
||||
For Standard Definition displays:
|
||||
* name-(theme).png
|
||||
* name.png
|
||||
|
||||
## Tray
|
||||
|
||||
Place any PNG file in this directory to be able to use them as tray icons.
|
||||
The name of the filename will be the ID to reference the image.
|
||||
|
||||
Example:
|
||||
|
||||
* `mypic.png` - May be referenced using `runtime.Tray.SetIcon("mypic")`
|
||||
|
||||
## Mac
|
||||
|
||||
The `mac` directory holds files specific to Mac builds, such as `Info.plist`. These may be edited and used as part of the build.
|
BIN
v2/pkg/buildassets/build/appicon.png
Normal file
After Width: | Height: | Size: 44 KiB |
14
v2/pkg/buildassets/build/darwin/Info.tmpl.plist
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>CFBundleName</key><string>{{.Name}}</string>
|
||||
<key>CFBundleExecutable</key><string>{{.Name}}</string>
|
||||
<key>CFBundleIdentifier</key><string>com.wails.{{.Name}}</string>
|
||||
<key>CFBundleVersion</key><string>1.0.0</string>
|
||||
<key>CFBundleGetInfoString</key><string>Built using Wails (https://wails.app)</string>
|
||||
<key>CFBundleShortVersionString</key><string>1.0.0</string>
|
||||
<key>CFBundleIconFile</key><string>iconfile</string>
|
||||
<key>LSMinimumSystemVersion</key><string>10.13.0</string>
|
||||
<key>NSHighResolutionCapable</key><string>true</string>
|
||||
<key>NSHumanReadableCopyright</key><string>Copyright.........</string>
|
||||
</dict></plist>
|
3
v2/pkg/buildassets/build/dialog/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# 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.
|
BIN
v2/pkg/buildassets/build/dialog/info-dark.png
Normal file
After Width: | Height: | Size: 780 B |
BIN
v2/pkg/buildassets/build/dialog/info-dark2x.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
v2/pkg/buildassets/build/dialog/info-light.png
Normal file
After Width: | Height: | Size: 764 B |
BIN
v2/pkg/buildassets/build/dialog/info-light2x.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
v2/pkg/buildassets/build/dialog/question-dark.png
Normal file
After Width: | Height: | Size: 941 B |
BIN
v2/pkg/buildassets/build/dialog/question-dark2x.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
v2/pkg/buildassets/build/dialog/question-light.png
Normal file
After Width: | Height: | Size: 930 B |
BIN
v2/pkg/buildassets/build/dialog/question-light2x.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
v2/pkg/buildassets/build/dialog/warning-dark.png
Normal file
After Width: | Height: | Size: 830 B |
BIN
v2/pkg/buildassets/build/dialog/warning-dark2x.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
v2/pkg/buildassets/build/dialog/warning-light.png
Normal file
After Width: | Height: | Size: 720 B |
BIN
v2/pkg/buildassets/build/dialog/warning-light2x.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
12
v2/pkg/buildassets/build/windows/wails.exe.manifest
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<assemblyIdentity type="win32" name="MyApplication" version="1.0.0.0" processorArchitecture="amd64"/>
|
||||
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
|
||||
<gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling> <!-- enables GDI DPI scaling -->
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
2
v2/pkg/buildassets/build/windows/wails.rc.tmpl
Normal file
@ -0,0 +1,2 @@
|
||||
100 ICON "app.ico"
|
||||
110 24 "{{.Name}}.exe.manifest"
|
76
v2/pkg/buildassets/buildassets.go
Normal file
@ -0,0 +1,76 @@
|
||||
package buildassets
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"github.com/leaanthony/debme"
|
||||
"github.com/leaanthony/gosod"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
//go:embed build
|
||||
var assets embed.FS
|
||||
|
||||
type assetData struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
// Install will install all default project assets
|
||||
func Install(targetDir string, projectName string) error {
|
||||
templateDir := gosod.New(assets)
|
||||
err := templateDir.Extract(targetDir, &assetData{Name: projectName})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Rename the manifest file
|
||||
windowsDir := filepath.Join(targetDir, "build", "windows")
|
||||
manifest := filepath.Join(windowsDir, "wails.exe.manifest")
|
||||
targetFile := filepath.Join(windowsDir, projectName+".exe.manifest")
|
||||
err = os.Rename(manifest, targetFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Rename the rc file
|
||||
rc := filepath.Join(windowsDir, "wails.rc")
|
||||
targetFile = filepath.Join(windowsDir, projectName+".rc")
|
||||
err = os.Rename(rc, targetFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegenerateRCFile will recreate the RC file
|
||||
func RegenerateRCFile(projectDir string, projectName string) error {
|
||||
targetFile, err := os.OpenFile(filepath.Join(projectDir, "build", "windows", projectName+".rc"), os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := &assetData{Name: projectName}
|
||||
templateData, err := assets.ReadFile("build/windows/wails.rc.tmpl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmpl, err := template.New("rc").Parse(string(templateData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tmpl.Execute(targetFile, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func RegenerateManifest(target string) error {
|
||||
a, err := debme.FS(assets, "build")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return a.CopyFile("windows/wails.exe.manifest", target, 0644)
|
||||
}
|
@ -152,7 +152,16 @@ func (b *BaseBuilder) CleanUp() {
|
||||
func (b *BaseBuilder) OutputFilename(options *Options) string {
|
||||
outputFile := options.OutputFile
|
||||
if outputFile == "" {
|
||||
outputFile = b.projectData.OutputFilename
|
||||
target := strings.TrimSuffix(b.projectData.OutputFilename, ".exe")
|
||||
if b.projectData.OutputType != "desktop" {
|
||||
target += "-" + b.projectData.OutputType
|
||||
}
|
||||
switch b.options.Platform {
|
||||
case "windows":
|
||||
outputFile = b.projectData.OutputFilename
|
||||
case "darwin", "linux":
|
||||
outputFile = fmt.Sprintf("%s-%s-%s", target, b.options.Platform, b.options.Arch)
|
||||
}
|
||||
}
|
||||
return outputFile
|
||||
}
|
||||
@ -306,7 +315,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
|
||||
println("Done.")
|
||||
// If we are targeting windows, dump the DLLs
|
||||
if options.Platform == "windows" {
|
||||
err := os.WriteFile(filepath.Join(appDir, "webview2.dll"), x64.WebView2, 0755)
|
||||
err := os.WriteFile(filepath.Join(appDir, "webview.dll"), x64.WebView2, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func Build(options *Options) (string, error) {
|
||||
options.ProjectData = projectData
|
||||
|
||||
// Set build directory
|
||||
options.BuildDirectory = filepath.Join(options.ProjectData.Path, "build", options.Platform, options.OutputType)
|
||||
options.BuildDirectory = filepath.Join(options.ProjectData.Path, "build", "bin")
|
||||
|
||||
// Save the project type
|
||||
projectData.OutputType = options.OutputType
|
||||
@ -161,8 +161,14 @@ func Build(options *Options) (string, error) {
|
||||
return "", fmt.Errorf("%s - %s", err.Error(), stderr)
|
||||
}
|
||||
// Remove temp binaries
|
||||
fs.DeleteFile(filepath.Join(options.BuildDirectory, amd64Filename))
|
||||
fs.DeleteFile(filepath.Join(options.BuildDirectory, arm64Filename))
|
||||
err = fs.DeleteFile(filepath.Join(options.BuildDirectory, amd64Filename))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = fs.DeleteFile(filepath.Join(options.BuildDirectory, arm64Filename))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
projectData.OutputFilename = outputFile
|
||||
options.CompiledBinary = filepath.Join(options.BuildDirectory, outputFile)
|
||||
} else {
|
||||
@ -171,7 +177,6 @@ func Build(options *Options) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
outputLogger.Println("Done.")
|
||||
|
||||
// Do we need to pack the app?
|
||||
if options.Pack {
|
||||
|
@ -25,11 +25,11 @@ func (d *DesktopBuilder) BuildAssets(options *Options) error {
|
||||
var err error
|
||||
|
||||
// Check assets directory exists
|
||||
if !fs.DirExists(options.ProjectData.AssetsDir) {
|
||||
if !fs.DirExists(options.ProjectData.BuildDir) {
|
||||
// Path to default assets
|
||||
defaultAssets := fs.RelativePath("./internal/assets")
|
||||
// Copy the default assets directory
|
||||
err := fs.CopyDir(defaultAssets, options.ProjectData.AssetsDir)
|
||||
err := fs.CopyDir(defaultAssets, options.ProjectData.BuildDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -106,7 +106,7 @@ func (d *DesktopBuilder) BuildBaseAssets(assets *html.AssetBundle, options *Opti
|
||||
func (d *DesktopBuilder) processApplicationIcon(assetDir string) error {
|
||||
|
||||
// Copy default icon if one doesn't exist
|
||||
iconFile := filepath.Join(d.projectData.AssetsDir, "appicon.png")
|
||||
iconFile := filepath.Join(d.projectData.BuildDir, "appicon.png")
|
||||
if !fs.FileExists(iconFile) {
|
||||
err := fs.CopyFile(defaultIconPath(), iconFile)
|
||||
if err != nil {
|
||||
|
@ -27,7 +27,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
||||
var err error
|
||||
|
||||
// Get all the tray icon filenames
|
||||
trayIconDirectory := filepath.Join(options.ProjectData.AssetsDir, "tray")
|
||||
trayIconDirectory := filepath.Join(options.ProjectData.BuildDir, "tray")
|
||||
|
||||
// If the directory doesn't exist, create it
|
||||
if !fs.DirExists(trayIconDirectory) {
|
||||
@ -116,7 +116,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
|
||||
var err error
|
||||
|
||||
// Get all the dialog icon filenames
|
||||
dialogIconDirectory := filepath.Join(options.ProjectData.AssetsDir, "dialog")
|
||||
dialogIconDirectory := filepath.Join(options.ProjectData.BuildDir, "dialog")
|
||||
var dialogIconFilenames []string
|
||||
|
||||
// If the directory does not exist, create it
|
||||
|
@ -8,7 +8,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
||||
// var err error
|
||||
//
|
||||
// // Get all the tray icon filenames
|
||||
// trayIconDirectory := filepath.Join(options.ProjectData.AssetsDir, "tray")
|
||||
// trayIconDirectory := filepath.Join(options.ProjectData.BuildDir, "tray")
|
||||
//
|
||||
// // If the directory doesn't exist, create it
|
||||
// if !fs.DirExists(trayIconDirectory) {
|
||||
@ -97,7 +97,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
|
||||
// var err error
|
||||
//
|
||||
// // Get all the dialog icon filenames
|
||||
// dialogIconDirectory := filepath.Join(options.ProjectData.AssetsDir, "dialog")
|
||||
// dialogIconDirectory := filepath.Join(options.ProjectData.BuildDir, "dialog")
|
||||
// var dialogIconFilenames []string
|
||||
//
|
||||
// // If the directory does not exist, create it
|
||||
|
@ -30,12 +30,6 @@ func (b *HybridBuilder) BuildAssets(options *Options) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Build static assets
|
||||
err = b.buildCustomAssets(b.projectData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -63,18 +57,6 @@ func (b *HybridBuilder) BuildBaseAssets(options *Options) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Build desktop static assets
|
||||
err = b.desktop.buildCustomAssets(b.projectData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Build server static assets
|
||||
err = b.server.buildCustomAssets(b.projectData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,13 @@
|
||||
<plist version="1.0"><dict>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>CFBundleName</key><string>{{.Title}}</string>
|
||||
<key>CFBundleExecutable</key><string>{{.Exe}}</string>
|
||||
<key>CFBundleIdentifier</key><string>{{.PackageID}}</string>
|
||||
<key>CFBundleVersion</key><string>{{.Version}}</string>
|
||||
<key>CFBundleGetInfoString</key><string>Built by {{.Author}} using Wails (https://wails.app)</string>
|
||||
<key>CFBundleShortVersionString</key><string>{{.Version}}</string>
|
||||
<key>CFBundleExecutable</key><string>{{.Title}}</string>
|
||||
<key>CFBundleIdentifier</key><string>com.wails.{{.Title}}</string>
|
||||
<key>CFBundleVersion</key><string>1.0.0</string>
|
||||
<key>CFBundleGetInfoString</key><string>Built using Wails (https://wails.app)</string>
|
||||
<key>CFBundleShortVersionString</key><string>1.0.0</string>
|
||||
<key>CFBundleIconFile</key><string>iconfile</string>
|
||||
<key>LSMinimumSystemVersion</key><string>10.13.0</string>
|
||||
<key>NSHighResolutionCapable</key><string>true</string>
|
||||
<key>NSHumanReadableCopyright</key><string>Copyright.........</string>
|
||||
</dict></plist>
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
cd "$(dirname "$0")"
|
||||
exec ./{{.OutputFilename}}
|
@ -14,7 +14,7 @@ func packageProject(options *Options, platform string) error {
|
||||
|
||||
var err error
|
||||
switch platform {
|
||||
case "linux", "darwin":
|
||||
case "darwin", "windows":
|
||||
err = packageApplication(options)
|
||||
default:
|
||||
err = fmt.Errorf("packing not supported for %s yet", platform)
|
||||
|
@ -49,7 +49,7 @@ func packageApplication(options *Options) error {
|
||||
}
|
||||
|
||||
// Generate Icons
|
||||
err = processApplicationIcon(resourceDir, options.ProjectData.AssetsDir)
|
||||
err = processApplicationIcon(resourceDir, options.ProjectData.BuildDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -68,7 +68,7 @@ func packageApplication(options *Options) error {
|
||||
func processPList(options *Options, contentsDirectory string) error {
|
||||
|
||||
// Check if plist already exists in project dir
|
||||
plistFile := filepath.Join(options.ProjectData.AssetsDir, "mac", "Info.plist")
|
||||
plistFile := filepath.Join(options.ProjectData.BuildDir, "darwin", "Info.plist")
|
||||
|
||||
// If the file doesn't exist, generate it
|
||||
if !fs.FileExists(plistFile) {
|
||||
|
@ -1,6 +1,78 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/leaanthony/winicon"
|
||||
"github.com/wailsapp/wails/v2/internal/fs"
|
||||
"github.com/wailsapp/wails/v2/pkg/buildassets"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func packageApplication(options *Options) error {
|
||||
// TBD
|
||||
// Generate icon
|
||||
var err error
|
||||
err = generateIcoFile(options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Ensure RC file is present
|
||||
err = generateRCFile(options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Ensure Manifest is present
|
||||
err = generateManifest(options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Run
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateManifest(options *Options) error {
|
||||
filename := options.ProjectData.Name + ".exe.manifest"
|
||||
manifestFile := filepath.Join(options.ProjectData.Path, "build", "windows", filename)
|
||||
if !fs.FileExists(manifestFile) {
|
||||
return buildassets.RegenerateManifest(manifestFile)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateRCFile(options *Options) error {
|
||||
filename := options.ProjectData.Name + ".rc"
|
||||
rcFile := filepath.Join(options.ProjectData.Path, "build", "windows", filename)
|
||||
if !fs.FileExists(rcFile) {
|
||||
return buildassets.RegenerateRCFile(options.ProjectData.Path, options.ProjectData.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateIcoFile(options *Options) error {
|
||||
// Check ico file exists already
|
||||
icoFile := filepath.Join(options.ProjectData.Path, "build", "windows", "app.ico")
|
||||
if !fs.FileExists(icoFile) {
|
||||
// Check icon exists
|
||||
appicon := filepath.Join(options.ProjectData.Path, "build", "appicon.png")
|
||||
if !fs.FileExists(appicon) {
|
||||
return fmt.Errorf("application icon missing: %s", appicon)
|
||||
}
|
||||
// Load icon
|
||||
input, err := os.Open(appicon)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
output, err := os.OpenFile(icoFile, os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = winicon.GenerateIcon(input, output, []int{256, 128, 64, 48, 32, 16})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -37,12 +37,6 @@ func (s *ServerBuilder) BuildAssets(_ *Options) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Build static assets
|
||||
err = s.buildCustomAssets(s.projectData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|