blob: 982160b1d6d7ab0f92d4351877666284cfaf5fac [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.
Shinichiro Hamajid78cba12015-12-18 15:26:17 +090018ifneq ($(filter-out false,$(USE_GOMA)),)
Shinichiro Hamajib601d4b2015-08-29 11:58:47 +090019 # Goma requires a lot of processes and file descriptors.
20 ifeq ($(shell echo $$(($$(ulimit -u) < 2500 || $$(ulimit -n) < 16000))),1)
21 $(warning Max user processes and/or open files are insufficient)
22 ifeq ($(shell uname),Darwin)
23 $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android to relax the limit)
24 else
25 $(error Adjust the limit by ulimit -u and ulimit -n)
26 endif
27 endif
28
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090029 ifdef GOMA_DIR
30 goma_dir := $(GOMA_DIR)
31 else
32 goma_dir := $(HOME)/goma
33 endif
34 goma_ctl := $(goma_dir)/goma_ctl.py
Shinichiro Hamaji09295a82015-09-24 17:51:20 +090035 GOMA_CC := $(goma_dir)/gomacc
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090036
37 $(if $(wildcard $(goma_ctl)),, \
38 $(warning You should have goma in $$GOMA_DIR or $(HOME)/goma) \
39 $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android for detail))
40
41 # Append gomacc to existing *_WRAPPER variables so it's possible to
42 # use both ccache and gomacc.
Shinichiro Hamaji09295a82015-09-24 17:51:20 +090043 CC_WRAPPER := $(strip $(CC_WRAPPER) $(GOMA_CC))
44 CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(GOMA_CC))
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090045
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090046 # gomacc can start goma client's daemon process automatically, but
47 # it is safer and faster to start up it beforehand. We run this as a
48 # background process so this won't slow down the build.
Shinichiro Hamaji21a18b72015-11-13 15:02:46 +090049 # We use "ensure_start" command when the compiler_proxy is already
50 # running and uses GOMA_HERMETIC=error flag. The compiler_proxy will
51 # restart otherwise.
52 # TODO(hamaji): Remove this condition after http://b/25676777 is fixed.
53 $(shell ( if ( curl http://localhost:$$($(GOMA_CC) port)/flagz | grep GOMA_HERMETIC=error ); then cmd=ensure_start; else cmd=restart; fi; GOMA_HERMETIC=error $(goma_ctl) $${cmd} ) &> /dev/null &)
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090054
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090055 goma_ctl :=
56 goma_dir :=
57endif