blob: 2fb37a752505ea2ae97f4588431771527d8176fa [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
Dan Willemsenc4f595e2016-09-08 12:45:15 -070017# Used by the compiler wrapper, but should only be set by gomacc
18unexport GOMACC_PATH
19
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090020# Notice: this works only with Google's Goma build infrastructure.
Shinichiro Hamajid78cba12015-12-18 15:26:17 +090021ifneq ($(filter-out false,$(USE_GOMA)),)
Shinichiro Hamajib601d4b2015-08-29 11:58:47 +090022 # Goma requires a lot of processes and file descriptors.
23 ifeq ($(shell echo $$(($$(ulimit -u) < 2500 || $$(ulimit -n) < 16000))),1)
24 $(warning Max user processes and/or open files are insufficient)
25 ifeq ($(shell uname),Darwin)
26 $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android to relax the limit)
27 else
28 $(error Adjust the limit by ulimit -u and ulimit -n)
29 endif
30 endif
31
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090032 ifdef GOMA_DIR
33 goma_dir := $(GOMA_DIR)
34 else
35 goma_dir := $(HOME)/goma
36 endif
37 goma_ctl := $(goma_dir)/goma_ctl.py
Shinichiro Hamaji09295a82015-09-24 17:51:20 +090038 GOMA_CC := $(goma_dir)/gomacc
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090039
40 $(if $(wildcard $(goma_ctl)),, \
41 $(warning You should have goma in $$GOMA_DIR or $(HOME)/goma) \
42 $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android for detail))
43
44 # Append gomacc to existing *_WRAPPER variables so it's possible to
45 # use both ccache and gomacc.
Shinichiro Hamaji09295a82015-09-24 17:51:20 +090046 CC_WRAPPER := $(strip $(CC_WRAPPER) $(GOMA_CC))
47 CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(GOMA_CC))
Yoshisato Yanagisawa4f3e5682017-06-05 18:08:36 +090048 JAVAC_WRAPPER := $(strip $(JAVAC_WRAPPER) $(GOMA_CC))
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090049
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090050 # gomacc can start goma client's daemon process automatically, but
51 # it is safer and faster to start up it beforehand. We run this as a
52 # background process so this won't slow down the build.
Yoshisato Yanagisawaa2ca2702016-09-13 12:53:08 +090053 ifndef NOSTART_GOMA
54 $(shell ( $(goma_ctl) ensure_start ) &> /dev/null &)
55 endif
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090056
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +090057 goma_ctl :=
58 goma_dir :=
59endif