Shinichiro Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 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 | |
Dan Willemsen | c4f595e | 2016-09-08 12:45:15 -0700 | [diff] [blame^] | 17 | # Used by the compiler wrapper, but should only be set by gomacc |
| 18 | unexport GOMACC_PATH |
| 19 | |
Shinichiro Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 20 | # Notice: this works only with Google's Goma build infrastructure. |
Shinichiro Hamaji | d78cba1 | 2015-12-18 15:26:17 +0900 | [diff] [blame] | 21 | ifneq ($(filter-out false,$(USE_GOMA)),) |
Shinichiro Hamaji | b601d4b | 2015-08-29 11:58:47 +0900 | [diff] [blame] | 22 | # 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 Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 32 | 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 Hamaji | 09295a8 | 2015-09-24 17:51:20 +0900 | [diff] [blame] | 38 | GOMA_CC := $(goma_dir)/gomacc |
Shinichiro Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 39 | |
| 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 Hamaji | 09295a8 | 2015-09-24 17:51:20 +0900 | [diff] [blame] | 46 | CC_WRAPPER := $(strip $(CC_WRAPPER) $(GOMA_CC)) |
| 47 | CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(GOMA_CC)) |
Shinichiro Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 48 | |
Shinichiro Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 49 | # gomacc can start goma client's daemon process automatically, but |
| 50 | # it is safer and faster to start up it beforehand. We run this as a |
| 51 | # background process so this won't slow down the build. |
Fang Deng | c0829a5 | 2016-07-19 01:33:04 +0000 | [diff] [blame] | 52 | $(shell ( $(goma_ctl) ensure_start ) &> /dev/null &) |
Shinichiro Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 53 | |
Shinichiro Hamaji | ee482fd | 2015-08-17 17:38:24 +0900 | [diff] [blame] | 54 | goma_ctl := |
| 55 | goma_dir := |
| 56 | endif |