@@ -32,8 +32,9 @@ import(".mapper")
3232import (" .builder" , {inherit = true })
3333
3434function _make_modulebuildflags (target , module , opt )
35+ assert (not module .headerunit )
3536 local flags
36- if opt and opt .bmi then
37+ if opt .bmi then
3738 local module_outputflag = support .get_moduleoutputflag (target )
3839
3940 flags = {" -x" , " c++-module" }
@@ -45,20 +46,25 @@ function _make_modulebuildflags(target, module, opt)
4546 table .join2 (flags , {" -Wno-include-angled-in-module-purview" , " -Wno-reserved-module-identifier" , " -Wno-deprecated-declarations" })
4647 end
4748 table.insert (flags , module_outputflag .. module .bmifile )
48- elseif not module . headerunit and not module . implementation and not module . interface then
49+ else
4950 flags = {" -x" , " c++" }
51+ local std = (module .name == " std" or module .name == " std.compat" )
52+ if std then
53+ table .join2 (flags , {" -Wno-include-angled-in-module-purview" , " -Wno-reserved-module-identifier" , " -Wno-deprecated-declarations" })
54+ end
5055 end
5156 return flags
5257end
5358
5459function _compile_one_step (target , module , opt )
5560 -- get flags
61+ local module_outputflag = support .get_moduleoutputflag (target )
5662 if module_outputflag then
57- local flags = _make_modulebuildflags (target , module , { bmi = true , objectfile = true } )
63+ local flags = _make_modulebuildflags (target , module , opt )
5864 if opt and opt .batchcmds then
59- _batchcmds_compile (opt .batchcmds , target , flags , module . sourcefile , module . objectfile )
65+ _batchcmds_compile (opt .batchcmds , target , flags , module , opt )
6066 else
61- _compile (target , flags , module . sourcefile , module . objectfile )
67+ _compile (target , flags , module , opt )
6268 end
6369 else
6470 _compile_bmi_step (target , module , opt )
@@ -67,20 +73,20 @@ function _compile_one_step(target, module, opt)
6773end
6874
6975function _compile_bmi_step (target , module , opt )
70- local flags = _make_modulebuildflags (target , module , { bmi = true , objectfile = false } )
76+ local flags = _make_modulebuildflags (target , module , opt )
7177 if opt and opt .batchcmds then
72- _batchcmds_compile (opt .batchcmds , target , flags , module . sourcefile , module . bmifile , opt )
78+ _batchcmds_compile (opt .batchcmds , target , flags , module , opt )
7379 else
74- _compile (target , flags , module . sourcefile , module . bmifile )
80+ _compile (target , flags , module , opt )
7581 end
7682end
7783
7884function _compile_objectfile_step (target , module , opt )
79- local flags = _make_modulebuildflags (target , module , { bmi = false , objectfile = false } )
85+ local flags = _make_modulebuildflags (target , module , opt )
8086 if opt and opt .batchcmds then
81- _batchcmds_compile (opt .batchcmds , target , flags , module . sourcefile , module . objectfile , { bmifile = module . bmifile } )
87+ _batchcmds_compile (opt .batchcmds , target , flags , module , opt )
8288 else
83- _compile (target , flags , module . sourcefile , module . objectfile , { bmifile = module . bmifile } )
89+ _compile (target , flags , module , opt )
8490 end
8591end
8692
@@ -96,34 +102,47 @@ function _make_headerunitflags(target, headerunit)
96102end
97103
98104-- do compile
99- function _compile (target , flags , sourcefile , outputfile , opt )
105+ function _compile (target , flags , module , opt )
106+
100107 opt = opt or {}
108+ local sourcefile = module .sourcefile
109+ local outputfile = ((opt .bmi and not opt .objectfile ) or opt .headerunit ) and module .bmifile or module .objectfile
101110 local dryrun = option .get (" dry-run" )
102111 local compinst = target :compiler (" cxx" )
103112 local compflags = compinst :compflags ({sourcefile = sourcefile , target = target , sourcekind = " cxx" })
104- flags = table .join (flags or {}, compflags or {})
105-
106- local bmifile = opt and opt .bmifile
107-
113+ flags = table .join (compflags or {}, flags or {})
108114 -- trace
115+ local cmd
109116 if option .get (" verbose" ) then
110- print ( compinst :compcmd (bmifile or sourcefile , outputfile , {target = target , compflags = flags , sourcekind = " cxx" , rawargs = true }) )
117+ cmd = " \n " .. compinst :compcmd (sourcefile , outputfile , {target = target , compflags = flags , sourcekind = " cxx" , rawargs = true })
111118 end
119+ show_progress (target , module , table .join (opt , {cmd = cmd }))
112120
113121 -- do compile
114122 if not dryrun then
115- assert (compinst :compile (bmifile or sourcefile , outputfile , {target = target , compflags = flags }))
123+ assert (compinst :compile (sourcefile , outputfile , {target = target , compflags = flags }))
116124 end
117125end
118126
119127-- do compile for batchcmds
120128-- @note we need to use batchcmds:compilev to translate paths in compflags for generator, e.g. -Ixx
121- function _batchcmds_compile (batchcmds , target , flags , sourcefile , outputfile , opt )
129+ function _batchcmds_compile (batchcmds , target , flags , module , opt )
122130 opt = opt or {}
131+ local sourcefile = module .sourcefile
132+ local outputfile = (opt .bmi and not opt .objectfile ) and module .bmifile or module .objectfile
123133 local compinst = target :compiler (" cxx" )
124134 local compflags = compinst :compflags ({sourcefile = sourcefile , target = target , sourcekind = " cxx" })
125- flags = table .join (" -c" , compflags or {}, flags , {" -o" , outputfile , opt .bmifile or sourcefile })
126- batchcmds :compilev (flags , {compiler = compinst , sourcekind = " cxx" })
135+ flags = table .join (" -c" , compflags or {}, flags or {}, {" -o" , outputfile , sourcefile })
136+
137+ -- trace
138+ local cmd
139+ if option .get (" verbose" ) then
140+ cmd = " \n " .. compinst :compcmd (sourcefile , outputfile , {target = target , compflags = flags , sourcekind = " cxx" , rawargs = true })
141+ end
142+ show_progress (target , module , table .join (opt , {cmd = cmd , batchcmds = batchcmds }))
143+
144+ -- do compile
145+ batchcmds :compilev (flags , {compiler = compinst , sourcekind = " cxx" , verbose = false })
127146end
128147
129148-- get module requires flags
@@ -223,15 +242,12 @@ function make_module_job(target, module, opt)
223242 end
224243
225244 if bmi and objectfile then
226- progress .show (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s" , target :fullname (), module .name )
227- _compile_one_step (target , module )
245+ _compile_one_step (target , module , opt )
228246 elseif bmi then
229- progress .show (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.bmi.$(mode) %s" , target :fullname (), module .name )
230- _compile_bmi_step (target , module )
247+ _compile_bmi_step (target , module , opt )
231248 else
232249 if support .has_module_extension (module .sourcefile ) or module .interface or module .implementation then
233- progress .show (opt .progress , " compiling.$(mode) %s" , module .sourcefile )
234- _compile_objectfile_step (target , module )
250+ _compile_objectfile_step (target , module , opt )
235251 else
236252 os .tryrm (module .objectfile ) -- force rebuild for .cpp files
237253 end
@@ -257,15 +273,12 @@ function make_module_buildcmds(target, batchcmds, module, opt)
257273 end
258274
259275 if bmi and objectfile then
260- batchcmds :show_progress (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s" , target :fullname (), module .name )
261- _compile_one_step (target , module , {batchcmds = batchcmds })
276+ _compile_one_step (target , module , table .join (opt , {batchcmds = batchcmds }))
262277 elseif bmi then
263- batchcmds :show_progress (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.bmi.$(mode) %s" , target :fullname (), module .name )
264- _compile_bmi_step (target , module , {batchcmds = batchcmds })
278+ _compile_bmi_step (target , module , table .join (opt , {batchcmds = batchcmds }))
265279 else
266280 if support .has_module_extension (module .sourcefile ) or module .interface or module .implementation then
267- batchcmds :show_progress (opt .progress , " compiling.$(mode) %s" , module .sourcefile )
268- _compile_objectfile_step (target , module , {batchcmds = batchcmds })
281+ _compile_objectfile_step (target , module , table .join (opt , {batchcmds = batchcmds }))
269282 else
270283 batchcmds :rm (module .objectfile ) -- force rebuild for .cpp files
271284 end
279292function make_headerunit_job (target , headerunit , opt )
280293 local build = should_build (target , headerunit )
281294 if build then
282- local name = headerunit .unique and path .filename (headerunit .name ) or headerunit .name
283- progress .show (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s" , target :fullname (), name )
284- _compile (target , _make_headerunitflags (target , headerunit ), headerunit .sourcefile , headerunit .bmifile )
295+ _compile (target , _make_headerunitflags (target , headerunit ), headerunit , table .join (opt , {headerunit = true }))
285296 end
286297end
287298
@@ -293,9 +304,7 @@ function make_headerunit_buildcmds(target, batchcmds, headerunit, opt)
293304
294305 local build = should_build (target , headerunit )
295306 if build then
296- local name = headerunit .unique and path .filename (headerunit .name ) or headerunit .name
297- batchcmds :show_progress (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s" , target :fullname (), name )
298- _batchcmds_compile (batchcmds , target , table .join (_make_headerunitflags (target , headerunit )), headerunit .sourcefile , headerunit .bmifile )
307+ _batchcmds_compile (batchcmds , target , table .join (_make_headerunitflags (target , headerunit )), headerunit , table .join (opt , {headerunit = true }))
299308 batchcmds :add_depfiles (headerunit .sourcefile )
300309 end
301310 batchcmds :add_depvalues (depvalues )
0 commit comments