mirror of
https://github.com/taigrr/wails.git
synced 2026-04-07 15:42:42 -07:00
Compare commits
7 Commits
v2-alpha-a
...
v2.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0564d0aa98 | ||
|
|
3a136a73ca | ||
|
|
50c219307f | ||
|
|
de3038b302 | ||
|
|
6eb4b0a419 | ||
|
|
41d2158375 | ||
|
|
5d7f57e80b |
@@ -63,6 +63,10 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
outputFilename := ""
|
||||
command.StringFlag("o", "Output filename", &outputFilename)
|
||||
|
||||
// Clean build directory
|
||||
cleanBuildDirectory := false
|
||||
command.BoolFlag("clean", "Clean the build directory before building", &cleanBuildDirectory)
|
||||
|
||||
appleIdentity := ""
|
||||
if runtime.GOOS == "darwin" {
|
||||
command.StringFlag("sign", "Signs your app with the given identity.", &appleIdentity)
|
||||
@@ -112,16 +116,17 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
|
||||
// Create BuildOptions
|
||||
buildOptions := &build.Options{
|
||||
Logger: logger,
|
||||
OutputType: outputType,
|
||||
OutputFile: outputFilename,
|
||||
Mode: mode,
|
||||
Pack: pack,
|
||||
LDFlags: ldflags,
|
||||
Compiler: compilerCommand,
|
||||
KeepAssets: keepAssets,
|
||||
AppleIdentity: appleIdentity,
|
||||
Verbosity: verbosity,
|
||||
Logger: logger,
|
||||
OutputType: outputType,
|
||||
OutputFile: outputFilename,
|
||||
CleanBuildDirectory: cleanBuildDirectory,
|
||||
Mode: mode,
|
||||
Pack: pack,
|
||||
LDFlags: ldflags,
|
||||
Compiler: compilerCommand,
|
||||
KeepAssets: keepAssets,
|
||||
AppleIdentity: appleIdentity,
|
||||
Verbosity: verbosity,
|
||||
}
|
||||
|
||||
// Calculate platform and arch
|
||||
@@ -148,6 +153,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
fmt.Fprintf(w, "Compiler: \t%s\n", buildOptions.Compiler)
|
||||
fmt.Fprintf(w, "Build Mode: \t%s\n", buildModeText)
|
||||
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, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
|
||||
if len(buildOptions.OutputFile) > 0 {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package main
|
||||
|
||||
var version = "v2.0.0-alpha.55"
|
||||
var version = "v2.0.0-alpha.57"
|
||||
|
||||
@@ -212,10 +212,12 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
|
||||
|
||||
// Get application build directory
|
||||
appDir := options.BuildDirectory
|
||||
//err = cleanBuildDirectory(options)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
if options.CleanBuildDirectory {
|
||||
err = cleanBuildDirectory(options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if options.LDFlags != "" {
|
||||
commands.Add("-ldflags")
|
||||
|
||||
@@ -28,22 +28,23 @@ var modeMap = []string{"Debug", "Production"}
|
||||
|
||||
// Options contains all the build options as well as the project data
|
||||
type Options struct {
|
||||
LDFlags string // Optional flags to pass to linker
|
||||
Logger *clilogger.CLILogger // All output to the logger
|
||||
OutputType string // EG: desktop, server....
|
||||
Mode Mode // release or debug
|
||||
ProjectData *project.Project // The project data
|
||||
Pack bool // Create a package for the app after building
|
||||
Platform string // The platform to build for
|
||||
Arch string // The architecture to build for
|
||||
Compiler string // The compiler command to use
|
||||
IgnoreFrontend bool // Indicates if the frontend does not need building
|
||||
OutputFile string // Override the output filename
|
||||
BuildDirectory string // Directory to use for building the application
|
||||
CompiledBinary string // Fully qualified path to the compiled binary
|
||||
KeepAssets bool // /Keep the generated assets/files
|
||||
Verbosity int // Verbosity level (0 - silent, 1 - default, 2 - verbose)
|
||||
AppleIdentity string
|
||||
LDFlags string // Optional flags to pass to linker
|
||||
Logger *clilogger.CLILogger // All output to the logger
|
||||
OutputType string // EG: desktop, server....
|
||||
Mode Mode // release or debug
|
||||
ProjectData *project.Project // The project data
|
||||
Pack bool // Create a package for the app after building
|
||||
Platform string // The platform to build for
|
||||
Arch string // The architecture to build for
|
||||
Compiler string // The compiler command to use
|
||||
IgnoreFrontend bool // Indicates if the frontend does not need building
|
||||
OutputFile string // Override the output filename
|
||||
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
|
||||
KeepAssets bool // /Keep the generated assets/files
|
||||
Verbosity int // Verbosity level (0 - silent, 1 - default, 2 - verbose)
|
||||
AppleIdentity string
|
||||
}
|
||||
|
||||
// GetModeAsString returns the current mode as a string
|
||||
|
||||
51
v2/pkg/mac/mac.go
Normal file
51
v2/pkg/mac/mac.go
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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