diff --git a/CBUILD_VERSION b/CBUILD_VERSION index 8f9174b..abae0d9 100644 --- a/CBUILD_VERSION +++ b/CBUILD_VERSION @@ -1 +1 @@ -2.1.2 \ No newline at end of file +2.1.3 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d68c43a..fa5913b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v2.1.3 ++ 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) + # v2.1.2 + changed compile_c and compile_cpp functions + bootstrap now can print help and list of installed versions diff --git a/cbuild.sh b/cbuild.sh index 3813ddb..73106bb 100644 --- a/cbuild.sh +++ b/cbuild.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -INSTALLED_CBUILD_VERSION=2.1.2 +INSTALLED_CBUILD_VERSION=2.1.3 # set \t size to 4 spaces tabs 4 diff --git a/default.config b/default.config index e7d871f..ffc3937 100644 --- a/default.config +++ b/default.config @@ -1,5 +1,5 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.1.2 +CBUILD_VERSION=2.1.3 CONFIG_VERSION=1 PROJECT="%PROJECT_NAME%" diff --git a/example_dependency_configs/libexample1.config b/example_dependency_configs/libexample1.config index 6a5d812..6a0a9af 100644 --- a/example_dependency_configs/libexample1.config +++ b/example_dependency_configs/libexample1.config @@ -6,5 +6,8 @@ DEP_POST_BUILD_COMMAND='' DEP_CLEAN_COMMAND='make clean' # won't be copied to project $OUTDIR DEP_STATIC_OUT_FILES='libexample1.a libexample1_addon.a' -# will be copied tp project $OUTDIR +PRESERVE_OUT_DIRECTORY_STRUCTURE=false; +# will be copied to project $OUTDIR DEP_DYNAMIC_OUT_FILES='libexample1.config.json' +# will be copied to project $OUTDIR +DEP_OTHER_OUT_FILES='' diff --git a/example_dependency_configs/libexample2.config b/example_dependency_configs/libexample2.config index 0a491e5..6314ccb 100644 --- a/example_dependency_configs/libexample2.config +++ b/example_dependency_configs/libexample2.config @@ -4,14 +4,17 @@ DEP_PRE_BUILD_COMMAND='' DEP_POST_BUILD_COMMAND='' DEP_CLEAN_COMMAND='make clean' DEP_STATIC_OUT_FILES='' +DEP_OTHER_OUT_FILES='' case $OS in WINDOWS) - DEP_BUILD_COMMAND='make libexample2.dll' - DEP_DYNAMIC_OUT_FILES='libexample2.dll' + DEP_BUILD_COMMAND='make libexample2.dll && mkdir -p win-x64 && mv libexample.dll win-x64' + DEP_DYNAMIC_OUT_FILES='win-x64/libexample2.dll' + PRESERVE_OUT_DIRECTORY_STRUCTURE=true # library will be copied to $OUTDIR/win-x64 ;; LINUX) - DEP_BUILD_COMMAND='make libexample2.so' - DEP_DYNAMIC_OUT_FILES='libexample2.so' + DEP_BUILD_COMMAND='make libexample2.so && mkdir -p linux-x64 && mv libexample.so linux-x64' + DEP_DYNAMIC_OUT_FILES='linux-x64/libexample2.so' + PRESERVE_OUT_DIRECTORY_STRUCTURE=true # library will be copied to $OUTDIR/linux-x64 ;; *) error "operating system $OS has no configuration variants" diff --git a/functions.sh b/functions.sh index a095246..1a7e75b 100755 --- a/functions.sh +++ b/functions.sh @@ -64,7 +64,7 @@ function build_dependency { local build_needed="$force_build" if [ "$build_needed" != true ]; then - for file in $DEP_STATIC_OUT_FILES $DEP_DYNAMIC_OUT_FILES; do + for file in $DEP_STATIC_OUT_FILES $DEP_DYNAMIC_OUT_FILES $DEP_OTHER_OUT_FILES; do if [ ! -f "$file" ]; then myprint "${GRAY}missing file '$file'" local build_needed=true @@ -82,17 +82,36 @@ function build_dependency { fi if [ ! -z "$DEP_DYNAMIC_OUT_FILES" ]; then - # copy each file to $OUTDIR - cp -rv $DEP_DYNAMIC_OUT_FILES "$proj_root_dir/$OUTDIR" - # symlink each file to $OBJDIR/dynamic_libs + # copies each file to $OUTDIR and creates symbolic link in $OBJDIR/dynamic_libs for file in $DEP_DYNAMIC_OUT_FILES; do # doesnt return error if called not like this - f=$(realpath $file) - ln -sfv $f "$proj_root_dir/$OBJDIR/dynamic_libs" + real_file=$(realpath $file) + file_dir=$(dirname $file) + if [ "$PRESERVE_OUT_DIRECTORY_STRUCTURE" = true ] && [ "$file_dir" != '.' ]; then + mkdir -p "$proj_root_dir/$OUTDIR/$file_dir" + mkdir -p "$proj_root_dir/$OBJDIR/dynamic_libs/$file_dir" + cp -v "$file" "$proj_root_dir/$OUTDIR/$file" + ln -sfv "$real_file" "$proj_root_dir/$OBJDIR/dynamic_libs/$file" + else + cp -v "$file" "$proj_root_dir/$OUTDIR/" + ln -sfv "$real_file" "$proj_root_dir/$OBJDIR/dynamic_libs/" + fi + done + fi + if [ ! -z "$DEP_OTHER_OUT_FILES" ]; then + # copies each file to $OUTDIR + for file in $DEP_OTHER_OUT_FILES; do + if [ "$PRESERVE_OUT_DIRECTORY_STRUCTURE" = true ]; then + file_dir=$(dirname $file) + mkdir -p "$proj_root_dir/$OUTDIR/$file_dir" + cp -v "$file" "$proj_root_dir/$OUTDIR/$file" + else + cp -v "$file" "$proj_root_dir/$OUTDIR/" + fi done fi if [ ! -z "$DEP_STATIC_OUT_FILES" ]; then - # symlink each file to $OBJDIR/static_libs + # creates symbolic link to each file in $OBJDIR/static_libs for file in $DEP_STATIC_OUT_FILES; do # doesnt return error if called not like this f=$(realpath $file) @@ -101,6 +120,17 @@ function build_dependency { fi cd "$proj_root_dir" + + # unsed all dependency config variables to not mess with next dependencies + unset DEP_WORKING_DIR + unset DEP_PRE_BUILD_COMMAND + unset DEP_BUILD_COMMAND + unset DEP_POST_BUILD_COMMAND + unset DEP_CLEAN_COMMAND + unset DEP_STATIC_OUT_FILES + unset PRESERVE_OUT_DIRECTORY_STRUCTURE + unset DEP_DYNAMIC_OUT_FILES + unset DEP_OTHER_OUT_FILES } function build_dependencies { diff --git a/setup.sh b/setup.sh index 085b67f..c810c85 100644 --- a/setup.sh +++ b/setup.sh @@ -4,7 +4,7 @@ # exit on errors set -xeo pipefail -CBUILD_VERSION=2.1.2 +CBUILD_VERSION=$(