File: Makefile

package info (click to toggle)
android-platform-build 1%3A8.1.0%2Br23-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,620 kB
  • sloc: python: 12,074; cpp: 6,068; cs: 5,512; makefile: 2,356; sh: 1,829; java: 1,359; ansic: 987
file content (93 lines) | stat: -rw-r--r-- 3,704 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Copyright 2015 Google Inc. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Find source file location from path to this Makefile
MAKEPARALLEL_SRC_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
ifndef MAKEPARALLEL_SRC_PATH
  MAKEPARALLEL_SRC_PATH := .
endif

# Set defaults if they weren't set by the including Makefile
MAKEPARALLEL_CXX ?= $(CXX)
MAKEPARALLEL_LD ?= $(CXX)
MAKEPARALLEL_INTERMEDIATES_PATH ?= .
MAKEPARALLEL_BIN_PATH ?= .

MAKEPARALLEL_CXX_SRCS := \
	makeparallel.cpp

MAKEPARALLEL_CXXFLAGS := -Wall -Werror -MMD -MP

MAKEPARALLEL_CXX_SRCS := $(addprefix $(MAKEPARALLEL_SRC_PATH)/,\
	$(MAKEPARALLEL_CXX_SRCS))

MAKEPARALLEL_CXX_OBJS := $(patsubst $(MAKEPARALLEL_SRC_PATH)/%.cpp,$(MAKEPARALLEL_INTERMEDIATES_PATH)/%.o,$(MAKEPARALLEL_CXX_SRCS))

MAKEPARALLEL := $(MAKEPARALLEL_BIN_PATH)/makeparallel

ifeq ($(shell uname),Linux)
MAKEPARALLEL_LIBS := -lrt -lpthread
endif

# Rule to build makeparallel into MAKEPARALLEL_BIN_PATH
$(MAKEPARALLEL): $(MAKEPARALLEL_CXX_OBJS)
	@mkdir -p $(dir $@)
	$(MAKEPARALLEL_LD) -std=c++11 $(MAKEPARALLEL_CXXFLAGS) -o $@ $^ $(MAKEPARALLEL_LIBS)

# Rule to build source files into object files in MAKEPARALLEL_INTERMEDIATES_PATH
$(MAKEPARALLEL_CXX_OBJS): $(MAKEPARALLEL_INTERMEDIATES_PATH)/%.o: $(MAKEPARALLEL_SRC_PATH)/%.cpp
	@mkdir -p $(dir $@)
	$(MAKEPARALLEL_CXX) -c -std=c++11 $(MAKEPARALLEL_CXXFLAGS) -o $@ $<

makeparallel_clean:
	rm -rf $(MAKEPARALLEL)
	rm -rf $(MAKEPARALLEL_INTERMEDIATES_PATH)/*.o
	rm -rf $(MAKEPARALLEL_INTERMEDIATES_PATH)/*.d

.PHONY: makeparallel_clean

-include $(MAKEPARALLEL_INTERMEDIATES_PATH)/*.d

.PHONY: makeparallel_test
MAKEPARALLEL_TEST := MAKEFLAGS= MAKELEVEL= MAKEPARALLEL=$(MAKEPARALLEL) $(MAKE) -f Makefile.test test
MAKEPARALLEL_NINJA_TEST := MAKEFLAGS= MAKELEVEL= MAKEPARALLEL="$(MAKEPARALLEL) --ninja" $(MAKE) -f Makefile.test test
makeparallel_test: $(MAKEPARALLEL)
	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -j1234
	@EXPECTED="-j123"  $(MAKEPARALLEL_TEST) -j123
	@EXPECTED=""       $(MAKEPARALLEL_TEST) -j1
	@EXPECTED="-j$$(($$(nproc) + 2))"   $(MAKEPARALLEL_TEST) -j
	@EXPECTED=""       $(MAKEPARALLEL_TEST)

	@EXPECTED="-j1234" $(MAKEPARALLEL_NINJA_TEST) -j1234
	@EXPECTED="-j123"  $(MAKEPARALLEL_NINJA_TEST) -j123
	@EXPECTED="-j1"    $(MAKEPARALLEL_NINJA_TEST) -j1
	@EXPECTED="-j1"    $(MAKEPARALLEL_NINJA_TEST)
	@EXPECTED=""       $(MAKEPARALLEL_NINJA_TEST) -j
	@EXPECTED=""       $(MAKEPARALLEL_NINJA_TEST) -j -l

	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) --no-print-directory -j1234
	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) --no-print-directory -k -j1234
	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -k -j1234
	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -j1234 -k
	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -kt -j1234

	@EXPECTED="-j1234"     $(MAKEPARALLEL_NINJA_TEST) --no-print-directory -j1234
	@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) --no-print-directory -k -j1234
	@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -k -j1234
	@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -j1234 -k
	@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -kt -j1234

	@EXPECTED=""       $(MAKEPARALLEL_TEST) A=-j1234

	@EXPECTED="-j1234 args" ARGS="args" $(MAKEPARALLEL_TEST) -j1234