Raw
1 #!/bin/sh
2
3 if test "$#" -lt 2
4 then
5 exit 1
6 fi
7
8 SOURCE_DIR="$1"
9 BUILD_DIR="$2"
10 BUILD_TYPE=debug
11
12 shift 2
13
14 for arg
15 do
16 case "$arg" in
17 --release)
18 BUILD_TYPE=release;;
19 esac
20 done
21
22 case "$(cargo -vV | sed -n 's/^host: \(.*\)$/\1/p')" in
23 *-windows-msvc)
24 LIBNAME=gitcore.lib
25 PATH="$(echo "$PATH" | tr ':' '\n' | grep -Ev "^(/mingw64/bin|/usr/bin)$" | paste -sd: -):/mingw64/bin:/usr/bin"
26 export PATH
27 ;;
28 *-windows-*)
29 LIBNAME=gitcore.lib;;
30 *)
31 LIBNAME=libgitcore.a;;
32 esac
33
34 cargo build --lib --quiet --manifest-path="$SOURCE_DIR/Cargo.toml" --target-dir="$BUILD_DIR" "$@"
35 RET=$?
36 if test $RET -ne 0
37 then
38 exit $RET
39 fi
40
41 if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1
42 then
43 cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a"
44 fi