Bug 1684463 - [devtools] Part 1: Shorten the _createAttribute function by refactoring...
[gecko.git] / client.mk
blob95b61418dd12b7e1be61c9646a62118c3c4678cf
1 # -*- makefile -*-
2 # vim:set ts=8 sw=8 sts=8 noet:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Defines main targets for driving the Firefox build system.
9 # This make file should not be invoked directly. Instead, use
10 # `mach` (likely `mach build`) for invoking the build system.
12 # Options:
13 # MOZ_OBJDIR - Destination object directory
14 # MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
16 #######################################################################
17 # Defines
19 ifdef MACH
20 ifndef NO_BUILDSTATUS_MESSAGES
21 define BUILDSTATUS
22 @echo 'BUILDSTATUS $1'
24 endef
25 endif
26 endif
29 CWD := $(CURDIR)
31 ifeq "$(CWD)" "/"
32 CWD := /.
33 endif
35 PYTHON3 ?= python3
37 ####################################
38 # Load mozconfig Options
40 include $(OBJDIR)/.mozconfig-client-mk
42 ifdef MOZ_PARALLEL_BUILD
43 MOZ_MAKE_FLAGS := $(filter-out -j%,$(MOZ_MAKE_FLAGS))
44 MOZ_MAKE_FLAGS += -j$(MOZ_PARALLEL_BUILD)
45 endif
47 # Automatically add -jN to make flags if not defined. N defaults to number of cores.
48 ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS)))
49 cores=$(shell $(PYTHON3) -c 'import multiprocessing; print(multiprocessing.cpu_count())')
50 MOZ_MAKE_FLAGS += -j$(cores)
51 endif
53 ifdef MOZ_AUTOMATION
54 ifeq (4.0,$(firstword $(sort 4.0 $(MAKE_VERSION))))
55 MOZ_MAKE_FLAGS += --output-sync=line
56 endif
57 endif
59 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
61 #######################################################################
62 # Rules
64 # The default rule is build
65 build::
67 ifndef MACH
68 $(error client.mk must be used via `mach`. Try running \
69 `./mach $(firstword $(MAKECMDGOALS) $(.DEFAULT_GOAL))`)
70 endif
72 # In automation, manage an sccache daemon. The starting of the server
73 # needs to be in a make file so sccache inherits the jobserver.
74 ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
75 build::
76 # Terminate any sccache server that might still be around.
77 -$(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server > /dev/null 2>&1
78 # Start a new server, ensuring it gets the jobserver file descriptors
79 # from make (but don't use the + prefix when make -n is used, so that
80 # the command doesn't run in that case)
81 mkdir -p $(UPLOAD_PATH)
82 $(if $(findstring n,$(filter-out --%, $(MAKEFLAGS))),,+)env SCCACHE_LOG=sccache=debug SCCACHE_ERROR_LOG=$(UPLOAD_PATH)/sccache.log $(MOZBUILD_MANAGE_SCCACHE_DAEMON) --start-server
83 endif
85 ####################################
86 # Build it
88 build::
89 +$(MOZ_MAKE)
91 ifdef MOZ_AUTOMATION
92 build::
93 +$(MOZ_MAKE) automation/build
94 endif
96 # This makefile doesn't support parallel execution. It does pass
97 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
98 # in parallel.
99 .NOTPARALLEL:
101 .PHONY: \
102 build