Compare commits

..

1 Commits

Author SHA1 Message Date
b12dcfe243 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-05-01 23:25:31 +01:00

View File

@ -21,7 +21,7 @@ fi
# function because it will result in `pwd` not this scripts directory.
_build_dir_py=${0:a:h}/build-dir.py
# Prompt user to interactively choose a build directory for `build` to build.
# Interactively choose a `~build` directory for `build` to build.
# TODO: Support arguments:
# * [x] [-h,--help] - show this help message and exit
# * [x] [--build] - execute the build commend
@ -52,8 +52,9 @@ build-dir() {
echo "could not determine build command"
return 1
fi
# Redefine the new alias.
# Redefine the `build` alias and update the `~build` hash directory.
alias build="$build"
hash -d build=$build_dir
# If `--build` is specified then evaluate the command.
[[ "$1" = "--build" ]] && eval $build || true
}