Import('env') # Find all of the sections in the file def parse_guide(source): data = open(source).read() sections = [] for entry in data.split('(*'): if not entry: continue meta = entry.split('*)')[0] name = meta.split('*')[0] section = name.split('.')[0].replace(' ', '_') if not section in sections: sections.append(section) return sections # Find out what files are going to be created def guide_emitter(target, source, env): target_fmt = str(target[0]).replace('.html', '_%s.html') sections = parse_guide(str(source[0])) target.extend(map(lambda s: target_fmt % s, sections)) return target, source # Define a generator and set up the builder def guide_generator(source, target, env, for_signature): return 'python python/guide2html.py %s %s' % (source[0], target[0]) bld = Builder(generator = guide_generator, suffix = '.html', emitter = guide_emitter) env.Append(BUILDERS = {'GenGuide': bld}) # Build the guide guide = env.GenGuide('guide', 'guide.dat.txt') # Set up the installation actions installfiles = [] installfiles.append(env.Install('${PREFIX}/share/tunnelhack/doc', guide)) import glob images = glob.glob('img/*.png') installfiles.append(env.Install('${PREFIX}/share/tunnelhack/doc/img', images)) portraits = glob.glob('img/portraits/*.png') installfiles.append(env.Install('${PREFIX}/share/tunnelhack/doc/img/potraits', portraits)) # Pass the actions back to the SConstruct Return('installfiles')