1if not modules then modules = { } end modules ['data-use'] = {
2 version = 1.001,
3 comment = "companion to luat-lib.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local format = string.format
10
11local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
12
13local report_mounts = logs.reporter("resolvers","mounts")
14
15local resolvers = resolvers
16local findfile = resolvers.findfile
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66statistics.register("used config file", function() return caches.configfiles() end)
67statistics.register("used cache path", function() return caches.usedpaths() end)
68
69
70
71function statistics.savefmtstatus(texname,formatbanner,sourcefile,banner)
72 local enginebanner = status.banner
73 if formatbanner and enginebanner and sourcefile then
74 local luvname = file.replacesuffix(texname,"luv")
75 local luvdata = {
76 enginebanner = enginebanner,
77 formatbanner = formatbanner,
78 sourcehash = md5.hex(io.loaddata(findfile(sourcefile)) or "unknown"),
79 sourcefile = sourcefile,
80 luaversion = LUAVERSION,
81 luaformat = LUAFORMAT or 0,
82 formatid = LUATEXFORMATID,
83 functionality = LUATEXFUNCTIONALITY,
84 }
85 io.savedata(luvname,table.serialize(luvdata,true))
86 lua.registerinitexfinalizer(function()
87 if jit then
88 logs.report("format banner","%s lua: %s jit",banner,LUAVERSION)
89 else
90 logs.report("format banner","%s lua: %s, format: %s",banner,LUAVERSION,LUAFORMAT)
91 end
92 logs.newline()
93 end, "show banner")
94 end
95end
96
97
98
99
100
101function statistics.checkfmtstatus(texname)
102 local enginebanner = status.banner
103 if enginebanner and texname then
104 local luvname = file.replacesuffix(texname,"luv")
105 if lfs.isfile(luvname) then
106 local luv = dofile(luvname)
107 if luv and luv.sourcefile then
108 local sourcehash = md5.hex(io.loaddata(findfile(luv.sourcefile)) or "unknown")
109 local luvbanner = luv.enginebanner or "?"
110 if luvbanner ~= enginebanner then
111 return format("engine mismatch (luv: %s <> bin: %s)",luvbanner,enginebanner)
112 end
113 local luvhash = luv.sourcehash or "?"
114 if luvhash ~= sourcehash then
115 return format("source mismatch (luv: %s <> bin: %s)",luvhash,sourcehash)
116 end
117 local luvluaversion = luv.luaversion or 0
118 local engluaversion = LUAVERSION or 0
119 if luvluaversion ~= engluaversion then
120 return format("lua mismatch (luv: %s <> bin: %s)",luvluaversion,engluaversion)
121 end
122
123 local luvluaformat = luv.luaformat or 0
124 local engluaformat = LUAFORMAT or 0
125 if luvluaformat ~= engluaformat then
126 return format("lua bytecode format mismatch (luv: %s <> bin: %s)",luvluaformat,engluaformat)
127 end
128
129 local luvfunctionality = luv.functionality or 0
130 local engfunctionality = status.development_id or 0
131 if luvfunctionality ~= engfunctionality then
132 return format("functionality mismatch (luv: %s <> bin: %s)",luvfunctionality,engfunctionality)
133 end
134 local luvformatid = luv.formatid or 0
135 local engformatid = status.format_id or 0
136 if luvformatid ~= engformatid then
137 return format("formatid mismatch (luv: %s <> bin: %s)",luvformatid,engformatid)
138 end
139 else
140 return "invalid status file"
141 end
142 else
143 return "missing status file"
144 end
145 end
146 return true
147end
148 |