Skip to content

Commit

Permalink
Removed some test messages (#61)
Browse files Browse the repository at this point in the history
Forward error return of WriteProjectFile
  • Loading branch information
bgn42 authored Jun 28, 2024
1 parent 362be2c commit 9f13299
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions internal/stm32CubeMX/stm32CubeMX.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func Process(cbuildGenIdxYmlPath, outPath, cubeMxPath string, runCubeMx bool, pi
log.Fatal(err)
}
fIoc.Close()
log.Debugf("mxproject len %d", st.Size())
for { // wait for .mxproject change
if !running {
break // out of loop if CubeMX does not run anymore
Expand Down Expand Up @@ -283,7 +282,7 @@ func Process(cbuildGenIdxYmlPath, outPath, cubeMxPath string, runCubeMx bool, pi
} else {
projectFile, err = WriteProjectFile(workDir, bridgeParams[0])
if err != nil {
return nil
return err
}
log.Debugf("Generated file: %v", projectFile)

Expand All @@ -292,19 +291,16 @@ func Process(cbuildGenIdxYmlPath, outPath, cubeMxPath string, runCubeMx bool, pi
return errors.New("generator '" + gParms.ID + "' missing. Install from '" + gParms.DownloadURL + "'")
}
}
log.Debugf("pid of CubeMX in main: %d", pid)
// here cubeMX runs
exe, err := os.Executable()
if err != nil {
return err
}
log.Debugf("exe %s", exe)
ownPath, err := filepath.EvalSymlinks((exe))
if err != nil {
return err
}
cmd := exec.Command(ownPath) //nolint
log.Debugf("daemonize as %s", ownPath)
cmd.Args = os.Args
cmd.Args = append(cmd.Args, "-p", fmt.Sprint(pid)) // pid of cubeMX
log.Debugf("cmd.Start as %v", cmd)
Expand Down Expand Up @@ -409,7 +405,7 @@ func WriteProjectFile(workDir string, params BridgeParamType) (string, error) {

err = os.WriteFile(filePath, []byte(text.GetLine()), 0600)
if err != nil {
log.Infof("Error writing %v", err)
log.Errorf("Error writing %v", err)
return "", err
}

Expand Down Expand Up @@ -666,7 +662,7 @@ func GetToolchain(compiler string) (string, error) {

toolchain, ok := toolchainMapping[compiler]
if !ok {
return "", errors.New("unknown compiler")
return "", errors.New("unknown compiler '" + compiler + "'")
}
return toolchain, nil
}
Expand All @@ -681,7 +677,7 @@ func GetRelativePathAdd(outPath string, compiler string) (string, error) {

folder, ok := pathMapping[compiler]
if !ok {
return "", errors.New("unknown compiler")
return "", errors.New("unknown compiler '" + compiler + "'")
}

lastPath := filepath.Base(outPath)
Expand All @@ -704,7 +700,7 @@ func GetToolchainFolderPath(outPath string, compiler string) (string, error) {

toolchainFolder, ok := toolchainFolderMapping[compiler]
if !ok {
return "", errors.New("unknown compiler")
return "", errors.New("unknown compiler '" + compiler + "'")
}

lastPath := filepath.Base(outPath)
Expand Down Expand Up @@ -866,7 +862,7 @@ func GetLinkerScripts(outPath string, bridgeParams BridgeParamType) ([]string, e
case "GCC", "CLANG":
fileExtesion = ".ld"
default:
return nil, errors.New("unknown compiler")
return nil, errors.New("unknown compiler '" + bridgeParams.Compiler + "'")
}

if bridgeParams.GeneratorMap != "" {
Expand Down Expand Up @@ -902,7 +898,7 @@ func GetLinkerScripts(outPath string, bridgeParams BridgeParamType) ([]string, e
}
}
default:
return nil, errors.New("unknown compiler")
return nil, errors.New("unknown compiler '" + bridgeParams.Compiler + "'")
}

if !utils.DirExists(linkerFolder) {
Expand Down

0 comments on commit 9f13299

Please sign in to comment.