This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 316b566f473f5ce38c33564925c1ca5b135f0284
Author: Christopher Collins <ccoll...@apache.org>
AuthorDate: Fri Oct 4 13:57:33 2019 -0700

    Execute custom commands from pkg directory
    
    E.g., if the following script exists:
    
        apps/blinky/scripts/run.sh
    
    then `apps/blinky/pkg.yml` can specify:
    
        pkg.pre_build_cmds:
            scripts/run.sh: 100
---
 newt/builder/extcmd.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/newt/builder/extcmd.go b/newt/builder/extcmd.go
index b8e7746..8821e65 100644
--- a/newt/builder/extcmd.go
+++ b/newt/builder/extcmd.go
@@ -132,6 +132,16 @@ func (t *TargetBuilder) execExtCmds(sf stage.StageFunc, 
userSrcDir string,
                toks[0] = cmd
        }
 
+       // Execute the commands from the package's directory.
+       pwd, err := os.Getwd()
+       if err != nil {
+               return util.ChildNewtError(err)
+       }
+       if err := os.Chdir(sf.Pkg.BasePath()); err != nil {
+               return util.ChildNewtError(err)
+       }
+       defer os.Chdir(pwd)
+
        util.StatusMessage(util.VERBOSITY_DEFAULT, "Executing %s\n", sf.Name)
        if err := util.ShellInteractiveCommand(toks, envs, true); err != nil {
                return err

Reply via email to