blob: 7fc6c461d93aaa949f66898511e8183bbaba74c6 [file] [log] [blame]
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +09001#
2# Copyright (C) 2015 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# Notice: this works only with Google's Goma build infrastructure.
18ifneq ($(USE_GOMA),)
19 # Check if USE_NINJA is defined because GNU make won't work well
20 # with goma. Note this file is evaluated twice, once with
21 # USE_NINJA=true by GNU make and once with USE_NINJA=false by kati
22 # which is invoked by GNU make. So, we cannot test the value of
23 # USE_NINJA.
24 ifndef USE_NINJA
25 $(error USE_GOMA=true works only with USE_NINJA=true)
26 endif
27
Shinichiro Hamajib601d4b2015-08-29 11:58:47 +090028 # Goma requires a lot of processes and file descriptors.
29 ifeq ($(shell echo $$(($$(ulimit -u) < 2500 || $$(ulimit -n) < 16000))),1)
30 $(warning Max user processes and/or open files are insufficient)
31 ifeq ($(shell uname),Darwin)
32 $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android to relax the limit)
33 else
34 $(error Adjust the limit by ulimit -u and ulimit -n)
35 endif
36 endif
37
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090038 ifdef GOMA_DIR
39 goma_dir := $(GOMA_DIR)
40 else
41 goma_dir := $(HOME)/goma
42 endif
43 goma_ctl := $(goma_dir)/goma_ctl.py
44 goma_cc := $(goma_dir)/gomacc
45
46 $(if $(wildcard $(goma_ctl)),, \
47 $(warning You should have goma in $$GOMA_DIR or $(HOME)/goma) \
48 $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android for detail))
49
50 # Append gomacc to existing *_WRAPPER variables so it's possible to
51 # use both ccache and gomacc.
52 CC_WRAPPER := $(strip $(CC_WRAPPER) $(goma_cc))
53 CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(goma_cc))
54
55 # Ninja file generated by kati uses this for remote jobs (i.e.,
56 # commands which contain gomacc). Note the parallelism of all other
57 # jobs will be limited the number of cores.
58 KATI_REMOTE_NUM_JOBS_FLAG := --remote_num_jobs=500
59
60 # gomacc can start goma client's daemon process automatically, but
61 # it is safer and faster to start up it beforehand. We run this as a
62 # background process so this won't slow down the build.
63 $(shell $(goma_ctl) ensure_start &> /dev/null &)
64
65 goma_cc :=
66 goma_ctl :=
67 goma_dir :=
68endif