@@ -188,10 +188,14 @@ local function compileSingleMetaDoc(uri, script, metaLang, status)
188
188
if not suc then
189
189
log .debug (' MiddleScript:\n ' , middleScript )
190
190
end
191
+ local text = table.concat (compileBuf )
191
192
if disable and status == ' default' then
192
- return nil
193
+ return text , false
194
+ end
195
+ if status == ' disable' then
196
+ return text , false
193
197
end
194
- return table.concat ( compileBuf )
198
+ return text , true
195
199
end
196
200
197
201
local function loadMetaLocale (langID , result )
@@ -222,11 +226,8 @@ local function initBuiltIn(uri)
222
226
loadMetaLocale (langID , metaLang )
223
227
end
224
228
225
- if scp :get (' metaPath' ) == metaPath :string () then
226
- log .debug (' Has meta path, skip:' , metaPath :string ())
227
- return
228
- end
229
- scp :set (' metaPath' , metaPath :string ())
229
+ local metaPaths = {}
230
+ scp :set (' metaPaths' , metaPaths )
230
231
local suc = xpcall (function ()
231
232
if not fs .exists (metaPath ) then
232
233
fs .create_directories (metaPath )
@@ -241,13 +242,10 @@ local function initBuiltIn(uri)
241
242
for libName , status in pairs (define .BuiltIn ) do
242
243
status = config .get (uri , ' Lua.runtime.builtin' )[libName ] or status
243
244
log .debug (' Builtin status:' , libName , status )
244
- if status == ' disable' then
245
- goto CONTINUE
246
- end
247
245
248
246
--- @type fs.path
249
247
local libPath = templateDir / (libName .. ' .lua' )
250
- local metaDoc = compileSingleMetaDoc (uri , fsu .loadFile (libPath ), metaLang , status )
248
+ local metaDoc , include = compileSingleMetaDoc (uri , fsu .loadFile (libPath ), metaLang , status )
251
249
if metaDoc then
252
250
metaDoc = encoder .encode (encoding , metaDoc , ' auto' )
253
251
@@ -258,13 +256,17 @@ local function initBuiltIn(uri)
258
256
259
257
local ok , err = out :saveFile (outputLibName , metaDoc )
260
258
if not ok then
261
- log .debug (" Save Meta File:" , err )
259
+ log .debug (" Save Meta File Failed :" , err )
262
260
goto CONTINUE
263
261
end
264
262
265
263
local outputPath = metaPath / outputLibName
266
264
m .metaPaths [outputPath :string ()] = true
267
265
log .debug (' Meta path:' , outputPath :string ())
266
+
267
+ if include then
268
+ metaPaths [# metaPaths + 1 ] = outputPath :string ()
269
+ end
268
270
end
269
271
:: CONTINUE::
270
272
end
0 commit comments