Compare commits

..

6 Commits

10 changed files with 145 additions and 38 deletions

View File

@ -1 +1 @@
2.1.4 2.2.0

View File

@ -1,35 +1,43 @@
# v2.1.4 ## 2.2.0
+ **config**: removed slash after `--fullpath-after` in `VALGRIND_ARGS`
+ **config**: removed `CONFIG_VERSION` variable
+ **config**: added `LINKER_LIBS` variable
+ added `detect_arch` function and `ARCH` global variable
+ added [default vscode launch config](./default_vscode/)
+ refactored `sed` calls to not use `-i` argument because it caused errors on NTFS
## v2.1.4
+ added `-Wl,-rpath` argument generation in `link()`. It forces ld to link to local shared library in `OUTDIR` + added `-Wl,-rpath` argument generation in `link()`. It forces ld to link to local shared library in `OUTDIR`
# v2.1.3 ## v2.1.3
+ added `DEP_OTHER_OUT_FILES` to dependency configs + added `DEP_OTHER_OUT_FILES` to dependency configs
+ if `PRESERVE_OUT_DIRECTORY_STRUCTURE=true` then `DEP_DYNAMIC_OUT_FILES` and `DEP_OTHER_OUT_FILES` are copied to `OUTDIR` preserving directory structure (example_dir/lib1.so -> $OUTDIR/example_dir/lib1.so) + if `PRESERVE_OUT_DIRECTORY_STRUCTURE=true` then `DEP_DYNAMIC_OUT_FILES` and `DEP_OTHER_OUT_FILES` are copied to `OUTDIR` preserving directory structure (example_dir/lib1.so -> $OUTDIR/example_dir/lib1.so)
# v2.1.2 ## v2.1.2
+ changed compile_c and compile_cpp functions + changed compile_c and compile_cpp functions
+ bootstrap now can print help and list of installed versions + bootstrap now can print help and list of installed versions
# v2.1.1 ## v2.1.1
+ **config**: removed `TESTS_C` and `TESTS_CPP` compilation + **config**: removed `TESTS_C` and `TESTS_CPP` compilation
# v2.1.0 ## v2.1.0
+ **config**: no more `current.config` and `default.config`, just `project.config` + **config**: no more `current.config` and `default.config`, just `project.config`
+ improved version checking + improved version checking
+ `setup.sh` now installs each minor version in separate dicectory + `setup.sh` now installs each minor version in separate dicectory
+ added `bootstrap.sh` which automaticly selects cbuild version specified in project config + added `bootstrap.sh` which automaticly selects cbuild version specified in project config
# v2.0.2 ## v2.0.2
+ new dependency resolution system (see **config** and `example_dependency_configs`) + new dependency resolution system (see **config** and `example_dependency_configs`)
+ **config**: changed description of `OBJDIR` + **config**: changed description of `OBJDIR`
+ **config**: added task `rebuild_dependencies` + **config**: added task `rebuild_dependencies`
+ added variable `TASK_ARGS` which can be used in task scripts + added variable `TASK_ARGS` which can be used in task scripts
# v2.0.1 ## v2.0.1
+ updated `.gitignore` + updated `.gitignore`
+ **config**: added `pwd` call to `valgrind` task + **config**: added `pwd` call to `valgrind` task
+ **config**: added `""` empty task check + **config**: added `""` empty task check
# 2.0.0 ## 2.0.0
+ updated setup.sh to do system-wide installation + updated setup.sh to do system-wide installation
+ deleted makefile (call `./cbuild.sh` or installed `cbuild`) + deleted makefile (call `./cbuild.sh` or installed `cbuild`)
+ added command line arguments: + added command line arguments:
@ -42,7 +50,7 @@
+ `init.sh` became `config.sh` with function `load_config` + `init.sh` became `config.sh` with function `load_config`
+ moved color variables and print functions to `myprint.sh` + moved color variables and print functions to `myprint.sh`
# v1.7.0 ## v1.7.0
+ added function `resolve_dependencies` to `link` + added function `resolve_dependencies` to `link`
+ added variables `DEPS_BASEDIR` and `DEPS` to config + added variables `DEPS_BASEDIR` and `DEPS` to config
+ added script `rebuild_dep.sh` which can be called through `Makefile` + added script `rebuild_dep.sh` which can be called through `Makefile`
@ -51,7 +59,7 @@
+ added task `no_task` which is been set in `init.sh` when `TASK` is empty + added task `no_task` which is been set in `init.sh` when `TASK` is empty
+ now `STATIC_LIB_FILE` starts with "lib" + now `STATIC_LIB_FILE` starts with "lib"
# v1.6.0 ## v1.6.0
+ `build_profile` task was split to `profile` and `gprof` + `build_profile` task was split to `profile` and `gprof`
+ added task `sanitize` + added task `sanitize`
+ default C++ standard set to `c++11` + default C++ standard set to `c++11`
@ -60,7 +68,7 @@
+ added function `try_delete_dir_or_file` for `clean` task + added function `try_delete_dir_or_file` for `clean` task
+ dead code removal in `build_exec` and `build_static_lib` + dead code removal in `build_exec` and `build_static_lib`
# v1.5.0 ## v1.5.0
+ added task `clean` + added task `clean`
+ added task `exec_dbg` + added task `exec_dbg`
+ added task `build_profile` + added task `build_profile`

View File

@ -120,5 +120,6 @@ if [ -f "$LOG_FILE" ]; then
-e 's/\[[0-9]m//g' \ -e 's/\[[0-9]m//g' \
-e 's/ H //g' \ -e 's/ H //g' \
-e 's/\[3gH //g' \ -e 's/\[3gH //g' \
-i "$LOG_FILE" "$LOG_FILE" > "$LOG_FILE.clean"
mv "$LOG_FILE.clean" "$LOG_FILE"
fi fi

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
INSTALLED_CBUILD_VERSION=2.1.4 INSTALLED_CBUILD_VERSION=2.2.0
# set \t size to 4 spaces # set \t size to 4 spaces
tabs 4 tabs 4
@ -89,17 +89,30 @@ do
else else
mkdir -p "$new_project_dir" mkdir -p "$new_project_dir"
fi fi
if ask_yn "create default cbuild project config?"; then
# create project config
project_config_path="$new_project_dir/project.config" project_config_path="$new_project_dir/project.config"
cp "$CBUILD_INSTALL_DIR/default.config" "$project_config_path" cp "$CBUILD_INSTALL_DIR/default.config" "$project_config_path.temp"
myprint "Enter project name: " myprint "Enter project name: "
read -r project_name read -r project_name
sed -i "s,\%PROJECT_NAME\%,$project_name,g" "$project_config_path" 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 config at '$project_config_path'"
fi
if ask_yn "Copy default .gitignore?"; then if ask_yn "Copy default .gitignore?"; then
cp "$CBUILD_INSTALL_DIR/.gitignore" "$new_project_dir/" cp -v "$CBUILD_INSTALL_DIR/.gitignore" "$new_project_dir/"
fi fi
if ask_yn "Copy default .vscode launch tasks?"; then
new_project_vscode_dir="$new_project_dir/.vscode"
mkdir -p "$new_project_vscode_dir"
cp -vr "$CBUILD_INSTALL_DIR/default_vscode/"* "$new_project_vscode_dir/"
sed "s,\%PROJECT_NAME\%,$project_name,g" \
"$new_project_vscode_dir/launch.json" > "$new_project_vscode_dir/launch.json.temp"
mv "$new_project_vscode_dir/launch.json.temp" "$new_project_vscode_dir/launch.json"
fi
exit 0 exit 0
;; ;;
*) *)

View File

@ -19,6 +19,7 @@ function load_config {
fi fi
OS=$(detect_os) OS=$(detect_os)
ARCH=$(detect_arch)
myprint_quiet $quiet "${GREEN}detected OS: $OS" myprint_quiet $quiet "${GREEN}detected OS: $OS"
# getting version of cbuild installation # getting version of cbuild installation

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
CBUILD_VERSION=2.1.4 CBUILD_VERSION=2.2.0
CONFIG_VERSION=1
PROJECT="%PROJECT_NAME%" PROJECT="%PROJECT_NAME%"
CMP_C="gcc" CMP_C="gcc"
@ -32,13 +31,16 @@ case "$OS" in
WINDOWS) WINDOWS)
EXEC_FILE="$PROJECT.exe" EXEC_FILE="$PROJECT.exe"
SHARED_LIB_FILE="$PROJECT.dll" SHARED_LIB_FILE="$PROJECT.dll"
# example: "-I./" # example: "-I./dependencies/include/SDL2"
INCLUDE="" INCLUDE=""
# example: "-lSDL2 -lSDL2_image"
LINKER_LIBS=""
;; ;;
LINUX) LINUX)
EXEC_FILE="$PROJECT" EXEC_FILE="$PROJECT"
SHARED_LIB_FILE="$PROJECT.so" SHARED_LIB_FILE="$PROJECT.so"
INCLUDE="" INCLUDE=""
LINKER_LIBS=""
;; ;;
*) *)
error "operating system $OS has no configuration variants" error "operating system $OS has no configuration variants"
@ -57,7 +59,7 @@ case "$TASK" in
# -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code # -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" 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" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
@ -66,7 +68,7 @@ case "$TASK" in
build_exec_dbg) build_exec_dbg)
C_ARGS="-O0 -g3" C_ARGS="-O0 -g3"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
@ -75,7 +77,7 @@ case "$TASK" in
build_shared_lib) build_shared_lib)
C_ARGS="-O2 -fpic -flto -shared" C_ARGS="-O2 -fpic -flto -shared"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
@ -84,7 +86,7 @@ case "$TASK" in
build_shared_lib_dbg) build_shared_lib_dbg)
C_ARGS="-O0 -g3 -fpic -shared" C_ARGS="-O0 -g3 -fpic -shared"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
@ -125,7 +127,7 @@ case "$TASK" in
# -fprofile-prefix-path sets path where profiling info about objects will be saved # -fprofile-prefix-path sets path where profiling info about objects will be saved
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/profile.sh TASK_SCRIPT=cbuild/default_tasks/profile.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
@ -138,7 +140,7 @@ case "$TASK" in
# -pg adds code to executable, that generates file containing function call info (gmon.out) # -pg adds code to executable, that generates file containing function call info (gmon.out)
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/gprof.sh TASK_SCRIPT=cbuild/default_tasks/gprof.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
@ -152,7 +154,7 @@ case "$TASK" in
# -pg adds code to executable, that generates file containing function call info (gmon.out) # -pg adds code to executable, that generates file containing function call info (gmon.out)
C_ARGS="-O2 -flto=auto -fuse-linker-plugin" C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/callgrind.sh TASK_SCRIPT=cbuild/default_tasks/callgrind.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
@ -162,7 +164,7 @@ case "$TASK" in
OUTDIR="$OUTDIR/sanitize" OUTDIR="$OUTDIR/sanitize"
C_ARGS="-O0 -g3 -fsanitize=undefined,address" C_ARGS="-O0 -g3 -fsanitize=undefined,address"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/exec.sh TASK_SCRIPT=cbuild/default_tasks/exec.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=

1
default_vscode/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
settings.json

View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "gdb_debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/%PROJECT_NAME%",
"windows": { "program": "${workspaceFolder}/bin/%PROJECT_NAME%.exe" },
"preLaunchTask": "build_exec_dbg",
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bin",
"externalConsole": false,
"internalConsoleOptions": "neverOpen",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}

31
default_vscode/tasks.json Normal file
View File

@ -0,0 +1,31 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build_exec_dbg",
"detail": "build project with debug symbols",
"type": "cppbuild",
"command": "bash",
"args": [
"-c",
"cbuild build_exec_dbg"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build"
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": false,
"clear": true
}
}
]
}

View File

@ -3,9 +3,9 @@
include "cbuild/myprint.sh" include "cbuild/myprint.sh"
function detect_os { function detect_os {
local uname_rezult="$(uname -o)" local uname_result="$(uname -o)"
# myprint "uname rezult: '$uname_rezult'" # myprint "uname result: '$uname_result'"
case "$uname_rezult" in case "$uname_result" in
Msys | Cygwin | MS/Windows) Msys | Cygwin | MS/Windows)
safeprint WINDOWS safeprint WINDOWS
;; ;;
@ -19,7 +19,28 @@ function detect_os {
safeprint MACOS safeprint MACOS
;; ;;
*) *)
error "unknown operating system: $uname_rezult" error "unknown operating system: $uname_result"
;;
esac
}
function detect_arch {
local uname_result="$(uname -m)"
case "$uname_result" in
arm | arm32 | armhf | aarch32)
safeprint arm32
;;
arm64 | aarch64 | aarch64_be | armv8b | armv8l)
safeprint arm64
;;
x86 | i386 | i486 | i686)
safeprint x86
;;
x64 | x86_64 | amd64)
safeprint x64
;;
*)
error "unknown CPU architecture: $uname_result"
;; ;;
esac esac
} }