You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2020/11/24 12:12:24 UTC
[mynewt-newt] branch master updated: newt;
fix flag use when building dependencies. Specifically, need the
missing asflags when using clang to build sim.
This is an automated email from the ASF dual-hosted git repository.
marko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
The following commit(s) were added to refs/heads/master by this push:
new 064a5ca newt; fix flag use when building dependencies. Specifically, need the missing asflags when using clang to build sim.
new cf1e699 Merge pull request #421 from mkiiskila/fix_dep_flags
064a5ca is described below
commit 064a5ca1a950d4cef1430cc60166548f59317343
Author: Marko Kiiskila <ma...@apache.org>
AuthorDate: Mon Nov 23 15:41:49 2020 +0200
newt; fix flag use when building dependencies.
Specifically, need the missing asflags when using clang to build sim.
---
newt/toolchain/compiler.go | 28 ++++++++++++++++++++++++----
newt/toolchain/deps.go | 6 +++---
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go
index cf0531a..ad264ac 100644
--- a/newt/toolchain/compiler.go
+++ b/newt/toolchain/compiler.go
@@ -487,19 +487,39 @@ func (c *Compiler) CompileFileCmd(file string, compilerType int) (
return cmd, nil
}
-// Generates a dependency Makefile (.d) for the specified source C file.
+// Generates a dependency Makefile (.d) for the specified source file.
//
// @param file The name of the source file.
-func (c *Compiler) GenDepsForFile(file string) error {
+func (c *Compiler) GenDepsForFile(file string, compilerType int) error {
depPath := c.dstFilePath(file) + ".d"
depDir := filepath.Dir(depPath)
if util.NodeNotExist(depDir) {
os.MkdirAll(depDir, 0755)
}
+ var cmdName string
+ var flags []string
+ switch compilerType {
+ case COMPILER_TYPE_C:
+ cmdName = c.ccPath
+ flags = c.cflagsStrings()
+ case COMPILER_TYPE_ASM:
+ cmdName = c.asPath
+
+ // Include both the compiler flags and the assembler flags.
+ // XXX: This is not great. We don't have a way of specifying compiler
+ // flags without also passing them to the assembler.
+ flags = append(c.cflagsStrings(), c.aflagsStrings()...)
+ case COMPILER_TYPE_CPP:
+ cmdName = c.cppPath
+ flags = append(c.cflagsStrings(), c.cxxflagsStrings()...)
+ default:
+ return util.NewNewtError("Unknown compiler type")
+ }
+
srcPath := strings.TrimPrefix(file, c.baseDir+"/")
- cmd := []string{c.ccPath}
- cmd = append(cmd, c.cflagsStrings()...)
+ cmd := []string{cmdName}
+ cmd = append(cmd, flags...)
cmd = append(cmd, c.includesStrings()...)
cmd = append(cmd, []string{"-MM", "-MG", srcPath}...)
diff --git a/newt/toolchain/deps.go b/newt/toolchain/deps.go
index 48b5462..ee6bc62 100644
--- a/newt/toolchain/deps.go
+++ b/newt/toolchain/deps.go
@@ -206,7 +206,7 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
if commandHasChanged(objPath, cmd) {
logRebuildReqdCmdChanged(srcFile)
- err := tracker.compiler.GenDepsForFile(srcFile)
+ err := tracker.compiler.GenDepsForFile(srcFile, compilerType)
if err != nil {
return false, err
}
@@ -214,7 +214,7 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
}
if util.NodeNotExist(depPath) {
- err := tracker.compiler.GenDepsForFile(srcFile)
+ err := tracker.compiler.GenDepsForFile(srcFile, compilerType)
if err != nil {
return false, err
}
@@ -246,7 +246,7 @@ func (tracker *DepTracker) CompileRequired(srcFile string,
}
if srcModTime.After(depModTime) {
- err := tracker.compiler.GenDepsForFile(srcFile)
+ err := tracker.compiler.GenDepsForFile(srcFile, compilerType)
if err != nil {
return false, err
}