9999
100100-- provide toolchain include dir for stl headerunit when p1689 is not supported
101101function toolchain_includedirs (target )
102-
103102 for _ , toolchain_inst in ipairs (target :toolchains ()) do
104103 if toolchain_inst :name () == " msvc" then
105104 local vcvars = toolchain_inst :config (" vcvars" )
@@ -117,22 +116,27 @@ function has_two_phase_compilation_support(_)
117116end
118117
119118-- build c++23 standard modules if needed
120- function get_stdmodules (target )
121-
122- if target :policy (" build.c++.modules.std" ) then
123- local msvc = target :toolchain (" msvc" )
124- if msvc then
125- local vcvars = msvc :config (" vcvars" )
126- if vcvars .VCInstallDir and vcvars .VCToolsVersion then
127- modules = {}
128-
129- local stdmodulesdir = path .join (vcvars .VCInstallDir , " Tools" , " MSVC" , vcvars .VCToolsVersion , " modules" )
130-
131- if os .isdir (stdmodulesdir ) then
132- return {path .normalize (path .join (stdmodulesdir , " std.ixx" )), path .normalize (path .join (stdmodulesdir , " std.compat.ixx" ))}
133- end
119+ function get_stdmodules (target , opt )
120+ opt = opt or {}
121+ if not target :policy (" build.c++.modules.std" ) then
122+ return
123+ end
124+ local msvc
125+ if opt .toolchain then
126+ msvc = import (" core.tool.toolchain" , {anonymous = true }).load (" msvc" , {plat = opt .toolchain :plat (), arch = opt .toolchain :arch ()})
127+ else
128+ msvc = target :toolchain (" msvc" )
129+ end
130+ if msvc and msvc :check () then
131+ local vcvars = msvc :config (" vcvars" )
132+ if vcvars .VCInstallDir and vcvars .VCToolsVersion then
133+ local stdmodulesdir = path .join (vcvars .VCInstallDir , " Tools" , " MSVC" , vcvars .VCToolsVersion , " modules" )
134+ if os .isdir (stdmodulesdir ) then
135+ return {path .normalize (path .join (stdmodulesdir , " std.ixx" )), path .normalize (path .join (stdmodulesdir , " std.compat.ixx" ))}
134136 end
135137 end
138+ end
139+ if not opt .dont_warn then
136140 wprint (" std and std.compat modules not found! disabling them for the build" )
137141 end
138142end
@@ -142,7 +146,6 @@ function get_bmi_extension()
142146end
143147
144148function get_ifcoutputflag (target )
145-
146149 local ifcoutputflag = _g .ifcoutputflag
147150 if ifcoutputflag == nil then
148151 local compinst = target :compiler (" cxx" )
@@ -156,7 +159,6 @@ function get_ifcoutputflag(target)
156159end
157160
158161function get_ifconlyflag (target )
159-
160162 local ifconlyflag = _g .ifconlyflag
161163 if ifconlyflag == nil then
162164 local compinst = target :compiler (" cxx" )
@@ -169,7 +171,6 @@ function get_ifconlyflag(target)
169171end
170172
171173function get_interfaceflag (target )
172-
173174 local interfaceflag = _g .interfaceflag
174175 if interfaceflag == nil then
175176 local compinst = target :compiler (" cxx" )
@@ -183,7 +184,6 @@ function get_interfaceflag(target)
183184end
184185
185186function get_referenceflag (target )
186-
187187 local referenceflag = _g .referenceflag
188188 if referenceflag == nil then
189189 local compinst = target :compiler (" cxx" )
@@ -197,7 +197,6 @@ function get_referenceflag(target)
197197end
198198
199199function get_headernameflag (target )
200-
201200 local headernameflag = _g .headernameflag
202201 if headernameflag == nil then
203202 local compinst = target :compiler (" cxx" )
@@ -211,7 +210,6 @@ function get_headernameflag(target)
211210end
212211
213212function get_headerunitflag (target )
214-
215213 local headerunitflag = _g .headerunitflag
216214 if headerunitflag == nil then
217215 local compinst = target :compiler (" cxx" )
@@ -226,7 +224,6 @@ function get_headerunitflag(target)
226224end
227225
228226function get_exportheaderflag (target )
229-
230227 local exportheaderflag = _g .exportheaderflag
231228 if exportheaderflag == nil then
232229 if get_headernameflag (target ) then
@@ -238,7 +235,6 @@ function get_exportheaderflag(target)
238235end
239236
240237function get_scandependenciesflag (target )
241-
242238 local scandependenciesflag = _g .scandependenciesflag
243239 if scandependenciesflag == nil then
244240 local compinst = target :compiler (" cxx" )
@@ -261,7 +257,6 @@ function get_scandependenciesflag(target)
261257end
262258
263259function get_cppversionflag (target )
264-
265260 local cppversionflag = _g .cppversionflag
266261 if cppversionflag == nil then
267262 local compinst = target :compiler (" cxx" )
@@ -272,7 +267,6 @@ function get_cppversionflag(target)
272267end
273268
274269function get_internalpartitionflag (target )
275-
276270 local internalpartitionflag = _g .internalpartitionflag
277271 if internalpartitionflag == nil then
278272 local compinst = target :compiler (" cxx" )
0 commit comments