| Home | Trees | Indices | Help |
|
|---|
|
|
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2006-2008 (ita)
4
5 "Gnome support"
6
7 import os, re
8 import TaskGen, Utils, Runner, Task, Build, Options, Logs
9 import cc
10 from Logs import error
11 from TaskGen import taskgen, before, after, feature
12
13 n1_regexp = re.compile('<refentrytitle>(.*)</refentrytitle>', re.M)
14 n2_regexp = re.compile('<manvolnum>(.*)</manvolnum>', re.M)
17 if Options.commands['install']:
18 dir = Build.bld.get_install_path('${PREFIX}/etc/gconf/schemas/%s.schemas' % prog_name)
19 if not Options.options.destdir:
20 # add the gconf schema
21 Utils.pprint('YELLOW', 'Installing GConf schema')
22 command = 'gconftool-2 --install-schema-file=%s 1> /dev/null' % dir
23 ret = Runner.exec_command(command)
24 else:
25 Utils.pprint('YELLOW', 'GConf schema not installed. After install, run this:')
26 Utils.pprint('YELLOW', 'gconftool-2 --install-schema-file=%s' % dir)
27
29 dir = Build.bld.get_install_path('${DATADIR}/icons/hicolor')
30 if Options.commands['install']:
31 if not Options.options.destdir:
32 # update the pixmap cache directory
33 Utils.pprint('YELLOW', "Updating Gtk icon cache.")
34 command = 'gtk-update-icon-cache -q -f -t %s' % dir
35 ret = Runner.exec_command(command)
36 else:
37 Utils.pprint('YELLOW', 'Icon cache not updated. After install, run this:')
38 Utils.pprint('YELLOW', 'gtk-update-icon-cache -q -f -t %s' % dir)
39
41 if Options.commands['install']:
42 # now the scrollkeeper update if we can write to the log file
43 if os.path.iswriteable('/var/log/scrollkeeper.log'):
44 dir1 = Build.bld.get_install_path('${PREFIX}/var/scrollkeeper')
45 dir2 = Build.bld.get_install_path('${DATADIR}/omf/%s' % prog_name)
46 command = 'scrollkeeper-update -q -p %s -o %s' % (dir1, dir2)
47 ret = Runner.exec_command(command)
48
50 if schemas: postinstall_schemas(prog_name)
51 if icons: postinstall_icons()
52 if scrollkeeper: postinstall_scrollkeeper(prog_name)
53
58
60 self.env['APPNAME'] = self.doc_module
61 lst = self.to_list(self.doc_linguas)
62 for x in lst:
63 tsk = self.create_task('xml2po')
64 node = self.path.find_resource(x+'/'+x+'.po')
65 src = self.path.find_resource('C/%s.xml' % self.doc_module)
66 out = self.path.find_or_declare('%s/%s.xml' % (x, self.doc_module))
67 tsk.set_inputs([node, src])
68 tsk.set_outputs(out)
69
70 tsk2 = self.create_task('xsltproc2po')
71 out2 = self.path.find_or_declare('%s/%s-%s.omf' % (x, self.doc_module, x))
72 tsk2.set_outputs(out2)
73 node = self.path.find_resource(self.doc_module+".omf.in")
74 tsk2.inputs = [node, out]
75
76 tsk2.run_after.append(tsk)
77
78
79 if Options.is_install:
80 path = self.install_path + 'gnome/help/%s/%s' % (self.doc_module, x)
81 Build.bld.install_files(self.install_path + 'omf', out2.abspath(self.env))
82 for y in self.to_list(self.doc_figures):
83 try:
84 os.stat(self.path.abspath() + '/' + x + '/' + y)
85 Common.install_as(path + '/' + y, self.path.abspath() + '/' + x + '/' + y)
86 except:
87 Common.install_as(path + '/' + y, self.path.abspath() + '/C/' + y)
88 Common.install_as(path + '/%s.xml' % self.doc_module, out.abspath(self.env))
89
93 TaskGen.task_gen(self)
94 self.source = 'xmlfile'
95 self.xslt = 'xlsltfile'
96 self.target = 'hey'
97 self.default_install_path = '${PREFIX}'
98 self.task_created = None
99
101 self.env = self.env.copy()
102 tree = Build.bld
103 xmlfile = self.path.find_resource(self.source)
104 xsltfile = self.path.find_resource(self.xslt)
105 tsk = self.create_task('xmlto')
106 tsk.set_inputs([xmlfile, xsltfile])
107 tsk.set_outputs(xmlfile.change_ext('html'))
108 tsk.install_path = self.install_path
109
111 node = self.inputs[0]
112
113 env = self.env
114 variant = node.variant(env)
115
116 fi = open(node.abspath(env), 'r')
117 content = fi.read()
118 fi.close()
119
120 # we should use a sgml parser :-/
121 name = n1_regexp.findall(content)[0]
122 num = n2_regexp.findall(content)[0]
123
124 doc_name = name+'.'+num
125 return ([], [doc_name])
126
128 "override the Task method, see the Task.py"
129
130 def sgml_outputs():
131 dps = Build.bld.raw_deps[self.unique_id()]
132 name = dps[0]
133 self.set_outputs(self.task_generator.path.find_or_declare(name))
134
135 tree = Build.bld
136
137 # get the task signatures from previous runs
138 key = self.unique_id()
139 prev_sigs = tree.task_sigs.get(key, ())
140 if prev_sigs and prev_sigs[2] == self.compute_sig_implicit_deps():
141 sgml_outputs()
142 return prev_sigs[2]
143
144 # no previous run or the signature of the dependencies has changed, rescan the dependencies
145 (nodes, names) = self.scan()
146 if Logs.verbose and Logs.zones:
147 debug('deps: scanner for %s returned %s %s' % (str(self), str(nodes), str(names)))
148
149 # store the dependencies in the cache
150 tree = Build.bld
151 tree.node_deps[self.unique_id()] = nodes
152 tree.raw_deps[self.unique_id()] = names
153 sgml_outputs()
154
155 # recompute the signature and return it
156 sig = self.compute_sig_implicit_deps()
157
158 return sig
159
162 TaskGen.task_gen.__init__(self)
163 self.tasks = []
164 self.appname = k[0] # the first argument is the appname - will disappear
166
167 def install_result(task):
168 out = task.outputs[0]
169 name = out.name
170 ext = name[-1]
171 env = task.env
172 Build.bld.install_files('DATADIR', 'man/man%s/' % ext, out.abspath(env), env)
173
174 tree = Build.bld
175 tree.rescan(self.path)
176 for name in Build.bld.cache_dir_contents[self.path.id]:
177 base, ext = os.path.splitext(name)
178 if ext != '.sgml': continue
179
180 task = self.create_task('sgml2man')
181 task.set_inputs(self.path.find_resource(name))
182 task.task_generator = self
183 if Options.is_install: task.install = install_result
184 # no outputs, the scanner does it
185 # no caching for now, this is not a time-critical feature
186 # in the future the scanner can be used to do more things (find dependencies, etc)
187 task.scan()
188
189 # Unlike the sgml and doc processing, the dbus and marshal beast
190 # generate c/c++ code that we want to mix
191 # here we attach new methods to TaskGen.task_gen
192
193 @taskgen
194 -def add_marshal_file(self, filename, prefix, mode):
195 if not hasattr(self, 'marshal_lst'): self.marshal_lst = []
196 self.meths.add('process_marshal')
197 self.marshal_lst.append([filename, prefix, mode])
198
202 for i in getattr(self, 'marshal_lst', []):
203 env = self.env.copy()
204 node = self.path.find_resource(i[0])
205
206 if not node:
207 raise Utils.WafError('file not found on gnome obj '+i[0])
208
209 if i[2] == '--header':
210
211 env['GGM_PREFIX'] = i[1]
212 env['GGM_MODE'] = i[2]
213
214 task = self.create_task('glib_genmarshal', env)
215 task.set_inputs(node)
216 task.set_outputs(node.change_ext('.h'))
217
218 elif i[2] == '--body':
219 env['GGM_PREFIX'] = i[1]
220 env['GGM_MODE'] = i[2]
221
222 # the c file generated will be processed too
223 outnode = node.change_ext('.c')
224 self.allnodes.append(outnode)
225
226 task = self.create_task('glib_genmarshal', env)
227 task.set_inputs(node)
228 task.set_outputs(node.change_ext('.c'))
229 else:
230 error("unknown type for marshal "+i[2])
231
237