utzig commented on a change in pull request #195: Allow build_profile to be 
overridden per package
URL: https://github.com/apache/mynewt-newt/pull/195#discussion_r206490111
 
 

 ##########
 File path: newt/builder/build.go
 ##########
 @@ -245,10 +245,40 @@ func collectCompileEntriesDir(srcDir string, c 
*toolchain.Compiler,
        return entries, nil
 }
 
+// Determines which build profile to use when building the specified package.
+// 1. If the package specifies a "pkg.build_profile" value, that is returned:
+//
+//      pkg.build_profile: debug
+//
+// 2. Else if the target specifies this package in its
+//    "target.package_profiles" map, that value is returned:
+//
+//      target.package_profiles:
+//          'apps/blinky': debug
+//          '@apache-mynewt-core/sys/log/full': debug
+//
+// 3. Else, "" is returned (falls back to the target's general build profile).
+func (b *Builder) buildProfileFor(bpkg *BuildPackage) string {
+       bp := bpkg.BuildProfile(b)
+       if bp != "" {
+               return bp
+       }
+
+       tgt := b.targetBuilder.GetTarget()
+       return tgt.PkgProfiles[bpkg.rpkg.Lpkg.FullName()]
+}
+
 func (b *Builder) newCompiler(bpkg *BuildPackage,
        dstDir string) (*toolchain.Compiler, error) {
 
-       c, err := b.targetBuilder.NewCompiler(dstDir)
+       var buildProfile string
+       if bpkg == nil {
+               buildProfile = ""
+       } else {
+               buildProfile = b.buildProfileFor(bpkg)
+       }
 
 Review comment:
   I guess `if/else` above could simply be:
   ```
   if bpkg != nil {
       buildProfile = b.buildProfileFor(bpkg)
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to