diff --git a/CBUILD_VERSION b/CBUILD_VERSION index 0476155..cc6612c 100644 --- a/CBUILD_VERSION +++ b/CBUILD_VERSION @@ -1 +1 @@ -2.2.4 \ No newline at end of file +2.3.0 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 003736b..67177c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.0 ++ added ***project user config***! Read more in `./project.config.user.default` ++ renamed default config to `project.config.default` + ## 2.2.4 + **default config**: C standard changed to C99 + **default config**: enabled more warnings diff --git a/cbuild.sh b/cbuild.sh index 5111239..b1eee5b 100644 --- a/cbuild.sh +++ b/cbuild.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -INSTALLED_CBUILD_VERSION=2.2.4 +INSTALLED_CBUILD_VERSION=2.3.0 # set \t size to 4 spaces tabs 4 @@ -92,19 +92,23 @@ do # create project config project_config_path="$new_project_dir/project.config" - cp "$CBUILD_INSTALL_DIR/default.config" "$project_config_path.temp" - myprint "Enter project name: " + cp "$CBUILD_INSTALL_DIR/project.config.default" "$project_config_path.temp" + myprint "${WHITE}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 config at '$project_config_path'" + 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'" - if ask_yn "Copy default .gitignore?"; then + if ask_yn "${WHITE}Copy default .gitignore?"; then cp -v "$CBUILD_INSTALL_DIR/.gitignore" "$new_project_dir/" fi - if ask_yn "Copy default .vscode launch tasks?"; then + if ask_yn "${WHITE}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 @@ -133,15 +137,17 @@ function call_task { load_config "$project_config_path" "$task" true if [ ! -z "$PRE_TASK_SCRIPT" ]; then - myprint "${BLUE}executing ${WHITE}$TASK_SCRIPT" + myprint "${BLUE}executing ${WHITE}'$PRE_TASK_SCRIPT'" include "$PRE_TASK_SCRIPT" fi - myprint "${BLUE}executing ${WHITE}$TASK_SCRIPT" - include "$TASK_SCRIPT" + if [ ! -z "$TASK_SCRIPT" ]; then + 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 } diff --git a/config.sh b/config.sh index 29f9497..6486768 100644 --- a/config.sh +++ b/config.sh @@ -9,7 +9,7 @@ function load_config { TASK="$2" local quiet=$3 - myprint "${BLUE}loading config ${WHITE}'$(realpath $project_config_path)'" + myprint "${BLUE}loading ${WHITE}'$project_config_path'" if [ -z "$project_config_path" ]; then error "config path is null" @@ -50,6 +50,15 @@ function load_config { # throw error on undefined variable usage 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" @@ -60,5 +69,5 @@ function load_config { # dont thorw error on undefined variable set +u - myprint_quiet $quiet "${GREEN}loaded cbuild config" + myprint_quiet $quiet "${GREEN}config loading completed" } diff --git a/default.config b/project.config.default similarity index 99% rename from default.config rename to project.config.default index 43a14fe..473ae6a 100644 --- a/default.config +++ b/project.config.default @@ -1,5 +1,5 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.2.4 +CBUILD_VERSION=2.3.0 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='.' +DEPENDENCY_CONFIGS_DIR='dependencies' # List of dependency config files in DEPENDENCY_CONFIGS_DIR separated by space. ENABLED_DEPENDENCIES='' diff --git a/project.config.user.default b/project.config.user.default new file mode 100644 index 0000000..901aa1d --- /dev/null +++ b/project.config.user.default @@ -0,0 +1,11 @@ +#!/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=".."