Skip to content

Commit

Permalink
Fix CmakeList.txt $(...) compiler flags
Browse files Browse the repository at this point in the history
This fixes the issue: #516
  • Loading branch information
m-gorecki authored and kasjer committed Jun 26, 2023
1 parent 5c0ea32 commit 9dbd3da
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions newt/toolchain/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"io/ioutil"
"mynewt.apache.org/newt/newt/cfgv"
"mynewt.apache.org/newt/newt/pkg"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -315,12 +316,50 @@ func loadFlags(yc ycfg.YCfg, settings *cfgv.Settings, key string, cfg *cfgv.Sett
return flags
}

func getConfigMap(compilerDir string) (map[string]string, error) {
dstMap := make(map[string]string)

scfg, err := config.ReadFile(compilerDir + "/" + pkg.SYSCFG_YAML_FILENAME)
if err != nil {
return nil, err
}

for _, setting := range scfg.AllSettings() {
aSetting, ok := setting.(map[interface{}]interface{})
if ok {
for settingName, settingFields := range aSetting {
aSettingName := settingName.(string)
aSettingFields, ok := settingFields.(map[interface{}]interface{})
if ok {
for settingField, fieldValue := range aSettingFields {
if settingField == "value" {
aFieldValue, ok := fieldValue.(string)
if ok {
dstMap[aSettingName] = aFieldValue
}
}
}
}
}
}
}

return dstMap, nil
}

func (c *Compiler) load(compilerDir string, buildProfile string, cfg *cfgv.Settings) error {
yc, err := config.ReadFile(compilerDir + "/" + COMPILER_FILENAME)
if err != nil {
return err
}

if cfg == nil {
cfgMap, err := getConfigMap(compilerDir)
if err == nil {
cfg = cfgv.NewSettingsFromMap(cfgMap)
}
}

settings := cfgv.NewSettingsFromMap(map[string]string{
buildProfile: "1",
strings.ToUpper(runtime.GOOS): "1",
Expand Down

0 comments on commit 9dbd3da

Please sign in to comment.