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 | |
| 17 | # Notice: this works only with Google's Goma build infrastructure. |
| 18 | ifneq ($(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 | ifdef GOMA_DIR |
| 29 | goma_dir := $(GOMA_DIR) |
| 30 | else |
| 31 | goma_dir := $(HOME)/goma |
| 32 | endif |
| 33 | goma_ctl := $(goma_dir)/goma_ctl.py |
| 34 | goma_cc := $(goma_dir)/gomacc |
| 35 | |
| 36 | $(if $(wildcard $(goma_ctl)),, \ |
| 37 | $(warning You should have goma in $$GOMA_DIR or $(HOME)/goma) \ |
| 38 | $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android for detail)) |
| 39 | |
| 40 | # Append gomacc to existing *_WRAPPER variables so it's possible to |
| 41 | # use both ccache and gomacc. |
| 42 | CC_WRAPPER := $(strip $(CC_WRAPPER) $(goma_cc)) |
| 43 | CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(goma_cc)) |
| 44 | |
| 45 | # Ninja file generated by kati uses this for remote jobs (i.e., |
| 46 | # commands which contain gomacc). Note the parallelism of all other |
| 47 | # jobs will be limited the number of cores. |
| 48 | KATI_REMOTE_NUM_JOBS_FLAG := --remote_num_jobs=500 |
| 49 | |
| 50 | # 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. |
| 53 | $(shell $(goma_ctl) ensure_start &> /dev/null &) |
| 54 | |
| 55 | goma_cc := |
| 56 | goma_ctl := |
| 57 | goma_dir := |
| 58 | endif |