# license: lgpl-2.1
# programmer: Kevin Day
#
-# The purpose of this script is to create release directories from the project source.
+# The purpose of this script is to create releases from the project source.
# These release directories can then be used to compile the project or to package the project.
# The dependencies of this script are: basename, bash, chmod, grep, and sed.
exit 0
fi
- if [[ ! -d $path_build ]] ; then
- echo -e "${c_error}ERROR: build directory '$path_build' is invalid or missing.$c_reset"
+ if [[ $operation_failure == "fail-multiple" ]] ; then
+ echo -e "${c_error}ERROR: only one operation may be specified at a time.$c_reset"
exit 1
- fi
-
- if [[ ! -d $path_destination ]] ; then
- mkdir -vp $path_destination
- if [[ $? -ne 0 ]] ; then
- echo -e "${c_error}ERROR: package directory '$path_destination' is invalid or could not be created.$c_reset"
+ elif [[ $operation == "build" ]] ; then
+ if [[ ! -d $path_build ]] ; then
+ echo -e "${c_error}ERROR: build directory '$path_build' is invalid or missing.$c_reset"
exit 1
fi
- fi
- if [[ ! -d $path_sources ]] ; then
- echo -e "${c_error}ERROR: sources directory '$path_sources' is invalid or missing.$c_reset"
- exit 1
- fi
+ if [[ ! -d $path_destination ]] ; then
+ mkdir -vp $path_destination
+ if [[ $? -ne 0 ]] ; then
+ echo -e "${c_error}ERROR: package directory '$path_destination' is invalid or could not be created.$c_reset"
+ exit 1
+ fi
+ fi
- if [[ ! -d ${path_sources}level_0/ ]] ; then
- echo -e "${c_error}ERROR: build sources directory '${path_sources}level_0/' is invalid or missing.$c_reset"
- exit 1
- fi
+ if [[ ! -d $path_sources ]] ; then
+ echo -e "${c_error}ERROR: sources directory '$path_sources' is invalid or missing.$c_reset"
+ exit 1
+ fi
- if [[ ! -d ${path_sources}level_1/ ]] ; then
- echo -e "${c_error}ERROR: build sources directory '${path_sources}level_1/' is invalid or missing.$c_reset"
- exit 1
- fi
+ if [[ ! -d ${path_sources}level_0/ ]] ; then
+ echo -e "${c_error}ERROR: build sources directory '${path_sources}level_0/' is invalid or missing.$c_reset"
+ exit 1
+ fi
- if [[ ! -d ${path_sources}level_2/ ]] ; then
- echo -e "${c_error}ERROR: build sources directory '${path_sources}level_2/' is invalid or missing.$c_reset"
- exit 1
- fi
+ if [[ ! -d ${path_sources}level_1/ ]] ; then
+ echo -e "${c_error}ERROR: build sources directory '${path_sources}level_1/' is invalid or missing.$c_reset"
+ exit 1
+ fi
- if [[ ! -d ${path_sources}level_3/ ]] ; then
- echo -e "${c_error}ERROR: build sources directory '${path_sources}level_3/' is invalid or missing.$c_reset"
- exit 1
- fi
+ if [[ ! -d ${path_sources}level_2/ ]] ; then
+ echo -e "${c_error}ERROR: build sources directory '${path_sources}level_2/' is invalid or missing.$c_reset"
+ exit 1
+ fi
+
+ if [[ ! -d ${path_sources}level_3/ ]] ; then
+ echo -e "${c_error}ERROR: build sources directory '${path_sources}level_3/' is invalid or missing.$c_reset"
+ exit 1
+ fi
- if [[ $operation_failure == "fail-multiple" ]] ; then
- echo -e "${c_error}ERROR: only one operation may be specified at a time.$c_reset"
- exit 1
- elif [[ $operation == "build" ]] ; then
if [[ $mode_individual == "" && $mode_level == "" && $mode_monolithic == "" && $mode_program == "" ]] ; then
mode_individual="yes"
fi
if [[ $mode_program == "yes" ]] ; then
package_operation_program
fi
+ elif [[ $operation == "dependencies" ]] ; then
+ if [[ ! -d $path_sources ]] ; then
+ echo -e "${c_error}ERROR: sources directory '$path_sources' is invalid or missing.$c_reset"
+ exit 1
+ fi
+
+ package_operation_dependencies
elif [[ $operation == "clean" ]] ; then
+ if [[ ! -d $path_destination ]] ; then
+ echo -e "${c_warning}WARNING: package directory '$path_destination' does not exist, there is nothing to clean.$c_reset"
+ exit 0
+ fi
+
package_operation_clean
elif [[ $operation == "" ]] ; then
echo -e "${c_error}ERROR: no operation was given.$c_reset"
echo -e " ${c_notice}Version $version$c_reset"
echo
echo -e "$c_highlight$system_name$c_reset $c_notice<${c_reset}operation$c_notice>$c_reset"
- echo -e " ${c_important}build${c_reset} Build the package"
- echo -e " ${c_important}clean${c_reset} Delete all built packages"
+ echo -e " ${c_important}build${c_reset} Build the package"
+ echo -e " ${c_important}dependencies${c_reset} Rebuild all dependencies"
+ echo -e " ${c_important}clean${c_reset} Delete all built packages"
echo
echo -e "${c_highlight}Options:$c_reset"
echo -e " -${c_important}h$c_reset, --${c_important}help$c_reset Print this help screen"
local name=
local level=
local directory=
+ local package=
for level in level_0 level_1 level_2 ; do
name="fll-$level"
local name=
local level=
local directory=
+ local package=
local subdirectory=
local pathname=
local failure=
local name=
local directory=
+ local package=
if [[ ! -d ${path_destination}program ]] ; then
mkdir -vp ${path_destination}program
fi
}
+package_operation_dependencies() {
+ local failure=
+ local level_0_libraries=
+ local level_1_libraries=
+ local level_2_libraries=
+ local level_0_headers=
+ local level_1_headers=
+ local level_2_headers=
+
+ package_dependencies_individual
+
+ if [[ $failure != "" ]] ; then
+ return;
+ fi
+
+ package_dependencies_level
+
+ if [[ $failure != "" ]] ; then
+ return;
+ fi
+
+ package_dependencies_monolithic
+}
+
+package_dependencies_individual() {
+ local level=
+ local directory=
+ local settings=
+ local name=
+ local dependencies=
+ local dependency=
+ local sub_level=
+ local sub_dependencies=
+ local sub_dependency=
+ local sub_sub_level=
+ local sub_sub_dependencies=
+ local sub_sub_dependency=
+ local individual_dependencies=
+
+ for directory in ${path_sources}level_0/* ${path_sources}level_1/* ${path_sources}level_2/* ${path_sources}level_3/* ; do
+ name="$(echo $directory | sed -e "s|${path_sources}level_0/||" -e "s|${path_sources}level_1/||" -e "s|${path_sources}level_2/||" -e "s|${path_sources}level_3/||")"
+
+ echo
+ echo -e "${c_highlight}Building Dependencies For $c_reset$c_notice${name}$c_reset${c_highlight}.$c_reset"
+
+ if [[ ! -f ${directory}/data/build/dependencies ]] ; then
+ echo -e "${c_error}ERROR: cannot build dependencies, failed to find $c_notice${directory}/data/build/dependencies$c_error.$c_reset"
+ failure=1
+ return
+ fi
+ if [[ ! -f ${directory}/data/build/settings ]] ; then
+ echo -e "${c_error}ERROR: cannot build dependencies for $c_reset$c_notice${name}$c_reset${c_error}, failed to find $c_notice${directory}/data/build/settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ dependencies=
+ if [[ -f ${directory}/data/build/dependencies ]] ; then
+ dependencies=$(cat ${directory}/data/build/dependencies)
+ fi
+
+ individual_dependencies=
+ for dependency in $dependencies ; do
+ if [[ $(echo "$dependency" | grep -o "^f_") != "" ]] ; then
+ level=level_0
+ elif [[ $(echo "$dependency" | grep -o "^fl_") != "" ]] ; then
+ level=level_1
+ elif [[ $(echo "$dependency" | grep -o "^fll_") != "" ]] ; then
+ level=level_2
+ else
+ echo -e "${c_warning}WARNING: failed to detect level for dependency $c_notice$dependency$c_warning.$c_reset"
+ continue
+ fi
+
+ if [[ ! -d ${path_sources}${level}/${dependency}/data/build/ ]] ; then
+ echo -e "${c_error}ERROR: failed to find dependency data directory $c_notice${path_sources}${level}/${dependency}/data/build/$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ sub_dependencies=
+ if [[ -f ${path_sources}${level}/${dependency}/data/build/dependencies ]] ; then
+ sub_dependencies=$(cat ${path_sources}${level}/${dependency}/data/build/dependencies)
+ fi
+
+ for sub_dependency in $sub_dependencies ; do
+ if [[ $(echo "$sub_dependency" | grep -o "^f_") != "" ]] ; then
+ sub_level=level_0
+ elif [[ $(echo "$sub_dependency" | grep -o "^fl_") != "" ]] ; then
+ sub_level=level_1
+ else
+ echo -e "${c_warning}WARNING: failed to detect level for sub-dependency $c_notice$sub_dependency$c_warning.$c_reset"
+ continue
+ fi
+
+ if [[ ! -d ${path_sources}${sub_level}/${sub_dependency}/data/build/ ]] ; then
+ echo -e "${c_error}ERROR: failed to find dependency data directory $c_notice${path_sources}${sub_level}/${sub_dependency}/data/build/$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ sub_sub_dependencies=
+ if [[ -f ${path_sources}${sub_level}/${sub_dependency}/data/build/dependencies ]] ; then
+ sub_sub_dependencies=$(cat ${path_sources}${sub_level}/${sub_dependency}/data/build/dependencies)
+ fi
+
+ for sub_sub_dependency in $sub_sub_dependencies ; do
+ if [[ $(echo "$sub_sub_dependency" | grep -o "^f_") != "" ]] ; then
+ sub_sub_level=level_0
+ else
+ echo -e "${c_warning}WARNING: failed to detect level for sub-sub-dependency $c_notice$sub_sub_dependency$c_warning.$c_reset"
+ continue
+ fi
+
+ package_dependencies_append "$sub_sub_level" "$sub_sub_dependency"
+ done
+
+ if [[ $failure != "" ]] ; then
+ break;
+ fi
+
+ package_dependencies_append "$sub_level" "$sub_dependency"
+
+ if [[ $failure != "" ]] ; then
+ break;
+ fi
+ done
+
+ if [[ $failure != "" ]] ; then
+ break;
+ fi
+
+ package_dependencies_append "$level" "$dependency"
+
+ if [[ $failure != "" ]] ; then
+ break;
+ fi
+ done
+
+ if [[ $failure != "" ]] ; then
+ break;
+ fi
+
+ individual_dependencies=$(echo "$individual_dependencies" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ if [[ $individual_dependencies != "" ]] ; then
+ echo -e " $individual_dependencies"
+ individual_dependencies=" $individual_dependencies"
+ fi
+
+ settings=${directory}/data/build/settings
+ sed -i -e "s|^build_libraries_fll\>.*\$|build_libraries_fll$individual_dependencies|" $settings
+
+ if [[ $? -ne 0 ]] ; then
+ echo -e "${c_error}ERROR: failed to update settings file $c_notice${settings}$c_error.$c_reset"
+ failure=1
+ return
+ fi
+ done
+}
+
+package_dependencies_level() {
+ local directory=
+ local name=
+ local settings=
+ local library=
+ local libraries=
+ local header=
+ local headers=
+
+ package_dependencies_level_update "level_0"
+
+ if [[ $failure != "" ]] ; then
+ return;
+ fi
+
+ package_dependencies_level_update "level_1"
+
+ if [[ $failure != "" ]] ; then
+ return;
+ fi
+
+ package_dependencies_level_update "level_2"
+}
+
+package_dependencies_level_update() {
+ local level="$1"
+ local level_libraries=
+ local level_headers=
+ local monolithic_libraries=
+ local monolithic_headers=
+
+ echo
+ echo -e "${c_highlight}Building Dependencies: $c_notice$level${c_highlight}.$c_reset"
+
+ for directory in $path_sources${level}/* ; do
+ name="$(echo $directory | sed -e "s|$path_sources${level}/||")"
+
+ settings=${directory}/data/build/settings
+ if [[ ! -f $settings ]] ; then
+ echo -e "${c_error}ERROR: failed to find settings file $c_notice$settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ libraries=$(grep -o '^build_sources_library\>.*$' $settings | sed -e 's|^build_sources_library\>||' -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ for library in $libraries ; do
+ level_libraries="$level_libraries $library"
+ monolithic_libraries="$monolithic_libraries $level/$library"
+ done
+
+ headers=$(grep -o '^build_sources_headers\>.*$' $settings | sed -e 's|^build_sources_headers\>||' -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ for header in $headers ; do
+ level_headers="$level_headers $header"
+ monolithic_headers="$monolithic_headers $level/$header"
+ done
+ done
+
+ settings=${path_sources}/build/${level}/settings
+
+ if [[ ! -f $settings ]] ; then
+ echo -e "${c_error}ERROR: failed to find settings file $c_notice$settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ level_libraries=$(echo "$level_libraries" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ if [[ $level_libraries != "" ]] ; then
+ echo " $level_libraries"
+ level_libraries=" $level_libraries"
+ fi
+
+ sed -i -e "s|^build_sources_library\>.*\$|build_sources_library$level_libraries|" $settings
+
+ if [[ $? -ne 0 ]] ; then
+ echo -e "${c_error}ERROR: failed to update libraries for settings file $c_notice$settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ level_headers=$(echo "$level_headers" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ if [[ $level_headers != "" ]] ; then
+ echo " $level_headers"
+ level_headers=" $level_headers"
+ fi
+
+ sed -i -e "s|^build_sources_headers\>.*\$|build_sources_headers$level_headers|" $settings
+
+ if [[ $? -ne 0 ]] ; then
+ echo -e "${c_error}ERROR: failed to update headers for settings file $c_notice$settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ if [[ $level == "level_0" ]] ; then
+ level_0_libraries=$(echo "$monolithic_libraries" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ level_0_headers=$(echo "$monolithic_headers" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ elif [[ $level == "level_1" ]] ; then
+ level_1_libraries=$(echo "$monolithic_libraries" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ level_1_headers=$(echo "$monolithic_headers" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ elif [[ $level == "level_2" ]] ; then
+ level_2_libraries=$(echo "$monolithic_libraries" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ level_2_headers=$(echo "$monolithic_headers" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ fi
+}
+
+package_dependencies_monolithic() {
+ local monolithic_libraries=""
+ local monolithic_headers=""
+
+ echo
+ echo -e "${c_highlight}Building Dependencies: ${c_notice}monolithic${c_highlight}.$c_reset"
+
+ if [[ $level_0_libraries != "" ]] ; then
+ monolithic_libraries="$level_0_libraries"
+ fi
+
+ if [[ $level_0_headers != "" ]] ; then
+ monolithic_headers="$level_0_headers"
+ fi
+
+ if [[ $level_1_libraries != "" ]] ; then
+ if [[ $monolithic_libraries == "" ]] ; then
+ monolithic_libraries="$level_1_libraries"
+ else
+ monolithic_libraries="$monolithic_libraries $level_1_libraries"
+ fi
+ fi
+
+ if [[ $level_1_headers != "" ]] ; then
+ if [[ $monolithic_libraries == "" ]] ; then
+ monolithic_headers="$level_1_headers"
+ else
+ monolithic_headers="$monolithic_headers $level_1_headers"
+ fi
+ fi
+
+ if [[ $level_2_libraries != "" ]] ; then
+ if [[ $monolithic_libraries == "" ]] ; then
+ monolithic_libraries="$level_2_libraries"
+ else
+ monolithic_libraries="$monolithic_libraries $level_2_libraries"
+ fi
+ fi
+
+ if [[ $level_2_headers != "" ]] ; then
+ if [[ $monolithic_libraries == "" ]] ; then
+ monolithic_headers="$level_2_headers"
+ else
+ monolithic_headers="$monolithic_headers $level_2_headers"
+ fi
+ fi
+
+ settings=${path_sources}/build/monolithic/settings
+
+ if [[ $monolithic_libraries != "" ]] ; then
+ echo " $monolithic_libraries"
+ monolithic_libraries=" $monolithic_libraries"
+ fi
+
+ sed -i -e "s|^build_sources_library\>.*\$|build_sources_library$monolithic_libraries|" $settings
+
+ if [[ $? -ne 0 ]] ; then
+ echo -e "${c_error}ERROR: failed to update libraries for settings file $c_notice$settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+
+ if [[ $monolithic_headers != "" ]] ; then
+ echo " $monolithic_headers"
+ monolithic_headers=" $monolithic_headers"
+ fi
+
+ sed -i -e "s|^build_sources_headers\>.*\$|build_sources_headers$monolithic_headers|" $settings
+
+ if [[ $? -ne 0 ]] ; then
+ echo -e "${c_error}ERROR: failed to update headers for settings file $c_notice$settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+}
+
+package_dependencies_append() {
+ local level="$1"
+ local dependency="$2"
+ local settings=
+ local libraries=
+
+ settings=${path_sources}${level}/${dependency}/data/build/settings
+ if [[ ! -f $settings ]] ; then
+ echo -e "${c_error}ERROR: failed to find dependency settings file $c_notice$settings$c_error.$c_reset"
+ failure=1
+ return
+ fi
+
+ libraries=$(grep -o '^build_sources_library\>.*$' $settings | sed -e 's|^build_sources_library\>||' -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
+ if [[ $libraries != "" ]] ; then
+ if [[ $(echo $individual_dependencies | grep -o "\-l$dependency\>") == "" ]] ; then
+ individual_dependencies="-l$dependency $individual_dependencies"
+ fi
+ fi
+}
+
package_operation_clean(){
local i=
unset package_operation_level
unset package_operation_monolithic
unset package_operation_program
+ unset package_operation_dependencies
+ unset package_dependencies_individual
+ unset package_dependencies_level
+ unset package_dependencies_level_update
+ unset package_dependencies_monolithic
+ unset package_dependencies_append
unset package_cleanup
}