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