ninja 1.21 KB
Newer Older
1
#!/usr/bin/env bash
2

3 4 5 6
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

7
OS="$(uname -s)"
8
THIS_DIR="$(dirname "${0}")"
9

10 11 12 13 14
function print_help() {
cat <<-EOF
No prebuilt ninja binary was found for this system.
Try building your own binary by doing:
  cd ~
Takuto Ikuta's avatar
Takuto Ikuta committed
15
  git clone https://github.com/martine/ninja.git -b v1.8.2
16
  cd ninja && ./configure.py --bootstrap
17 18 19 20
Then add ~/ninja/ to your PATH.
EOF
}

21 22
case "$OS" in
  Linux)
23
    MACHINE=$(uname -m)
24
    case "$MACHINE" in
25 26 27
      i?86|x86_64)
        LONG_BIT=$(getconf LONG_BIT)
        # We know we are on x86 but we need to use getconf to determine
28
        # bittage of the userspace install (e.g. when running 32-bit userspace
29 30 31 32 33 34
        # on x86_64 kernel)
        exec "${THIS_DIR}/ninja-linux${LONG_BIT}" "$@";;
      *)
        echo Unknown architecture \($MACHINE\) -- unable to run ninja.
        print_help
        exit 1;;
35 36 37 38
    esac
    ;;
  Darwin)    exec "${THIS_DIR}/ninja-mac" "$@";;
  CYGWIN*)   exec cmd.exe /c $(cygpath -t windows $0).exe "$@";;
39
  MINGW*)    cmd.exe //c $0.exe "$@";;
40
  *)         echo "Unsupported OS ${OS}"
41
             print_help
42 43
             exit 1;;
esac