blob: 55138f20d3718f3a98080bd0bf2e1df2d00394ca (
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# Rules for Jamfile.jam
if ( $(toolset:I=^mingw) )
{
if ( $(configuration) = "debug" )
{
CCFLAGS += -D_DEBUG ;
}
else
{
CCFLAGS += -DNDEBUG -O3 ;
}
actions ObjectAction
{
%$(toolset)_PATH%\bin\gcc -W -Wall -Wextra -Werror -pedantic -c $(>) -o $(<) $(CCFLAGS)
}
actions LibraryAction
{
%$(toolset)_PATH%\bin\ar rc $(<) $(>)
}
actions LinkAction
{
%$(toolset)_PATH%\bin\g++ $(>) -o $(<) $(LDFLAGS)
}
actions CoverageAction
{
%$(toolset)_PATH%\bin\gcov $(>:\\) $(GCOVFLAGS) | perl tests/gcov-filter.pl
}
}
else if ( $(toolset:I^=msvc) )
{
if ( $(configuration) = "debug" )
{
CCFLAGS += /D_DEBUG /MTd ;
}
else
{
CCFLAGS += /DNDEBUG /Ox /MT ;
}
if ( $(toolset) != msvc6 )
{
CCFLAGS += /Wp64 /W4 ;
}
else
{
CCFLAGS += /W3 ; # lots of warnings at W4 in standard library
}
actions ObjectAction
{
%$(toolset)_PATH%\bin\cl.exe /EHsc /WX /I%$(toolset)_PATH%\include /c $(>) /Fo$(<) /nologo $(CCFLAGS)
}
actions LibraryAction
{
%$(toolset)_PATH%\bin\lib.exe /NOLOGO /OUT:$(<) $(>)
}
actions LinkAction
{
%$(toolset)_PATH%\bin\link.exe /SUBSYSTEM:CONSOLE /NOLOGO /OUT:$(<) $(>) /LIBPATH:%$(toolset)_PATH%\lib /LIBPATH:%$(toolset)_PATH%\PlatformSDK\lib $(LDFLAGS)
}
actions CoverageAction
{
}
}
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) ;
}
|