@@ -188,10 +188,14 @@ local function compileSingleMetaDoc(uri, script, metaLang, status)
188188 if not suc then
189189 log .debug (' MiddleScript:\n ' , middleScript )
190190 end
191+ local text = table.concat (compileBuf )
191192 if disable and status == ' default' then
192- return nil
193+ return text , false
194+ end
195+ if status == ' disable' then
196+ return text , false
193197 end
194- return table.concat ( compileBuf )
198+ return text , true
195199end
196200
197201local function loadMetaLocale (langID , result )
@@ -222,11 +226,8 @@ local function initBuiltIn(uri)
222226 loadMetaLocale (langID , metaLang )
223227 end
224228
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 )
230231 local suc = xpcall (function ()
231232 if not fs .exists (metaPath ) then
232233 fs .create_directories (metaPath )
@@ -241,13 +242,10 @@ local function initBuiltIn(uri)
241242 for libName , status in pairs (define .BuiltIn ) do
242243 status = config .get (uri , ' Lua.runtime.builtin' )[libName ] or status
243244 log .debug (' Builtin status:' , libName , status )
244- if status == ' disable' then
245- goto CONTINUE
246- end
247245
248246 --- @type fs.path
249247 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 )
251249 if metaDoc then
252250 metaDoc = encoder .encode (encoding , metaDoc , ' auto' )
253251
@@ -258,13 +256,17 @@ local function initBuiltIn(uri)
258256
259257 local ok , err = out :saveFile (outputLibName , metaDoc )
260258 if not ok then
261- log .debug (" Save Meta File:" , err )
259+ log .debug (" Save Meta File Failed :" , err )
262260 goto CONTINUE
263261 end
264262
265263 local outputPath = metaPath / outputLibName
266264 m .metaPaths [outputPath :string ()] = true
267265 log .debug (' Meta path:' , outputPath :string ())
266+
267+ if include then
268+ metaPaths [# metaPaths + 1 ] = outputPath :string ()
269+ end
268270 end
269271 :: CONTINUE::
270272 end
0 commit comments