Skip to content

Commit

Permalink
Merge pull request #2 from RamtinKosari/develop
Browse files Browse the repository at this point in the history
Release Version 1.0
  • Loading branch information
RamtinKosari committed Feb 25, 2024
2 parents 16fb2c9 + 9bda253 commit c3b91ad
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ RESET='\033[0m'
WARNING="${YELLOW}[WARNING]${RESET}"
FAILED="${RED}[FAILED]${RESET}"

# - Default Extentions List
# EXTENTION_LIST=".cpp .hpp"
# - Default Extensions List
EXTENSION_LIST=( "*.cpp" "*.hpp" )

# - User Extensions List
USER_EXTENSION_LIST=()

if [ ! -d "../build" ]; then
mkdir ../build
else
Expand All @@ -31,8 +33,8 @@ OPTS=$(getopt -o e:p: -l extensions:,packages: -n "$0" -- "$@")
eval set -- "$OPTS"
while true; do
case "$1" in
-e|--extentions)
EXTENSION_LIST="$2" # Set the provided extensions
-e|--extensions)
USER_EXTENSION_LIST+=("$2")
shift 2
;;
-p|--packages)
Expand All @@ -49,17 +51,26 @@ while true; do
esac
done

# - Find All Files with Given Extentions
find_expression=()
for ext in "${EXTENSION_LIST[@]}"; do
find_expression+=("-name" "$ext" "-o")
done
find_expression=("${find_expression[@]:0:$((${#find_expression[@]}-1))}")
# - Find All Files with Given Extensions
if [ ${#USER_EXTENSION_LIST[@]} -ne 0 ]; then
find_expression=()
for ext in "${USER_EXTENSION_LIST[@]}"; do
find_expression+=("-name" "$ext" "-o")
done
find_expression=("${find_expression[@]:0:$((${#find_expression[@]}-1))}")
else
find_expression=()
for ext in "${EXTENSION_LIST[@]}"; do
find_expression+=("-name" "$ext" "-o")
done
find_expression=("${find_expression[@]:0:$((${#find_expression[@]}-1))}")
fi
source_files=$(find . -type f \( "${find_expression[@]}" \))


# - Check if Source List is Empty
if [ -z "$source_files" ]; then
echo -e "$WARNING No Files with Used Extentions Found in the Project Directory."
echo -e "$WARNING No Files with Used Extensions Found in the Project Directory."
exit 1
fi

Expand Down

0 comments on commit c3b91ad

Please sign in to comment.