Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run custom commands at build time #335

Merged
merged 5 commits into from
Oct 2, 2019

Commits on Sep 24, 2019

  1. Separate env var generation from builder

    Before commit: a `Builder` object was required to calculate the
    environment variables to pass to external scripts.
    
    This is a nuissance when no `Builder` is available (e.g., when loading
    an mfgimage, or for the upcomimg per-package commands feature).
    
    After commit: Environment variables are divided into three sets (basic,
    settings, slot).  The sets are divided according to the inputs required
    to generate them.  Now the appropriate variables can be calculated
    without a `Builder` object.
    ccollins476ad committed Sep 24, 2019
    Configuration menu
    Copy the full SHA
    0bfa401 View commit details
    Browse the repository at this point in the history
  2. util: interactive shell: error on nonzero exit

    Prior to this change, ShellInteractiveCommand() would never return an
    error.
    
    Now, this function returns an error if the specified command exits with
    a nonzero status.  This change makes the function consistent with the
    other "shell command" functions in the util package.
    ccollins476ad committed Sep 24, 2019
    Configuration menu
    Copy the full SHA
    70d99f8 View commit details
    Browse the repository at this point in the history
  3. stage: Simplify sorting function

    It is simpler to just use `sort.Slice()` rather than create a sorter
    type.
    ccollins476ad committed Sep 24, 2019
    Configuration menu
    Copy the full SHA
    669cb27 View commit details
    Browse the repository at this point in the history

Commits on Sep 25, 2019

  1. Run custom commands at build time

    This commit adds the ability to run custom commands at build time.
    
    This PR adds the ability to run custom commands at build time.
    
    A package specifies custom commands in its `pkg.yml` file.  There are
    three types of commands:
    1. pre_build_cmds (run before the build)
    2. pre_link_cmds (run after compilation, before linking)
    3. post_build_cmds (run after the build)
    
    Example (apps/blinky/pkg.yml):
    ```
    pkg.pre_build_cmds:
        scripts/pre_build1.sh: 100
        scripts/pre_build2.sh: 200
    
    pkg.pre_link_cmds:
        scripts/pre_link.sh: 500
    
    pkg.post_build_cmds:
        scripts/post_build.sh: 100
    ```
    
    For each command, the string on the left specifies the command to run.
    The number on the right indicates the command's relative ordering.
    
    When newt builds this example, it performs the following sequence:
    
    * scripts/pre_build1.sh
    * scripts/pre_build2.sh
    * [compile]
    * scripts/pre_link.sh
    * [link]
    * scripts/post_build.sh
    
    If other packages specify custom commands, those commands would also be
    executed during the above sequence.  For example, if another package
    specifies a pre command with an ordering of 150, that command would run
    immediately after `pre_build1.sh`.  In the case of a tie, the commands
    are run in lexicographic order.
    
    All commands are run from the project's base directory.  In the above
    example, the `scripts` directory is a sibling of `targets`.
    
    See <apache#335> for details.
    ccollins476ad committed Sep 25, 2019
    Configuration menu
    Copy the full SHA
    962ce2b View commit details
    Browse the repository at this point in the history
  2. cmake: print warning if any custom commands

    We don't currently support custom commands in cmake output.  Print a
    warning if the user runs the "target cmake" command on a target that
    specified custom commands.
    ccollins476ad committed Sep 25, 2019
    Configuration menu
    Copy the full SHA
    1ddda70 View commit details
    Browse the repository at this point in the history