Compare commits
No commits in common. "579dd5916e41c15910dd3b63a65785a92e326fea" and "49ccc769333e597a9f679f0c552e55a7dff206ce" have entirely different histories.
579dd5916e
...
49ccc76933
@ -1 +1 @@
|
||||
2.3.0
|
||||
2.2.4
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,13 +1,6 @@
|
||||
## 2.3.0
|
||||
+ Added ***project user config***! Read more in `./project.config.user.default`
|
||||
+ Changed `include` function: replaced prefix `cbuild/` with `@cbuild/`.
|
||||
+ **CONFIG:** Changed `cbuild/default_tasks` to `@cbuild/default_tasks`
|
||||
+ Moved most scripts to `include/`
|
||||
+ Renamed default config to `./project.config.default`
|
||||
|
||||
## 2.2.4
|
||||
+ *default config*: C standard changed to C99
|
||||
+ *default config*: enabled more warnings
|
||||
+ **default config**: C standard changed to C99
|
||||
+ **default config**: enabled more warnings
|
||||
+ added file `default_vscode/c_cpp_properties.json`
|
||||
+ fixed copying of `default_vscode` files
|
||||
|
||||
|
||||
34
cbuild.sh
34
cbuild.sh
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
INSTALLED_CBUILD_VERSION=2.3.0
|
||||
INSTALLED_CBUILD_VERSION=2.2.4
|
||||
|
||||
# set \t size to 4 spaces
|
||||
tabs 4
|
||||
@ -33,16 +33,16 @@ fi
|
||||
|
||||
function include {
|
||||
local script_path="$1"
|
||||
if [[ "$script_path" == @cbuild/* ]]; then
|
||||
script_path="$CBUILD_INSTALL_DIR/$(echo $script_path | sed 's,^@cbuild/,,')"
|
||||
if [[ "$script_path" == cbuild/* ]]; then
|
||||
script_path="$CBUILD_INSTALL_DIR/$(echo $script_path | sed 's,^cbuild/,,')"
|
||||
fi
|
||||
# echp "including script $script_path"
|
||||
. "$script_path"
|
||||
}
|
||||
|
||||
include "@cbuild/include/myprint.sh"
|
||||
include "@cbuild/include/functions.sh"
|
||||
include "@cbuild/include/config.sh"
|
||||
include "cbuild/myprint.sh"
|
||||
include "cbuild/functions.sh"
|
||||
include "cbuild/config.sh"
|
||||
|
||||
function print_help {
|
||||
myprint "cbuild v$INSTALLED_CBUILD_VERSION"
|
||||
@ -92,23 +92,19 @@ do
|
||||
|
||||
# create project config
|
||||
project_config_path="$new_project_dir/project.config"
|
||||
cp "$CBUILD_INSTALL_DIR/project.config.default" "$project_config_path.temp"
|
||||
myprint "${WHITE}Enter project name: "
|
||||
cp "$CBUILD_INSTALL_DIR/default.config" "$project_config_path.temp"
|
||||
myprint "Enter project name: "
|
||||
read -r project_name
|
||||
sed "s,\%PROJECT_NAME\%,$project_name,g" \
|
||||
"$project_config_path.temp" > "$project_config_path"
|
||||
rm "$project_config_path.temp"
|
||||
myprint "${GREEN}Created '$project_config_path'"
|
||||
# create project user default config
|
||||
project_user_config_path="$new_project_dir/project.config.user.default"
|
||||
cp "$CBUILD_INSTALL_DIR/project.config.user.default" "$project_user_config_path"
|
||||
myprint "${GREEN}Created '$project_user_config_path'"
|
||||
myprint "${GREEN}created config at '$project_config_path'"
|
||||
|
||||
if ask_yn "${WHITE}Copy default .gitignore?"; then
|
||||
if ask_yn "Copy default .gitignore?"; then
|
||||
cp -v "$CBUILD_INSTALL_DIR/.gitignore" "$new_project_dir/"
|
||||
fi
|
||||
|
||||
if ask_yn "${WHITE}Copy default .vscode launch tasks?"; then
|
||||
if ask_yn "Copy default .vscode launch tasks?"; then
|
||||
new_project_vscode_dir="$new_project_dir/.vscode"
|
||||
mkdir -pv "$new_project_vscode_dir"
|
||||
for vscode_dir_f in $(find "$CBUILD_INSTALL_DIR/default_vscode/" -type f); do
|
||||
@ -137,17 +133,15 @@ function call_task {
|
||||
load_config "$project_config_path" "$task" true
|
||||
|
||||
if [ ! -z "$PRE_TASK_SCRIPT" ]; then
|
||||
myprint "${BLUE}executing ${WHITE}'$PRE_TASK_SCRIPT'"
|
||||
myprint "${BLUE}executing ${WHITE}$TASK_SCRIPT"
|
||||
include "$PRE_TASK_SCRIPT"
|
||||
fi
|
||||
|
||||
if [ ! -z "$TASK_SCRIPT" ]; then
|
||||
myprint "${BLUE}executing ${WHITE}'$TASK_SCRIPT'"
|
||||
myprint "${BLUE}executing ${WHITE}$TASK_SCRIPT"
|
||||
include "$TASK_SCRIPT"
|
||||
fi
|
||||
|
||||
if [ ! -z "$POST_TASK_SCRIPT" ]; then
|
||||
myprint "${BLUE}executing ${WHITE}'$POST_TASK_SCRIPT'"
|
||||
myprint "${BLUE}executing ${WHITE}$POST_TASK_SCRIPT"
|
||||
include "$POST_TASK_SCRIPT"
|
||||
fi
|
||||
}
|
||||
|
||||
0
include/chmod_scripts.sh → chmod_scripts.sh
Normal file → Executable file
0
include/chmod_scripts.sh → chmod_scripts.sh
Normal file → Executable file
@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
include "@cbuild/include/myprint.sh"
|
||||
include "@cbuild/include/functions.sh"
|
||||
include "@cbuild/include/detect_os.sh"
|
||||
include cbuild/myprint.sh
|
||||
include cbuild/functions.sh
|
||||
include cbuild/detect_os.sh
|
||||
|
||||
function load_config {
|
||||
local project_config_path="$1"
|
||||
TASK="$2"
|
||||
local quiet=$3
|
||||
|
||||
myprint "${BLUE}loading ${WHITE}'$project_config_path'"
|
||||
myprint "${BLUE}loading config ${WHITE}'$(realpath $project_config_path)'"
|
||||
|
||||
if [ -z "$project_config_path" ]; then
|
||||
error "config path is null"
|
||||
@ -51,15 +51,6 @@ function load_config {
|
||||
set -u
|
||||
include "$project_config_path"
|
||||
|
||||
# load project user config
|
||||
local project_user_config_path="$project_config_path.user"
|
||||
if [ ! -f "$project_user_config_path" ]; then
|
||||
myprint "${YELLOW}creating default project user config ${WHITE}$project_user_config_path"
|
||||
cp "$project_user_config_path.default" "$project_user_config_path"
|
||||
fi
|
||||
myprint "${BLUE}loading ${WHITE}'$project_user_config_path'"
|
||||
include "$project_user_config_path"
|
||||
|
||||
mkdir -p "$OUTDIR"
|
||||
mkdir -p "$OBJDIR/objects"
|
||||
mkdir -p "$OBJDIR/static_libs"
|
||||
@ -69,5 +60,5 @@ function load_config {
|
||||
# dont thorw error on undefined variable
|
||||
set +u
|
||||
|
||||
myprint_quiet $quiet "${GREEN}config loading completed"
|
||||
myprint_quiet $quiet "${GREEN}loaded cbuild config"
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
CBUILD_VERSION=2.3.0
|
||||
CBUILD_VERSION=2.2.4
|
||||
|
||||
PROJECT="%PROJECT_NAME%"
|
||||
CMP_C="gcc"
|
||||
@ -22,7 +22,7 @@ SRC_CPP="$(find src -name '*.cpp')"
|
||||
|
||||
# Directory with dependency configs.
|
||||
# See cbuild/example_dependency_configs
|
||||
DEPENDENCY_CONFIGS_DIR='dependencies'
|
||||
DEPENDENCY_CONFIGS_DIR='.'
|
||||
# List of dependency config files in DEPENDENCY_CONFIGS_DIR separated by space.
|
||||
ENABLED_DEPENDENCIES=''
|
||||
|
||||
@ -71,61 +71,61 @@ case "$TASK" in
|
||||
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||
PRE_TASK_SCRIPT=""
|
||||
TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# creates executable with debug info and no optimizations
|
||||
build_exec_dbg)
|
||||
C_ARGS="-O0 -g3"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||
PRE_TASK_SCRIPT=""
|
||||
TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# creates shared library
|
||||
build_shared_lib)
|
||||
C_ARGS="-O2 -fpic -flto -shared"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
||||
PRE_TASK_SCRIPT=""
|
||||
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# creates shared library with debug symbols and no optimizations
|
||||
build_shared_lib_dbg)
|
||||
C_ARGS="-O0 -g3 -fpic -shared"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
||||
PRE_TASK_SCRIPT=""
|
||||
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# creates static library
|
||||
build_static_lib)
|
||||
C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
PRE_TASK_SCRIPT=""
|
||||
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# creates static library with debug symbols and no optimizations
|
||||
build_static_lib_dbg)
|
||||
C_ARGS="-O0 -g3"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
PRE_TASK_SCRIPT=""
|
||||
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# executes $EXEC_FILE
|
||||
exec)
|
||||
TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
|
||||
TASK_SCRIPT=cbuild/default_tasks/exec.sh
|
||||
;;
|
||||
# executes $EXEC_FILE with valgrind memory checker
|
||||
valgrind)
|
||||
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd)/ --leak-check=full --show-leak-kinds=all"
|
||||
TASK_SCRIPT="@cbuild/default_tasks/valgrind.sh"
|
||||
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
|
||||
;;
|
||||
# generates profiling info
|
||||
profile)
|
||||
@ -139,9 +139,9 @@ case "$TASK" in
|
||||
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||
TASK_SCRIPT="@cbuild/default_tasks/profile.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
TASK_SCRIPT=cbuild/default_tasks/profile.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# compiles program with -pg and runs it with gprof
|
||||
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||
@ -152,9 +152,9 @@ case "$TASK" in
|
||||
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||
TASK_SCRIPT="@cbuild/default_tasks/gprof.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
TASK_SCRIPT=cbuild/default_tasks/gprof.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# compiles program and runs it with callgrind (part of valgrind)
|
||||
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||
@ -166,9 +166,9 @@ case "$TASK" in
|
||||
C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||
TASK_SCRIPT="@cbuild/default_tasks/callgrind.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
TASK_SCRIPT=cbuild/default_tasks/callgrind.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# compiles executable with sanitizers and executes it to find errors and warnings
|
||||
sanitize)
|
||||
@ -176,19 +176,19 @@ case "$TASK" in
|
||||
C_ARGS="-O0 -g3 -fsanitize=undefined,address"
|
||||
CPP_ARGS="$C_ARGS"
|
||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||
TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
|
||||
POST_TASK_SCRIPT=""
|
||||
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
TASK_SCRIPT=cbuild/default_tasks/exec.sh
|
||||
POST_TASK_SCRIPT=
|
||||
;;
|
||||
# rebuilds specified dependencies
|
||||
# EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts`
|
||||
# 'all' can be specified to rebuild all dependencies
|
||||
rebuild_dependencies)
|
||||
TASK_SCRIPT="@cbuild/default_tasks/rebuild_dependencies.sh"
|
||||
TASK_SCRIPT=cbuild/default_tasks/rebuild_dependencies.sh
|
||||
;;
|
||||
# deletes generated files
|
||||
clean)
|
||||
TASK_SCRIPT="@cbuild/default_tasks/clean.sh"
|
||||
TASK_SCRIPT=cbuild/default_tasks/clean.sh
|
||||
;;
|
||||
# nothing to do
|
||||
"" | no_task)
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
include "@cbuild/include/myprint.sh"
|
||||
include "cbuild/myprint.sh"
|
||||
|
||||
function detect_os {
|
||||
local uname_result="$(uname -o)"
|
||||
2
include/functions.sh → functions.sh
Normal file → Executable file
2
include/functions.sh → functions.sh
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
include "@cbuild/include/myprint.sh"
|
||||
include "cbuild/myprint.sh"
|
||||
|
||||
function exec_script_line {
|
||||
local script="$1"
|
||||
@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Project user config is ignored by git.
|
||||
# Here you can add variables that users might want to change
|
||||
# on their local machine, without commiting to the repository.
|
||||
|
||||
# Directory where you install dependencies.
|
||||
# Do not confuse with DEPENDENCY_CONFIGS_DIR
|
||||
# Example:
|
||||
# libexample source code is at `../libexample`, and dependency config
|
||||
# that specifies how to build this lib is at `dependencies/libexample.config`
|
||||
DEPENDENCIES_DIR=".."
|
||||
3
setup.sh
3
setup.sh
@ -66,12 +66,9 @@ if [ -f "$bootstrap_install_path" ]; then
|
||||
local_bootstrap_version_int=$(echo $local_bootstrap_version | sed 's/\.//g')
|
||||
|
||||
if [[ $local_bootstrap_version_int > $installed_bootstrap_version_int ]]; then
|
||||
echo "Found outdated bootstrap.sh in '$CBUILD_INSTALL_DIR', updating"
|
||||
ln -sf "$(realpath $CBUILD_INSTALL_DIR/bootstrap.sh)" -T "$bootstrap_install_path"
|
||||
fi
|
||||
else
|
||||
echo "Not found bootstrap.sh in '$CBUILD_INSTALL_DIR', installing"
|
||||
ln -sf "$(realpath $CBUILD_INSTALL_DIR/bootstrap.sh)" -T "$bootstrap_install_path"
|
||||
fi
|
||||
echo "Link bootstrap.sh to $CBUILD_BIN_DIR"
|
||||
ln -sf "$(realpath $bootstrap_install_path)" -T "$CBUILD_BIN_DIR/cbuild"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user