blob: 9715596a05f8e11ba310ae6f684d70cc62ef7397 [file] [log] [blame]
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +09001#!/bin/bash
2#
Shinichiro Hamajib69bf8a2015-06-10 14:52:06 +09003# Copyright 2015 Google Inc. All rights reserved
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090017# A wrapper for kati which generates build.ninja mainly for Android.
18#
19
20set -e
21
22kati_dir=$(cd $(dirname $0) && pwd)
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090023extra_flags=
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090024goma_flag=
25
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090026while [ x"$1" != x"" ]; do
27 case "$1" in
28 --help)
29 cat - <<EOF
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090030Usage:
31 m2n # for full-build
Shinichiro Hamajid34c0e12015-06-04 16:53:47 +090032 m2n --goma # use goma. \$HOME/goma must exist
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090033 m2n bionic # works like mmm
34EOF
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090035 exit 1
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090036 ;;
Shinichiro Hamajie85764a2015-06-04 17:08:27 +090037
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090038 --goma)
39 if [ ! -e $HOME/goma/goma_ctl.py ]; then
40 echo "$HOME/goma/goma_ctl.py should exist to use goma"
41 exit 1
42 fi
43 $HOME/goma/goma_ctl.py ensure_start
44 goma_flag=--goma_dir=$HOME/goma
Shinichiro Hamajib740b722015-06-08 14:23:52 +090045 shift
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090046 ;;
47
48 --*)
49 extra_flags+=" $1"
50 shift
51 ;;
52
53 *)
Shinichiro Hamajie85764a2015-06-04 17:08:27 +090054 target=$1
55 shift
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090056 ;;
57 esac
58done
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090059
60kati=${kati_dir}/kati
61
62if [ x"${target}" != x"" ]; then
63 export ONE_SHOT_MAKEFILE=${target}/Android.mk
64 echo ONE_SHOT_MAKEFILE=${ONE_SHOT_MAKEFILE}
65fi
66
Shinichiro Hamaji2eac7682015-06-05 13:27:56 +090067${kati} --ninja --ignore_optional_include=out/%.P ${goma_flag} ${extra_flags}
Shinichiro Hamaji5fb52572015-06-04 16:20:32 +090068
69echo ninja.sh and build.ninja were generated, please run ./ninja.sh