bootstrap help and version list
This commit is contained in:
parent
5c1b063399
commit
0b5eed8b4c
1
CBUILD_VERSION
Normal file
1
CBUILD_VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
2.1.1
|
||||||
20
README.md
20
README.md
@ -1,23 +1,31 @@
|
|||||||
# cbuild
|
# cbuild
|
||||||
My C/C++ build system written in bash.
|
My C/C++ build system written in sh.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
```bash
|
```sh
|
||||||
git clone https://timerix.ddns.net:3322/cbuild.git
|
git clone https://timerix.ddns.net:3322/cbuild.git
|
||||||
cd cbuild
|
cd cbuild
|
||||||
sudo ./setup.sh
|
sudo ./setup.sh
|
||||||
```
|
```
|
||||||
|
Can be installed to `~/.local/` if you have no root rights.
|
||||||
|
- ```sh
|
||||||
|
./setup.sh --local
|
||||||
|
```
|
||||||
|
- Then add `~/.local/bin` to `PATH` in your shell config.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
1. Initialize cbuild project in some directory:
|
1. Initialize cbuild project in some directory:
|
||||||
```bash
|
```sh
|
||||||
cd some_project
|
cd some_project
|
||||||
cbuild --new-project
|
cbuild --new-project
|
||||||
```
|
```
|
||||||
|
2. Edit `project.config`.
|
||||||
2. Edit `default.config`.
|
|
||||||
3. Call some tasks:
|
3. Call some tasks:
|
||||||
```bash
|
```sh
|
||||||
cbuild build_exec_dbg exec
|
cbuild build_exec_dbg exec
|
||||||
```
|
```
|
||||||
|
P.S. See help
|
||||||
|
```sh
|
||||||
|
cbuild -h
|
||||||
|
```
|
||||||
|
|||||||
67
bootstrap.sh
67
bootstrap.sh
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
CBUILD_BOOTSTRAP_VERSION=1.0.0
|
CBUILD_BOOTSTRAP_VERSION=1.0.1
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
function version_parse {
|
function version_parse {
|
||||||
@ -29,29 +29,56 @@ function exec_script_line {
|
|||||||
eval "$line_str"
|
eval "$line_str"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function print_version_list {
|
||||||
|
dir_local="$HOME/.local/share/cbuild"
|
||||||
|
dir_global="/usr/local/share/cbuild"
|
||||||
|
files=""
|
||||||
|
if [ -d "$dir_local" ]; then
|
||||||
|
files+="$(find $dir_local -name 'CBUILD_VERSION')"
|
||||||
|
fi
|
||||||
|
if [ -d "$dir_global" ]; then
|
||||||
|
files+="$(find $dir_global -name 'CBUILD_VERSION')"
|
||||||
|
fi
|
||||||
|
for f in $files; do
|
||||||
|
cat $f | sed '$a\'
|
||||||
|
done | sort -V
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_help {
|
||||||
|
echo "cbuild-bootstrap v$CBUILD_BOOTSTRAP_VERSION"
|
||||||
|
echo "Script that launches a specific cbuild version selected by user or defined in a project config."
|
||||||
|
echo "Usage: cbuild [OPTIONS]"
|
||||||
|
echo "Options:"
|
||||||
|
echo " -h, --help Show this message"
|
||||||
|
echo " -v, --version Shows version"
|
||||||
|
echo " -c, --config FILE Set project config file path (default=./project.config)"
|
||||||
|
echo " --list-versions Shows list of installed cbuild versions"
|
||||||
|
}
|
||||||
|
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
project_config_path="./project.config"
|
project_config_path="./project.config"
|
||||||
args=($@)
|
args=($@)
|
||||||
args_count=${#args[@]}
|
args_count=${#args[@]}
|
||||||
i=0
|
i=0
|
||||||
|
if [ $args_count -eq 0 ]; then
|
||||||
function get_next_arg {
|
print_help
|
||||||
i=$((i+1))
|
fi
|
||||||
safeprint "${args[i]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
while [ $i -lt $args_count ]
|
while [ $i -lt $args_count ]
|
||||||
do
|
do
|
||||||
case "${args[i]}" in
|
case "${args[i]}" in
|
||||||
'-v' | '--version')
|
'-v' | '--version')
|
||||||
echo "cbuild-bootstrap v$CBUILD_BOOTSTRAP_VERSION"
|
echo "cbuild-bootstrap v$CBUILD_BOOTSTRAP_VERSION"
|
||||||
;;
|
;;
|
||||||
'-c' | '--config')
|
'-h' | '--help')
|
||||||
project_config_path="$(get_next_arg)"
|
print_help
|
||||||
;;
|
;;
|
||||||
'-n' | '--new-project')
|
'-c' | '--config')
|
||||||
echo "enter project cbuild version (example: 2.1.0)"
|
i=$((i+1))
|
||||||
read -r CBUILD_VERSION
|
project_config_path="${args[i]}"
|
||||||
|
;;
|
||||||
|
'--list-versions')
|
||||||
|
print_version_list
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
@ -59,9 +86,21 @@ do
|
|||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
# read version from project config if not specified
|
|
||||||
if [ -z "$CBUILD_VERSION" ]; then
|
if [ -z "$CBUILD_VERSION" ]; then
|
||||||
exec_script_line "$project_config_path" 2
|
if [ -f "$project_config_path" ]; then
|
||||||
|
# read version from project config
|
||||||
|
exec_script_line "$project_config_path" 2
|
||||||
|
else
|
||||||
|
echo "project config not found"
|
||||||
|
echo "list of installed cbuild versions:"
|
||||||
|
versions=$(print_version_list)
|
||||||
|
|
||||||
|
echo "$versions"
|
||||||
|
latest_version=$(echo "$versions" | tail -n 1)
|
||||||
|
echo "select version (default=$latest_version):"
|
||||||
|
read -r CBUILD_VERSION
|
||||||
|
[ -z "$CBUILD_VERSION" ] && CBUILD_VERSION=$latest_version
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version_parse "$CBUILD_VERSION"
|
version_parse "$CBUILD_VERSION"
|
||||||
|
|||||||
14
cbuild.sh
14
cbuild.sh
@ -47,11 +47,12 @@ include "cbuild/config.sh"
|
|||||||
function print_help {
|
function print_help {
|
||||||
myprint "cbuild v$INSTALLED_CBUILD_VERSION"
|
myprint "cbuild v$INSTALLED_CBUILD_VERSION"
|
||||||
myprint "C/C++ project build system written in bash."
|
myprint "C/C++ project build system written in bash."
|
||||||
myprint "Usage: cbuild [OPTIONS] [TASK]"
|
myprint "Usage: cbuild [OPTIONS] [TASKS]"
|
||||||
myprint " -h, --help Show this message"
|
myprint "Options:"
|
||||||
myprint " -v, --version Shows version"
|
myprint " -h, --help Show this message"
|
||||||
myprint " -n, --new-project [PROJ_DIR] Initialize new cbuild project directory (default=./)"
|
myprint " -v, --version Shows version"
|
||||||
myprint " -c, --config FILE Set project config file path (default=./project.config)"
|
myprint " -c, --config FILE Set project config file path (default=./project.config)"
|
||||||
|
myprint " -n, --new-project [DIR] Initialize new cbuild project directory (default=./)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
@ -62,6 +63,7 @@ selected_tasks_array=()
|
|||||||
i=0
|
i=0
|
||||||
if [ $args_count -eq 0 ]; then
|
if [ $args_count -eq 0 ]; then
|
||||||
print_help
|
print_help
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while [ $i -lt $args_count ]
|
while [ $i -lt $args_count ]
|
||||||
@ -84,6 +86,8 @@ do
|
|||||||
new_project_dir="${args[i]}"
|
new_project_dir="${args[i]}"
|
||||||
if [ -z "$new_project_dir" ]; then
|
if [ -z "$new_project_dir" ]; then
|
||||||
new_project_dir="."
|
new_project_dir="."
|
||||||
|
else
|
||||||
|
mkdir -p "$new_project_dir"
|
||||||
fi
|
fi
|
||||||
if ask_yn "create default cbuild project config?"; then
|
if ask_yn "create default cbuild project config?"; then
|
||||||
project_config_path="$new_project_dir/project.config"
|
project_config_path="$new_project_dir/project.config"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user