fixed go . -a -c not resolving correct directory
This commit is contained in:
parent
4aaee3d230
commit
61bd6bba74
1 changed files with 37 additions and 42 deletions
79
main.go
79
main.go
|
@ -74,70 +74,61 @@ func printHelp() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if flag.Lookup("h").Value.(flag.Getter).Get().(bool) {
|
||||
printHelp()
|
||||
}
|
||||
|
||||
// Only check dependencies if NOT skipping them
|
||||
if !skipDeps {
|
||||
if err := spitfire.CheckDependencies(); err != nil {
|
||||
log.Fatalf("System check failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Set version to current date if it's empty and release is nightly
|
||||
if version == "" && release == "nightly" {
|
||||
version = time.Now().Format("2006.01.02") // Set version to current date if nightly
|
||||
version = time.Now().Format("2006.01.02")
|
||||
}
|
||||
|
||||
// Save the initial directory
|
||||
var err2 error
|
||||
initialDir, err2 = os.Getwd()
|
||||
if err2 != nil {
|
||||
log.Fatalf("Failed to get current working directory: %v", err2)
|
||||
}
|
||||
fmt.Printf("Initial working directory: %s\n", initialDir)
|
||||
|
||||
if uploadPath != "" {
|
||||
uploadPath, err2 = spitfire.ResolvePath(uploadPath)
|
||||
if err2 != nil {
|
||||
log.Fatalf("Failed to convert uploadPath to absolute path: %v", err2)
|
||||
}
|
||||
fmt.Printf("Resolved uploadPath: %s\n", uploadPath)
|
||||
var err error
|
||||
initialDir, err = os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get current working directory: %v", err)
|
||||
}
|
||||
|
||||
var buildDir string // Store the resolved build directory here
|
||||
|
||||
// Perform build if necessary
|
||||
if all || buildFlag || prePatch || postPatch || clean || update || run {
|
||||
BuildProcess()
|
||||
buildDir = BuildProcess()
|
||||
if buildDir == "" {
|
||||
log.Fatalf("Build process completed, but no build directory was found.")
|
||||
}
|
||||
fmt.Printf("Build directory from process: %s\n", buildDir)
|
||||
}
|
||||
|
||||
// Resolve build directory for compression/upload
|
||||
if compress || upload {
|
||||
// Resolve the build directory dynamically
|
||||
fmt.Println("Resolving build directory dynamically...")
|
||||
sourcePath, err := spitfire.ResolvePath("./mozilla-release")
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving source path: %v", err)
|
||||
if buildDir == "" { // Resolve dynamically if no build was performed
|
||||
fmt.Println("No build directory detected during build process. Resolving dynamically...")
|
||||
sourcePath, err := spitfire.ResolvePath("./mozilla-release")
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving source path: %v", err)
|
||||
}
|
||||
fmt.Printf("Resolved source path: %s\n", sourcePath)
|
||||
|
||||
buildDir, err = spitfire.ResolveBuildDir(sourcePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving build directory dynamically: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
buildDir, err := spitfire.ResolveBuildDir(sourcePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving build directory dynamically: %v", err)
|
||||
if buildDir == "" {
|
||||
log.Fatalf("No build directory found for compression or upload.")
|
||||
}
|
||||
fmt.Printf("Resolved build directory: %s\n", buildDir)
|
||||
fmt.Printf("Resolved build directory for compress/upload: %s\n", buildDir)
|
||||
|
||||
// Validate that the build directory exists
|
||||
stat, err := os.Stat(buildDir)
|
||||
if os.IsNotExist(err) {
|
||||
log.Fatalf("Error: build directory does not exist at %s\n", buildDir)
|
||||
} else if err != nil {
|
||||
log.Fatalf("Error accessing build directory: %v\n", err)
|
||||
} else if !stat.IsDir() {
|
||||
log.Fatalf("Error: path exists but is not a directory: %s\n", buildDir)
|
||||
}
|
||||
|
||||
// Proceed with packaging and uploading
|
||||
PackageAndUploadProcess(buildDir)
|
||||
}
|
||||
|
||||
|
@ -145,12 +136,14 @@ func main() {
|
|||
}
|
||||
|
||||
// Update the BuildProcess function to pass patchesRepo
|
||||
func BuildProcess() {
|
||||
func BuildProcess() string {
|
||||
sourcePath, err := spitfire.ResolvePath("./mozilla-release")
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving source path: %v", err)
|
||||
}
|
||||
|
||||
var buildDir string
|
||||
|
||||
if all {
|
||||
spitfire.DownloadSource(sourcePath, sourceRepo)
|
||||
spitfire.DiscardChanges(sourcePath)
|
||||
|
@ -162,7 +155,7 @@ func BuildProcess() {
|
|||
spitfire.Configure(sourcePath)
|
||||
spitfire.Build(sourcePath)
|
||||
// Detect the build directory dynamically
|
||||
buildDir, err := spitfire.ResolveBuildDir(sourcePath)
|
||||
buildDir, err = spitfire.ResolveBuildDir(sourcePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving build directory: %v", err)
|
||||
}
|
||||
|
@ -182,7 +175,7 @@ func BuildProcess() {
|
|||
spitfire.Configure(sourcePath)
|
||||
spitfire.Build(sourcePath)
|
||||
// Detect the build directory dynamically
|
||||
buildDir, err := spitfire.ResolveBuildDir(sourcePath)
|
||||
buildDir, err = spitfire.ResolveBuildDir(sourcePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving build directory: %v", err)
|
||||
}
|
||||
|
@ -210,7 +203,7 @@ func BuildProcess() {
|
|||
fmt.Println("Patches updated.")
|
||||
} else if postPatch {
|
||||
// Detect the build directory dynamically
|
||||
buildDir, err := spitfire.ResolveBuildDir(sourcePath)
|
||||
buildDir, err = spitfire.ResolveBuildDir(sourcePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Error resolving build directory: %v", err)
|
||||
}
|
||||
|
@ -225,6 +218,8 @@ func BuildProcess() {
|
|||
} else if run {
|
||||
spitfire.RunProject(sourcePath)
|
||||
}
|
||||
|
||||
return buildDir
|
||||
}
|
||||
|
||||
// PackageAndUploadProcess handles compressing, packaging, and uploading the build to SourceForge.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue