Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for GCC, CLANG and IAR compiler. #38

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/sys v0.13.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqR
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion internal/readFile/readFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Process(inFile, inFile2, outPath string) error {
}

if mxprojectFile != "" {
mxprojectAll, _ := stm32cubemx.IniReader(mxprojectFile, false)
mxprojectAll, _ := stm32cubemx.IniReader(mxprojectFile, params.Subsystem[0].Compiler, false)

if params.Board == "" && params.Device == "" {
params.Board = "Test Board"
Expand Down
41 changes: 31 additions & 10 deletions internal/stm32CubeMX/iniReader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type MxprojectType struct {
PreviousLibFiles struct {
LibFiles []string
}
PreviousUsedKeilFiles struct {
PreviousUsedFiles struct {
SourceFiles []string
HeaderPath []string
CDefines []string
Expand Down Expand Up @@ -188,7 +188,7 @@ func AppendToCores(iniSectionCore IniSectionCore, list *[]IniSectionCore) {
*list = append(*list, iniSectionCore)
}

func IniReader(path string, trustzone bool) (MxprojectAllType, error) {
func IniReader(path string, compiler string, trustzone bool) (MxprojectAllType, error) {
var mxprojectAll MxprojectAllType

if !utils.FileExists(path) {
Expand Down Expand Up @@ -218,7 +218,7 @@ func IniReader(path string, trustzone bool) (MxprojectAllType, error) {
}
coreName := core.CoreName
trustzone := core.trustzone
mxproject, _ := GetData(inidata, iniName)
mxproject, _ := GetData(inidata, iniName, compiler)
mxproject.CoreName = coreName
mxproject.Trustzone = trustzone
mxprojectAll.Mxproject = append(mxprojectAll.Mxproject, mxproject)
Expand Down Expand Up @@ -283,20 +283,26 @@ func GetSections(inidata *ini.File, iniSections *IniSectionsType) error {
return nil
}

func GetData(inidata *ini.File, iniName string) (MxprojectType, error) {
func GetData(inidata *ini.File, iniName string, compiler string) (MxprojectType, error) {
var mxproject MxprojectType
var sectionName string
const PreviousUsedKeilFilesID = "PreviousUsedKeilFiles"
var PreviousUsedFilesID string

PreviousUsedFilesID, err := GetPreviousUsedFilesID(compiler)
if err != nil {
return mxproject, err
}

if iniName != "" {
sectionName = iniName + ":" + PreviousUsedKeilFilesID
sectionName = iniName + ":" + PreviousUsedFilesID
} else {
sectionName = PreviousUsedKeilFilesID
sectionName = PreviousUsedFilesID
}
section := inidata.Section(sectionName)
if section != nil {
StoreItemCsv(&mxproject.PreviousUsedKeilFiles.SourceFiles, section, "SourceFiles")
StoreItemCsv(&mxproject.PreviousUsedKeilFiles.HeaderPath, section, "HeaderPath")
StoreItemCsv(&mxproject.PreviousUsedKeilFiles.CDefines, section, "CDefines")
StoreItemCsv(&mxproject.PreviousUsedFiles.SourceFiles, section, "SourceFiles")
StoreItemCsv(&mxproject.PreviousUsedFiles.HeaderPath, section, "HeaderPath")
StoreItemCsv(&mxproject.PreviousUsedFiles.CDefines, section, "CDefines")
PrintItemCsv(section, "SourceFiles")
PrintItemCsv(section, "HeaderPath")
PrintItemCsv(section, "CDefines")
Expand Down Expand Up @@ -343,3 +349,18 @@ func GetData(inidata *ini.File, iniName string) (MxprojectType, error) {

return mxproject, nil
}

func GetPreviousUsedFilesID(compiler string) (string, error) {
var sectionMapping = map[string]string{
"AC6": "PreviousUsedKeilFiles",
"GCC": "PreviousUsedCubeIDEFiles",
"IAR": "PreviousUsedIarFiles",
"CLANG": "PreviousUsedCubeIDEFiles",
}

PreviousUsedFilesID, ok := sectionMapping[compiler]
if !ok {
return "", errors.New("unknown compiler")
}
return PreviousUsedFilesID, nil
}
Loading
Loading