forked from ddddavidmartin/Pre-commit-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit-compile
executable file
·49 lines (39 loc) · 1.44 KB
/
pre-commit-compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Git pre-commit compile hook. Make project and in case of error abort commit.
# Script based on: http://benjamin-meyer.blogspot.com/2008/10/git-hooks.html
# Make sure this script is executable and set the Makefile location MAKEFILE.
# This file is part of a set of unofficial pre-commit hooks available
# at github.
# Link: https://github.com/githubbrowser/Pre-commit-hooks
# Contact: David Martin, david.martin.mailbox@googlemail.com
###########################################################
# SETTINGS:
# Path to your makefile
# MAKEFILE="/home/user/project/src/Makefile"
MAKEFILE="/home/user/project/src/Makefile"
# Additional options for the make call. Eg. --quiet to not print any output
# or -j to make use of multiple cpu cores.
# OPTIONS="--quiet -j"
OPTIONS="--quiet"
###########################################################
# There should be no need to change anything below this line.
source $(dirname "$0")/"canonicalize_filename.sh"
# exit on error
set -e
MAKEPATH="$(dirname "$MAKEFILE")"
echo "Building project."
if [ -f "$MAKEFILE" ] ; then
cd "$MAKEPATH"
make $OPTIONS -f "$MAKEFILE"
if [ $? != 0 ] ; then
echo "Build failure. Aborting commit."
exit 1
fi
echo "Build success."
else
echo "Error: Makefile not found. Aborting commit."
echo "Set the correct path in $(canonicalize_filename "$0")."
echo "Skip pre-commit hooks with --no-verify (not recommended)."
exit 1
fi
exit 0