@@ -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,8 +46,12 @@ 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
@@ -55,11 +60,11 @@ function _compile_one_step(target, module, opt)
5560 -- get flags
5661 local module_outputflag = support .get_moduleoutputflag (target )
5762 if module_outputflag then
58- local flags = _make_modulebuildflags (target , module , { bmi = true , objectfile = true } )
63+ local flags = _make_modulebuildflags (target , module , opt )
5964 if opt and opt .batchcmds then
60- _batchcmds_compile (opt .batchcmds , target , flags , module . sourcefile , module . objectfile )
65+ _batchcmds_compile (opt .batchcmds , target , flags , module , opt )
6166 else
62- _compile (target , flags , module . sourcefile , module . objectfile )
67+ _compile (target , flags , module , opt )
6368 end
6469 else
6570 _compile_bmi_step (target , module , opt )
@@ -68,20 +73,20 @@ function _compile_one_step(target, module, opt)
6873end
6974
7075function _compile_bmi_step (target , module , opt )
71- local flags = _make_modulebuildflags (target , module , { bmi = true , objectfile = false } )
76+ local flags = _make_modulebuildflags (target , module , opt )
7277 if opt and opt .batchcmds then
73- _batchcmds_compile (opt .batchcmds , target , flags , module . sourcefile , module . bmifile , opt )
78+ _batchcmds_compile (opt .batchcmds , target , flags , module , opt )
7479 else
75- _compile (target , flags , module . sourcefile , module . bmifile )
80+ _compile (target , flags , module , opt )
7681 end
7782end
7883
7984function _compile_objectfile_step (target , module , opt )
80- local flags = _make_modulebuildflags (target , module , { bmi = false , objectfile = false } )
85+ local flags = _make_modulebuildflags (target , module , opt )
8186 if opt and opt .batchcmds then
82- _batchcmds_compile (opt .batchcmds , target , flags , module . sourcefile , module . objectfile , { bmifile = module . bmifile } )
87+ _batchcmds_compile (opt .batchcmds , target , flags , module , opt )
8388 else
84- _compile (target , flags , module . sourcefile , module . objectfile , { bmifile = module . bmifile } )
89+ _compile (target , flags , module , opt )
8590 end
8691end
8792
@@ -97,34 +102,47 @@ function _make_headerunitflags(target, headerunit)
97102end
98103
99104-- do compile
100- function _compile (target , flags , sourcefile , outputfile , opt )
105+ function _compile (target , flags , module , opt )
106+
101107 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
102110 local dryrun = option .get (" dry-run" )
103111 local compinst = target :compiler (" cxx" )
104112 local compflags = compinst :compflags ({sourcefile = sourcefile , target = target , sourcekind = " cxx" })
105113 flags = table .join (compflags or {}, flags or {})
106-
107- local bmifile = opt and opt .bmifile
108-
109114 -- trace
115+ local cmd
110116 if option .get (" verbose" ) then
111- 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 })
112118 end
119+ show_progress (target , module , table .join (opt , {cmd = cmd }))
113120
114121 -- do compile
115122 if not dryrun then
116- assert (compinst :compile (bmifile or sourcefile , outputfile , {target = target , compflags = flags }))
123+ assert (compinst :compile (sourcefile , outputfile , {target = target , compflags = flags }))
117124 end
118125end
119126
120127-- do compile for batchcmds
121128-- @note we need to use batchcmds:compilev to translate paths in compflags for generator, e.g. -Ixx
122- function _batchcmds_compile (batchcmds , target , flags , sourcefile , outputfile , opt )
129+ function _batchcmds_compile (batchcmds , target , flags , module , opt )
123130 opt = opt or {}
131+ local sourcefile = module .sourcefile
132+ local outputfile = (opt .bmi and not opt .objectfile ) and module .bmifile or module .objectfile
124133 local compinst = target :compiler (" cxx" )
125134 local compflags = compinst :compflags ({sourcefile = sourcefile , target = target , sourcekind = " cxx" })
126- flags = table .join (" -c" , compflags or {}, flags or {}, {" -o" , outputfile , opt .bmifile or sourcefile })
127- 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 })
128146end
129147
130148-- get module requires flags
@@ -224,15 +242,12 @@ function make_module_job(target, module, opt)
224242 end
225243
226244 if bmi and objectfile then
227- progress .show (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s" , target :fullname (), module .name )
228- _compile_one_step (target , module )
245+ _compile_one_step (target , module , opt )
229246 elseif bmi then
230- progress .show (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.bmi.$(mode) %s" , target :fullname (), module .name )
231- _compile_bmi_step (target , module )
247+ _compile_bmi_step (target , module , opt )
232248 else
233249 if support .has_module_extension (module .sourcefile ) or module .interface or module .implementation then
234- progress .show (opt .progress , " compiling.$(mode) %s" , module .sourcefile )
235- _compile_objectfile_step (target , module )
250+ _compile_objectfile_step (target , module , opt )
236251 else
237252 os .tryrm (module .objectfile ) -- force rebuild for .cpp files
238253 end
@@ -258,15 +273,12 @@ function make_module_buildcmds(target, batchcmds, module, opt)
258273 end
259274
260275 if bmi and objectfile then
261- batchcmds :show_progress (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s" , target :fullname (), module .name )
262- _compile_one_step (target , module , {batchcmds = batchcmds })
276+ _compile_one_step (target , module , table .join (opt , {batchcmds = batchcmds }))
263277 elseif bmi then
264- batchcmds :show_progress (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.module.bmi.$(mode) %s" , target :fullname (), module .name )
265- _compile_bmi_step (target , module , {batchcmds = batchcmds })
278+ _compile_bmi_step (target , module , table .join (opt , {batchcmds = batchcmds }))
266279 else
267280 if support .has_module_extension (module .sourcefile ) or module .interface or module .implementation then
268- batchcmds :show_progress (opt .progress , " compiling.$(mode) %s" , module .sourcefile )
269- _compile_objectfile_step (target , module , {batchcmds = batchcmds })
281+ _compile_objectfile_step (target , module , table .join (opt , {batchcmds = batchcmds }))
270282 else
271283 batchcmds :rm (module .objectfile ) -- force rebuild for .cpp files
272284 end
280292function make_headerunit_job (target , headerunit , opt )
281293 local build = should_build (target , headerunit )
282294 if build then
283- local name = headerunit .unique and path .filename (headerunit .name ) or headerunit .name
284- progress .show (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s" , target :fullname (), name )
285- _compile (target , _make_headerunitflags (target , headerunit ), headerunit .sourcefile , headerunit .bmifile )
295+ _compile (target , _make_headerunitflags (target , headerunit ), headerunit , table .join (opt , {headerunit = true }))
286296 end
287297end
288298
@@ -294,9 +304,7 @@ function make_headerunit_buildcmds(target, batchcmds, headerunit, opt)
294304
295305 local build = should_build (target , headerunit )
296306 if build then
297- local name = headerunit .unique and path .filename (headerunit .name ) or headerunit .name
298- batchcmds :show_progress (opt .progress , " ${color.build.target}<%s> ${clear}${color.build.object}compiling.headerunit.$(mode) %s" , target :fullname (), name )
299- _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 }))
300308 batchcmds :add_depfiles (headerunit .sourcefile )
301309 end
302310 batchcmds :add_depvalues (depvalues )
0 commit comments