Compare commits

..

1 Commits

Author SHA1 Message Date
3c0f62d4d8 Add build utility commands
* `build` is an alias which on first use invokes `build-dir --build` to
  select a build directory, reconfigure the `build` alias, and invoke
  the `build` alias on the selected build directory.
* `debug` is an alias to the installed system native debugger.
* `build-dir` is a function to select a build directory by reconfiguring
  the `build` alias, it detects `build.ninja` or `Makefile` in the build
  directory and selects the appropriate `ninja` or `make` command.
  Depends on the `build-dir.py` Python script which uses the `pick`
  package to interactively select the build directory.
* `build-run` is a function which builds the specified target then
  attempts to run it, making the assumption it resides in the `bin`
  subdirectory of the build directory.
* `build-debug` is a function which build the specified tared then
  attempts to debug it using the system native debugger, making the
  assumption it resides in the `bin` subdirectory of the build
  directory.
2018-04-30 11:56:19 +01:00
2 changed files with 3 additions and 4 deletions

View File

@ -16,7 +16,7 @@ from pick import Picker
def main():
"""Main entry point to build_dir command."""
"""Main entry point to build-dir.py script."""
parser = ArgumentParser()
parser.add_argument('output')
parser.add_argument('--default', action='store_true')

View File

@ -47,16 +47,15 @@ build-dir() {
local build="make -j $cpu_count -C $build_dir"
fi
# If the build variable is not defined the command could not be determined.
echo "$build"
if [ -z $build ]; then
# TODO: Prompt user to choose a build command?
echo "could not determine build command"
return 1
fi
# Define the new alias.
# Redefine the new alias.
alias build="$build"
# If `--build` is specified then evaluate the command.
[[ "$1" = "--build" ]] && eval $build
[[ "$1" = "--build" ]] && eval $build || true
}
# Build then run a target residing in `$build_dir/bin`.