@@ -12,7 +12,6 @@ import (
1212 "io/fs"
1313 "os"
1414 "os/exec"
15- "path"
1615 "path/filepath"
1716 "runtime"
1817 "strings"
@@ -86,8 +85,7 @@ func Process(cbuildGenIdxYmlPath, outPath, cubeMxPath string, runCubeMx bool, pi
8685 return err
8786 }
8887 exPath := filepath .Dir (ex )
89- exPath = filepath .ToSlash (exPath )
90- cRoot = path .Dir (exPath )
88+ cRoot = filepath .Dir (exPath )
9189 }
9290 var generatorFile string
9391 err := filepath .Walk (cRoot , func (path string , f fs.FileInfo , err error ) error {
@@ -122,15 +120,19 @@ func Process(cbuildGenIdxYmlPath, outPath, cubeMxPath string, runCubeMx bool, pi
122120 return err
123121 }
124122
125- workDir := path .Dir (cbuildGenIdxYmlPath )
123+ workDir := filepath .Dir (cbuildGenIdxYmlPath )
126124 if parms .Output != "" {
127125 if filepath .IsAbs (parms .Output ) {
128126 workDir = parms .Output
129127 } else {
130- workDir = path .Join (workDir , parms .Output )
128+ workDir = filepath .Join (workDir , parms .Output )
131129 }
132130 } else {
133- workDir = path .Join (workDir , outPath )
131+ if filepath .IsAbs (outPath ) {
132+ workDir = outPath
133+ } else {
134+ workDir = filepath .Join (workDir , outPath )
135+ }
134136 }
135137 workDir = filepath .Clean (workDir )
136138 workDir = filepath .ToSlash (workDir )
@@ -144,10 +146,10 @@ func Process(cbuildGenIdxYmlPath, outPath, cubeMxPath string, runCubeMx bool, pi
144146 if pid >= 0 {
145147 lastPath := filepath .Base (cubeIocPath )
146148 if lastPath != "STM32CubeMX" {
147- cubeIocPath = path .Join (cubeIocPath , "STM32CubeMX" )
149+ cubeIocPath = filepath .Join (cubeIocPath , "STM32CubeMX" )
148150 }
149- iocprojectPath := path .Join (cubeIocPath , "STM32CubeMX.ioc" )
150- mxprojectPath := path .Join (cubeIocPath , ".mxproject" )
151+ iocprojectPath := filepath .Join (cubeIocPath , "STM32CubeMX.ioc" )
152+ mxprojectPath := filepath .Join (cubeIocPath , ".mxproject" )
151153 log .Debugf ("pid of CubeMX in daemon: %d" , pid )
152154 running = true
153155 first := true
@@ -272,9 +274,9 @@ func Process(cbuildGenIdxYmlPath, outPath, cubeMxPath string, runCubeMx bool, pi
272274 if runCubeMx {
273275 lastPath := filepath .Base (cubeIocPath )
274276 if lastPath != "STM32CubeMX" {
275- cubeIocPath = path .Join (cubeIocPath , "STM32CubeMX" )
277+ cubeIocPath = filepath .Join (cubeIocPath , "STM32CubeMX" )
276278 }
277- cubeIocPath = path .Join (cubeIocPath , "STM32CubeMX.ioc" )
279+ cubeIocPath = filepath .Join (cubeIocPath , "STM32CubeMX.ioc" )
278280
279281 var err error
280282 var pid int
@@ -339,17 +341,19 @@ func Launch(iocFile, projectFile string) (int, error) {
339341
340342 switch runtime .GOOS {
341343 case "windows" :
342- pathJava = path .Join (cubeEnv , "jre" , "bin" , "java.exe" )
343- pathCubeMx = path .Join (cubeEnv , "STM32CubeMX.exe" )
344+ pathJava = filepath .Join (cubeEnv , "jre" , "bin" , "java.exe" )
345+ pathCubeMx = filepath .Join (cubeEnv , "STM32CubeMX.exe" )
346+
344347 case "darwin" :
345- pathJava = path .Join (cubeEnv , "jre" , "Contents" , "Home" , "bin" , "java" )
346- arg0 = path .Join (cubeEnv , "stm32cubemx.icns" )
348+ pathJava = filepath .Join (cubeEnv , "jre" , "Contents" , "Home" , "bin" , "java" )
349+ arg0 = filepath .Join (cubeEnv , "stm32cubemx.icns" )
347350 arg0 = "-Xdock:icon=" + arg0
348351 arg1 = "-Xdock:name=STM32CubeMX"
349- pathCubeMx = path .Join (cubeEnv , "STM32CubeMX" )
352+ pathCubeMx = filepath .Join (cubeEnv , "STM32CubeMX" )
353+
350354 default :
351- pathJava = path .Join (cubeEnv , "jre" , "bin" , "java" )
352- pathCubeMx = path .Join (cubeEnv , "STM32CubeMX" )
355+ pathJava = filepath .Join (cubeEnv , "jre" , "bin" , "java" )
356+ pathCubeMx = filepath .Join (cubeEnv , "STM32CubeMX" )
353357 }
354358
355359 if runtime .GOOS == "darwin" {
@@ -626,7 +630,7 @@ func WriteCgenYmlSub(outPath string, mxproject MxprojectType, bridgeParam Bridge
626630
627631 cfgPath := "MX_Device"
628632 if bridgeParam .CubeContextFolder != "" {
629- cfgPath = path .Join (cfgPath , bridgeParam .CubeContextFolder )
633+ cfgPath = filepath .Join (cfgPath , bridgeParam .CubeContextFolder )
630634 }
631635 cfgPath , _ = utils .ConvertFilename (outPath , cfgPath , "" )
632636 cgen .GeneratorImport .AddPath = append (cgen .GeneratorImport .AddPath , cfgPath )
@@ -739,9 +743,9 @@ func GetRelativePathAdd(outPath string, compiler string) (string, error) {
739743 lastPath := filepath .Base (outPath )
740744 var relativePathAdd string
741745 if lastPath != "STM32CubeMX" {
742- relativePathAdd = path .Join (relativePathAdd , "STM32CubeMX" )
746+ relativePathAdd = filepath .Join (relativePathAdd , "STM32CubeMX" )
743747 }
744- relativePathAdd = path .Join (relativePathAdd , folder )
748+ relativePathAdd = filepath .Join (relativePathAdd , folder )
745749
746750 return relativePathAdd , nil
747751}
@@ -762,9 +766,9 @@ func GetToolchainFolderPath(outPath string, compiler string) (string, error) {
762766 lastPath := filepath .Base (outPath )
763767 toolchainFolderPath := outPath
764768 if lastPath != "STM32CubeMX" {
765- toolchainFolderPath = path .Join (outPath , "STM32CubeMX" )
769+ toolchainFolderPath = filepath .Join (outPath , "STM32CubeMX" )
766770 }
767- toolchainFolderPath = path .Join (toolchainFolderPath , toolchainFolder )
771+ toolchainFolderPath = filepath .Join (toolchainFolderPath , toolchainFolder )
768772
769773 return toolchainFolderPath , nil
770774}
@@ -784,7 +788,7 @@ func GetStartupFile(outPath string, bridgeParams BridgeParamType) (string, error
784788 }
785789
786790 if bridgeParams .Compiler == "GCC" || bridgeParams .Compiler == "CLANG" {
787- startupFolder = path .Join (startupFolder , bridgeParams .CubeContextFolder , "Application" , "Startup" )
791+ startupFolder = filepath .Join (startupFolder , bridgeParams .CubeContextFolder , "Application" , "Startup" )
788792 }
789793
790794 if ! utils .DirExists (startupFolder ) {
@@ -854,7 +858,7 @@ func GetSystemFile(outPath string, bridgeParams BridgeParamType) (string, error)
854858
855859 if bridgeParams .ProjectType == "multi-core" {
856860 systemFolder = filepath .Dir (toolchainFolder )
857- systemFolder = path .Join (systemFolder , "Common" )
861+ systemFolder = filepath .Join (systemFolder , "Common" )
858862 if ! utils .DirExists (toolchainFolder ) {
859863 systemFolder = ""
860864 }
@@ -864,10 +868,10 @@ func GetSystemFile(outPath string, bridgeParams BridgeParamType) (string, error)
864868 systemFolder = filepath .Dir (toolchainFolder )
865869
866870 if bridgeParams .CubeContextFolder != "" {
867- systemFolder = path .Join (systemFolder , bridgeParams .CubeContextFolder )
871+ systemFolder = filepath .Join (systemFolder , bridgeParams .CubeContextFolder )
868872 }
869873
870- systemFolder = path .Join (systemFolder , "Src" )
874+ systemFolder = filepath .Join (systemFolder , "Src" )
871875 }
872876
873877 if ! utils .DirExists (systemFolder ) {
@@ -917,7 +921,7 @@ func GetSystemFile(outPath string, bridgeParams BridgeParamType) (string, error)
917921// }
918922
919923// if bridgeParams.GeneratorMap != "" {
920- // linkerFolder = path .Join(linkerFolder, bridgeParams.GeneratorMap)
924+ // linkerFolder = filepath .Join(linkerFolder, bridgeParams.GeneratorMap)
921925// }
922926
923927// switch bridgeParams.Compiler {
@@ -939,13 +943,13 @@ func GetSystemFile(outPath string, bridgeParams BridgeParamType) (string, error)
939943// case "GCC", "CLANG":
940944// switch bridgeParams.ProjectType {
941945// case "multi-core":
942- // linkerFolder = path .Join(linkerFolder, bridgeParams.ForProjectPart)
946+ // linkerFolder = filepath .Join(linkerFolder, bridgeParams.ForProjectPart)
943947// case "trustzone":
944948// if bridgeParams.ForProjectPart == "secure" {
945- // linkerFolder = path .Join(linkerFolder, "Secure")
949+ // linkerFolder = filepath .Join(linkerFolder, "Secure")
946950// }
947951// if bridgeParams.ForProjectPart == "non-secure" {
948- // linkerFolder = path .Join(linkerFolder, "NonSecure")
952+ // linkerFolder = filepath .Join(linkerFolder, "NonSecure")
949953// }
950954// }
951955// default:
0 commit comments