1396
|
1 |
require 'rake/clean'
|
|
2 |
|
|
3 |
def dia_path_to_pdf_path(diaFile)
|
|
4 |
diaFile.pathmap("%{^#{DIADIR},#{FIGURESDIR}}X#{PDFEXT}")
|
|
5 |
end
|
|
6 |
|
|
7 |
PROJECT = 'libjava-esug12'
|
|
8 |
|
|
9 |
DIADIR = 'dia'
|
|
10 |
FIGURESDIR = 'figures'
|
|
11 |
|
|
12 |
PDFLATEX = 'pdflatex'
|
|
13 |
DIA = 'dia'
|
|
14 |
EPSTOPDF = 'epstopdf'
|
|
15 |
PDFVIEWER = 'evince'
|
|
16 |
SPELLCHECKPROG = 'aspell -t check'
|
|
17 |
BIBTEX = 'bibtex'
|
|
18 |
|
|
19 |
DIAEXT = '.dia'
|
|
20 |
EPSEXT = '.eps'
|
|
21 |
PDFEXT = '.pdf'
|
|
22 |
BBLFILE = "#{PROJECT}.bbl"
|
|
23 |
AUXFILE = "#{PROJECT}.aux"
|
|
24 |
PDFFILE = "#{PROJECT}.pdf"
|
|
25 |
DIAFIGURES = FileList['dia/*.dia']
|
|
26 |
TEXFILES = FileList['*.tex']
|
|
27 |
BIBFILES = FileList['*.bib']
|
|
28 |
CONVERTEDDIA = FileList.new.include(DIAFIGURES.collect {|each| dia_path_to_pdf_path(each)})
|
|
29 |
|
|
30 |
CLEAN.include(['*.log','*.aux','*.bbl','*.blg','*.lof'])
|
|
31 |
CLEAN.include(['*.dvi','*.toc','*.out','*.ps', '*.lot'])
|
|
32 |
CLEAN.include(['*.lol'])
|
|
33 |
CLEAN.include(CONVERTEDDIA)
|
|
34 |
CLOBBER.include("#{PROJECT}.pdf")
|
|
35 |
|
|
36 |
task :default => [:pdf]
|
|
37 |
|
|
38 |
desc "export images, compile bibtex files, generate pdf"
|
|
39 |
task :all => [:dia, :pdf, :bib ]
|
|
40 |
|
|
41 |
desc "generate pdf from #{PROJECT}.tex"
|
|
42 |
task :pdf => ["#{PROJECT}.pdf"]
|
|
43 |
|
|
44 |
file AUXFILE => (TEXFILES + CONVERTEDDIA) do
|
|
45 |
build_pdf
|
|
46 |
end
|
|
47 |
|
|
48 |
file BBLFILE => ([ AUXFILE ] + BIBFILES) do
|
|
49 |
build_bib
|
|
50 |
end
|
|
51 |
|
|
52 |
file "#{PROJECT}.pdf" => [ AUXFILE, BBLFILE ] + TEXFILES + CONVERTEDDIA do
|
|
53 |
build_pdf
|
|
54 |
build_pdf
|
|
55 |
build_pdf #I'm not sure if its needed, but at least I'm sure index is built completely
|
|
56 |
end
|
|
57 |
|
|
58 |
desc "export dia figures from #{DIADIR}/* to #{FIGURESDIR}/ as #{EPSEXT}"
|
|
59 |
task :dia => CONVERTEDDIA
|
|
60 |
|
|
61 |
DIAFIGURES.each do |each|
|
|
62 |
file dia_path_to_pdf_path(each) => [each] do
|
|
63 |
build_dia each
|
|
64 |
end
|
|
65 |
end
|
|
66 |
|
|
67 |
desc "compile bibtex files"
|
|
68 |
task :bib do
|
|
69 |
build_pdf
|
|
70 |
build_bib
|
|
71 |
build_pdf
|
|
72 |
build_pdf
|
|
73 |
end
|
|
74 |
|
|
75 |
desc "generate pdf and show it"
|
|
76 |
task :view => [:pdf] do
|
|
77 |
sh "#{PDFVIEWER} #{PROJECT}.pdf > /dev/null 2>&1 &"
|
|
78 |
end
|
|
79 |
|
|
80 |
desc "check spelling"
|
|
81 |
task :spellcheck do
|
|
82 |
spellcheck()
|
|
83 |
end
|
|
84 |
|
|
85 |
def build_dia(diaFile)
|
|
86 |
epsFile = diaFile.ext(EPSEXT)
|
|
87 |
pdfFile = diaFile.pathmap("%{^#{DIADIR},#{FIGURESDIR}}X#{PDFEXT}")
|
|
88 |
sh "#{DIA} #{diaFile} -e #{epsFile}"
|
|
89 |
sh "#{EPSTOPDF} #{epsFile} --outfile=\"#{pdfFile}\""
|
|
90 |
rm epsFile
|
|
91 |
end
|
|
92 |
|
|
93 |
def build_pdf()
|
|
94 |
sh "#{PDFLATEX} #{PROJECT}"
|
|
95 |
end
|
|
96 |
|
|
97 |
def build_bib()
|
|
98 |
#hackety hack - mtime granularity in ruby(or linux & ruby) is second
|
|
99 |
puts 'sleeping for 2 seconds, because I\'m lazy'
|
|
100 |
sleep 2
|
|
101 |
sh "#{BIBTEX} #{PROJECT}"
|
|
102 |
end
|
|
103 |
|
|
104 |
def spellcheck()
|
|
105 |
TEXFILES.each do
|
|
106 |
|each|
|
|
107 |
sh "#{SPELLCHECKPROG} #{each}"
|
|
108 |
end
|
|
109 |
end
|