srcdir='.'
blddir='output'

import os
 
def configure(conf):
    conf.check_tool('tex')
    conf.find_program('pygmentize')
    conf.find_program('dia')
    conf.env.PDFLATEXFLAGS = ['-shell-escape']

def build(bld):
    def dia(src, tgt, layers=None):
        ls = ''
        if layers:
            ls = ' --show-layers=%s' % layers

        return bld(source='diagrams' + os.sep + src + '.dia',
                   target='diagrams' + os.sep + tgt + '.eps',
            rule='dia ${SRC}' + ls + ' --export=${TGT}')

    dia('konfiguracja-model-lab-mapping', 'konfiguracja-model', 'model')
    dia('konfiguracja-model-lab-mapping', 'konfiguracja-laboratory', 'laboratory')
    dia('konfiguracja-model-lab-mapping', 'konfiguracja-mapping', 'model,laboratory,mapping')

    dia('reference-config', 'reference-config-model', 'model')
    dia('reference-config', 'reference-config-laboratory', 'laboratory')
    dia('reference-config', 'reference-config-schedule', 'schedule')

    dia('arete-master-arch', 'arete-master-arch')
    dia('arete-master-db', 'arete-master-db', 'db')

    dia('arete-master-controller-frontend-sequence', 'arete-master-controller-frontend-sequence')

    dia('arete-slave-arch', 'arete-slave-arch', 'arch')
    dia('arete-slave-db', 'arete-slave-db', 'db')

    dia('arete-arch', 'arete-arch', 'arch')
    dia('arete-deploy', 'arete-deploy', 'deploy')

    dia('arete-test-sequence', 'arete-test-sequence-deploy', 'deploy')
    dia('arete-test-sequence', 'arete-test-sequence-test', 'test')
    dia('arete-test-sequence', 'arete-test-sequence-trigger', 'trigger')
    dia('arete-test-sequence', 'arete-test-sequence-results', 'results')

    dia('arete-trigger', 'arete-nodes', 'nodes')
    dia('arete-trigger', 'arete-triggers', 'nodes,triggers')

    dia('example-01-sequence', 'example-01-sequence', 'seq')
    dia('example-02-sequence', 'example-02-sequence', 'seq')
    dia('example-03-sequence', 'example-03-sequence', 'seq')

    # i don't know how to copy those files to the build directory without this (-in) suffix
    bld(source='diagrams' + os.sep + 'intro-omnet-network-in.png', target='diagrams' + os.sep + 'intro-omnet-network.png', rule='cp ${SRC} ${TGT}')
    bld(source='diagrams' + os.sep + 'intro-omnet-histogram-in.png', target='diagrams' + os.sep + 'intro-omnet-histogram.png', rule='cp ${SRC} ${TGT}')
    bld(source='diagrams' + os.sep + '435_simpsons_under_construction.JPG', target='diagrams' + os.sep + 'under-construction.jpg', rule='cp ${SRC} ${TGT}')
    bld(source='diagrams' + os.sep + 'agh_znk_wbr_cmyk.eps', target='diagrams' + os.sep + 'agh-logo.eps', rule='cp ${SRC} ${TGT}')
    bld(source='diagrams' + os.sep + 'tcp-dccp-in.png', target='diagrams' + os.sep + 'tcp-dccp.png', rule='cp ${SRC} ${TGT}')

    bld.add_group()

    bld(features='tex', source='00-praca-magisterska.tex', prompt=0)
    bld(features='tex', source='01-przedmowa.tex', prompt=0)
    bld(features='tex', source='02-testowanie.tex', prompt=0)
    bld(features='tex', source='02-automatyzacja.tex', prompt=0)
    bld(features='tex', source='03-arete.tex', prompt=0)
    bld(features='tex', source='04-arete-master.tex', prompt=0)
    bld(features='tex', source='05-arete-slave.tex', prompt=0)
    bld(features='tex', source='06-przyklady.tex', prompt=0)
    bld(features='tex', source='06-weryfikacja.tex', prompt=0)
    bld(features='tex', source='07-podsumowanie.tex', prompt=0)

# vim: ft=python
