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 formatid = LUATEXFORMATID,
82 functionality = LUATEXFUNCTIONALITY,
83 }
84 io.savedata(luvname,table.serialize(luvdata,true))
85 lua.registerinitexfinalizer(function()
86 if jit then
87 logs.report("format banner","%s lua: %s jit",banner,LUAVERSION)
88 else
89 logs.report("format banner","%s lua: %s",banner,LUAVERSION)
90 end
91 logs.newline()
92 end, "show banner")
93 end
94end
95
96
97
98
99
100function statistics.checkfmtstatus(texname)
101 local enginebanner = status.banner
102 if enginebanner and texname then
103 local luvname = file.replacesuffix(texname,"luv")
104 if lfs.isfile(luvname) then
105 local luv = dofile(luvname)
106 if luv and luv.sourcefile then
107 local sourcehash = md5.hex(io.loaddata(findfile(luv.sourcefile)) or "unknown")
108 local luvbanner = luv.enginebanner or "?"
109 if luvbanner ~= enginebanner then
110 return format("engine mismatch (luv: %s <> bin: %s)",luvbanner,enginebanner)
111 end
112 local luvhash = luv.sourcehash or "?"
113 if luvhash ~= sourcehash then
114 return format("source mismatch (luv: %s <> bin: %s)",luvhash,sourcehash)
115 end
116 local luvluaversion = luv.luaversion or 0
117 local engluaversion = LUAVERSION or 0
118 if luvluaversion ~= engluaversion then
119 return format("lua mismatch (luv: %s <> bin: %s)",luvluaversion,engluaversion)
120 end
121 local luvfunctionality = luv.functionality or 0
122 local engfunctionality = status.development_id or 0
123 if luvfunctionality ~= engfunctionality then
124 return format("functionality mismatch (luv: %s <> bin: %s)",luvfunctionality,engfunctionality)
125 end
126 local luvformatid = luv.formatid or 0
127 local engformatid = status.format_id or 0
128 if luvformatid ~= engformatid then
129 return format("formatid mismatch (luv: %s <> bin: %s)",luvformatid,engformatid)
130 end
131 else
132 return "invalid status file"
133 end
134 else
135 return "missing status file"
136 end
137 end
138 return true
139end
140 |