Skip to content

Commit

Permalink
Added cd option
Browse files Browse the repository at this point in the history
  • Loading branch information
stuin committed Aug 19, 2020
1 parent 18fd851 commit 3d87fd8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build commands without a number will be counted as build1.

Option |Merging|Desc |Vars
----- |----- |----- |-----
cd |none |move to directory and use its config |
files |path |lists all files passed to the build command |
output |none |sets the output file given to the other commands |
num |none |number of build commands to run |
Expand Down
1 change: 1 addition & 0 deletions config
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cd=./
files=*.cpp
output=a.out
terminal=xterm
Expand Down
48 changes: 28 additions & 20 deletions ezbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ GLOBAL=/etc/ezbuild
EMULATOR=""
PAUSE=""
TEST=""
CACHED=""
EXTRA=""

# Retrieve variable from recursive config files
Expand Down Expand Up @@ -82,16 +83,19 @@ headers() {
}

# Parse command arguments
while getopts ":epra:" options; do
while getopts ":eprca:" options; do
case "${options}" in
e )
EMULATOR="-e"
;;
p )
PAUSE="-p"
;;
t )
TEST="-t"
r )
TEST="-r"
;;
c )
CACHED="-c"
;;
a )
EXTRA=$OPTARG
Expand All @@ -106,16 +110,18 @@ EXTRA="$EXTRA $@"

# Redirect command to new window
if [ -n "$EMULATOR" ]; then
$(grab terminal) ezbuild $PAUSE $TEST $EXTRA
$(grab terminal) ezbuild $PAUSE $TEST $CACHED $EXTRA
exit 0
fi

cd $(grab cd)

if [ -n "$TEST" ]; then
# Run latest build
runcmd=$(echo $(grab tester) | sed "s:%output:$(grab output):")
rundir=$(grab testdir)
cd $rundir
$runcmd $EXTRA $(grab testargs 1)
$runcmd $EXTRA $(grab testargs)
else
# Retrieve config for actual build
files=$(echo " $(echo $(grab files 2))" | sed "s: ./: :g")
Expand All @@ -127,22 +133,24 @@ else
cached=$(echo $files | sed "$caching")
depfinder=$(grab depfinder)

# Remove cached items from file list
if [ -n "$caching" ]; then
IFS=' '
for val in $files; do
cacheval=$(echo " $val" | sed "$caching ; s:^ ::")
# If source or header files newer than cache
if [ -e "$cacheval" -a "$val" -ot "$cacheval" ]; then
echo "Checking headers for $val"
h=$(headers "$depfinder" "$cacheval" "$val")
if [ -z "$h" ]; then
files=$(echo $files | sed "s:$val::g")
else
echo $h
if [ -n "$CACHED" ]; then
# Remove cached items from file list
if [ -n "$caching" ]; then
IFS=' '
for val in $files; do
cacheval=$(echo " $val" | sed "$caching ; s:^ ::")
# If source or header files newer than cache
if [ -e "$cacheval" -a "$val" -ot "$cacheval" ]; then
echo "Checking headers for $val"
h=$(headers "$depfinder" "$cacheval" "$val")
if [ -z "$h" ]; then
files=$(echo $files | sed "s:$val::g")
else
echo $h
fi
fi
fi
done
done
fi
fi

# Check if all files in cache
Expand Down

0 comments on commit 3d87fd8

Please sign in to comment.