You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by "m-gorecki (via GitHub)" <gi...@apache.org> on 2023/02/27 15:46:46 UTC

[GitHub] [mynewt-newt] m-gorecki opened a new pull request, #510: compiler: Add flags wildcard expressions

m-gorecki opened a new pull request, #510:
URL: https://github.com/apache/mynewt-newt/pull/510

   This adds the possibility to define and use wildcard expressions with compiler flags. To do so you have to define new value in compiler's syscfg.yml file, for example:
   
   EXAMPLE_WILDCARD:
     value:"-my -compiler -flags"
   
   Expression "$(EXAMPLE_WILDCARD)" used in any compiler flags definition in compiler.yml will be now replaced with the defined value (in this case whith "-my -compiler -flags"). It is also possible to override or add new wildcards from other syscfg.yml files, for example from some application's syscfg.yml


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [mynewt-newt] andrzej-kaczmarek commented on a diff in pull request #510: compiler: Add flags wildcard expressions

Posted by "andrzej-kaczmarek (via GitHub)" <gi...@apache.org>.
andrzej-kaczmarek commented on code in PR #510:
URL: https://github.com/apache/mynewt-newt/pull/510#discussion_r1119446479


##########
newt/toolchain/compiler.go:
##########
@@ -152,6 +153,36 @@ func (c *Compiler) GetLocalCompilerInfo() CompilerInfo {
 	return c.lclInfo
 }
 
+func (c *Compiler) ReplaceWildcardFlags() {
+	for _, wildcard := range c.settings.Names() {
+
+		for i, flag := range c.lclInfo.Lflags {
+			if strings.Contains(flag, "$("+wildcard+")") {
+				c.lclInfo.Lflags[i] = strings.ReplaceAll(flag, "$("+wildcard+")", c.settings.Get(wildcard))

Review Comment:
   would be better to match all `$(...)` in string and then replace each with corresponding syscfg value. this also allows to emit an error if referenced syscfg does not exist.



##########
newt/toolchain/compiler.go:
##########
@@ -332,6 +364,10 @@ func (c *Compiler) load(compilerDir string, buildProfile string) error {
 	c.lclInfo.Lflags = loadFlags(yc, settings, "compiler.ld.flags")
 	c.lclInfo.Aflags = loadFlags(yc, settings, "compiler.as.flags")
 
+	if c.settings != nil {
+		c.ReplaceWildcardFlags()

Review Comment:
   `loadFlags()` can handle it



##########
newt/toolchain/compiler.go:
##########
@@ -260,6 +291,7 @@ func NewCompiler(compilerDir string, dstDir string,
 		dstDir:          dstDir,
 		extraDeps:       []string{},
 		compileCommands: []CompileCommand{},
+		settings:        cfg,

Review Comment:
   pass directly to `load()`, no need to store it if not used in other places



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [mynewt-newt] andrzej-kaczmarek commented on a diff in pull request #510: compiler: Add compiler flags $(...) patterns

Posted by "andrzej-kaczmarek (via GitHub)" <gi...@apache.org>.
andrzej-kaczmarek commented on code in PR #510:
URL: https://github.com/apache/mynewt-newt/pull/510#discussion_r1134733549


##########
newt/toolchain/compiler.go:
##########
@@ -292,10 +293,20 @@ func loadFlags(yc ycfg.YCfg, settings *cfgv.Settings, key string) []string {
 		}
 	}
 
+	if cfg != nil {
+		for i, flag := range flags {
+			for _, c := range cfg.Names() {
+				if strings.Contains(flag, "$("+c+")") && cfg.Exists(c) {
+					flags[i] = strings.ReplaceAll(flag, "$("+c+")", cfg.Get(c))

Review Comment:
   no need to iterate all syscfg names to find matches, use `ReplaceAllStringFunc` instead



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [mynewt-newt] sjanc merged pull request #510: compiler: Add compiler flags $(...) patterns

Posted by "sjanc (via GitHub)" <gi...@apache.org>.
sjanc merged PR #510:
URL: https://github.com/apache/mynewt-newt/pull/510


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org