mirror of
https://github.com/taigrr/wails.git
synced 2026-04-17 04:05:12 -07:00
Compare commits
3 Commits
v2.0.0-alp
...
v2-alpha-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2f233abfb | ||
|
|
2dd8833e67 | ||
|
|
3c30924493 |
@@ -63,10 +63,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
outputFilename := ""
|
outputFilename := ""
|
||||||
command.StringFlag("o", "Output filename", &outputFilename)
|
command.StringFlag("o", "Output filename", &outputFilename)
|
||||||
|
|
||||||
// Clean build directory
|
|
||||||
cleanBuildDirectory := false
|
|
||||||
command.BoolFlag("clean", "Clean the build directory before building", &cleanBuildDirectory)
|
|
||||||
|
|
||||||
appleIdentity := ""
|
appleIdentity := ""
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
command.StringFlag("sign", "Signs your app with the given identity.", &appleIdentity)
|
command.StringFlag("sign", "Signs your app with the given identity.", &appleIdentity)
|
||||||
@@ -116,17 +112,16 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
|
|
||||||
// Create BuildOptions
|
// Create BuildOptions
|
||||||
buildOptions := &build.Options{
|
buildOptions := &build.Options{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
OutputType: outputType,
|
OutputType: outputType,
|
||||||
OutputFile: outputFilename,
|
OutputFile: outputFilename,
|
||||||
CleanBuildDirectory: cleanBuildDirectory,
|
Mode: mode,
|
||||||
Mode: mode,
|
Pack: pack,
|
||||||
Pack: pack,
|
LDFlags: ldflags,
|
||||||
LDFlags: ldflags,
|
Compiler: compilerCommand,
|
||||||
Compiler: compilerCommand,
|
KeepAssets: keepAssets,
|
||||||
KeepAssets: keepAssets,
|
AppleIdentity: appleIdentity,
|
||||||
AppleIdentity: appleIdentity,
|
Verbosity: verbosity,
|
||||||
Verbosity: verbosity,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate platform and arch
|
// Calculate platform and arch
|
||||||
@@ -153,7 +148,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
fmt.Fprintf(w, "Compiler: \t%s\n", buildOptions.Compiler)
|
fmt.Fprintf(w, "Compiler: \t%s\n", buildOptions.Compiler)
|
||||||
fmt.Fprintf(w, "Build Mode: \t%s\n", buildModeText)
|
fmt.Fprintf(w, "Build Mode: \t%s\n", buildModeText)
|
||||||
fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)
|
fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)
|
||||||
fmt.Fprintf(w, "Clean Build Dir: \t%t\n", buildOptions.CleanBuildDirectory)
|
|
||||||
fmt.Fprintf(w, "KeepAssets: \t%t\n", buildOptions.KeepAssets)
|
fmt.Fprintf(w, "KeepAssets: \t%t\n", buildOptions.KeepAssets)
|
||||||
fmt.Fprintf(w, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
|
fmt.Fprintf(w, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
|
||||||
if len(buildOptions.OutputFile) > 0 {
|
if len(buildOptions.OutputFile) > 0 {
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
var version = "v2.0.0-alpha.57"
|
var version = "v2.0.0-alpha.55"
|
||||||
|
|||||||
@@ -212,12 +212,10 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
|
|||||||
|
|
||||||
// Get application build directory
|
// Get application build directory
|
||||||
appDir := options.BuildDirectory
|
appDir := options.BuildDirectory
|
||||||
if options.CleanBuildDirectory {
|
//err = cleanBuildDirectory(options)
|
||||||
err = cleanBuildDirectory(options)
|
//if err != nil {
|
||||||
if err != nil {
|
// return err
|
||||||
return err
|
//}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if options.LDFlags != "" {
|
if options.LDFlags != "" {
|
||||||
commands.Add("-ldflags")
|
commands.Add("-ldflags")
|
||||||
|
|||||||
@@ -28,23 +28,22 @@ var modeMap = []string{"Debug", "Production"}
|
|||||||
|
|
||||||
// Options contains all the build options as well as the project data
|
// Options contains all the build options as well as the project data
|
||||||
type Options struct {
|
type Options struct {
|
||||||
LDFlags string // Optional flags to pass to linker
|
LDFlags string // Optional flags to pass to linker
|
||||||
Logger *clilogger.CLILogger // All output to the logger
|
Logger *clilogger.CLILogger // All output to the logger
|
||||||
OutputType string // EG: desktop, server....
|
OutputType string // EG: desktop, server....
|
||||||
Mode Mode // release or debug
|
Mode Mode // release or debug
|
||||||
ProjectData *project.Project // The project data
|
ProjectData *project.Project // The project data
|
||||||
Pack bool // Create a package for the app after building
|
Pack bool // Create a package for the app after building
|
||||||
Platform string // The platform to build for
|
Platform string // The platform to build for
|
||||||
Arch string // The architecture to build for
|
Arch string // The architecture to build for
|
||||||
Compiler string // The compiler command to use
|
Compiler string // The compiler command to use
|
||||||
IgnoreFrontend bool // Indicates if the frontend does not need building
|
IgnoreFrontend bool // Indicates if the frontend does not need building
|
||||||
OutputFile string // Override the output filename
|
OutputFile string // Override the output filename
|
||||||
BuildDirectory string // Directory to use for building the application
|
BuildDirectory string // Directory to use for building the application
|
||||||
CleanBuildDirectory bool // Indicates if the build directory should be cleaned before building
|
CompiledBinary string // Fully qualified path to the compiled binary
|
||||||
CompiledBinary string // Fully qualified path to the compiled binary
|
KeepAssets bool // /Keep the generated assets/files
|
||||||
KeepAssets bool // /Keep the generated assets/files
|
Verbosity int // Verbosity level (0 - silent, 1 - default, 2 - verbose)
|
||||||
Verbosity int // Verbosity level (0 - silent, 1 - default, 2 - verbose)
|
AppleIdentity string
|
||||||
AppleIdentity string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetModeAsString returns the current mode as a string
|
// GetModeAsString returns the current mode as a string
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
// build
|
|
||||||
package mac
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/leaanthony/slicer"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/wailsapp/wails/v2/internal/shell"
|
|
||||||
)
|
|
||||||
|
|
||||||
func StartAtLogin(enabled bool) error {
|
|
||||||
exe, err := os.Executable()
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "Error running os.Executable:")
|
|
||||||
}
|
|
||||||
binName := filepath.Base(exe)
|
|
||||||
if !strings.HasSuffix(exe, "/Contents/MacOS/"+binName) {
|
|
||||||
return fmt.Errorf("app needs to be running as package.app file to start at startup")
|
|
||||||
}
|
|
||||||
appPath := strings.TrimSuffix(exe, "/Contents/MacOS/"+binName)
|
|
||||||
var command string
|
|
||||||
if enabled {
|
|
||||||
command = fmt.Sprintf("tell application \"System Events\" to make login item at end with properties {name: \"%s\",path:\"%s\", hidden:false}", binName, appPath)
|
|
||||||
} else {
|
|
||||||
command = fmt.Sprintf("tell application \"System Events\" to delete login item \"%s\"", binName)
|
|
||||||
}
|
|
||||||
_, stde, err := shell.RunCommand("/tmp", "osascript", "-e", command)
|
|
||||||
if err != nil {
|
|
||||||
errors.Wrap(err, stde)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func StartsAtLogin() (bool, error) {
|
|
||||||
exe, err := os.Executable()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
binName := filepath.Base(exe)
|
|
||||||
results, stde, err := shell.RunCommand("/tmp", "osascript", "-e", `tell application "System Events" to get the name of every login item`)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.Wrap(err, stde)
|
|
||||||
}
|
|
||||||
results = strings.TrimSpace(results)
|
|
||||||
startupApps := slicer.String(strings.Split(results, ", "))
|
|
||||||
return startupApps.Contains(binName), nil
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user