blob: c956cbb2f109e64db8fda43da73aacb299f8503e [file] [log] [blame]
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +09001#!/bin/bash
2#
3# A wrapper for kati which generates build.ninja mainly for Android.
4#
5
6set -e
7
8kati_dir=$(cd $(dirname $0) && pwd)
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +09009extra_flags=
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090010goma_flag=
11
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090012while [ x"$1" != x"" ]; do
13 case "$1" in
14 --help)
15 cat - <<EOF
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090016Usage:
17 m2n # for full-build
Shinichiro Hamajid34c0e12015-06-04 16:53:47 +090018 m2n --goma # use goma. \$HOME/goma must exist
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090019 m2n bionic # works like mmm
20EOF
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090021 exit 1
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090022 ;;
Shinichiro Hamajie85764a2015-06-04 17:08:27 +090023
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090024 --goma)
25 if [ ! -e $HOME/goma/goma_ctl.py ]; then
26 echo "$HOME/goma/goma_ctl.py should exist to use goma"
27 exit 1
28 fi
29 $HOME/goma/goma_ctl.py ensure_start
30 goma_flag=--goma_dir=$HOME/goma
31 ;;
32
33 --*)
34 extra_flags+=" $1"
35 shift
36 ;;
37
38 *)
Shinichiro Hamajie85764a2015-06-04 17:08:27 +090039 target=$1
40 shift
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090041 ;;
42 esac
43done
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090044
45kati=${kati_dir}/kati
46
47if [ x"${target}" != x"" ]; then
48 export ONE_SHOT_MAKEFILE=${target}/Android.mk
49 echo ONE_SHOT_MAKEFILE=${ONE_SHOT_MAKEFILE}
50fi
51
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090052${kati} --ninja --ignore_optional_include=out/%.P ${goma_flag} ${extra_flags}
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090053
54echo ninja.sh and build.ninja were generated, please run ./ninja.sh