From a21ff16308785b4e1a00ef78ffaa334842e89aa7 Mon Sep 17 00:00:00 2001 From: partisan Date: Sat, 14 Dec 2024 18:09:56 +0100 Subject: [PATCH] updated run flag to create new profile each time --- spitfire/build.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/spitfire/build.go b/spitfire/build.go index 89bc64d..4dcbe96 100644 --- a/spitfire/build.go +++ b/spitfire/build.go @@ -6,6 +6,7 @@ import ( "os/exec" "path/filepath" "runtime" + "time" ) // Array to store errors @@ -243,15 +244,32 @@ func RunProject(sourcePath string) { return } - // Run the binary - cmd := exec.Command(binaryPath) + // Create a unique profile directory for each run + profilePath := filepath.Join(buildDir, fmt.Sprintf("profile_%d", time.Now().UnixNano())) + if err := os.Mkdir(profilePath, 0755); err != nil { + fmt.Printf("Failed to create profile directory: %v\n", err) + return + } + + // Run the binary with the new profile + cmd := exec.Command(binaryPath, "-no-remote", "-profile", profilePath) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Stdin = os.Stdin - fmt.Printf("Running binary: %s\n", binaryPath) + fmt.Printf("Running binary: %s with new profile at %s\n", binaryPath, profilePath) if err := cmd.Run(); err != nil { fmt.Printf("Failed to run the project: %v\n", err) + } else { + fmt.Println("Binary execution finished successfully.") + } + + // Delete the profile directory after execution + fmt.Printf("Deleting profile directory: %s\n", profilePath) + if err := os.RemoveAll(profilePath); err != nil { + fmt.Printf("Failed to delete profile directory: %v\n", err) + } else { + fmt.Println("Profile directory deleted successfully.") } }