goma.mk revision c1cba699701da30049fac564fe53c8448d19e9bd
1#
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
28  # 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
38  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  # gomacc can start goma client's daemon process automatically, but
56  # it is safer and faster to start up it beforehand. We run this as a
57  # background process so this won't slow down the build.
58  $(shell $(goma_ctl) ensure_start &> /dev/null &)
59
60  goma_cc :=
61  goma_ctl :=
62  goma_dir :=
63endif
64