Make Core2Core depend on pret-lam.lua.
[matthijs/master-project/report.git] / SConstruct
1 # Based on the Latex SConstruct at
2 # https://gutefee.massey.ac.nz/moin/HOWTO/LaTeX/LaTeX-SCons-Builder
3 #
4 import os
5 import os.path
6
7 #### Some configurations.
8
9 LATEX_PROJECT = 'Core2Core'
10
11 DEFAULT_TARGET = 'pdf'
12
13 GNUPLOT_DIAGRAMS = []
14
15 EPS_FIGURES = []
16
17 PDF_FIGURES = []
18
19 ## Some rather fixed configurations:
20
21 GNUPLOT_DIRECTORY = 'images'
22 GNUPLOT_EXTENSION = '.gnuplot'
23 EPS_DIRECTORY = 'eps'
24 EPS_EXTENSION = '.eps'
25 PDF_DIRECTORY = 'pdf'
26 PDF_EXTENSION = '.pdf'
27
28 #MAKEINDEX_EXTENSIONS = ['.glg', '.glo', '.gls']
29
30
31 #### Defining some new builders.
32 env = Environment()
33
34 ## eps2pdf Builder:
35 pdfBuilder = Builder(action='epstopdf $SOURCE --outfile=$TARGET',
36                      suffix='.pdf',
37                      src_suffix='.eps')
38 env.Append(BUILDERS={'Eps2pdf': pdfBuilder})
39
40 ## eps2eps Builder:
41 epsBuilder = Builder(action='pdftops -eps -level3 $SOURCE $TARGET',
42                      suffix='.eps',
43                      src_suffix='.pdf')
44 env.Append(BUILDERS={'Pdf2eps': epsBuilder})
45
46 ## GNUplot Builder:
47 gnuplotBuilder = Builder(action='gnuplot $SOURCE',
48                          suffix='.eps',
49                          src_suffix='.gnuplot')
50 env.Append(BUILDERS={'Gnuplot': gnuplotBuilder})
51
52 ## Context MkIV Builder:
53 contextBuilder = Builder(action=['texexec --lua $SOURCE','scp $TARGET ewi:'],
54                          suffix='.pdf',
55                          src_suffix='.tex')
56 env.Append(BUILDERS={'Context': contextBuilder})
57
58 # Import tex settings from the user environment
59 env['ENV']['TEXMFCNF'] = os.environ['TEXMFCNF']
60 env['ENV']['HOME'] = os.environ['HOME']
61 # Allow the SSH agent to be used
62 env['ENV']['SSH_AUTH_SOCK'] = os.environ['SSH_AUTH_SOCK']
63
64
65 #### The actual builds.
66
67 ## Context PDF build
68 pdfOutput = env.Context(LATEX_PROJECT)
69 Depends(pdfOutput, 'pret-lam.lua')
70 env.Alias('pdf', LATEX_PROJECT + '.pdf')
71
72 # Keep below code happy
73 dviOutput = pdfOutput
74
75 Default(DEFAULT_TARGET)
76
77 ## Create makeindex file list for dependencies and clean up:
78 #for item in MAKEINDEX_EXTENSIONS:
79 #    fileName = os.path.join(LATEX_PROJECT + item)
80 #    Depends(dviOutput, fileName)
81 #    Depends(pdfOutput, fileName)
82 #    Clean(dviOutput, fileName)
83 #    Clean(pdfOutput, fileName)
84
85 ## Build GNUplot figures:
86 for item in GNUPLOT_DIAGRAMS:
87     gnuplotFile = os.path.join(GNUPLOT_DIRECTORY, item + GNUPLOT_EXTENSION)
88     epsFile = os.path.join(EPS_DIRECTORY, item + EPS_EXTENSION)
89     pdfFile = os.path.join(PDF_DIRECTORY, item + PDF_EXTENSION)
90     
91     env.Gnuplot(epsFile, gnuplotFile)
92     dep = env.Eps2pdf(pdfFile, epsFile)
93     Depends(dep, epsFile)
94     
95     Depends(dviOutput, pdfFile)
96     Depends(pdfOutput, pdfFile)
97     
98 ## Build PDF figures:
99 for item in PDF_FIGURES:
100     epsFile = os.path.join(EPS_DIRECTORY, item + EPS_EXTENSION)
101     pdfFile = os.path.join(PDF_DIRECTORY, item + PDF_EXTENSION)
102
103     env.Pdf2eps(epsFile, pdfFile)
104
105     Depends(dviOutput, epsFile)
106
107 ## Build EPS figures:
108 for item in EPS_FIGURES:
109     epsFile = os.path.join(EPS_DIRECTORY, item + EPS_EXTENSION)
110     pdfFile = os.path.join(PDF_DIRECTORY, item + PDF_EXTENSION)
111     
112     env.Eps2pdf(pdfFile, epsFile)
113
114     Depends(pdfOutput, pdfFile)