@@ -31,14 +31,30 @@ import("support")
31
31
import (" .mapper" )
32
32
import (" .builder" , {inherit = true })
33
33
34
+ function _get_bmifile (target , module )
35
+ local has_reduced_bmi = support .get_modulesreducedbmiflag (target )
36
+ local has_two_phases = target :policy (" build.c++.modules.two_phases" )
37
+ local add_reduced_flag = not has_two_phases and has_reduced_bmi
38
+ local bmifile = module .bmifile
39
+
40
+ if has_two_phases and add_reduced_flag then
41
+ bmifile = path .join (path .directory (module .bmifile ), " reduced." .. path .filename (module .bmifile ))
42
+ end
43
+
44
+ return bmifile , add_reduced_flag
45
+ end
46
+
34
47
function _make_modulebuildflags (target , module , opt )
35
48
assert (not module .headerunit )
49
+
50
+ local modules_reduced_bmi_flag = support .get_modulesreducedbmiflag (target )
51
+ local has_two_phases = target :policy (" build.c++.modules.two_phases" )
36
52
local flags
37
- local two_phases = target :policy (" build.c++.modules.two_phases" )
38
53
if opt .bmi then
39
54
local module_outputflag = support .get_moduleoutputflag (target )
40
55
41
56
flags = {" -x" , " c++-module" }
57
+
42
58
if not opt .objectfile then
43
59
table.insert (flags , " --precompile" )
44
60
if target :has_tool (" cxx" , " clang_cl" ) then
@@ -49,10 +65,18 @@ function _make_modulebuildflags(target, module, opt)
49
65
if std then
50
66
table .join2 (flags , {" -Wno-include-angled-in-module-purview" , " -Wno-reserved-module-identifier" , " -Wno-deprecated-declarations" })
51
67
end
52
- table.insert (flags , module_outputflag .. module .bmifile )
68
+
69
+ local bmifile , add_reduced_flag = _get_bmifile (target , module )
70
+ if add_reduced_flag then
71
+ table.insert (flags , modules_reduced_bmi_flag )
72
+ end
73
+
74
+ if not has_two_phases or add_reduced_flag then
75
+ table.insert (flags , module_outputflag .. bmifile )
76
+ end
53
77
else
54
78
flags = {}
55
- if not two_phases or not module .bmifile then
79
+ if not has_two_phases or not module .bmifile then
56
80
flags = {" -x" , " c++" }
57
81
end
58
82
local std = (module .name == " std" or module .name == " std.compat" )
@@ -200,7 +224,8 @@ function _get_requiresflags(target, module)
200
224
local dep_module = mapper .get (target , required )
201
225
assert (dep_module , " module dependency %s required for %s not found" , required , name )
202
226
203
- local mapflag = dep_module .headerunit and modulefileflag .. dep_module .bmifile or format (" %s%s=%s" , modulefileflag , required , dep_module .bmifile )
227
+ local dep_bmifile , _ = dep .headerunit and dep_module .bmifile or _get_bmifile (target , dep_module )
228
+ local mapflag = dep_module .headerunit and modulefileflag .. dep_bmifile or format (" %s%s=%s" , modulefileflag , required , dep_bmifile )
204
229
table.insert (requiresflags , mapflag )
205
230
206
231
-- append deps
219
244
function _append_requires_flags (target , module )
220
245
local cxxflags = {}
221
246
local requiresflags = _get_requiresflags (target , module )
247
+ local has_two_phases = target :policy (" build.c++.modules.two_phases" )
222
248
local hide_dependencies = target :policy (" build.c++.modules.hide_dependencies" )
223
249
if # requiresflags > 0 then
224
250
for _ , flag in ipairs (requiresflags ) do
0 commit comments