1 # Based on the Latex SConstruct at
2 # https://gutefee.massey.ac.nz/moin/HOWTO/LaTeX/LaTeX-SCons-Builder
7 #### Some configurations.
9 LATEX_PROJECT = 'Core2Core'
11 DEFAULT_TARGET = 'pdf'
19 ## Some rather fixed configurations:
21 GNUPLOT_DIRECTORY = 'images'
22 GNUPLOT_EXTENSION = '.gnuplot'
24 EPS_EXTENSION = '.eps'
26 PDF_EXTENSION = '.pdf'
28 #MAKEINDEX_EXTENSIONS = ['.glg', '.glo', '.gls']
31 #### Defining some new builders.
35 pdfBuilder = Builder(action='epstopdf $SOURCE --outfile=$TARGET',
38 env.Append(BUILDERS={'Eps2pdf': pdfBuilder})
41 epsBuilder = Builder(action='pdftops -eps -level3 $SOURCE $TARGET',
44 env.Append(BUILDERS={'Pdf2eps': epsBuilder})
47 gnuplotBuilder = Builder(action='gnuplot $SOURCE',
49 src_suffix='.gnuplot')
50 env.Append(BUILDERS={'Gnuplot': gnuplotBuilder})
52 ## Context MkIV Builder:
53 contextBuilder = Builder(action=['texexec --lua $SOURCE','scp $TARGET ewi:'],
56 env.Append(BUILDERS={'Context': contextBuilder})
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']
65 #### The actual builds.
68 pdfOutput = env.Context(LATEX_PROJECT)
69 Depends(pdfOutput, 'pret-lam.lua')
70 env.Alias('pdf', LATEX_PROJECT + '.pdf')
72 # Keep below code happy
75 Default(DEFAULT_TARGET)
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)
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)
91 env.Gnuplot(epsFile, gnuplotFile)
92 dep = env.Eps2pdf(pdfFile, epsFile)
95 Depends(dviOutput, pdfFile)
96 Depends(pdfOutput, pdfFile)
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)
103 env.Pdf2eps(epsFile, pdfFile)
105 Depends(dviOutput, epsFile)
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)
112 env.Eps2pdf(pdfFile, epsFile)
114 Depends(pdfOutput, pdfFile)