blob: 4fda7f40cdfce5c05ce1d7c8a5b49063fb8606e9 (
plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# Rules for Jamfile.jam
actions ObjectAction
{
%MINGW_PATH%\bin\gcc -W -Wall -Wextra -Werror -pedantic -c $(>) -o $(<) $(CCFLAGS)
}
actions LibraryAction
{
%MINGW_PATH%\bin\ar rc $(<) $(>)
}
actions LinkAction
{
%MINGW_PATH%\bin\g++ $(>) -o $(<) $(LDFLAGS)
}
actions CoverageAction
{
%MINGW_PATH%\bin\gcov $(>:\\) $(GCOVFLAGS) | perl tests/gcov-filter.pl
}
actions RunAction
{
$(>:\\)
}
actions quietly ignore MakeDirAction
{
mkdir $(<:\\) >nul 2>&1
}
actions quietly ignore DeleteAction
{
del /F $(>:\\) >nul 2>&1
}
rule MakeFileDir TARGET
{
local DIR = $(TARGET:D) ;
MakeDirAction $(DIR) ;
Needs $(TARGET) : $(DIR) ;
}
rule Alias TARGET : SOURCE
{
NotFile $(TARGET) ;
Always $(TARGET) ;
Depends $(TARGET) : $(SOURCE) ;
}
rule Object TARGET : SOURCE
{
HDRRULE on $(SOURCE) = C.HdrRule ;
HDRSCAN on $(SOURCE) = $(C.HDRPATTERN) ;
MakeFileDir $(TARGET) ;
ObjectAction $(TARGET) : $(SOURCE) ;
Depends $(TARGET) : $(SOURCE) ;
}
rule Objects SOURCES
{
local OBJECTS ;
for SOURCE in $(SOURCES)
{
local OBJECT = $(BUILD)/$(SOURCE:S=.o) ;
Object $(OBJECT) : $(SOURCE) ;
OBJECTS += $(OBJECT) ;
}
return $(OBJECTS) ;
}
rule Library TARGET : SOURCES
{
# build object files
local OBJECTS = [ Objects $(SOURCES) ] ;
# build library
local LIBRARY = $(BUILD)/$(TARGET).a ;
MakeFileDir $(LIBRARY) ;
LibraryAction $(LIBRARY) : $(OBJECTS) ;
Depends $(LIBRARY) : $(OBJECTS) ;
# make alias
Alias $(TARGET) : $(LIBRARY) ;
# remember library path for linking
$(TARGET)_path = $(LIBRARY) ;
# remember library objects for coverage
$(TARGET)_objects = $(OBJECTS) ;
}
rule Application TARGET : SOURCES : LIBRARIES
{
# build object files
local OBJECTS = [ Objects $(SOURCES) ] ;
# get binary path
local EXECUTABLE = $(BUILD)/$(TARGET).exe ;
# set libraries
LDFLAGS on $(EXECUTABLE) = $(LDFLAGS) $($(LIBRARIES)_path) ;
# build application
MakeFileDir $(EXECUTABLE) ;
LinkAction $(EXECUTABLE) : $(OBJECTS) ;
Depends $(EXECUTABLE) : $(OBJECTS) $($(LIBRARIES)_path) ;
# make alias
Alias $(TARGET) : $(EXECUTABLE) ;
# remember executable path for running
$(TARGET)_path = $(EXECUTABLE) ;
# remember executable objects for coverage
$(TARGET)_objects = $(OBJECTS) $($(LIBRARIES)_objects) ;
}
rule CleanCoverage TARGET
{
# make target
local CLEAN_TARGET = $(TARGET)_clean_coverage ;
NotFile $(CLEAN_TARGET) ;
Always $(CLEAN_TARGET) ;
Depends $(TARGET) : $(CLEAN_TARGET) ;
# clean object files
local FILES = $($(SOURCE)_objects:S=.gcda) ;
DeleteAction $(CLEAN_TARGET) : $(FILES) ;
}
rule Test TARGET : SOURCE
{
# make alias
Alias $(TARGET) : $(SOURCE) ;
# run tests
RunAction $(TARGET) : $($(SOURCE)_path) ;
# remember executable objects for coverage
$(TARGET)_objects = $($(SOURCE)_objects) ;
# clean coverage files before run
CleanCoverage $(TARGET) ;
}
rule Coverage TARGET : SOURCE
{
local FILES = $($(SOURCE)_objects:S=.gcda) ;
# disable "independent target" warnings
NotFile $(FILES) ;
CoverageAction $(TARGET) : $(FILES) ;
Depends $(TARGET) : $(SOURCE) ;
}
|