Skip to content

Commit

Permalink
Refactored build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Kalatozishvili committed Sep 15, 2024
1 parent bff939e commit 7747835
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This source is part of "libxutils" project
# 2015-2023 Sun Dro (s.kalatoz@gmail.com)

PROJ_PATH=$(dirname $(readlink -f "$0"))
PROJ_PATH=$(pwd -P)/$(dirname "$0")
TOOL_PATH=$PROJ_PATH/tools
LIB_PATH=$PROJ_PATH

Expand Down
5 changes: 4 additions & 1 deletion clean.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash
PROJ_PATH=$(dirname $(readlink -f "$0"))
# This source is part of "libxutils" project
# 2015-2023 Sun Dro (s.kalatoz@gmail.com)

PROJ_PATH=$(pwd -P)/$(dirname "$0")

clean_path() {
cd "$@"
Expand Down
27 changes: 17 additions & 10 deletions misc/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ SMAKE_SSL_OBJ="\"find\": {\n\
},"

CMAKE_SSL_OBJ="find_package(OpenSSL)\n\
IF(OpenSSL_FOUND)\n\
set(CMAKE_C_FLAGS \"\${CMAKE_C_FLAGS} -D_XUTILS_USE_SSL\")\n\
ENDIF()"
if(OpenSSL_FOUND)\n\
include_directories(\${OPENSSL_INCLUDE_DIR})\n\
link_directories(\${OPENSSL_LIBRARIES})\n\
set(CMAKE_C_FLAGS \"\${CMAKE_C_FLAGS} -D_XUTILS_USE_SSL\")\n\
endif()"

modules=(
"crypt: AES"
Expand Down Expand Up @@ -329,8 +331,9 @@ fix_dependencies() {
name=${parts[1]}
var="USE_$name"

if [ -v $var ] && [ ${!var} == "y" ]; then
func="enable_${name,,}"
if [ ! -z "${!var}" ] && [ "${!var}" == "y" ]; then
# Use tr to convert the name to lowercase
func="enable_$(echo "$name" | tr '[:upper:]' '[:lower:]')"
eval "$func"
fi
done
Expand Down Expand Up @@ -364,16 +367,20 @@ process_modules() {
name=${parts[1]}
var="USE_$name"

if [ -v $var ] && [ ${!var} == "y" ]; then
echo "-- Using ${mod,,}.c"
# Check if the variable is set and its value is "y"
if [ ! -z "${!var}" ] && [ "${!var}" == "y" ]; then
# Use tr to convert the name to lowercase
lower_name=$(echo "$name" | tr '[:upper:]' '[:lower:]')
echo "-- Using ${lower_name}.c"
case $1 in
"make") sourceList="${sourceList}\n ${name,,}.${extension}" ;;
"cmake") sourceList="${sourceList}\n ${SOURCE_DIR}/${dir}/${name,,}.${extension}" ;;
"smake") sourceList="${sourceList}\n \"${SOURCE_DIR}/${dir}/${name,,}.${extension}\"," ;;
"make") sourceList="${sourceList}\n ${lower_name}.${extension}" ;;
"cmake") sourceList="${sourceList}\n ${SOURCE_DIR}/${dir}/${lower_name}.${extension}" ;;
"smake") sourceList="${sourceList}\n \"${SOURCE_DIR}/${dir}/${lower_name}.${extension}\"," ;;
esac
fi
done

# Strip the last comma if it exists
if [[ "${sourceList: -1}" == "," ]]; then
sourceList="${sourceList%,}"
fi
Expand Down

0 comments on commit 7747835

Please sign in to comment.