#!/usr/bin/env bash 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'" if [ -z "$project_config_path" ]; then error "config path is null" fi if [ ! -f "$project_config_path" ]; then error "${YELLOW}$project_config_path doesn't exist" fi OS=$(detect_os) ARCH=$(detect_arch) myprint_quiet $quiet "${GREEN}detected OS: $OS" # getting version of cbuild installation if [ -z "$INSTALLED_CBUILD_VERSION" ]; then error "couldnt get current cbuild installation version" fi # undefined task [ -z "$TASK" ] && TASK="no_task" # getting cbuild version from config (CBUILD_VERSION declaration is at line 2) exec_script_line "$project_config_path" 2 $quiet myprint_quiet $quiet "${WHITE}${project_config_path} cbuild version: ${CYAN}$CBUILD_VERSION" myprint_quiet $quiet "${WHITE}installed cbuild version: ${CYAN}$INSTALLED_CBUILD_VERSION" # checking versions version_parse $INSTALLED_CBUILD_VERSION installed version_parse $CBUILD_VERSION config if [ "$installed_version_major.$installed_version_minor" != "$config_version_major.$config_version_minor" ]; then error "config was created for cbuild$config_version_major.$config_version_minor, but loaded whith cbuild$installed_version_major.$installed_version_minor which is incompatible" fi if [[ $installed_version_patch < $config_version_patch ]]; then myprint "${YELLOW}New patch for cbuild$installed_version_major.$installed_version_minor is abaliable." myprint "${YELLOW}Install it to get latest bugfixes." fi # 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" mkdir -p "$OBJDIR/static_libs" mkdir -p "$OBJDIR/dynamic_libs" mkdir -p "$OBJDIR/profile" # dont thorw error on undefined variable set +u myprint_quiet $quiet "${GREEN}config loading completed" }