mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 00:09:56 +08:00
package by default. -p leaves resource artifacts
This commit is contained in:
parent
c15fd822c1
commit
5e466893cf
16
cmd/fs.go
16
cmd/fs.go
@ -80,6 +80,22 @@ func (fs *FSHelper) Cwd() string {
|
||||
return cwd
|
||||
}
|
||||
|
||||
// RemoveFile removes the given filename
|
||||
func (fs *FSHelper) RemoveFile(filename string) error {
|
||||
return os.Remove(filename)
|
||||
}
|
||||
|
||||
// RemoveFiles removes the given filenames
|
||||
func (fs *FSHelper) RemoveFiles(files []string) error {
|
||||
for _, filename := range files {
|
||||
err := os.Remove(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSubdirs will return a list of FQPs to subdirectories in the given directory
|
||||
func (fs *FSHelper) GetSubdirs(dir string) (map[string]string, error) {
|
||||
|
||||
|
@ -50,8 +50,9 @@ func InstallGoDependencies() error {
|
||||
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
||||
|
||||
// Generate Windows assets if needed
|
||||
if runtime.GOOS == "windows" && packageApp {
|
||||
err := PackageApplication(projectOptions)
|
||||
if runtime.GOOS == "windows" {
|
||||
cleanUp := !packageApp
|
||||
err := NewPackageHelper().PackageWindows(projectOptions, cleanUp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -107,14 +108,6 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
||||
}
|
||||
packSpinner.Success()
|
||||
|
||||
// Package application
|
||||
if runtime.GOOS != "windows" && packageApp {
|
||||
err = PackageApplication(projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ func (b *PackageHelper) Package(po *ProjectOptions) error {
|
||||
}
|
||||
return b.packageOSX(po)
|
||||
case "windows":
|
||||
return b.packageWindows(po)
|
||||
return b.PackageWindows(po, true)
|
||||
case "linux":
|
||||
return fmt.Errorf("linux is not supported at this time. Please see https://github.com/wailsapp/wails/issues/2")
|
||||
default:
|
||||
@ -150,7 +150,7 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *PackageHelper) packageWindows(po *ProjectOptions) error {
|
||||
func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
||||
|
||||
// Copy icon
|
||||
@ -196,6 +196,15 @@ func (b *PackageHelper) packageWindows(po *ProjectOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// clean up
|
||||
if cleanUp {
|
||||
filesToDelete := []string{tgtIconFile, tgtManifestFile, tgtRCFile}
|
||||
err := b.fs.RemoveFiles(filesToDelete)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user