handling wirh plugins

This commit is contained in:
Jörn-Michael Miehe 2019-09-24 13:40:46 +02:00
parent 67aef64bec
commit 152beeb5a5
3 changed files with 26 additions and 7 deletions

View file

@ -6,6 +6,7 @@
g_bin="$(readlink -f "$(which "$0")")" g_bin="$(readlink -f "$(which "$0")")"
g_lib=${g_bin/"bin"/"lib"} g_lib=${g_bin/"bin"/"lib"}
declare -a g_plugins
# #
# load base program # load base program

View file

@ -7,13 +7,11 @@ do_compile() { # $1:DIR $2:OBJECT $3:DONE
local object="$2" local object="$2"
local done="${3:-0}" local done="${3:-0}"
# build systems # build plugins
if [ -r "${dir}/Makefile" ]; then for plugin in ${g_plugins[@]}; do
# Makefile found try_${plugin} "${dir}" "${object}" \
echo -n "Found '${dir}/Makefile': "
do_make "${dir}" "Makefile" "${object}" \
&& local done="1" && local done="1"
fi done
# never leave $g_watchroot # never leave $g_watchroot
if [ "${dir}" != "${g_watchroot}" ]; then if [ "${dir}" != "${g_watchroot}" ]; then

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
g_plugins+=(make)
# compile using bare make command # compile using bare make command
do_make() { # $1:DIR $2:MAKEFILE $3:OBJECT do_make() { # $1:DIR $2:MAKEFILE $3:OBJECT
# extract params # extract params
@ -24,7 +26,7 @@ do_make() { # $1:DIR $2:MAKEFILE $3:OBJECT
echo "Making '${target}'. " echo "Making '${target}'. "
fi fi
make --no-print-directory -C "${dir}" -j ${target} make --no-print-directory -C "${dir}" -f "${makefile}" -j ${target}
else else
echo -n "SRCPAT '${srcpat}' mismatch. " echo -n "SRCPAT '${srcpat}' mismatch. "
@ -33,3 +35,21 @@ do_make() { # $1:DIR $2:MAKEFILE $3:OBJECT
return 0 return 0
} }
try_make() { # $1:DIR $2:OBJECT
# extract params
local dir="$1"
local object="$2"
local retval=1
for FILE in "${dir}"/Makefile "${dir}"/*.mk; do
if [ -r "${FILE}" ]; then
echo -n "Found '${FILE}': "
do_make "${dir}" "$(basename "${FILE}")" "${object}" \
&& local retval=0
echo ""
fi
done
return ${retval}
}