build optimizations and preperation for 1.2.0 release

This commit is contained in:
aomizu
2025-06-08 21:43:31 +09:00
parent ac893a1c19
commit eeddb97f57
11 changed files with 166 additions and 116 deletions

View File

@@ -2,5 +2,5 @@
Icon = "Icon.png" Icon = "Icon.png"
Name = "TurtleSilicon" Name = "TurtleSilicon"
ID = "com.tairasu.turtlesilicon" ID = "com.tairasu.turtlesilicon"
Version = "1.1.2" Version = "1.2.0"
Build = 26 Build = 33

View File

@@ -1,10 +1,10 @@
.PHONY: build clean .PHONY: build clean build-dev build-release
# Default target # Default target - optimized release build
all: build all: build-release
# Build the application with custom resource copying # Development build (larger, with debug symbols)
build: build-dev:
GOOS=darwin GOARCH=arm64 fyne package GOOS=darwin GOARCH=arm64 fyne package
@echo "Copying additional resources to app bundle..." @echo "Copying additional resources to app bundle..."
@mkdir -p TurtleSilicon.app/Contents/Resources/rosettax87 @mkdir -p TurtleSilicon.app/Contents/Resources/rosettax87
@@ -12,15 +12,37 @@ build:
@cp -R rosettax87/* TurtleSilicon.app/Contents/Resources/rosettax87/ @cp -R rosettax87/* TurtleSilicon.app/Contents/Resources/rosettax87/
@cp -R winerosetta/* TurtleSilicon.app/Contents/Resources/winerosetta/ @cp -R winerosetta/* TurtleSilicon.app/Contents/Resources/winerosetta/
@cp -R Icon.png TurtleSilicon.app/Contents/Resources/ @cp -R Icon.png TurtleSilicon.app/Contents/Resources/
@echo "Build complete!" @echo "Development build complete!"
build: build-dev
build-release:
@echo "Building optimized release version..."
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build \
-ldflags="-s -w -X main.appVersion=$$(grep Version FyneApp.toml | cut -d'"' -f2)" \
-trimpath \
-tags=release \
-o turtlesilicon .
@echo "Packaging with fyne..."
GOOS=darwin GOARCH=arm64 fyne package --release --executable turtlesilicon
@echo "Copying additional resources to app bundle..."
@mkdir -p TurtleSilicon.app/Contents/Resources/rosettax87
@mkdir -p TurtleSilicon.app/Contents/Resources/winerosetta
@cp -R rosettax87/* TurtleSilicon.app/Contents/Resources/rosettax87/
@cp -R winerosetta/* TurtleSilicon.app/Contents/Resources/winerosetta/
@cp -R Icon.png TurtleSilicon.app/Contents/Resources/
@echo "Stripping additional symbols..."
strip -x TurtleSilicon.app/Contents/MacOS/turtlesilicon
@echo "Optimized release build complete!"
@echo "Binary size: $$(ls -lah TurtleSilicon.app/Contents/MacOS/turtlesilicon | awk '{print $$5}')"
# Clean build artifacts # Clean build artifacts
clean: clean:
rm -rf TurtleSilicon.app rm -rf TurtleSilicon.app
rm -f TurtleSilicon.dmg rm -f TurtleSilicon.dmg
rm -f turtlesilicon
# Build DMG without code signing dmg: build-release
dmg: build
@echo "Creating DMG file..." @echo "Creating DMG file..."
@hdiutil create -volname TurtleSilicon -srcfolder TurtleSilicon.app -ov -format UDZO TurtleSilicon.dmg @hdiutil create -volname TurtleSilicon -srcfolder TurtleSilicon.app -ov -format UDZO TurtleSilicon.dmg
@echo "DMG created: TurtleSilicon.dmg" @echo "DMG created: TurtleSilicon.dmg"

10
main.go
View File

@@ -1,11 +1,11 @@
package main package main
import ( import (
"turtlesilicon/pkg/debug"
"turtlesilicon/pkg/service" "turtlesilicon/pkg/service"
"turtlesilicon/pkg/ui" "turtlesilicon/pkg/ui"
"turtlesilicon/pkg/utils" "turtlesilicon/pkg/utils"
"log"
"strings" "strings"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
@@ -15,7 +15,7 @@ import (
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
) )
const appVersion = "1.1.2" const appVersion = "1.2.0"
func main() { func main() {
TSApp := app.NewWithID("com.tairasu.turtlesilicon") TSApp := app.NewWithID("com.tairasu.turtlesilicon")
@@ -27,9 +27,9 @@ func main() {
go func() { go func() {
prefs, _ := utils.LoadPrefs() prefs, _ := utils.LoadPrefs()
latest, notes, update, err := utils.CheckForUpdate(appVersion) latest, notes, update, err := utils.CheckForUpdate(appVersion)
log.Printf("DEBUG RAW: latest=%q", latest) debug.Printf("DEBUG RAW: latest=%q", latest)
latestVersion := strings.TrimLeft(latest, "v.") latestVersion := strings.TrimLeft(latest, "v.")
log.Printf("DEBUG: appVersion=%q, latest=%q, latestVersion=%q, suppressed=%q, update=%v, err=%v\n", debug.Printf("DEBUG: appVersion=%q, latest=%q, latestVersion=%q, suppressed=%q, update=%v, err=%v\n",
appVersion, latest, latestVersion, prefs.SuppressedUpdateVersion, update, err) appVersion, latest, latestVersion, prefs.SuppressedUpdateVersion, update, err)
// Always skip popup if versions match // Always skip popup if versions match
if latestVersion == appVersion { if latestVersion == appVersion {
@@ -56,7 +56,7 @@ func main() {
// Set up cleanup when window closes // Set up cleanup when window closes
TSWindow.SetCloseIntercept(func() { TSWindow.SetCloseIntercept(func() {
log.Println("Application closing, cleaning up RosettaX87 service...") debug.Println("Application closing, cleaning up RosettaX87 service...")
service.CleanupService() service.CleanupService()
TSApp.Quit() TSApp.Quit()
}) })

15
pkg/debug/debug.go Normal file
View File

@@ -0,0 +1,15 @@
//go:build !release
package debug
import "log"
// Printf logs with fmt.Printf style formatting in debug builds
func Printf(format string, v ...interface{}) {
log.Printf(format, v...)
}
// Println logs with fmt.Println style in debug builds
func Println(v ...interface{}) {
log.Println(v...)
}

View File

@@ -0,0 +1,13 @@
//go:build release
package debug
// Printf is a no-op in release builds
func Printf(format string, v ...interface{}) {
// No-op in release builds to reduce binary size
}
// Println is a no-op in release builds
func Println(v ...interface{}) {
// No-op in release builds to reduce binary size
}

View File

@@ -3,12 +3,12 @@ package launcher
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"log"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"sync" "sync"
"turtlesilicon/pkg/debug"
"turtlesilicon/pkg/paths" // Corrected import path "turtlesilicon/pkg/paths" // Corrected import path
"turtlesilicon/pkg/utils" // Corrected import path "turtlesilicon/pkg/utils" // Corrected import path
@@ -40,7 +40,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
// Parse the shell command to extract components // Parse the shell command to extract components
// The shellCmd format is: cd <path> && <envVars> <rosettaExec> <wineloader> <wowExe> // The shellCmd format is: cd <path> && <envVars> <rosettaExec> <wineloader> <wowExe>
log.Printf("Parsing shell command: %s", shellCmd) debug.Printf("Parsing shell command: %s", shellCmd)
// Create the command without context cancellation // Create the command without context cancellation
cmd := exec.Command("sh", "-c", shellCmd) cmd := exec.Command("sh", "-c", shellCmd)
@@ -70,7 +70,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
scanner := bufio.NewScanner(stdout) scanner := bufio.NewScanner(stdout)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
log.Printf("GAME STDOUT: %s", line) debug.Printf("GAME STDOUT: %s", line)
} }
}() }()
@@ -78,7 +78,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
scanner := bufio.NewScanner(stderr) scanner := bufio.NewScanner(stderr)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
log.Printf("GAME STDERR: %s", line) debug.Printf("GAME STDERR: %s", line)
} }
}() }()
@@ -92,9 +92,9 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
}() }()
if err := cmd.Wait(); err != nil { if err := cmd.Wait(); err != nil {
log.Printf("Game process ended with error: %v", err) debug.Printf("Game process ended with error: %v", err)
} else { } else {
log.Println("Game process ended successfully") debug.Println("Game process ended successfully")
} }
}() }()
@@ -102,7 +102,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
} }
func LaunchGame(myWindow fyne.Window) { func LaunchGame(myWindow fyne.Window) {
log.Println("Launch Game button clicked") debug.Println("Launch Game button clicked")
if paths.CrossoverPath == "" { if paths.CrossoverPath == "" {
dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it in the patcher."), myWindow) dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it in the patcher."), myWindow)
@@ -131,7 +131,7 @@ func LaunchGame(myWindow fyne.Window) {
} }
gameMutex.Unlock() gameMutex.Unlock()
log.Println("Preparing to launch TurtleSilicon...") debug.Println("Preparing to launch TurtleSilicon...")
// Determine which WoW executable to use based on vanilla-tweaks preference // Determine which WoW executable to use based on vanilla-tweaks preference
var wowExePath string var wowExePath string
@@ -178,7 +178,7 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) {
} }
// Since RosettaX87 service is already running, we can directly launch WoW // Since RosettaX87 service is already running, we can directly launch WoW
log.Println("RosettaX87 service is running. Proceeding to launch WoW.") debug.Println("RosettaX87 service is running. Proceeding to launch WoW.")
if paths.CrossoverPath == "" || paths.TurtlewowPath == "" { if paths.CrossoverPath == "" || paths.TurtlewowPath == "" {
dialog.ShowError(fmt.Errorf("CrossOver path or TurtleWoW path is not set. Cannot launch WoW."), myWindow) dialog.ShowError(fmt.Errorf("CrossOver path or TurtleWoW path is not set. Cannot launch WoW."), myWindow)
@@ -211,21 +211,21 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) {
escapedShellCmd := utils.EscapeStringForAppleScript(shellCmd) escapedShellCmd := utils.EscapeStringForAppleScript(shellCmd)
cmd2Script := fmt.Sprintf("tell application \"Terminal\" to do script \"%s\"", escapedShellCmd) cmd2Script := fmt.Sprintf("tell application \"Terminal\" to do script \"%s\"", escapedShellCmd)
log.Println("Executing WoW launch command via AppleScript...") debug.Println("Executing WoW launch command via AppleScript...")
if !utils.RunOsascript(cmd2Script, myWindow) { if !utils.RunOsascript(cmd2Script, myWindow) {
return return
} }
log.Println("Launch command executed. Check the new terminal window.") debug.Println("Launch command executed. Check the new terminal window.")
} else { } else {
// Use integrated terminal // Use integrated terminal
log.Printf("Shell command for integrated terminal: %s", shellCmd) debug.Printf("Shell command for integrated terminal: %s", shellCmd)
log.Println("Executing WoW launch command with integrated terminal...") debug.Println("Executing WoW launch command with integrated terminal...")
if err := runGameIntegrated(myWindow, shellCmd); err != nil { if err := runGameIntegrated(myWindow, shellCmd); err != nil {
dialog.ShowError(fmt.Errorf("failed to launch game: %v", err), myWindow) dialog.ShowError(fmt.Errorf("failed to launch game: %v", err), myWindow)
return return
} }
log.Println("Game launched with integrated terminal. Check the application logs for output.") debug.Println("Game launched with integrated terminal. Check the application logs for output.")
} }
} }

View File

@@ -2,11 +2,11 @@ package launcher
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"turtlesilicon/pkg/debug"
"turtlesilicon/pkg/paths" "turtlesilicon/pkg/paths"
"turtlesilicon/pkg/utils" "turtlesilicon/pkg/utils"
@@ -55,7 +55,7 @@ func ApplyVanillaTweaks(myWindow fyne.Window) error {
tempVanillaTweaksPath := filepath.Join(paths.TurtlewowPath, "vanilla-tweaks.exe") tempVanillaTweaksPath := filepath.Join(paths.TurtlewowPath, "vanilla-tweaks.exe")
// Copy vanilla-tweaks.exe to TurtleWoW directory // Copy vanilla-tweaks.exe to TurtleWoW directory
log.Printf("Copying vanilla-tweaks.exe from %s to %s", vanillaTweaksPath, tempVanillaTweaksPath) debug.Printf("Copying vanilla-tweaks.exe from %s to %s", vanillaTweaksPath, tempVanillaTweaksPath)
sourceFile, err := os.Open(vanillaTweaksPath) sourceFile, err := os.Open(vanillaTweaksPath)
if err != nil { if err != nil {
return fmt.Errorf("failed to open vanilla-tweaks.exe: %v", err) return fmt.Errorf("failed to open vanilla-tweaks.exe: %v", err)
@@ -75,7 +75,7 @@ func ApplyVanillaTweaks(myWindow fyne.Window) error {
// Ensure the copied file is executable // Ensure the copied file is executable
if err := os.Chmod(tempVanillaTweaksPath, 0755); err != nil { if err := os.Chmod(tempVanillaTweaksPath, 0755); err != nil {
log.Printf("Warning: failed to set executable permission on vanilla-tweaks.exe: %v", err) debug.Printf("Warning: failed to set executable permission on vanilla-tweaks.exe: %v", err)
} }
// Build the command to apply vanilla-tweaks using the correct format: // Build the command to apply vanilla-tweaks using the correct format:
@@ -84,17 +84,17 @@ func ApplyVanillaTweaks(myWindow fyne.Window) error {
utils.QuotePathForShell(paths.TurtlewowPath), utils.QuotePathForShell(paths.TurtlewowPath),
utils.QuotePathForShell(wineloader2Path)) utils.QuotePathForShell(wineloader2Path))
log.Printf("Applying vanilla-tweaks with command: %s", shellCmd) debug.Printf("Applying vanilla-tweaks with command: %s", shellCmd)
// Execute the command // Execute the command
cmd := exec.Command("sh", "-c", shellCmd) cmd := exec.Command("sh", "-c", shellCmd)
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
log.Printf("vanilla-tweaks command output: %s", string(output)) debug.Printf("vanilla-tweaks command output: %s", string(output))
// Clean up the temporary vanilla-tweaks.exe file // Clean up the temporary vanilla-tweaks.exe file
if cleanupErr := os.Remove(tempVanillaTweaksPath); cleanupErr != nil { if cleanupErr := os.Remove(tempVanillaTweaksPath); cleanupErr != nil {
log.Printf("Warning: failed to clean up temporary vanilla-tweaks.exe: %v", cleanupErr) debug.Printf("Warning: failed to clean up temporary vanilla-tweaks.exe: %v", cleanupErr)
} }
// Always check if the output file was created, regardless of exit code // Always check if the output file was created, regardless of exit code
@@ -103,7 +103,7 @@ func ApplyVanillaTweaks(myWindow fyne.Window) error {
if foundPath == "" { if foundPath == "" {
// Only report error if no output file was created // Only report error if no output file was created
if err != nil { if err != nil {
log.Printf("vanilla-tweaks command failed: %v", err) debug.Printf("vanilla-tweaks command failed: %v", err)
return fmt.Errorf("failed to apply vanilla-tweaks: %v\nOutput: %s", err, string(output)) return fmt.Errorf("failed to apply vanilla-tweaks: %v\nOutput: %s", err, string(output))
} else { } else {
return fmt.Errorf("vanilla-tweaks completed but WoW-tweaked.exe was not created\nOutput: %s", string(output)) return fmt.Errorf("vanilla-tweaks completed but WoW-tweaked.exe was not created\nOutput: %s", string(output))
@@ -112,10 +112,10 @@ func ApplyVanillaTweaks(myWindow fyne.Window) error {
// If we found the file but there was an error code, log it as a warning // If we found the file but there was an error code, log it as a warning
if err != nil { if err != nil {
log.Printf("vanilla-tweaks reported error but output file was created: %v", err) debug.Printf("vanilla-tweaks reported error but output file was created: %v", err)
} }
log.Println("vanilla-tweaks applied successfully") debug.Println("vanilla-tweaks applied successfully")
return nil return nil
} }

View File

@@ -5,12 +5,12 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"log"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
"turtlesilicon/pkg/debug"
"turtlesilicon/pkg/paths" // Corrected import path "turtlesilicon/pkg/paths" // Corrected import path
"turtlesilicon/pkg/utils" // Corrected import path "turtlesilicon/pkg/utils" // Corrected import path
@@ -19,7 +19,7 @@ import (
) )
func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) { func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
log.Println("Patch TurtleWoW clicked") debug.Println("Patch TurtleWoW clicked")
if paths.TurtlewowPath == "" { if paths.TurtlewowPath == "" {
dialog.ShowError(fmt.Errorf("TurtleWoW path not set. Please set it first."), myWindow) dialog.ShowError(fmt.Errorf("TurtleWoW path not set. Please set it first."), myWindow)
return return
@@ -37,25 +37,25 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
} }
for resourceName, destPath := range filesToCopy { for resourceName, destPath := range filesToCopy {
log.Printf("Processing resource: %s to %s", resourceName, destPath) debug.Printf("Processing resource: %s to %s", resourceName, destPath)
// Check if file already exists and has correct size // Check if file already exists and has correct size
if utils.PathExists(destPath) && utils.CompareFileWithBundledResource(destPath, resourceName) { if utils.PathExists(destPath) && utils.CompareFileWithBundledResource(destPath, resourceName) {
log.Printf("File %s already exists with correct size, skipping copy", destPath) debug.Printf("File %s already exists with correct size, skipping copy", destPath)
continue continue
} }
if utils.PathExists(destPath) { if utils.PathExists(destPath) {
log.Printf("File %s exists but has incorrect size, updating...", destPath) debug.Printf("File %s exists but has incorrect size, updating...", destPath)
} else { } else {
log.Printf("File %s does not exist, creating...", destPath) debug.Printf("File %s does not exist, creating...", destPath)
} }
resource, err := fyne.LoadResourceFromPath(resourceName) resource, err := fyne.LoadResourceFromPath(resourceName)
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to open bundled resource %s: %v", resourceName, err) errMsg := fmt.Sprintf("failed to open bundled resource %s: %v", resourceName, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
@@ -65,7 +65,7 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to create destination file %s: %v", destPath, err) errMsg := fmt.Sprintf("failed to create destination file %s: %v", destPath, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
@@ -76,22 +76,22 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to copy bundled resource %s to %s: %v", resourceName, destPath, err) errMsg := fmt.Sprintf("failed to copy bundled resource %s to %s: %v", resourceName, destPath, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
} }
log.Printf("Successfully copied %s to %s", resourceName, destPath) debug.Printf("Successfully copied %s to %s", resourceName, destPath)
} }
log.Printf("Preparing rosettax87 directory at: %s", targetRosettaX87Dir) debug.Printf("Preparing rosettax87 directory at: %s", targetRosettaX87Dir)
if err := os.RemoveAll(targetRosettaX87Dir); err != nil { if err := os.RemoveAll(targetRosettaX87Dir); err != nil {
log.Printf("Warning: could not remove existing rosettax87 folder '%s': %v", targetRosettaX87Dir, err) debug.Printf("Warning: could not remove existing rosettax87 folder '%s': %v", targetRosettaX87Dir, err)
} }
if err := os.MkdirAll(targetRosettaX87Dir, 0755); err != nil { if err := os.MkdirAll(targetRosettaX87Dir, 0755); err != nil {
errMsg := fmt.Sprintf("failed to create directory %s: %v", targetRosettaX87Dir, err) errMsg := fmt.Sprintf("failed to create directory %s: %v", targetRosettaX87Dir, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
@@ -103,12 +103,12 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
} }
for resourceName, destPath := range rosettaFilesToCopy { for resourceName, destPath := range rosettaFilesToCopy {
log.Printf("Processing rosetta resource: %s to %s", resourceName, destPath) debug.Printf("Processing rosetta resource: %s to %s", resourceName, destPath)
resource, err := fyne.LoadResourceFromPath(resourceName) resource, err := fyne.LoadResourceFromPath(resourceName)
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to open bundled resource %s: %v", resourceName, err) errMsg := fmt.Sprintf("failed to open bundled resource %s: %v", resourceName, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
@@ -118,7 +118,7 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to create destination file %s: %v", destPath, err) errMsg := fmt.Sprintf("failed to create destination file %s: %v", destPath, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
@@ -129,7 +129,7 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
destinationFile.Close() destinationFile.Close()
errMsg := fmt.Sprintf("failed to copy bundled resource %s to %s: %v", resourceName, destPath, err) errMsg := fmt.Sprintf("failed to copy bundled resource %s to %s: %v", resourceName, destPath, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
@@ -137,20 +137,20 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
destinationFile.Close() destinationFile.Close()
if filepath.Base(destPath) == "rosettax87" { if filepath.Base(destPath) == "rosettax87" {
log.Printf("Setting execute permission for %s", destPath) debug.Printf("Setting execute permission for %s", destPath)
if err := os.Chmod(destPath, 0755); err != nil { if err := os.Chmod(destPath, 0755); err != nil {
errMsg := fmt.Sprintf("failed to set execute permission for %s: %v", destPath, err) errMsg := fmt.Sprintf("failed to set execute permission for %s: %v", destPath, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
updateAllStatuses() updateAllStatuses()
return return
} }
} }
log.Printf("Successfully copied %s to %s", resourceName, destPath) debug.Printf("Successfully copied %s to %s", resourceName, destPath)
} }
log.Printf("Checking dlls.txt file at: %s", dllsTextFile) debug.Printf("Checking dlls.txt file at: %s", dllsTextFile)
winerosettaEntry := "winerosetta.dll" winerosettaEntry := "winerosetta.dll"
libSiliconPatchEntry := "libSiliconPatch.dll" libSiliconPatchEntry := "libSiliconPatch.dll"
needsWinerosettaUpdate := true needsWinerosettaUpdate := true
@@ -159,15 +159,15 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
if fileContentBytes, err := os.ReadFile(dllsTextFile); err == nil { if fileContentBytes, err := os.ReadFile(dllsTextFile); err == nil {
fileContent := string(fileContentBytes) fileContent := string(fileContentBytes)
if strings.Contains(fileContent, winerosettaEntry) { if strings.Contains(fileContent, winerosettaEntry) {
log.Printf("dlls.txt already contains %s", winerosettaEntry) debug.Printf("dlls.txt already contains %s", winerosettaEntry)
needsWinerosettaUpdate = false needsWinerosettaUpdate = false
} }
if strings.Contains(fileContent, libSiliconPatchEntry) { if strings.Contains(fileContent, libSiliconPatchEntry) {
log.Printf("dlls.txt already contains %s", libSiliconPatchEntry) debug.Printf("dlls.txt already contains %s", libSiliconPatchEntry)
needsLibSiliconPatchUpdate = false needsLibSiliconPatchUpdate = false
} }
} else { } else {
log.Printf("dlls.txt not found, will create a new one with both entries") debug.Printf("dlls.txt not found, will create a new one with both entries")
} }
if needsWinerosettaUpdate || needsLibSiliconPatchUpdate { if needsWinerosettaUpdate || needsLibSiliconPatchUpdate {
@@ -178,7 +178,7 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to read dlls.txt for update: %v", err) errMsg := fmt.Sprintf("failed to read dlls.txt for update: %v", err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
} }
} }
@@ -192,32 +192,32 @@ func PatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
if needsWinerosettaUpdate { if needsWinerosettaUpdate {
if !strings.Contains(updatedContent, winerosettaEntry+"\n") { if !strings.Contains(updatedContent, winerosettaEntry+"\n") {
updatedContent += winerosettaEntry + "\n" updatedContent += winerosettaEntry + "\n"
log.Printf("Adding %s to dlls.txt", winerosettaEntry) debug.Printf("Adding %s to dlls.txt", winerosettaEntry)
} }
} }
if needsLibSiliconPatchUpdate { if needsLibSiliconPatchUpdate {
if !strings.Contains(updatedContent, libSiliconPatchEntry+"\n") { if !strings.Contains(updatedContent, libSiliconPatchEntry+"\n") {
updatedContent += libSiliconPatchEntry + "\n" updatedContent += libSiliconPatchEntry + "\n"
log.Printf("Adding %s to dlls.txt", libSiliconPatchEntry) debug.Printf("Adding %s to dlls.txt", libSiliconPatchEntry)
} }
} }
if err := os.WriteFile(dllsTextFile, []byte(updatedContent), 0644); err != nil { if err := os.WriteFile(dllsTextFile, []byte(updatedContent), 0644); err != nil {
errMsg := fmt.Sprintf("failed to update dlls.txt: %v", err) errMsg := fmt.Sprintf("failed to update dlls.txt: %v", err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
} else { } else {
log.Printf("Successfully updated dlls.txt") debug.Printf("Successfully updated dlls.txt")
} }
} }
log.Println("TurtleWoW patching with bundled resources completed successfully.") debug.Println("TurtleWoW patching with bundled resources completed successfully.")
dialog.ShowInformation("Success", "TurtleWoW patching process completed using bundled resources.", myWindow) dialog.ShowInformation("Success", "TurtleWoW patching process completed using bundled resources.", myWindow)
updateAllStatuses() updateAllStatuses()
} }
func PatchCrossOver(myWindow fyne.Window, updateAllStatuses func()) { func PatchCrossOver(myWindow fyne.Window, updateAllStatuses func()) {
log.Println("Patch CrossOver clicked") debug.Println("Patch CrossOver clicked")
if paths.CrossoverPath == "" { if paths.CrossoverPath == "" {
dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it first."), myWindow) dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it first."), myWindow)
return return
@@ -234,7 +234,7 @@ func PatchCrossOver(myWindow fyne.Window, updateAllStatuses func()) {
return return
} }
log.Printf("Copying %s to %s", wineloaderOrig, wineloaderCopy) debug.Printf("Copying %s to %s", wineloaderOrig, wineloaderCopy)
if err := utils.CopyFile(wineloaderOrig, wineloaderCopy); err != nil { if err := utils.CopyFile(wineloaderOrig, wineloaderCopy); err != nil {
dialog.ShowError(fmt.Errorf("failed to copy wineloader: %w", err), myWindow) dialog.ShowError(fmt.Errorf("failed to copy wineloader: %w", err), myWindow)
paths.PatchesAppliedCrossOver = false paths.PatchesAppliedCrossOver = false
@@ -242,40 +242,40 @@ func PatchCrossOver(myWindow fyne.Window, updateAllStatuses func()) {
return return
} }
log.Printf("Executing: codesign --remove-signature %s", wineloaderCopy) debug.Printf("Executing: codesign --remove-signature %s", wineloaderCopy)
cmd := exec.Command("codesign", "--remove-signature", wineloaderCopy) cmd := exec.Command("codesign", "--remove-signature", wineloaderCopy)
combinedOutput, err := cmd.CombinedOutput() combinedOutput, err := cmd.CombinedOutput()
if err != nil { if err != nil {
derrMsg := fmt.Sprintf("failed to remove signature from %s: %v\nOutput: %s", wineloaderCopy, err, string(combinedOutput)) derrMsg := fmt.Sprintf("failed to remove signature from %s: %v\nOutput: %s", wineloaderCopy, err, string(combinedOutput))
dialog.ShowError(errors.New(derrMsg), myWindow) dialog.ShowError(errors.New(derrMsg), myWindow)
log.Println(derrMsg) debug.Println(derrMsg)
paths.PatchesAppliedCrossOver = false paths.PatchesAppliedCrossOver = false
if err := os.Remove(wineloaderCopy); err != nil { if err := os.Remove(wineloaderCopy); err != nil {
log.Printf("Warning: failed to cleanup wineloader2 after codesign failure: %v", err) debug.Printf("Warning: failed to cleanup wineloader2 after codesign failure: %v", err)
} }
updateAllStatuses() updateAllStatuses()
return return
} }
log.Printf("codesign output: %s", string(combinedOutput)) debug.Printf("codesign output: %s", string(combinedOutput))
log.Printf("Setting execute permissions for %s", wineloaderCopy) debug.Printf("Setting execute permissions for %s", wineloaderCopy)
if err := os.Chmod(wineloaderCopy, 0755); err != nil { if err := os.Chmod(wineloaderCopy, 0755); err != nil {
errMsg := fmt.Sprintf("failed to set executable permissions for %s: %v", wineloaderCopy, err) errMsg := fmt.Sprintf("failed to set executable permissions for %s: %v", wineloaderCopy, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
paths.PatchesAppliedCrossOver = false paths.PatchesAppliedCrossOver = false
updateAllStatuses() updateAllStatuses()
return return
} }
log.Println("CrossOver patching completed successfully.") debug.Println("CrossOver patching completed successfully.")
paths.PatchesAppliedCrossOver = true paths.PatchesAppliedCrossOver = true
dialog.ShowInformation("Success", "CrossOver patching process completed.", myWindow) dialog.ShowInformation("Success", "CrossOver patching process completed.", myWindow)
updateAllStatuses() updateAllStatuses()
} }
func UnpatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) { func UnpatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
log.Println("Unpatch TurtleWoW clicked") debug.Println("Unpatch TurtleWoW clicked")
if paths.TurtlewowPath == "" { if paths.TurtlewowPath == "" {
dialog.ShowError(fmt.Errorf("TurtleWoW path not set. Please set it first."), myWindow) dialog.ShowError(fmt.Errorf("TurtleWoW path not set. Please set it first."), myWindow)
return return
@@ -290,13 +290,13 @@ func UnpatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
// Remove the rosettaX87 directory // Remove the rosettaX87 directory
if utils.DirExists(rosettaX87DirPath) { if utils.DirExists(rosettaX87DirPath) {
log.Printf("Removing directory: %s", rosettaX87DirPath) debug.Printf("Removing directory: %s", rosettaX87DirPath)
if err := os.RemoveAll(rosettaX87DirPath); err != nil { if err := os.RemoveAll(rosettaX87DirPath); err != nil {
errMsg := fmt.Sprintf("failed to remove directory %s: %v", rosettaX87DirPath, err) errMsg := fmt.Sprintf("failed to remove directory %s: %v", rosettaX87DirPath, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
} else { } else {
log.Printf("Successfully removed directory: %s", rosettaX87DirPath) debug.Printf("Successfully removed directory: %s", rosettaX87DirPath)
} }
} }
@@ -304,25 +304,25 @@ func UnpatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
filesToRemove := []string{winerosettaDllPath, d3d9DllPath, libSiliconPatchDllPath} filesToRemove := []string{winerosettaDllPath, d3d9DllPath, libSiliconPatchDllPath}
for _, file := range filesToRemove { for _, file := range filesToRemove {
if utils.PathExists(file) { if utils.PathExists(file) {
log.Printf("Removing file: %s", file) debug.Printf("Removing file: %s", file)
if err := os.Remove(file); err != nil { if err := os.Remove(file); err != nil {
errMsg := fmt.Sprintf("failed to remove file %s: %v", file, err) errMsg := fmt.Sprintf("failed to remove file %s: %v", file, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
} else { } else {
log.Printf("Successfully removed file: %s", file) debug.Printf("Successfully removed file: %s", file)
} }
} }
} }
// Update dlls.txt file - remove winerosetta.dll and libSiliconPatch.dll entries // Update dlls.txt file - remove winerosetta.dll and libSiliconPatch.dll entries
if utils.PathExists(dllsTextFile) { if utils.PathExists(dllsTextFile) {
log.Printf("Updating dlls.txt file: %s", dllsTextFile) debug.Printf("Updating dlls.txt file: %s", dllsTextFile)
content, err := os.ReadFile(dllsTextFile) content, err := os.ReadFile(dllsTextFile)
if err != nil { if err != nil {
errMsg := fmt.Sprintf("failed to read dlls.txt file: %v", err) errMsg := fmt.Sprintf("failed to read dlls.txt file: %v", err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
} else { } else {
lines := strings.Split(string(content), "\n") lines := strings.Split(string(content), "\n")
filteredLines := make([]string, 0, len(lines)) filteredLines := make([]string, 0, len(lines))
@@ -338,21 +338,21 @@ func UnpatchTurtleWoW(myWindow fyne.Window, updateAllStatuses func()) {
if err := os.WriteFile(dllsTextFile, []byte(updatedContent), 0644); err != nil { if err := os.WriteFile(dllsTextFile, []byte(updatedContent), 0644); err != nil {
errMsg := fmt.Sprintf("failed to update dlls.txt file: %v", err) errMsg := fmt.Sprintf("failed to update dlls.txt file: %v", err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
} else { } else {
log.Printf("Successfully updated dlls.txt file") debug.Printf("Successfully updated dlls.txt file")
} }
} }
} }
log.Println("TurtleWoW unpatching completed successfully.") debug.Println("TurtleWoW unpatching completed successfully.")
paths.PatchesAppliedTurtleWoW = false paths.PatchesAppliedTurtleWoW = false
dialog.ShowInformation("Success", "TurtleWoW unpatching process completed.", myWindow) dialog.ShowInformation("Success", "TurtleWoW unpatching process completed.", myWindow)
updateAllStatuses() updateAllStatuses()
} }
func UnpatchCrossOver(myWindow fyne.Window, updateAllStatuses func()) { func UnpatchCrossOver(myWindow fyne.Window, updateAllStatuses func()) {
log.Println("Unpatch CrossOver clicked") debug.Println("Unpatch CrossOver clicked")
if paths.CrossoverPath == "" { if paths.CrossoverPath == "" {
dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it first."), myWindow) dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it first."), myWindow)
return return
@@ -361,21 +361,21 @@ func UnpatchCrossOver(myWindow fyne.Window, updateAllStatuses func()) {
wineloaderCopy := filepath.Join(paths.CrossoverPath, "Contents", "SharedSupport", "CrossOver", "CrossOver-Hosted Application", "wineloader2") wineloaderCopy := filepath.Join(paths.CrossoverPath, "Contents", "SharedSupport", "CrossOver", "CrossOver-Hosted Application", "wineloader2")
if utils.PathExists(wineloaderCopy) { if utils.PathExists(wineloaderCopy) {
log.Printf("Removing file: %s", wineloaderCopy) debug.Printf("Removing file: %s", wineloaderCopy)
if err := os.Remove(wineloaderCopy); err != nil { if err := os.Remove(wineloaderCopy); err != nil {
errMsg := fmt.Sprintf("failed to remove file %s: %v", wineloaderCopy, err) errMsg := fmt.Sprintf("failed to remove file %s: %v", wineloaderCopy, err)
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
updateAllStatuses() updateAllStatuses()
return return
} else { } else {
log.Printf("Successfully removed file: %s", wineloaderCopy) debug.Printf("Successfully removed file: %s", wineloaderCopy)
} }
} else { } else {
log.Printf("File not found to remove: %s", wineloaderCopy) debug.Printf("File not found to remove: %s", wineloaderCopy)
} }
log.Println("CrossOver unpatching completed successfully.") debug.Println("CrossOver unpatching completed successfully.")
paths.PatchesAppliedCrossOver = false paths.PatchesAppliedCrossOver = false
dialog.ShowInformation("Success", "CrossOver unpatching process completed.", myWindow) dialog.ShowInformation("Success", "CrossOver unpatching process completed.", myWindow)
updateAllStatuses() updateAllStatuses()

View File

@@ -1,11 +1,11 @@
package ui package ui
import ( import (
"log"
"net/url" "net/url"
"strings" "strings"
"time" "time"
"turtlesilicon/pkg/debug"
"turtlesilicon/pkg/launcher" "turtlesilicon/pkg/launcher"
"turtlesilicon/pkg/patching" "turtlesilicon/pkg/patching"
"turtlesilicon/pkg/service" "turtlesilicon/pkg/service"
@@ -23,7 +23,7 @@ func createOptionsComponents() {
metalHudCheckbox = widget.NewCheck("Enable Metal Hud (show FPS)", func(checked bool) { metalHudCheckbox = widget.NewCheck("Enable Metal Hud (show FPS)", func(checked bool) {
launcher.EnableMetalHud = checked launcher.EnableMetalHud = checked
log.Printf("Metal HUD enabled: %v", launcher.EnableMetalHud) debug.Printf("Metal HUD enabled: %v", launcher.EnableMetalHud)
}) })
metalHudCheckbox.SetChecked(launcher.EnableMetalHud) metalHudCheckbox.SetChecked(launcher.EnableMetalHud)
@@ -32,7 +32,7 @@ func createOptionsComponents() {
prefs, _ := utils.LoadPrefs() prefs, _ := utils.LoadPrefs()
prefs.ShowTerminalNormally = checked prefs.ShowTerminalNormally = checked
utils.SavePrefs(prefs) utils.SavePrefs(prefs)
log.Printf("Show terminal normally: %v", checked) debug.Printf("Show terminal normally: %v", checked)
}) })
showTerminalCheckbox.SetChecked(prefs.ShowTerminalNormally) showTerminalCheckbox.SetChecked(prefs.ShowTerminalNormally)
@@ -42,7 +42,7 @@ func createOptionsComponents() {
prefs, _ := utils.LoadPrefs() prefs, _ := utils.LoadPrefs()
prefs.EnableVanillaTweaks = checked prefs.EnableVanillaTweaks = checked
utils.SavePrefs(prefs) utils.SavePrefs(prefs)
log.Printf("Vanilla-tweaks enabled: %v", launcher.EnableVanillaTweaks) debug.Printf("Vanilla-tweaks enabled: %v", launcher.EnableVanillaTweaks)
}) })
vanillaTweaksCheckbox.SetChecked(prefs.EnableVanillaTweaks) vanillaTweaksCheckbox.SetChecked(prefs.EnableVanillaTweaks)
launcher.EnableVanillaTweaks = prefs.EnableVanillaTweaks launcher.EnableVanillaTweaks = prefs.EnableVanillaTweaks
@@ -64,7 +64,7 @@ func createOptionsComponents() {
prefs, _ := utils.LoadPrefs() prefs, _ := utils.LoadPrefs()
prefs.EnvironmentVariables = text prefs.EnvironmentVariables = text
utils.SavePrefs(prefs) utils.SavePrefs(prefs)
log.Printf("Environment variables updated: %v", launcher.CustomEnvVars) debug.Printf("Environment variables updated: %v", launcher.CustomEnvVars)
} }
} }
@@ -116,7 +116,7 @@ func createBottomBar(myWindow fyne.Window) fyne.CanvasObject {
githubURL := "https://github.com/tairasu/TurtleSilicon" githubURL := "https://github.com/tairasu/TurtleSilicon"
parsedURL, err := url.Parse(githubURL) parsedURL, err := url.Parse(githubURL)
if err != nil { if err != nil {
log.Printf("Error parsing GitHub URL: %v", err) debug.Printf("Error parsing GitHub URL: %v", err)
return return
} }
fyne.CurrentApp().OpenURL(parsedURL) fyne.CurrentApp().OpenURL(parsedURL)
@@ -183,7 +183,7 @@ func createWineRegistryComponents() {
// Run in goroutine to avoid blocking UI // Run in goroutine to avoid blocking UI
go func() { go func() {
if err := utils.SetOptionAsAltEnabled(true); err != nil { if err := utils.SetOptionAsAltEnabled(true); err != nil {
log.Printf("Failed to enable Option-as-Alt mapping: %v", err) debug.Printf("Failed to enable Option-as-Alt mapping: %v", err)
// Update UI on main thread // Update UI on main thread
fyne.Do(func() { fyne.Do(func() {
stopPulsingEffect() stopPulsingEffect()
@@ -191,7 +191,7 @@ func createWineRegistryComponents() {
}) })
time.Sleep(2 * time.Second) // Show error briefly time.Sleep(2 * time.Second) // Show error briefly
} else { } else {
log.Printf("Successfully enabled Option-as-Alt mapping") debug.Printf("Successfully enabled Option-as-Alt mapping")
// Update preferences // Update preferences
prefs, _ := utils.LoadPrefs() prefs, _ := utils.LoadPrefs()
prefs.RemapOptionAsAlt = true prefs.RemapOptionAsAlt = true
@@ -220,7 +220,7 @@ func createWineRegistryComponents() {
// Run in goroutine to avoid blocking UI // Run in goroutine to avoid blocking UI
go func() { go func() {
if err := utils.SetOptionAsAltEnabled(false); err != nil { if err := utils.SetOptionAsAltEnabled(false); err != nil {
log.Printf("Failed to disable Option-as-Alt mapping: %v", err) debug.Printf("Failed to disable Option-as-Alt mapping: %v", err)
// Update UI on main thread // Update UI on main thread
fyne.Do(func() { fyne.Do(func() {
stopPulsingEffect() stopPulsingEffect()
@@ -228,7 +228,7 @@ func createWineRegistryComponents() {
}) })
time.Sleep(2 * time.Second) // Show error briefly time.Sleep(2 * time.Second) // Show error briefly
} else { } else {
log.Printf("Successfully disabled Option-as-Alt mapping") debug.Printf("Successfully disabled Option-as-Alt mapping")
// Update preferences // Update preferences
prefs, _ := utils.LoadPrefs() prefs, _ := utils.LoadPrefs()
prefs.RemapOptionAsAlt = false prefs.RemapOptionAsAlt = false

View File

@@ -1,8 +1,7 @@
package ui package ui
import ( import (
"log" "turtlesilicon/pkg/debug"
"turtlesilicon/pkg/paths" "turtlesilicon/pkg/paths"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
@@ -35,7 +34,7 @@ func createLogoContainer() fyne.CanvasObject {
// Load the application logo // Load the application logo
logoResource, err := fyne.LoadResourceFromPath("Icon.png") logoResource, err := fyne.LoadResourceFromPath("Icon.png")
if err != nil { if err != nil {
log.Printf("Warning: could not load logo: %v", err) debug.Printf("Warning: could not load logo: %v", err)
} }
// Create the logo image with a smaller fixed size since we have a header now // Create the logo image with a smaller fixed size since we have a header now

View File

@@ -5,13 +5,14 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
"turtlesilicon/pkg/debug"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/dialog"
) )
@@ -95,16 +96,16 @@ func CopyDir(src string, dst string) error {
// RunOsascript runs an AppleScript command using osascript. // RunOsascript runs an AppleScript command using osascript.
func RunOsascript(scriptString string, myWindow fyne.Window) bool { func RunOsascript(scriptString string, myWindow fyne.Window) bool {
log.Printf("Executing AppleScript: %s", scriptString) debug.Printf("Executing AppleScript: %s", scriptString)
cmd := exec.Command("osascript", "-e", scriptString) cmd := exec.Command("osascript", "-e", scriptString)
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
if err != nil { if err != nil {
errMsg := fmt.Sprintf("AppleScript failed: %v\nOutput: %s", err, string(output)) errMsg := fmt.Sprintf("AppleScript failed: %v\nOutput: %s", err, string(output))
dialog.ShowError(errors.New(errMsg), myWindow) dialog.ShowError(errors.New(errMsg), myWindow)
log.Println(errMsg) debug.Println(errMsg)
return false return false
} }
log.Printf("osascript output: %s", string(output)) debug.Printf("osascript output: %s", string(output))
return true return true
} }
@@ -157,7 +158,7 @@ func CompareFileWithBundledResource(filePath, resourcePath string) bool {
// Get file size // Get file size
fileInfo, err := os.Stat(filePath) fileInfo, err := os.Stat(filePath)
if err != nil { if err != nil {
log.Printf("Failed to get file info for %s: %v", filePath, err) debug.Printf("Failed to get file info for %s: %v", filePath, err)
return false return false
} }
fileSize := fileInfo.Size() fileSize := fileInfo.Size()
@@ -165,10 +166,10 @@ func CompareFileWithBundledResource(filePath, resourcePath string) bool {
// Get bundled resource size // Get bundled resource size
resourceSize, err := GetBundledResourceSize(resourcePath) resourceSize, err := GetBundledResourceSize(resourcePath)
if err != nil { if err != nil {
log.Printf("Failed to get bundled resource size for %s: %v", resourcePath, err) debug.Printf("Failed to get bundled resource size for %s: %v", resourcePath, err)
return false return false
} }
log.Printf("Comparing file sizes: %s (%d bytes) vs %s (%d bytes)", filePath, fileSize, resourcePath, resourceSize) debug.Printf("Comparing file sizes: %s (%d bytes) vs %s (%d bytes)", filePath, fileSize, resourcePath, resourceSize)
return fileSize == resourceSize return fileSize == resourceSize
} }