1if not modules then modules = { } end modules [ ' trac-tex ' ] = {
2 version = 1 . 001 ,
3 comment = " companion to trac-deb.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 texhashtokens = tex . hashtokens
10
11local trackers = trackers
12local token = token
13local saved = { }
14local create = token . create
15local undefined = create ( " undefined " ) . command
16
17function trackers . savehash ( )
18 saved = texhashtokens ( )
19 return saved
20end
21
22function trackers . dumphashtofile ( filename , delta )
23 local list = { }
24 local hash = texhashtokens ( )
25 local create = token . create
26 for i = 1 , # hash do
27 local name = hash [ i ]
28 if not delta or not saved [ name ] then
29 local token = create ( name )
30 if token . command ~ = undefined then
31 local category = token . cmdname
32 local dk = list [ category ]
33 if not dk then
34 dk = {
35 names = { } ,
36 found = 0 ,
37
38 }
39 list [ category ] = dk
40 end
41 if token . protected then
42 if token . expandable then
43 dk . names [ name ] = " ep "
44 else
45 dk . names [ name ] = " -p "
46 end
47 else
48 if token . expandable then
49 dk . names [ name ] = " ep "
50 else
51 dk . names [ name ] = " -- "
52 end
53 end
54 dk . found = dk . found + 1
55 end
56 end
57 end
58 table . save ( filename or tex . jobname . . " -hash.log " , list )
59end
60
61local delta = nil
62
63local function dump_hash ( wanteddelta )
64 if delta = = nil then
65 saved = saved or trackers . savehash ( )
66 luatex . registerstopactions ( 1 , function ( ) dump_hash ( nil , wanteddelta ) end )
67 end
68 delta = wanteddelta
69end
70
71directives . register ( " system.dumphash " , function ( ) dump_hash ( false ) end )
72directives . register ( " system.dumpdelta " , function ( ) dump_hash ( true ) end )
73
74local function saveusedfilesintrees ( format )
75 local data = {
76 jobname = environment . jobname or " ? " ,
77 version = environment . version or " ? " ,
78 kind = environment . kind or " ? " ,
79 files = resolvers . foundintrees ( )
80 }
81 local filename = file . replacesuffix ( environment . jobname or " context-job " , ' jlg ' )
82 if format = = " lua " then
83 io . savedata ( filename , table . serialize ( data , true ) )
84 else
85 io . savedata ( filename , table . toxml ( data , " job " ) )
86 end
87end
88
89directives . register ( " system.dumpfiles " , function ( v )
90 luatex . registerstopactions ( function ( ) saveusedfilesintrees ( v ) end )
91end )
92
93 |