mirror of
https://github.com/taigrr/wails.git
synced 2026-04-13 18:38:11 -07:00
Compare commits
76 Commits
update-dep
...
387-Suppor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6203dba146 | ||
|
|
0cd8d6b760 | ||
|
|
7dd51bc4db | ||
|
|
8b1d20f979 | ||
|
|
ad034d3950 | ||
|
|
98337df92d | ||
|
|
9cc417cf04 | ||
|
|
030b954971 | ||
|
|
7a3ab27977 | ||
|
|
0e6265a9d7 | ||
|
|
b003a080b0 | ||
|
|
376ba743f4 | ||
|
|
aa8ffff68d | ||
|
|
613a44af5e | ||
|
|
2e15c4e045 | ||
|
|
421c13805d | ||
|
|
cc204ab1f7 | ||
|
|
a94a1a9fcb | ||
|
|
e860bd06ec | ||
|
|
6da02e6b44 | ||
|
|
7cd78df1cd | ||
|
|
bcecd854bc | ||
|
|
6339f230f9 | ||
|
|
131fd973cd | ||
|
|
f1d16a03ec | ||
|
|
cc99dcce80 | ||
|
|
a8ecc1e872 | ||
|
|
6fc419ab48 | ||
|
|
400bb37c03 | ||
|
|
10fc7d762b | ||
|
|
61b9e50b8e | ||
|
|
47916216de | ||
|
|
a2b066decb | ||
|
|
8d1238289f | ||
|
|
b232b608fa | ||
|
|
3b034ceadb | ||
|
|
75be8f698a | ||
|
|
a78acbb247 | ||
|
|
6e29d1b087 | ||
|
|
8171b644ca | ||
|
|
a691ef0580 | ||
|
|
151b4bff06 | ||
|
|
fb093c58d2 | ||
|
|
b68c69f4eb | ||
|
|
8405ce37f9 | ||
|
|
76edc7976e | ||
|
|
2ab8fc37ab | ||
|
|
c66e9cba5a | ||
|
|
b33794c883 | ||
|
|
5d719685d3 | ||
|
|
5b2e5b1d85 | ||
|
|
773bad45f6 | ||
|
|
404cd7d14e | ||
|
|
ea703acfed | ||
|
|
4750ee5d22 | ||
|
|
1bd9408e9e | ||
|
|
34202f1a2f | ||
|
|
9d6d77f768 | ||
|
|
fbff822ea9 | ||
|
|
da28683ddc | ||
|
|
b7f0155c3b | ||
|
|
f220e0e5bd | ||
|
|
b5bad14124 | ||
|
|
0f36ee7030 | ||
|
|
58761ccff4 | ||
|
|
059cbbfd9a | ||
|
|
339b0ecbaf | ||
|
|
615cc55b31 | ||
|
|
577b59aa89 | ||
|
|
45a507673e | ||
|
|
eb8a1f2303 | ||
|
|
566914a9c2 | ||
|
|
0866a633a3 | ||
|
|
0e7981cf87 | ||
|
|
ce3bd8f56f | ||
|
|
79188c503f |
@@ -22,4 +22,9 @@ Wails is what it is because of the time and effort given by these great people.
|
|||||||
* [Kris Raney](https://github.com/kraney)
|
* [Kris Raney](https://github.com/kraney)
|
||||||
* [Jack Mordaunt](https://github.com/JackMordaunt)
|
* [Jack Mordaunt](https://github.com/JackMordaunt)
|
||||||
* [Michael Hipp](https://github.com/MichaelHipp)
|
* [Michael Hipp](https://github.com/MichaelHipp)
|
||||||
* [Travis McLane](https://github.com/tmclane)
|
* [Travis McLane](https://github.com/tmclane)
|
||||||
|
* [Reuben Thomas-Davis](https://github.com/Rested)
|
||||||
|
* [Jarek](https://github.com/Jarek-SRT)
|
||||||
|
* [Konez2k](https://github.com/konez2k)
|
||||||
|
* [msms](https://github.com/sayuthisobri)
|
||||||
|
* [dedo1911](https://github.com/dedo1911)
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ _Debian: 8, 9, 10_
|
|||||||
|
|
||||||
_Ubuntu: 16.04, 18.04, 19.04_
|
_Ubuntu: 16.04, 18.04, 19.04_
|
||||||
|
|
||||||
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_
|
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_, Pop!_OS
|
||||||
|
|
||||||
#### Arch Linux
|
#### Arch Linux / ArchLabs
|
||||||
|
|
||||||
`sudo pacman -S webkit2gtk gtk3`
|
`sudo pacman -S webkit2gtk gtk3`
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// +build +linux +darwin !windows
|
// +build linux darwin !windows
|
||||||
|
|
||||||
package wails
|
package wails
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
21
cmd/fs.go
21
cmd/fs.go
@@ -12,6 +12,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
)
|
)
|
||||||
@@ -47,6 +48,22 @@ func (fs *FSHelper) FileExists(path string) bool {
|
|||||||
return fi.Mode().IsRegular()
|
return fi.Mode().IsRegular()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindFile returns the first occurrence of match inside path.
|
||||||
|
func (fs *FSHelper) FindFile(path, match string) (string, error) {
|
||||||
|
files, err := ioutil.ReadDir(path)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f := range files {
|
||||||
|
if !f.IsDir() && strings.Contains(f.Name(), match) {
|
||||||
|
return f.Name(), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", fmt.Errorf("file not found")
|
||||||
|
}
|
||||||
|
|
||||||
// CreateFile creates a file at the given filename location with the contents
|
// CreateFile creates a file at the given filename location with the contents
|
||||||
// set to the given data. It will create intermediary directories if needed.
|
// set to the given data. It will create intermediary directories if needed.
|
||||||
func (fs *FSHelper) CreateFile(filename string, data []byte) error {
|
func (fs *FSHelper) CreateFile(filename string, data []byte) error {
|
||||||
@@ -100,10 +117,10 @@ func (fs *FSHelper) RemoveFile(filename string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveFiles removes the given filenames
|
// RemoveFiles removes the given filenames
|
||||||
func (fs *FSHelper) RemoveFiles(files []string) error {
|
func (fs *FSHelper) RemoveFiles(files []string, continueOnError bool) error {
|
||||||
for _, filename := range files {
|
for _, filename := range files {
|
||||||
err := os.Remove(filename)
|
err := os.Remove(filename)
|
||||||
if err != nil {
|
if err != nil && !continueOnError {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
284
cmd/helpers.go
284
cmd/helpers.go
@@ -5,12 +5,15 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/leaanthony/mewn"
|
"github.com/leaanthony/mewn"
|
||||||
|
"github.com/leaanthony/mewn/lib"
|
||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
)
|
)
|
||||||
@@ -56,21 +59,141 @@ func InstallGoDependencies(verbose bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildApplication will attempt to build the project based on the given inputs
|
// EmbedAssets will embed the built frontend assets via mewn.
|
||||||
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
func EmbedAssets() ([]string, error) {
|
||||||
|
mewnFiles := lib.GetMewnFiles([]string{}, false)
|
||||||
|
|
||||||
// Generate Windows assets if needed
|
referencedAssets, err := lib.GetReferencedAssets(mewnFiles)
|
||||||
if runtime.GOOS == "windows" {
|
if err != nil {
|
||||||
cleanUp := !packageApp
|
return []string{}, err
|
||||||
err := NewPackageHelper().PackageWindows(projectOptions, cleanUp)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Mewn is installed
|
targetFiles := []string{}
|
||||||
err := CheckMewn(projectOptions.Verbose)
|
|
||||||
|
for _, referencedAsset := range referencedAssets {
|
||||||
|
packfileData, err := lib.GeneratePackFileString(referencedAsset, false)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
targetFile := filepath.Join(referencedAsset.BaseDir, referencedAsset.PackageName+"-mewn.go")
|
||||||
|
targetFiles = append(targetFiles, targetFile)
|
||||||
|
ioutil.WriteFile(targetFile, []byte(packfileData), 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetFiles, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitializeCrossCompilation(verbose bool) error {
|
||||||
|
// Check Docker
|
||||||
|
if err := CheckIfInstalled("docker"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var packSpinner *spinner.Spinner
|
||||||
|
if !verbose {
|
||||||
|
packSpinner = spinner.New("Pulling wailsapp/xgo:latest docker image... (may take a while)")
|
||||||
|
packSpinner.SetSpinSpeed(50)
|
||||||
|
packSpinner.Start()
|
||||||
|
} else {
|
||||||
|
println("Pulling wailsapp/xgo:latest docker image... (may take a while)")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := NewProgramHelper(verbose).RunCommandArray([]string{"docker",
|
||||||
|
"pull", "wailsapp/xgo:latest"})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if packSpinner != nil {
|
||||||
|
packSpinner.Error()
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if packSpinner != nil {
|
||||||
|
packSpinner.Success()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildDocker builds the project using the cross compiling wailsapp/xgo:latest container
|
||||||
|
func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOptions) error {
|
||||||
|
var packSpinner *spinner.Spinner
|
||||||
|
if buildMode == BuildModeBridge {
|
||||||
|
return fmt.Errorf("you cant serve the application in cross-compilation")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check build directory
|
||||||
|
buildDirectory := filepath.Join(fs.Cwd(), "build")
|
||||||
|
if !fs.DirExists(buildDirectory) {
|
||||||
|
fs.MkDir(buildDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
|
buildCommand := slicer.String()
|
||||||
|
userid := 1000
|
||||||
|
user, _ := user.Current()
|
||||||
|
if i, err := strconv.Atoi(user.Uid); err == nil {
|
||||||
|
userid = i
|
||||||
|
}
|
||||||
|
for _, arg := range []string{
|
||||||
|
"docker",
|
||||||
|
"run",
|
||||||
|
"--rm",
|
||||||
|
"-v", fmt.Sprintf("%s:/build", filepath.Join(fs.Cwd(), "build")),
|
||||||
|
"-v", fmt.Sprintf("%s:/source", fs.Cwd()),
|
||||||
|
"-e", fmt.Sprintf("LOCAL_USER_ID=%v", userid),
|
||||||
|
"-e", fmt.Sprintf("FLAG_LDFLAGS=%s", ldFlags(projectOptions, buildMode)),
|
||||||
|
"-e", "FLAG_V=false",
|
||||||
|
"-e", "FLAG_X=false",
|
||||||
|
"-e", "FLAG_RACE=false",
|
||||||
|
"-e", "FLAG_BUILDMODE=default",
|
||||||
|
"-e", "FLAG_TRIMPATH=false",
|
||||||
|
"-e", fmt.Sprintf("TARGETS=%s", projectOptions.Platform+"/"+projectOptions.Architecture),
|
||||||
|
"-e", "GOPROXY=",
|
||||||
|
"-e", "GO111MODULE=on",
|
||||||
|
"wailsapp/xgo:latest",
|
||||||
|
".",
|
||||||
|
} {
|
||||||
|
buildCommand.Add(arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileMessage := fmt.Sprintf(
|
||||||
|
"Packing + Compiling project for %s/%s using docker image wailsapp/xgo:latest",
|
||||||
|
projectOptions.Platform, projectOptions.Architecture)
|
||||||
|
|
||||||
|
if buildMode == BuildModeDebug {
|
||||||
|
compileMessage += " (Debug Mode)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if !projectOptions.Verbose {
|
||||||
|
packSpinner = spinner.New(compileMessage + "...")
|
||||||
|
packSpinner.SetSpinSpeed(50)
|
||||||
|
packSpinner.Start()
|
||||||
|
} else {
|
||||||
|
println(compileMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := NewProgramHelper(projectOptions.Verbose).RunCommandArray(buildCommand.AsSlice())
|
||||||
|
if err != nil {
|
||||||
|
if packSpinner != nil {
|
||||||
|
packSpinner.Error()
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if packSpinner != nil {
|
||||||
|
packSpinner.Success()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildNative builds on the target platform itself.
|
||||||
|
func BuildNative(binaryName string, forceRebuild bool, buildMode string, projectOptions *ProjectOptions) error {
|
||||||
|
|
||||||
|
// Check Mewn is installed
|
||||||
|
if err := CheckMewn(projectOptions.Verbose); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := CheckWindres(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,18 +213,17 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildCommand := slicer.String()
|
buildCommand := slicer.String()
|
||||||
buildCommand.Add("mewn")
|
buildCommand.Add("go")
|
||||||
|
|
||||||
|
buildCommand.Add("build")
|
||||||
if buildMode == BuildModeBridge {
|
if buildMode == BuildModeBridge {
|
||||||
// Ignore errors
|
// Ignore errors
|
||||||
buildCommand.Add("-i")
|
buildCommand.Add("-i")
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCommand.Add("build")
|
|
||||||
|
|
||||||
if binaryName != "" {
|
if binaryName != "" {
|
||||||
// Alter binary name based on OS
|
// Alter binary name based on OS
|
||||||
switch runtime.GOOS {
|
switch projectOptions.Platform {
|
||||||
case "windows":
|
case "windows":
|
||||||
if !strings.HasSuffix(binaryName, ".exe") {
|
if !strings.HasSuffix(binaryName, ".exe") {
|
||||||
binaryName += ".exe"
|
binaryName += ".exe"
|
||||||
@@ -111,7 +233,7 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
binaryName = strings.TrimSuffix(binaryName, ".exe")
|
binaryName = strings.TrimSuffix(binaryName, ".exe")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildCommand.Add("-o", binaryName)
|
buildCommand.Add("-o", filepath.Join("build", binaryName))
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are forcing a rebuild
|
// If we are forcing a rebuild
|
||||||
@@ -119,31 +241,13 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
buildCommand.Add("-a")
|
buildCommand.Add("-a")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup ld flags
|
buildCommand.AddSlice([]string{"-ldflags", ldFlags(projectOptions, buildMode)})
|
||||||
ldflags := "-w -s "
|
|
||||||
if buildMode == BuildModeDebug {
|
if projectOptions.Verbose {
|
||||||
ldflags = ""
|
fmt.Printf("Command: %v\n", buildCommand.AsSlice())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add windows flags
|
err := NewProgramHelper(projectOptions.Verbose).RunCommandArray(buildCommand.AsSlice())
|
||||||
if runtime.GOOS == "windows" && buildMode == BuildModeProd {
|
|
||||||
ldflags += "-H windowsgui "
|
|
||||||
}
|
|
||||||
|
|
||||||
ldflags += "-X github.com/wailsapp/wails.BuildMode=" + buildMode
|
|
||||||
|
|
||||||
// If we wish to generate typescript
|
|
||||||
if projectOptions.typescriptDefsFilename != "" {
|
|
||||||
cwd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
filename := filepath.Join(cwd, projectOptions.FrontEnd.Dir, projectOptions.typescriptDefsFilename)
|
|
||||||
ldflags += " -X github.com/wailsapp/wails/lib/binding.typescriptDefinitionFilename=" + filename
|
|
||||||
}
|
|
||||||
|
|
||||||
buildCommand.AddSlice([]string{"-ldflags", ldflags})
|
|
||||||
err = NewProgramHelper(projectOptions.Verbose).RunCommandArray(buildCommand.AsSlice())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if packSpinner != nil {
|
if packSpinner != nil {
|
||||||
packSpinner.Error()
|
packSpinner.Error()
|
||||||
@@ -154,7 +258,55 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
packSpinner.Success()
|
packSpinner.Success()
|
||||||
}
|
}
|
||||||
|
|
||||||
// packageApp
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildApplication will attempt to build the project based on the given inputs
|
||||||
|
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// embed resources
|
||||||
|
targetFiles, err := EmbedAssets()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if projectOptions.CrossCompile {
|
||||||
|
if err := InitializeCrossCompilation(projectOptions.Verbose); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helper := NewPackageHelper(projectOptions.Platform)
|
||||||
|
|
||||||
|
// Generate windows resources
|
||||||
|
if projectOptions.Platform == "windows" {
|
||||||
|
if err := helper.PackageWindows(projectOptions, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup temporary embedded assets
|
||||||
|
defer func() {
|
||||||
|
for _, filename := range targetFiles {
|
||||||
|
if err := os.Remove(filename); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if projectOptions.Platform == "windows" {
|
||||||
|
helper.CleanWindows(projectOptions)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if projectOptions.CrossCompile {
|
||||||
|
err = BuildDocker(binaryName, buildMode, projectOptions)
|
||||||
|
} else {
|
||||||
|
err = BuildNative(binaryName, forceRebuild, buildMode, projectOptions)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if packageApp {
|
if packageApp {
|
||||||
err = PackageApplication(projectOptions)
|
err = PackageApplication(projectOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -167,22 +319,14 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
|
|
||||||
// PackageApplication will attempt to package the application in a platform dependent way
|
// PackageApplication will attempt to package the application in a platform dependent way
|
||||||
func PackageApplication(projectOptions *ProjectOptions) error {
|
func PackageApplication(projectOptions *ProjectOptions) error {
|
||||||
// Package app
|
|
||||||
message := "Generating .app"
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
err := CheckWindres()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
message = "Generating resource bundle"
|
|
||||||
}
|
|
||||||
var packageSpinner *spinner.Spinner
|
var packageSpinner *spinner.Spinner
|
||||||
if projectOptions.Verbose {
|
if projectOptions.Verbose {
|
||||||
packageSpinner = spinner.New(message)
|
packageSpinner = spinner.New("Packaging application...")
|
||||||
packageSpinner.SetSpinSpeed(50)
|
packageSpinner.SetSpinSpeed(50)
|
||||||
packageSpinner.Start()
|
packageSpinner.Start()
|
||||||
}
|
}
|
||||||
err := NewPackageHelper().Package(projectOptions)
|
|
||||||
|
err := NewPackageHelper(projectOptions.Platform).Package(projectOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if packageSpinner != nil {
|
if packageSpinner != nil {
|
||||||
packageSpinner.Error()
|
packageSpinner.Error()
|
||||||
@@ -244,7 +388,7 @@ func CheckMewn(verbose bool) (err error) {
|
|||||||
|
|
||||||
// CheckWindres checks if Windres is installed and if not, aborts
|
// CheckWindres checks if Windres is installed and if not, aborts
|
||||||
func CheckWindres() (err error) {
|
func CheckWindres() (err error) {
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" { // FIXME: Handle windows cross-compile for windows!
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
programHelper := NewProgramHelper()
|
programHelper := NewProgramHelper()
|
||||||
@@ -254,6 +398,15 @@ func CheckWindres() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckIfInstalled returns if application is installed
|
||||||
|
func CheckIfInstalled(application string) (err error) {
|
||||||
|
programHelper := NewProgramHelper()
|
||||||
|
if !programHelper.IsInstalled(application) {
|
||||||
|
return fmt.Errorf("%s not installed. Ensure you have installed %s correctly", application, application)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// InstallFrontendDeps attempts to install the frontend dependencies based on the given options
|
// InstallFrontendDeps attempts to install the frontend dependencies based on the given options
|
||||||
func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forceRebuild bool, caller string) error {
|
func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forceRebuild bool, caller string) error {
|
||||||
|
|
||||||
@@ -377,7 +530,7 @@ func ServeProject(projectOptions *ProjectOptions, logger *Logger) error {
|
|||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
logger.Green(">>>>> To connect, you will need to run '" + projectOptions.FrontEnd.Serve + "' in the '" + projectOptions.FrontEnd.Dir + "' directory <<<<<")
|
logger.Green(">>>>> To connect, you will need to run '" + projectOptions.FrontEnd.Serve + "' in the '" + projectOptions.FrontEnd.Dir + "' directory <<<<<")
|
||||||
}()
|
}()
|
||||||
location, err := filepath.Abs(projectOptions.BinaryName)
|
location, err := filepath.Abs(filepath.Join("build", projectOptions.BinaryName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -393,3 +546,28 @@ func ServeProject(projectOptions *ProjectOptions, logger *Logger) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ldFlags(po *ProjectOptions, buildMode string) string {
|
||||||
|
// Setup ld flags
|
||||||
|
ldflags := "-w -s "
|
||||||
|
if buildMode == BuildModeDebug {
|
||||||
|
ldflags = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add windows flags
|
||||||
|
if po.Platform == "windows" && buildMode == BuildModeProd {
|
||||||
|
ldflags += "-H windowsgui "
|
||||||
|
}
|
||||||
|
|
||||||
|
ldflags += "-X github.com/wailsapp/wails.BuildMode=" + buildMode
|
||||||
|
|
||||||
|
// If we wish to generate typescript
|
||||||
|
if po.typescriptDefsFilename != "" {
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err == nil {
|
||||||
|
filename := filepath.Join(cwd, po.FrontEnd.Dir, po.typescriptDefsFilename)
|
||||||
|
ldflags += " -X github.com/wailsapp/wails/lib/binding.typescriptDefinitionFilename=" + filename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ldflags
|
||||||
|
}
|
||||||
|
|||||||
37
cmd/linux.go
37
cmd/linux.go
@@ -53,6 +53,16 @@ const (
|
|||||||
Deepin
|
Deepin
|
||||||
// Raspbian distribution
|
// Raspbian distribution
|
||||||
Raspbian
|
Raspbian
|
||||||
|
// Tumbleweed (OpenSUSE) distribution
|
||||||
|
Tumbleweed
|
||||||
|
// Leap (OpenSUSE) distribution
|
||||||
|
Leap
|
||||||
|
// ArchLabs distribution
|
||||||
|
ArchLabs
|
||||||
|
// PopOS distribution
|
||||||
|
PopOS
|
||||||
|
// Solus distribution
|
||||||
|
Solus
|
||||||
)
|
)
|
||||||
|
|
||||||
// DistroInfo contains all the information relating to a linux distribution
|
// DistroInfo contains all the information relating to a linux distribution
|
||||||
@@ -110,13 +120,15 @@ func parseOsRelease(osRelease string) *DistroInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check distro name against list of distros
|
// Check distro name against list of distros
|
||||||
switch osID {
|
switch strings.ToLower(osID) {
|
||||||
case "fedora":
|
case "fedora":
|
||||||
result.Distribution = Fedora
|
result.Distribution = Fedora
|
||||||
case "centos":
|
case "centos":
|
||||||
result.Distribution = CentOS
|
result.Distribution = CentOS
|
||||||
case "arch":
|
case "arch":
|
||||||
result.Distribution = Arch
|
result.Distribution = Arch
|
||||||
|
case "archlabs":
|
||||||
|
result.Distribution = ArchLabs
|
||||||
case "debian":
|
case "debian":
|
||||||
result.Distribution = Debian
|
result.Distribution = Debian
|
||||||
case "ubuntu":
|
case "ubuntu":
|
||||||
@@ -147,6 +159,14 @@ func parseOsRelease(osRelease string) *DistroInfo {
|
|||||||
result.Distribution = Deepin
|
result.Distribution = Deepin
|
||||||
case "raspbian":
|
case "raspbian":
|
||||||
result.Distribution = Raspbian
|
result.Distribution = Raspbian
|
||||||
|
case "opensuse-tumbleweed":
|
||||||
|
result.Distribution = Tumbleweed
|
||||||
|
case "opensuse-leap":
|
||||||
|
result.Distribution = Leap
|
||||||
|
case "pop":
|
||||||
|
result.Distribution = PopOS
|
||||||
|
case "solus":
|
||||||
|
result.Distribution = Solus
|
||||||
default:
|
default:
|
||||||
result.Distribution = Unknown
|
result.Distribution = Unknown
|
||||||
}
|
}
|
||||||
@@ -183,6 +203,17 @@ func DpkgInstalled(packageName string) (bool, error) {
|
|||||||
return exitCode == 0, nil
|
return exitCode == 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EOpkgInstalled uses dpkg to see if a package is installed
|
||||||
|
func EOpkgInstalled(packageName string) (bool, error) {
|
||||||
|
program := NewProgramHelper()
|
||||||
|
eopkg := program.FindProgram("eopkg")
|
||||||
|
if eopkg == nil {
|
||||||
|
return false, fmt.Errorf("cannot check dependencies: eopkg not found")
|
||||||
|
}
|
||||||
|
stdout, _, _, _ := eopkg.Run("info", packageName)
|
||||||
|
return strings.HasPrefix(stdout, "Installed"), nil
|
||||||
|
}
|
||||||
|
|
||||||
// PacmanInstalled uses pacman to see if a package is installed.
|
// PacmanInstalled uses pacman to see if a package is installed.
|
||||||
func PacmanInstalled(packageName string) (bool, error) {
|
func PacmanInstalled(packageName string) (bool, error) {
|
||||||
program := NewProgramHelper()
|
program := NewProgramHelper()
|
||||||
@@ -254,5 +285,9 @@ func RequestSupportForDistribution(distroInfo *DistroInfo) error {
|
|||||||
|
|
||||||
fmt.Println("Opening browser to file request.")
|
fmt.Println("Opening browser to file request.")
|
||||||
browser.OpenURL(fullURL + url.PathEscape(params))
|
browser.OpenURL(fullURL + url.PathEscape(params))
|
||||||
|
result = Prompt("We have a guide for adding support for your distribution. Would you like to view it?", "yes")
|
||||||
|
if strings.ToLower(result) == "yes" {
|
||||||
|
browser.OpenURL("https://wails.app/guides/distro/")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,25 @@ UBUNTU_CODENAME=bionic
|
|||||||
if result.Distribution != Ubuntu {
|
if result.Distribution != Ubuntu {
|
||||||
t.Errorf("expected 'Ubuntu' ID but got '%d'", result.Distribution)
|
t.Errorf("expected 'Ubuntu' ID but got '%d'", result.Distribution)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTumbleweedDetection(t *testing.T) {
|
||||||
|
osrelease := `
|
||||||
|
NAME="openSUSE Tumbleweed"
|
||||||
|
# VERSION="20200414"
|
||||||
|
ID="opensuse-tumbleweed"
|
||||||
|
ID_LIKE="opensuse suse"
|
||||||
|
VERSION_ID="20200414"
|
||||||
|
PRETTY_NAME="openSUSE Tumbleweed"
|
||||||
|
ANSI_COLOR="0;32"
|
||||||
|
CPE_NAME="cpe:/o:opensuse:tumbleweed:20200414"
|
||||||
|
BUG_REPORT_URL="https://bugs.opensuse.org"
|
||||||
|
HOME_URL="https://www.opensuse.org/"
|
||||||
|
LOGO="distributor-logo"
|
||||||
|
`
|
||||||
|
|
||||||
|
result := parseOsRelease(osrelease)
|
||||||
|
if result.Distribution != Tumbleweed {
|
||||||
|
t.Errorf("expected 'Tumbleweed' ID but got '%d'", result.Distribution)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,15 @@ distributions:
|
|||||||
gccversioncommand: &gccdumpfullversion -dumpfullversion
|
gccversioncommand: &gccdumpfullversion -dumpfullversion
|
||||||
programs: *debiandefaultprograms
|
programs: *debiandefaultprograms
|
||||||
libraries: *debiandefaultlibraries
|
libraries: *debiandefaultlibraries
|
||||||
|
pop:
|
||||||
|
id: pop
|
||||||
|
releases:
|
||||||
|
default:
|
||||||
|
version: default
|
||||||
|
name: Pop!_OS
|
||||||
|
gccversioncommand: &gccdumpfullversion -dumpfullversion
|
||||||
|
programs: *debiandefaultprograms
|
||||||
|
libraries: *debiandefaultlibraries
|
||||||
kali:
|
kali:
|
||||||
id: kali
|
id: kali
|
||||||
releases:
|
releases:
|
||||||
@@ -176,6 +185,15 @@ distributions:
|
|||||||
gccversioncommand: *gccdumpversion
|
gccversioncommand: *gccdumpversion
|
||||||
programs: *archdefaultprograms
|
programs: *archdefaultprograms
|
||||||
libraries: *archdefaultlibraries
|
libraries: *archdefaultlibraries
|
||||||
|
archlabs:
|
||||||
|
id: archlabs
|
||||||
|
releases:
|
||||||
|
default:
|
||||||
|
version: default
|
||||||
|
name: ArchLabs
|
||||||
|
gccversioncommand: *gccdumpversion
|
||||||
|
programs: *archdefaultprograms
|
||||||
|
libraries: *archdefaultlibraries
|
||||||
manjaro:
|
manjaro:
|
||||||
id: manjaro
|
id: manjaro
|
||||||
releases:
|
releases:
|
||||||
@@ -223,3 +241,51 @@ distributions:
|
|||||||
gccversioncommand: *gccdumpfullversion
|
gccversioncommand: *gccdumpfullversion
|
||||||
programs: *debiandefaultprograms
|
programs: *debiandefaultprograms
|
||||||
libraries: *debiandefaultlibraries
|
libraries: *debiandefaultlibraries
|
||||||
|
solus:
|
||||||
|
id: solus
|
||||||
|
releases:
|
||||||
|
default:
|
||||||
|
version: default
|
||||||
|
name: Solus
|
||||||
|
gccversioncommand: *gccdumpfullversion
|
||||||
|
programs: &solusdefaultprograms
|
||||||
|
- name: gcc
|
||||||
|
help: Please install with `sudo eopkg it -c system.devel` and try again
|
||||||
|
- name: pkg-config
|
||||||
|
help: Please install with `sudo eopkg it -c system.devel` and try again
|
||||||
|
- name: npm
|
||||||
|
help: Please install with `sudo eopkg it nodejs` and try again
|
||||||
|
libraries: &solusdefaultlibraries
|
||||||
|
- name: libgtk-3-devel
|
||||||
|
help: Please install with `sudo eopkg it libgtk-3-devel` and try again
|
||||||
|
- name: libwebkit-gtk-devel
|
||||||
|
help: Please install with `sudo eopkg it libwebkit-gtk-devel` and try again
|
||||||
|
|
||||||
|
opensuse-tumbleweed:
|
||||||
|
id: opensuse-tumbleweed
|
||||||
|
releases:
|
||||||
|
default:
|
||||||
|
version: default
|
||||||
|
name: openSUSE Tumbleweed
|
||||||
|
gccversioncommand: *gccdumpfullversion
|
||||||
|
programs: &opensusedefaultprograms
|
||||||
|
- name: gcc
|
||||||
|
help: Please install with `sudo zypper in gcc-c++` and try again
|
||||||
|
- name: pkg-config
|
||||||
|
help: Please install with `sudo zypper in pkgconf-pkg-config` and try again
|
||||||
|
- name: npm
|
||||||
|
help: Please install `sudo zypper in nodejs` and try again
|
||||||
|
libraries: &opensusedefaultlibraries
|
||||||
|
- name: gtk3-devel
|
||||||
|
help: Please install with `sudo zypper in gtk3-devel` and try again
|
||||||
|
- name: webkit2gtk3-devel
|
||||||
|
help: Please install with `sudo zypper in webkit2gtk3-devel` and try again
|
||||||
|
opensuse-leap:
|
||||||
|
id: opensuse-leap
|
||||||
|
releases:
|
||||||
|
default:
|
||||||
|
version: default
|
||||||
|
name: openSUSE Leap
|
||||||
|
gccversioncommand: *gccdumpfullversion
|
||||||
|
programs: *opensusedefaultprograms
|
||||||
|
libraries: *opensusedefaultlibraries
|
||||||
|
|||||||
242
cmd/package.go
242
cmd/package.go
@@ -1,9 +1,12 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
"image/png"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -14,21 +17,24 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jackmordaunt/icns"
|
"github.com/jackmordaunt/icns"
|
||||||
|
"golang.org/x/image/draw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PackageHelper helps with the 'wails package' command
|
// PackageHelper helps with the 'wails package' command
|
||||||
type PackageHelper struct {
|
type PackageHelper struct {
|
||||||
fs *FSHelper
|
platform string
|
||||||
log *Logger
|
fs *FSHelper
|
||||||
system *SystemHelper
|
log *Logger
|
||||||
|
system *SystemHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPackageHelper creates a new PackageHelper!
|
// NewPackageHelper creates a new PackageHelper!
|
||||||
func NewPackageHelper() *PackageHelper {
|
func NewPackageHelper(platform string) *PackageHelper {
|
||||||
return &PackageHelper{
|
return &PackageHelper{
|
||||||
fs: NewFSHelper(),
|
platform: platform,
|
||||||
log: NewLogger(),
|
fs: NewFSHelper(),
|
||||||
system: NewSystemHelper(),
|
log: NewLogger(),
|
||||||
|
system: NewSystemHelper(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +59,111 @@ func newPlistData(title, exe, packageID, version, author string) *plistData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type windowsIcoHeader struct {
|
||||||
|
_ uint16
|
||||||
|
imageType uint16
|
||||||
|
imageCount uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
type windowsIcoDescriptor struct {
|
||||||
|
width uint8
|
||||||
|
height uint8
|
||||||
|
colours uint8
|
||||||
|
_ uint8
|
||||||
|
planes uint16
|
||||||
|
bpp uint16
|
||||||
|
size uint32
|
||||||
|
offset uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type windowsIcoContainer struct {
|
||||||
|
Header windowsIcoDescriptor
|
||||||
|
Data []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateWindowsIcon(pngFilename string, iconfile string) error {
|
||||||
|
sizes := []int{256, 128, 64, 48, 32, 16}
|
||||||
|
|
||||||
|
pngfile, err := os.Open(pngFilename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer pngfile.Close()
|
||||||
|
|
||||||
|
pngdata, err := png.Decode(pngfile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
icons := []windowsIcoContainer{}
|
||||||
|
|
||||||
|
for _, size := range sizes {
|
||||||
|
rect := image.Rect(0, 0, int(size), int(size))
|
||||||
|
rawdata := image.NewRGBA(rect)
|
||||||
|
scale := draw.CatmullRom
|
||||||
|
scale.Scale(rawdata, rect, pngdata, pngdata.Bounds(), draw.Over, nil)
|
||||||
|
|
||||||
|
icondata := new(bytes.Buffer)
|
||||||
|
writer := bufio.NewWriter(icondata)
|
||||||
|
err = png.Encode(writer, rawdata)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
writer.Flush()
|
||||||
|
|
||||||
|
imgSize := size
|
||||||
|
if imgSize >= 256 {
|
||||||
|
imgSize = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
data := icondata.Bytes()
|
||||||
|
|
||||||
|
icn := windowsIcoContainer{
|
||||||
|
Header: windowsIcoDescriptor{
|
||||||
|
width: uint8(imgSize),
|
||||||
|
height: uint8(imgSize),
|
||||||
|
planes: 1,
|
||||||
|
bpp: 32,
|
||||||
|
size: uint32(len(data)),
|
||||||
|
},
|
||||||
|
Data: data,
|
||||||
|
}
|
||||||
|
icons = append(icons, icn)
|
||||||
|
}
|
||||||
|
|
||||||
|
outfile, err := os.Create(iconfile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer outfile.Close()
|
||||||
|
|
||||||
|
ico := windowsIcoHeader{
|
||||||
|
imageType: 1,
|
||||||
|
imageCount: uint16(len(sizes)),
|
||||||
|
}
|
||||||
|
err = binary.Write(outfile, binary.LittleEndian, ico)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
offset := uint32(6 + 16*len(sizes))
|
||||||
|
for _, icon := range icons {
|
||||||
|
icon.Header.offset = offset
|
||||||
|
err = binary.Write(outfile, binary.LittleEndian, icon.Header)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
offset += icon.Header.size
|
||||||
|
}
|
||||||
|
for _, icon := range icons {
|
||||||
|
_, err = outfile.Write(icon.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func defaultString(val string, defaultVal string) string {
|
func defaultString(val string, defaultVal string) string {
|
||||||
if val != "" {
|
if val != "" {
|
||||||
return val
|
return val
|
||||||
@@ -63,29 +174,30 @@ func defaultString(val string, defaultVal string) string {
|
|||||||
func (b *PackageHelper) getPackageFileBaseDir() string {
|
func (b *PackageHelper) getPackageFileBaseDir() string {
|
||||||
// Calculate template base dir
|
// Calculate template base dir
|
||||||
_, filename, _, _ := runtime.Caller(1)
|
_, filename, _, _ := runtime.Caller(1)
|
||||||
return filepath.Join(path.Dir(filename), "packages", runtime.GOOS)
|
return filepath.Join(path.Dir(filename), "packages", b.platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Package the application into a platform specific package
|
// Package the application into a platform specific package
|
||||||
func (b *PackageHelper) Package(po *ProjectOptions) error {
|
func (b *PackageHelper) Package(po *ProjectOptions) error {
|
||||||
switch runtime.GOOS {
|
switch b.platform {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
// Check we have the exe
|
|
||||||
if !b.fs.FileExists(po.BinaryName) {
|
|
||||||
return fmt.Errorf("cannot bundle non-existent binary file '%s'. Please build with 'wails build' first", po.BinaryName)
|
|
||||||
}
|
|
||||||
return b.packageOSX(po)
|
return b.packageOSX(po)
|
||||||
case "windows":
|
case "windows":
|
||||||
return b.PackageWindows(po, false)
|
return b.PackageWindows(po, true)
|
||||||
case "linux":
|
case "linux":
|
||||||
return fmt.Errorf("linux is not supported at this time. Please see https://github.com/wailsapp/wails/issues/2")
|
return b.packageLinux(po)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("platform '%s' not supported for bundling yet", runtime.GOOS)
|
return fmt.Errorf("platform '%s' not supported for bundling yet", b.platform)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *PackageHelper) packageLinux(po *ProjectOptions) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Package the application for OSX
|
// Package the application for OSX
|
||||||
func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||||
|
build := path.Join(b.fs.Cwd(), "build")
|
||||||
|
|
||||||
system := NewSystemHelper()
|
system := NewSystemHelper()
|
||||||
config, err := system.LoadConfig()
|
config, err := system.LoadConfig()
|
||||||
@@ -102,18 +214,25 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
|||||||
appname := po.Name + ".app"
|
appname := po.Name + ".app"
|
||||||
|
|
||||||
// Check binary exists
|
// Check binary exists
|
||||||
source := path.Join(b.fs.Cwd(), exe)
|
source := path.Join(build, exe)
|
||||||
if !b.fs.FileExists(source) {
|
if po.CrossCompile == true {
|
||||||
// We need to build!
|
file, err := b.fs.FindFile(build, "darwin")
|
||||||
return fmt.Errorf("Target '%s' not available. Has it been compiled yet?", exe)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
source = path.Join(build, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !b.fs.FileExists(source) {
|
||||||
|
// We need to build!
|
||||||
|
return fmt.Errorf("Target '%s' not available. Has it been compiled yet?", source)
|
||||||
|
}
|
||||||
// Remove the existing package
|
// Remove the existing package
|
||||||
os.RemoveAll(appname)
|
os.RemoveAll(appname)
|
||||||
|
|
||||||
exeDir := path.Join(b.fs.Cwd(), appname, "/Contents/MacOS")
|
exeDir := path.Join(build, appname, "/Contents/MacOS")
|
||||||
b.fs.MkDirs(exeDir, 0755)
|
b.fs.MkDirs(exeDir, 0755)
|
||||||
resourceDir := path.Join(b.fs.Cwd(), appname, "/Contents/Resources")
|
resourceDir := path.Join(build, appname, "/Contents/Resources")
|
||||||
b.fs.MkDirs(resourceDir, 0755)
|
b.fs.MkDirs(resourceDir, 0755)
|
||||||
tmpl := template.New("infoPlist")
|
tmpl := template.New("infoPlist")
|
||||||
plistFile := filepath.Join(b.getPackageFileBaseDir(), "info.plist")
|
plistFile := filepath.Join(b.getPackageFileBaseDir(), "info.plist")
|
||||||
@@ -129,7 +248,7 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
filename := path.Join(b.fs.Cwd(), appname, "Contents", "Info.plist")
|
filename := path.Join(build, appname, "Contents", "Info.plist")
|
||||||
err = ioutil.WriteFile(filename, tpl.Bytes(), 0644)
|
err = ioutil.WriteFile(filename, tpl.Bytes(), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -150,22 +269,37 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CleanWindows removes any windows related files found in the directory
|
||||||
|
func (b *PackageHelper) CleanWindows(po *ProjectOptions) {
|
||||||
|
pdir := b.fs.Cwd()
|
||||||
|
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
||||||
|
exts := []string{".ico", ".exe.manifest", ".rc", "-res.syso"}
|
||||||
|
rsrcs := []string{}
|
||||||
|
for _, ext := range exts {
|
||||||
|
rsrcs = append(rsrcs, filepath.Join(pdir, basename+ext))
|
||||||
|
}
|
||||||
|
b.fs.RemoveFiles(rsrcs, true)
|
||||||
|
}
|
||||||
|
|
||||||
// PackageWindows packages the application for windows platforms
|
// PackageWindows packages the application for windows platforms
|
||||||
func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||||
|
outputDir := b.fs.Cwd()
|
||||||
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
||||||
|
|
||||||
// Copy icon
|
// Copy default icon if needed
|
||||||
tgtIconFile := filepath.Join(b.fs.Cwd(), basename+".ico")
|
icon, err := b.copyIcon()
|
||||||
if !b.fs.FileExists(tgtIconFile) {
|
if err != nil {
|
||||||
srcIconfile := filepath.Join(b.getPackageFileBaseDir(), "wails.ico")
|
return err
|
||||||
err := b.fs.CopyFile(srcIconfile, tgtIconFile)
|
}
|
||||||
if err != nil {
|
|
||||||
return err
|
// Generate icon from PNG
|
||||||
}
|
err = generateWindowsIcon(icon, po.BinaryName+".ico")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy manifest
|
// Copy manifest
|
||||||
tgtManifestFile := filepath.Join(b.fs.Cwd(), basename+".exe.manifest")
|
tgtManifestFile := filepath.Join(outputDir, basename+".exe.manifest")
|
||||||
if !b.fs.FileExists(tgtManifestFile) {
|
if !b.fs.FileExists(tgtManifestFile) {
|
||||||
srcManifestfile := filepath.Join(b.getPackageFileBaseDir(), "wails.exe.manifest")
|
srcManifestfile := filepath.Join(b.getPackageFileBaseDir(), "wails.exe.manifest")
|
||||||
err := b.fs.CopyFile(srcManifestfile, tgtManifestFile)
|
err := b.fs.CopyFile(srcManifestfile, tgtManifestFile)
|
||||||
@@ -175,7 +309,7 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy rc file
|
// Copy rc file
|
||||||
tgtRCFile := filepath.Join(b.fs.Cwd(), basename+".rc")
|
tgtRCFile := filepath.Join(outputDir, basename+".rc")
|
||||||
if !b.fs.FileExists(tgtRCFile) {
|
if !b.fs.FileExists(tgtRCFile) {
|
||||||
srcRCfile := filepath.Join(b.getPackageFileBaseDir(), "wails.rc")
|
srcRCfile := filepath.Join(b.getPackageFileBaseDir(), "wails.rc")
|
||||||
rcfilebytes, err := ioutil.ReadFile(srcRCfile)
|
rcfilebytes, err := ioutil.ReadFile(srcRCfile)
|
||||||
@@ -190,33 +324,37 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build syso
|
// Build syso
|
||||||
sysofile := filepath.Join(b.fs.Cwd(), basename+"-res.syso")
|
sysofile := filepath.Join(outputDir, basename+"-res.syso")
|
||||||
|
|
||||||
batfile, err := fs.LocalDir(".")
|
// cross-compile
|
||||||
if err != nil {
|
if b.platform != runtime.GOOS {
|
||||||
return err
|
args := []string{
|
||||||
}
|
"docker", "run", "--rm",
|
||||||
|
"-v", outputDir + ":/build",
|
||||||
|
"--entrypoint", "/bin/sh",
|
||||||
|
"wailsapp/xgo:latest",
|
||||||
|
"-c", "/usr/bin/x86_64-w64-mingw32-windres -o /build/" + basename + "-res.syso /build/" + basename + ".rc",
|
||||||
|
}
|
||||||
|
if err := NewProgramHelper().RunCommandArray(args); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
batfile, err := fs.LocalDir(".")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
windresBatFile := filepath.Join(batfile.fullPath, "windres.bat")
|
windresBatFile := filepath.Join(batfile.fullPath, "windres.bat")
|
||||||
windresCommand := []string{windresBatFile, sysofile, tgtRCFile}
|
windresCommand := []string{windresBatFile, sysofile, tgtRCFile}
|
||||||
err = NewProgramHelper().RunCommandArray(windresCommand)
|
err = NewProgramHelper().RunCommandArray(windresCommand)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean up
|
|
||||||
if cleanUp {
|
|
||||||
filesToDelete := []string{tgtIconFile, tgtManifestFile, tgtRCFile, sysofile}
|
|
||||||
err := b.fs.RemoveFiles(filesToDelete)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *PackageHelper) copyIcon(resourceDir string) (string, error) {
|
func (b *PackageHelper) copyIcon() (string, error) {
|
||||||
|
|
||||||
// TODO: Read this from project.json
|
// TODO: Read this from project.json
|
||||||
const appIconFilename = "appicon.png"
|
const appIconFilename = "appicon.png"
|
||||||
@@ -241,7 +379,7 @@ func (b *PackageHelper) copyIcon(resourceDir string) (string, error) {
|
|||||||
|
|
||||||
func (b *PackageHelper) packageIconOSX(resourceDir string) error {
|
func (b *PackageHelper) packageIconOSX(resourceDir string) error {
|
||||||
|
|
||||||
srcIcon, err := b.copyIcon(resourceDir)
|
srcIcon, err := b.copyIcon()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0"><dict>
|
<plist version="1.0"><dict>
|
||||||
|
<key>CFBundlePackageType</key><string>APPL</string>
|
||||||
<key>CFBundleName</key><string>{{.Title}}</string>
|
<key>CFBundleName</key><string>{{.Title}}</string>
|
||||||
<key>CFBundleExecutable</key><string>{{.Exe}}</string>
|
<key>CFBundleExecutable</key><string>{{.Exe}}</string>
|
||||||
<key>CFBundleIdentifier</key><string>{{.PackageID}}</string>
|
<key>CFBundleIdentifier</key><string>{{.PackageID}}</string>
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
100 ICON "$NAME$.ico"
|
100 ICON "$NAME$.ico"
|
||||||
100 24 "$NAME$.exe.manifest"
|
110 24 "$NAME$.exe.manifest"
|
||||||
@@ -138,11 +138,11 @@ func (p *ProgramHelper) RunCommand(command string) error {
|
|||||||
|
|
||||||
// RunCommandArray runs the command specified in the array
|
// RunCommandArray runs the command specified in the array
|
||||||
func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error {
|
func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error {
|
||||||
program := args[0]
|
programCommand := args[0]
|
||||||
// TODO: Run FindProgram here and get the full path to the exe
|
// TODO: Run FindProgram here and get the full path to the exe
|
||||||
program, err := exec.LookPath(program)
|
program, err := exec.LookPath(programCommand)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: Looks like '%s' isn't installed. Please install and try again.", program)
|
fmt.Printf("ERROR: Looks like '%s' isn't installed. Please install and try again.", programCommand)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -159,6 +158,9 @@ type ProjectOptions struct {
|
|||||||
WailsVersion string
|
WailsVersion string
|
||||||
typescriptDefsFilename string
|
typescriptDefsFilename string
|
||||||
Verbose bool `json:"-"`
|
Verbose bool `json:"-"`
|
||||||
|
CrossCompile bool
|
||||||
|
Platform string
|
||||||
|
Architecture string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defaults sets the default project template
|
// Defaults sets the default project template
|
||||||
@@ -333,11 +335,6 @@ func processBinaryName(po *ProjectOptions) {
|
|||||||
if po.BinaryName == "" {
|
if po.BinaryName == "" {
|
||||||
var binaryNameComputed = computeBinaryName(po.Name)
|
var binaryNameComputed = computeBinaryName(po.Name)
|
||||||
po.BinaryName = Prompt("The output binary name", binaryNameComputed)
|
po.BinaryName = Prompt("The output binary name", binaryNameComputed)
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
if !strings.HasSuffix(po.BinaryName, ".exe") {
|
|
||||||
po.BinaryName += ".exe"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fmt.Println("Output binary Name: " + po.BinaryName)
|
fmt.Println("Output binary Name: " + po.BinaryName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,16 +274,18 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
|
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian:
|
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS:
|
||||||
libraryChecker = DpkgInstalled
|
libraryChecker = DpkgInstalled
|
||||||
case Arch, ArcoLinux, Manjaro, ManjaroARM:
|
case Arch, ArcoLinux, ArchLabs, Manjaro, ManjaroARM:
|
||||||
libraryChecker = PacmanInstalled
|
libraryChecker = PacmanInstalled
|
||||||
case CentOS, Fedora:
|
case CentOS, Fedora, Tumbleweed, Leap:
|
||||||
libraryChecker = RpmInstalled
|
libraryChecker = RpmInstalled
|
||||||
case Gentoo:
|
case Gentoo:
|
||||||
libraryChecker = EqueryInstalled
|
libraryChecker = EqueryInstalled
|
||||||
case VoidLinux:
|
case VoidLinux:
|
||||||
libraryChecker = XbpsInstalled
|
libraryChecker = XbpsInstalled
|
||||||
|
case Solus:
|
||||||
|
libraryChecker = EOpkgInstalled
|
||||||
default:
|
default:
|
||||||
return false, RequestSupportForDistribution(distroInfo)
|
return false, RequestSupportForDistribution(distroInfo)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.1.4",
|
"core-js": "^3.6.4",
|
||||||
"react": "^16.8.6",
|
"react": "^16.13.0",
|
||||||
"react-dom": "^16.8.6",
|
"react-dom": "^16.13.0",
|
||||||
"wails-react-scripts": "3.0.1-2",
|
"wails-react-scripts": "3.0.1-2",
|
||||||
"react-modal": "3.8.1",
|
"react-modal": "3.11.2",
|
||||||
"@wailsapp/runtime": "^1.0.0"
|
"@wailsapp/runtime": "^1.0.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
|||||||
@@ -8,21 +8,21 @@
|
|||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.6.1",
|
"core-js": "^3.6.4",
|
||||||
"regenerator-runtime": "^0.13.3",
|
"regenerator-runtime": "^0.13.3",
|
||||||
"vue": "^2.5.22",
|
"vue": "^2.6.11",
|
||||||
"@wailsapp/runtime": "^1.0.0"
|
"@wailsapp/runtime": "^1.0.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vue/cli-plugin-babel": "^3.4.0",
|
"@vue/cli-plugin-babel": "^4.2.3",
|
||||||
"@vue/cli-plugin-eslint": "^3.4.0",
|
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||||
"@vue/cli-service": "^3.4.0",
|
"@vue/cli-service": "^4.2.3",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.1.0",
|
||||||
"eslint": "^5.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-plugin-vue": "^5.0.0",
|
"eslint-plugin-vue": "^6.2.1",
|
||||||
"eventsource-polyfill": "^0.9.6",
|
"eventsource-polyfill": "^0.9.6",
|
||||||
"vue-template-compiler": "^2.5.21",
|
"vue-template-compiler": "^2.6.11",
|
||||||
"webpack-hot-middleware": "^2.24.3"
|
"webpack-hot-middleware": "^2.25.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -7,24 +7,24 @@
|
|||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.6.1",
|
"core-js": "^3.6.4",
|
||||||
"regenerator-runtime": "^0.13.3",
|
"regenerator-runtime": "^0.13.3",
|
||||||
"material-design-icons-iconfont": "^5.0.1",
|
"material-design-icons-iconfont": "^5.0.1",
|
||||||
"vue": "^2.5.22",
|
"vue": "^2.5.22",
|
||||||
"vuetify": "^1.5.14",
|
"vuetify": "^1.5.14",
|
||||||
"@wailsapp/runtime": "^1.0.0"
|
"@wailsapp/runtime": "^1.0.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vue/cli-plugin-babel": "^3.4.0",
|
"@vue/cli-plugin-babel": "^4.2.3",
|
||||||
"@vue/cli-plugin-eslint": "^3.4.0",
|
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||||
"@vue/cli-service": "^3.4.0",
|
"@vue/cli-service": "^4.2.3",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.1.0",
|
||||||
"eslint": "^5.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-plugin-vue": "^5.0.0",
|
"eslint-plugin-vue": "^6.2.1",
|
||||||
"eventsource-polyfill": "^0.9.6",
|
"eventsource-polyfill": "^0.9.6",
|
||||||
"vue-template-compiler": "^2.5.21",
|
"vue-template-compiler": "^2.6.11",
|
||||||
"webpack-hot-middleware": "^2.24.3"
|
"webpack-hot-middleware": "^2.25.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -8,23 +8,23 @@
|
|||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.6.1",
|
"core-js": "^3.6.4",
|
||||||
"regenerator-runtime": "^0.13.3",
|
"regenerator-runtime": "^0.13.3",
|
||||||
"vue": "^2.5.22",
|
"vue": "^2.6.11",
|
||||||
"vuetify": "^2.0.15",
|
"vuetify": "^2.2.15",
|
||||||
"@wailsapp/runtime": "^1.0.0"
|
"@wailsapp/runtime": "^1.0.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mdi/font": "^4.3.95",
|
"@mdi/font": "^4.9.95",
|
||||||
"@vue/cli-plugin-babel": "^3.4.0",
|
"@vue/cli-plugin-babel": "^4.2.3",
|
||||||
"@vue/cli-plugin-eslint": "^3.4.0",
|
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||||
"@vue/cli-service": "^3.4.0",
|
"@vue/cli-service": "^4.2.3",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.1.0",
|
||||||
"eslint": "^5.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-plugin-vue": "^5.0.0",
|
"eslint-plugin-vue": "^6.2.1",
|
||||||
"eventsource-polyfill": "^0.9.6",
|
"eventsource-polyfill": "^0.9.6",
|
||||||
"vue-template-compiler": "^2.5.21",
|
"vue-template-compiler": "^2.6.11",
|
||||||
"webpack-hot-middleware": "^2.24.3"
|
"webpack-hot-middleware": "^2.25.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
// Version - Wails version
|
// Version - Wails version
|
||||||
const Version = "v1.0.3-pre1"
|
const Version = "v1.6.0-pre3"
|
||||||
|
|||||||
@@ -3,11 +3,24 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
"github.com/wailsapp/wails/cmd"
|
"github.com/wailsapp/wails/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getSupportedPlatforms returns a slice of platform/architecture
|
||||||
|
// targets that are buildable using the cross-platform 'x' option.
|
||||||
|
func getSupportedPlatforms() []string {
|
||||||
|
return []string{
|
||||||
|
"darwin/amd64",
|
||||||
|
"linux/amd64",
|
||||||
|
"linux/arm-7",
|
||||||
|
"windows/amd64",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
var packageApp = false
|
var packageApp = false
|
||||||
@@ -15,6 +28,7 @@ func init() {
|
|||||||
var debugMode = false
|
var debugMode = false
|
||||||
var typescriptFilename = ""
|
var typescriptFilename = ""
|
||||||
var verbose = false
|
var verbose = false
|
||||||
|
var platform = ""
|
||||||
|
|
||||||
buildSpinner := spinner.NewSpinner()
|
buildSpinner := spinner.NewSpinner()
|
||||||
buildSpinner.SetSpinSpeed(50)
|
buildSpinner.SetSpinSpeed(50)
|
||||||
@@ -28,6 +42,14 @@ func init() {
|
|||||||
BoolFlag("verbose", "Verbose output", &verbose).
|
BoolFlag("verbose", "Verbose output", &verbose).
|
||||||
StringFlag("t", "Generate Typescript definitions to given file (at runtime)", &typescriptFilename)
|
StringFlag("t", "Generate Typescript definitions to given file (at runtime)", &typescriptFilename)
|
||||||
|
|
||||||
|
var b strings.Builder
|
||||||
|
for _, plat := range getSupportedPlatforms() {
|
||||||
|
fmt.Fprintf(&b, " - %s\n", plat)
|
||||||
|
}
|
||||||
|
initCmd.StringFlag("x",
|
||||||
|
fmt.Sprintf("Cross-compile application to specified platform via xgo\n%s", b.String()),
|
||||||
|
&platform)
|
||||||
|
|
||||||
initCmd.Action(func() error {
|
initCmd.Action(func() error {
|
||||||
|
|
||||||
message := "Building Application"
|
message := "Building Application"
|
||||||
@@ -52,6 +74,25 @@ func init() {
|
|||||||
return fmt.Errorf("Unable to find 'project.json'. Please check you are in a Wails project directory")
|
return fmt.Errorf("Unable to find 'project.json'. Please check you are in a Wails project directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set cross-compile
|
||||||
|
projectOptions.Platform = runtime.GOOS
|
||||||
|
if len(platform) > 0 {
|
||||||
|
supported := false
|
||||||
|
for _, plat := range getSupportedPlatforms() {
|
||||||
|
if plat == platform {
|
||||||
|
supported = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !supported {
|
||||||
|
return fmt.Errorf("Unsupported platform '%s' specified.\nPlease run `wails build -h` to see the supported platform/architecture options.", platform)
|
||||||
|
}
|
||||||
|
|
||||||
|
projectOptions.CrossCompile = true
|
||||||
|
plat := strings.Split(platform, "/")
|
||||||
|
projectOptions.Platform = plat[0]
|
||||||
|
projectOptions.Architecture = plat[1]
|
||||||
|
}
|
||||||
|
|
||||||
// Validate config
|
// Validate config
|
||||||
// Check if we have a frontend
|
// Check if we have a frontend
|
||||||
err = cmd.ValidateFrontendConfig(projectOptions)
|
err = cmd.ValidateFrontendConfig(projectOptions)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
"github.com/wailsapp/wails/cmd"
|
"github.com/wailsapp/wails/cmd"
|
||||||
@@ -35,6 +36,7 @@ func init() {
|
|||||||
// Project options
|
// Project options
|
||||||
projectOptions := &cmd.ProjectOptions{}
|
projectOptions := &cmd.ProjectOptions{}
|
||||||
projectOptions.Verbose = verbose
|
projectOptions.Verbose = verbose
|
||||||
|
projectOptions.Platform = runtime.GOOS
|
||||||
|
|
||||||
// Check we are in project directory
|
// Check we are in project directory
|
||||||
// Check project.json loads correctly
|
// Check project.json loads correctly
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -22,6 +22,7 @@ require (
|
|||||||
github.com/stretchr/testify v1.3.0 // indirect
|
github.com/stretchr/testify v1.3.0 // indirect
|
||||||
github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba
|
github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect
|
||||||
|
golang.org/x/image v0.0.0-20200430140353-33d19683fad8
|
||||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect
|
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect
|
||||||
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862
|
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862
|
||||||
golang.org/x/text v0.3.0
|
golang.org/x/text v0.3.0
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -70,6 +70,8 @@ golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnf
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
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/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 h1:6M3SDHlHHDCx2PcQw3S4KsR170vGqDhJDOmpVd4Hjak=
|
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 h1:6M3SDHlHHDCx2PcQw3S4KsR170vGqDhJDOmpVd4Hjak=
|
||||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ type Bridge struct {
|
|||||||
server *http.Server
|
server *http.Server
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
sessions map[string]session
|
sessions map[string]*session
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise the Bridge Renderer
|
// Initialise the Bridge Renderer
|
||||||
func (h *Bridge) Initialise(appConfig interfaces.AppConfig, ipcManager interfaces.IPCManager, eventManager interfaces.EventManager) error {
|
func (h *Bridge) Initialise(appConfig interfaces.AppConfig, ipcManager interfaces.IPCManager, eventManager interfaces.EventManager) error {
|
||||||
h.sessions = map[string]session{}
|
h.sessions = map[string]*session{}
|
||||||
h.ipcManager = ipcManager
|
h.ipcManager = ipcManager
|
||||||
h.appConfig = appConfig
|
h.appConfig = appConfig
|
||||||
h.eventManager = eventManager
|
h.eventManager = eventManager
|
||||||
@@ -70,13 +70,11 @@ func (h *Bridge) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Bridge) startSession(conn *websocket.Conn) {
|
func (h *Bridge) startSession(conn *websocket.Conn) {
|
||||||
s := session{
|
s := newSession(conn,
|
||||||
conn: conn,
|
h.bindingCache,
|
||||||
bindingCache: h.bindingCache,
|
h.ipcManager,
|
||||||
ipc: h.ipcManager,
|
logger.NewCustomLogger("BridgeSession"),
|
||||||
log: h.log,
|
h.eventManager)
|
||||||
eventManager: h.eventManager,
|
|
||||||
}
|
|
||||||
|
|
||||||
conn.SetCloseHandler(func(int, string) error {
|
conn.SetCloseHandler(func(int, string) error {
|
||||||
h.log.Infof("Connection dropped [%s].", s.Identifier())
|
h.log.Infof("Connection dropped [%s].", s.Identifier())
|
||||||
@@ -160,7 +158,7 @@ func (h *Bridge) NotifyEvent(event *messages.EventData) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message := fmt.Sprintf("window.wails._.Notify('%s','%s')", event.Name, data)
|
message := fmt.Sprintf("window.wails._.Notify('%s','%s')", event.Name, data)
|
||||||
dead := []session{}
|
dead := []*session{}
|
||||||
for _, session := range h.sessions {
|
for _, session := range h.sessions {
|
||||||
err := session.evalJS(message, notifyMessage)
|
err := session.evalJS(message, notifyMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -207,6 +205,9 @@ func (h *Bridge) SetTitle(title string) {
|
|||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Bridge) Close() {
|
func (h *Bridge) Close() {
|
||||||
h.log.Debug("Shutting down")
|
h.log.Debug("Shutting down")
|
||||||
|
for _, session := range h.sessions {
|
||||||
|
session.Shutdown()
|
||||||
|
}
|
||||||
err := h.server.Close()
|
err := h.server.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.log.Errorf(err.Error())
|
h.log.Errorf(err.Error())
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package renderer
|
package renderer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"time"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/leaanthony/mewn"
|
"github.com/leaanthony/mewn"
|
||||||
@@ -20,7 +21,22 @@ type session struct {
|
|||||||
ipc interfaces.IPCManager
|
ipc interfaces.IPCManager
|
||||||
|
|
||||||
// Mutex for writing to the socket
|
// Mutex for writing to the socket
|
||||||
lock sync.Mutex
|
shutdown chan bool
|
||||||
|
writeChan chan []byte
|
||||||
|
|
||||||
|
done bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSession(conn *websocket.Conn, bindingCache []string, ipc interfaces.IPCManager, logger *logger.CustomLogger, eventMgr interfaces.EventManager) *session {
|
||||||
|
return &session{
|
||||||
|
conn: conn,
|
||||||
|
bindingCache: bindingCache,
|
||||||
|
ipc: ipc,
|
||||||
|
log: logger,
|
||||||
|
eventManager: eventMgr,
|
||||||
|
shutdown: make(chan bool),
|
||||||
|
writeChan: make(chan []byte, 100),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identifier returns a string identifier for the remote connection.
|
// Identifier returns a string identifier for the remote connection.
|
||||||
@@ -33,19 +49,15 @@ func (s *session) Identifier() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) sendMessage(msg string) error {
|
func (s *session) sendMessage(msg string) error {
|
||||||
s.lock.Lock()
|
if !s.done {
|
||||||
defer s.lock.Unlock()
|
s.writeChan <- *(*[]byte)(unsafe.Pointer(&msg))
|
||||||
|
|
||||||
if err := s.conn.WriteMessage(websocket.TextMessage, []byte(msg)); err != nil {
|
|
||||||
s.log.Debug(err.Error())
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) start(firstSession bool) {
|
func (s *session) start(firstSession bool) {
|
||||||
s.log.Infof("Connected to frontend.")
|
s.log.Infof("Connected to frontend.")
|
||||||
|
go s.writePump()
|
||||||
|
|
||||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||||
s.evalJS(wailsRuntime, wailsRuntimeMessage)
|
s.evalJS(wailsRuntime, wailsRuntimeMessage)
|
||||||
@@ -74,6 +86,10 @@ func (s *session) start(firstSession bool) {
|
|||||||
s.log.Debugf("Got message: %#v\n", string(buffer))
|
s.log.Debugf("Got message: %#v\n", string(buffer))
|
||||||
|
|
||||||
s.ipc.Dispatch(string(buffer), s.Callback)
|
s.ipc.Dispatch(string(buffer), s.Callback)
|
||||||
|
|
||||||
|
if s.done {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +99,38 @@ func (s *session) Callback(data string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) evalJS(js string, mtype messageType) error {
|
func (s *session) evalJS(js string, mtype messageType) error {
|
||||||
|
|
||||||
// Prepend message type to message
|
// Prepend message type to message
|
||||||
return s.sendMessage(mtype.toString() + js)
|
return s.sendMessage(mtype.toString() + js)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shutdown
|
||||||
|
func (s *session) Shutdown() {
|
||||||
|
s.done = true
|
||||||
|
s.shutdown <- true
|
||||||
|
s.log.Debugf("session %v exit", s.Identifier())
|
||||||
|
}
|
||||||
|
|
||||||
|
// writePump pulls messages from the writeChan and sends them to the client
|
||||||
|
// since it uses a channel to read the messages the socket is protected without locks
|
||||||
|
func (s *session) writePump() {
|
||||||
|
s.log.Debugf("Session %v - writePump start", s.Identifier())
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case msg, ok := <-s.writeChan:
|
||||||
|
s.conn.SetWriteDeadline(time.Now().Add(1 * time.Second))
|
||||||
|
if !ok {
|
||||||
|
s.log.Debug("writeChan was closed!")
|
||||||
|
s.conn.WriteMessage(websocket.CloseMessage, []byte{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.conn.WriteMessage(websocket.TextMessage, msg); err != nil {
|
||||||
|
s.log.Debug(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case <-s.shutdown:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.log.Debug("writePump exiting...")
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -139,7 +139,7 @@ struct webview_priv
|
|||||||
#define DEFAULT_URL \
|
#define DEFAULT_URL \
|
||||||
"data:text/" \
|
"data:text/" \
|
||||||
"html,%3C%21DOCTYPE%20html%3E%0A%3Chtml%20lang=%22en%22%3E%0A%3Chead%3E%" \
|
"html,%3C%21DOCTYPE%20html%3E%0A%3Chtml%20lang=%22en%22%3E%0A%3Chead%3E%" \
|
||||||
"3Cmeta%20charset=%22utf-8%22%3E%3Cmeta%20http-equiv=%22IE=edge%22%" \
|
"3Cmeta%20charset=%22utf-8%22%3E%3Cmeta%20http-equiv=%22IE=edge%22%" \
|
||||||
"20content=%22IE=edge%22%3E%3C%2Fhead%3E%0A%3Cbody%3E%3Cdiv%20id=%22app%22%" \
|
"20content=%22IE=edge%22%3E%3C%2Fhead%3E%0A%3Cbody%3E%3Cdiv%20id=%22app%22%" \
|
||||||
"3E%3C%2Fdiv%3E%3Cscript%20type=%22text%2Fjavascript%22%3E%3C%2Fscript%3E%" \
|
"3E%3C%2Fdiv%3E%3Cscript%20type=%22text%2Fjavascript%22%3E%3C%2Fscript%3E%" \
|
||||||
"3C%2Fbody%3E%0A%3C%2Fhtml%3E"
|
"3C%2Fbody%3E%0A%3C%2Fhtml%3E"
|
||||||
@@ -1227,7 +1227,7 @@ struct webview_priv
|
|||||||
}
|
}
|
||||||
VariantInit(&myURL);
|
VariantInit(&myURL);
|
||||||
myURL.vt = VT_BSTR;
|
myURL.vt = VT_BSTR;
|
||||||
// #ifndef UNICODE
|
// #ifndef UNICODE
|
||||||
{
|
{
|
||||||
wchar_t *buffer = webview_to_utf16(webPageName);
|
wchar_t *buffer = webview_to_utf16(webPageName);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
@@ -1237,9 +1237,9 @@ struct webview_priv
|
|||||||
myURL.bstrVal = SysAllocString(buffer);
|
myURL.bstrVal = SysAllocString(buffer);
|
||||||
GlobalFree(buffer);
|
GlobalFree(buffer);
|
||||||
}
|
}
|
||||||
// #else
|
// #else
|
||||||
// myURL.bstrVal = SysAllocString(webPageName);
|
// myURL.bstrVal = SysAllocString(webPageName);
|
||||||
// #endif
|
// #endif
|
||||||
if (!myURL.bstrVal)
|
if (!myURL.bstrVal)
|
||||||
{
|
{
|
||||||
badalloc:
|
badalloc:
|
||||||
@@ -1277,7 +1277,7 @@ struct webview_priv
|
|||||||
if (!SafeArrayAccessData(sfArray, (void **)&pVar))
|
if (!SafeArrayAccessData(sfArray, (void **)&pVar))
|
||||||
{
|
{
|
||||||
pVar->vt = VT_BSTR;
|
pVar->vt = VT_BSTR;
|
||||||
// #ifndef UNICODE
|
// #ifndef UNICODE
|
||||||
{
|
{
|
||||||
wchar_t *buffer = webview_to_utf16(url);
|
wchar_t *buffer = webview_to_utf16(url);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
@@ -1287,9 +1287,9 @@ struct webview_priv
|
|||||||
bstr = SysAllocString(buffer);
|
bstr = SysAllocString(buffer);
|
||||||
GlobalFree(buffer);
|
GlobalFree(buffer);
|
||||||
}
|
}
|
||||||
// #else
|
// #else
|
||||||
// bstr = SysAllocString(url);
|
// bstr = SysAllocString(url);
|
||||||
// #endif
|
// #endif
|
||||||
if ((pVar->bstrVal = bstr))
|
if ((pVar->bstrVal = bstr))
|
||||||
{
|
{
|
||||||
htmlDoc2->lpVtbl->write(htmlDoc2, sfArray);
|
htmlDoc2->lpVtbl->write(htmlDoc2, sfArray);
|
||||||
@@ -1410,6 +1410,8 @@ struct webview_priv
|
|||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.lpfnWndProc = wndproc;
|
wc.lpfnWndProc = wndproc;
|
||||||
wc.lpszClassName = classname;
|
wc.lpszClassName = classname;
|
||||||
|
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(100));
|
||||||
|
wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(100));
|
||||||
RegisterClassEx(&wc);
|
RegisterClassEx(&wc);
|
||||||
|
|
||||||
style = WS_OVERLAPPEDWINDOW;
|
style = WS_OVERLAPPEDWINDOW;
|
||||||
@@ -1444,12 +1446,12 @@ struct webview_priv
|
|||||||
rect.right - rect.left, rect.bottom - rect.top,
|
rect.right - rect.left, rect.bottom - rect.top,
|
||||||
HWND_DESKTOP, NULL, hInstance, (void *)w);
|
HWND_DESKTOP, NULL, hInstance, (void *)w);
|
||||||
#else
|
#else
|
||||||
w->priv.hwnd =
|
w->priv.hwnd =
|
||||||
CreateWindowEx(0, classname, w->title, style, rect.left, rect.top,
|
CreateWindowEx(0, classname, w->title, style, rect.left, rect.top,
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
rect.right - rect.left, rect.bottom - rect.top,
|
||||||
HWND_DESKTOP, NULL, hInstance, (void *)w);
|
HWND_DESKTOP, NULL, hInstance, (void *)w);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (w->priv.hwnd == 0)
|
if (w->priv.hwnd == 0)
|
||||||
{
|
{
|
||||||
OleUninitialize();
|
OleUninitialize();
|
||||||
@@ -1466,8 +1468,7 @@ struct webview_priv
|
|||||||
#else
|
#else
|
||||||
SetWindowText(w->priv.hwnd, w->title);
|
SetWindowText(w->priv.hwnd, w->title);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ShowWindow(w->priv.hwnd, SW_SHOWDEFAULT);
|
ShowWindow(w->priv.hwnd, SW_SHOWDEFAULT);
|
||||||
UpdateWindow(w->priv.hwnd);
|
UpdateWindow(w->priv.hwnd);
|
||||||
SetFocus(w->priv.hwnd);
|
SetFocus(w->priv.hwnd);
|
||||||
@@ -1494,6 +1495,11 @@ struct webview_priv
|
|||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
{
|
{
|
||||||
|
// Disable refresh when pressing F5 on windows
|
||||||
|
if (msg.wParam == VK_F5)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
HRESULT r = S_OK;
|
HRESULT r = S_OK;
|
||||||
IWebBrowser2 *webBrowser2;
|
IWebBrowser2 *webBrowser2;
|
||||||
IOleObject *browser = *w->priv.browser;
|
IOleObject *browser = *w->priv.browser;
|
||||||
@@ -1603,7 +1609,7 @@ struct webview_priv
|
|||||||
|
|
||||||
WEBVIEW_API void webview_set_title(struct webview *w, const char *title)
|
WEBVIEW_API void webview_set_title(struct webview *w, const char *title)
|
||||||
{
|
{
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
wchar_t *u16title = webview_to_utf16(title);
|
wchar_t *u16title = webview_to_utf16(title);
|
||||||
if (u16title == NULL)
|
if (u16title == NULL)
|
||||||
{
|
{
|
||||||
@@ -1611,12 +1617,11 @@ struct webview_priv
|
|||||||
}
|
}
|
||||||
SetWindowText(w->priv.hwnd, u16title);
|
SetWindowText(w->priv.hwnd, u16title);
|
||||||
GlobalFree(u16title);
|
GlobalFree(u16title);
|
||||||
#else
|
#else
|
||||||
SetWindowText(w->priv.hwnd, title);
|
SetWindowText(w->priv.hwnd, title);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
||||||
{
|
{
|
||||||
if (w->priv.is_fullscreen == !!fullscreen)
|
if (w->priv.is_fullscreen == !!fullscreen)
|
||||||
@@ -1927,22 +1932,26 @@ struct webview_priv
|
|||||||
[script setValue:self forKey:@"external"];
|
[script setValue:self forKey:@"external"];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void webview_run_input_open_panel(id self, SEL cmd, id webview,
|
static void webview_run_input_open_panel(id self, SEL cmd, id webview,
|
||||||
id listener, BOOL allowMultiple) {
|
id listener, BOOL allowMultiple)
|
||||||
|
{
|
||||||
char filename[256] = "";
|
char filename[256] = "";
|
||||||
struct webview *w =
|
struct webview *w =
|
||||||
(struct webview *)objc_getAssociatedObject(self, "webview");
|
(struct webview *)objc_getAssociatedObject(self, "webview");
|
||||||
|
|
||||||
webview_dialog(w, WEBVIEW_DIALOG_TYPE_OPEN, WEBVIEW_DIALOG_FLAG_FILE, "", "",
|
webview_dialog(w, WEBVIEW_DIALOG_TYPE_OPEN, WEBVIEW_DIALOG_FLAG_FILE, "", "",
|
||||||
filename, 255);
|
filename, 255);
|
||||||
if (strlen(filename)) {
|
filename[255] = '\0';
|
||||||
|
if (strlen(filename) > 0)
|
||||||
|
{
|
||||||
[listener chooseFilename:[NSString stringWithUTF8String:filename]];
|
[listener chooseFilename:[NSString stringWithUTF8String:filename]];
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
[listener cancel];
|
[listener cancel];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void webview_external_invoke(id self, SEL cmd, id arg)
|
static void webview_external_invoke(id self, SEL cmd, id arg)
|
||||||
{
|
{
|
||||||
struct webview *w =
|
struct webview *w =
|
||||||
@@ -1955,7 +1964,7 @@ static void webview_run_input_open_panel(id self, SEL cmd, id webview,
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
w->external_invoke_cb(w, [(NSString *)(arg)UTF8String]);
|
w->external_invoke_cb(w, [(NSString *)(arg) UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
WEBVIEW_API int webview_init(struct webview *w)
|
WEBVIEW_API int webview_init(struct webview *w)
|
||||||
|
|||||||
2799
runtime/js/package-lock.json
generated
2799
runtime/js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@wailsapp/runtime",
|
"name": "@wailsapp/runtime",
|
||||||
"version": "1.0.10",
|
"version": "1.0.11",
|
||||||
"description": "Wails Javascript runtime library",
|
"description": "Wails Javascript runtime library",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"types": "runtime.d.ts",
|
"types": "runtime.d.ts",
|
||||||
@@ -25,4 +25,4 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dts-gen": "^0.5.8"
|
"dts-gen": "^0.5.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
12
runtime/js/runtime/runtime.d.ts
vendored
12
runtime/js/runtime/runtime.d.ts
vendored
@@ -6,12 +6,12 @@ declare const wailsapp__runtime: {
|
|||||||
OpenURL(url: string): Promise<any>;
|
OpenURL(url: string): Promise<any>;
|
||||||
};
|
};
|
||||||
Events: {
|
Events: {
|
||||||
Acknowledge(eventName: string): void;
|
Acknowledge(eventName: string): void;
|
||||||
Emit(eventName: string): void;
|
Emit(eventName: string, data?: any): void;
|
||||||
Heartbeat(eventName: string, timeInMilliseconds: number, callback: () => void): void;
|
Heartbeat(eventName: string, timeInMilliseconds: number, callback: (data?: any) => void): void;
|
||||||
On(eventName: string, callback: () => void): void;
|
On(eventName: string, callback: (data?: any) => void): void;
|
||||||
OnMultiple(eventName: string, callback: () => void, maxCallbacks: number): void;
|
OnMultiple(eventName: string, callback: (data?: any) => void, maxCallbacks: number): void;
|
||||||
Once(eventName: string, callback: () => void): void;
|
Once(eventName: string, callback: (data?: any) => void): void;
|
||||||
};
|
};
|
||||||
Init(callback: () => void): void;
|
Init(callback: () => void): void;
|
||||||
Log: {
|
Log: {
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "**** Checking if Wails passes unit tests ****"
|
||||||
|
if ! go test ./...
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: Unit tests failed!"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
# Build runtime
|
# Build runtime
|
||||||
echo "**** Building Runtime ****"
|
echo "**** Building Runtime ****"
|
||||||
cd runtime/js
|
cd runtime/js
|
||||||
@@ -15,9 +23,23 @@ cd lib/renderer
|
|||||||
mewn
|
mewn
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
echo "**** Installing Wails locally ****"
|
|
||||||
cd cmd/wails
|
cd cmd/wails
|
||||||
go install
|
echo "**** Checking if Wails compiles ****"
|
||||||
|
if ! go build .
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: Build failed!"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "**** Installing Wails locally ****"
|
||||||
|
if ! go install
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: Install failed!"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
echo "**** Tidying the mods! ****"
|
echo "**** Tidying the mods! ****"
|
||||||
|
|||||||
Reference in New Issue
Block a user