Start support for sourceless tasks
This commit is contained in:
parent
fcb60d97b9
commit
bc4e4c1180
|
@ -97,7 +97,7 @@ run() {
|
|||
# Overriden by -f/--force to force rebuild when no update is available
|
||||
FORCE=0
|
||||
|
||||
# Find targeted projects from args and extra arguments
|
||||
# Find targeted projects and extra flags from args
|
||||
PROJECTS=()
|
||||
BASEDIR="$HOME/.forgebuild"
|
||||
FOUND_BASEDIR=0
|
||||
|
@ -114,13 +114,12 @@ for arg in "$@"; do
|
|||
FORCE=1
|
||||
elif [[ "$arg" = "-b" ]] || [[ "$arg" = "--basedir" ]]; then
|
||||
FOUND_BASEDIR=1
|
||||
# Maybe it's a task name and we find a corresponding source?
|
||||
# TODO: Support source-less tasks https://tildegit.org/southerntofu/git-build.sh/issues/8
|
||||
elif [ -f $BASEDIR/$arg.source ]; then
|
||||
elif [ -x $BASEDIR/$arg ]; then
|
||||
export i18n_task="$arg"
|
||||
debug found_task
|
||||
PROJECTS+=("$arg")
|
||||
# Maybe it's a repo URL and we find a corresponding task?
|
||||
# TODO: maybe remove this? multiple URLs can point to the same repo so..
|
||||
elif matches="$(grep --files-with-matches --word-regexp "$arg" $BASEDIR/*.source)"; then
|
||||
# Iterate over the files found to extract the task name
|
||||
IFS= echo "$matches" | while read -r file; do
|
||||
|
@ -151,8 +150,9 @@ echo "$BASHPID" > $BASEDIR/.LOCK
|
|||
# If no project argument passed, default to all projects
|
||||
if [[ ${#PROJECTS[*]} = 0 ]]; then
|
||||
info no_task
|
||||
# TODO: sourceless tasks
|
||||
for file in $BASEDIR/*.source; do
|
||||
for file in $BASEDIR/*; do
|
||||
# Skip non-executable files
|
||||
[ ! -x $file ] && continue
|
||||
# Extract the project name from path
|
||||
task="$(basename $file .source)"
|
||||
export i18n_task="$task"
|
||||
|
@ -161,16 +161,11 @@ if [[ ${#PROJECTS[*]} = 0 ]]; then
|
|||
done
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Check if we have host-specific config or default to the config/ folder
|
||||
[ -d $BASEDIR/$HOSTNAME ] && CONFDIR="$BASEDIR/$HOSTNAME" || CONFDIR=$BASEDIR/config
|
||||
export i18n_config="$CONFDIR"
|
||||
info config
|
||||
|
||||
# TODO: sourceless tasks
|
||||
for p_name in ${PROJECTS[*]}; do
|
||||
# For translations
|
||||
export i18n_task="$p_name"
|
||||
|
@ -190,6 +185,15 @@ for p_name in ${PROJECTS[*]}; do
|
|||
continue
|
||||
fi
|
||||
info process
|
||||
|
||||
# Before we clone/checkout the source, maybe it's a sourceless task?
|
||||
if [ ! -f $BASEDIR/$p_name.source ]; then
|
||||
# If $p_name.done exists, the task was already run
|
||||
[ -f $BASEDIR/$p_name.done ] && continue
|
||||
run $p_name
|
||||
continue
|
||||
fi
|
||||
|
||||
# checkout a specific branch/commit
|
||||
if [ -f $BASEDIR/$p_name.checkout ]; then
|
||||
p_branch="$(cat $BASEDIR/$p_name.checkout)"
|
||||
|
|
Loading…
Reference in New Issue