-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
161 lines (131 loc) · 4.61 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# encoding: utf-8
require_relative '../nastroje/rakefile_common'
task :all => [:kompletar, :zaltar, :nedele, :triduum]
task :default => [:all]
RUBY_COMMAND = 'ruby'
PSALM_PREPROCESSOR = 'pslm.rb'
#PSALM_PREPROCESSOR = File.join Dir.pwd, '..', 'nastroje', 'psalmpreprocessor.rb'
def genzalm(zalm, options="", adresar='generovane/')
wd = Dir.pwd
syrovy = wd+"/zalmy/"+zalm
peceny = adresar+zalm.gsub(/\.zalm/, '')+'.tex'
file peceny => [syrovy, adresar] do
if options.is_a? Array then
sh PSALM_PREPROCESSOR, *options, syrovy
else
sh "#{PSALM_PREPROCESSOR} --output #{peceny} #{options} #{syrovy}"
end
sh "vlna #{peceny}"
end
return peceny
end
def genspojenyzalm(zdroje, vysledek, options='', adresar='generovane/')
wd = Dir.pwd
syrove = zdroje.map {|zalm| wd+"/zalmy/"+zalm }
peceny = adresar+vysledek
add_options = [
"--output #{peceny}",
"--join"
]
file peceny => syrove do
if options.is_a? Array then
sh PSALM_PREPROCESSOR, *(options + add_options + syrove)
else
sh "#{PSALM_PREPROCESSOR} #{options} #{add_options.join(' ')} #{syrove.join ' '}"
end
sh "vlna #{peceny}"
end
return peceny
end
task "test_lilypondbook_version" do
v = `lilypond-book --version`.rstrip
if v !~ /^2\.19/ then
STDERR.puts
STDERR.puts "!!! Expect problems. Compilation of notated parts of the antiphonal tested only with lilypond-book 2.19.x !!! [#{v} found]"
STDERR.puts
else
puts "LilyPond version [#{v}] OK."
end
end
def no_ext(fname)
fname[0 .. fname.rindex('.')-1]
end
def swap_ext(fname, newext)
no_ext(fname) + '.' + newext
end
# generates all necessary tasks to compile a booklet using Typographus
def typographus(main, latex='pdflatex', biblatex=false, &blk)
outdir = File.join 'vystup', File.basename(main).sub(/\.tytex$/, '')
#typographus = "#{LYV_CMD} tex"
typographus = File.join('..', 'nastroje', 'typographus.rb')
main_b = File.basename(main)
lytex = swap_ext main_b, 'lytex'
tex = File.join(outdir, swap_ext(main_b, 'tex'))
final = File.join(outdir, swap_ext(main_b, 'pdf'))
wd = Dir.pwd
file lytex => [main, 'spolecne_antifonar.ly', '../nastroje/typographus.rb'] + Dir['../nastroje/lib/typographus/*.rb'] do
ruby typographus, main
sh "vlna #{lytex}"
end
file final => [lytex, 'spolecne.tex'] do
FileUtils.mkdir_p outdir
sh "lilypond-book --left-padding=0 --output=#{outdir} --pdf #{lytex}"
latex_commands = {
'pdflatex' => "pdflatex -shell-escape #{File.basename(tex)}",
'xelatex' => "xelatex -output-driver=\"xdvipdfmx -q -E\" #{File.basename(tex)}"
}
chdir outdir
2.times { sh latex_commands[latex] }
if biblatex || blk then
if biblatex
cp '../../bibliografie_admc.bib', '.'
sh 'biber', no_ext(File.basename(tex))
end
# block can be used to insert a piece of functionality -
# like customized generation of bibliography/indices/... -
# before latex is re-run for the last time
blk&.call
sh latex_commands[latex]
end
chdir wd
end
return final
end
Rake::Task["test_lilypondbook_version"].execute
def dir_task(dir)
file dir do
FileUtils.mkdir_p dir
end
end
# directory expected to exist by all the older tasks
FileUtils.mkdir_p 'vystup'
##############
# promenne pouzivane vice ulohami - argumenty pro program psalmpreprocessor.rb
$o_canticletitle = " --pretitle \"kantikum\\\\\\\\ \""
$o_doxology = " --output-append \" \\doxologieZkratka\""
$o_doxology_full = ' --append "' + File.read('zalmy/doxologie.zalm') + '"'
$o_warnmarks = ' --mark-short-verses'
$commonoptions_withoutdoxology = "--lettrine --dashes --no-paragraph --guillemets"
$commonoptions = $commonoptions_withoutdoxology+$o_doxology
$canticleoptions = $commonoptions+$o_canticletitle
# prikaz pouzivany ke zpracovani vsech extrahovanych not pro
# nedelni antifonar.
# na konec se pouze pripoji (pripadne dalsi volby a) jmeno souboru ke zpracovani.
$splitscores_command = "#{RUBY_COMMAND} -I ../nastroje "+
"../nastroje/splitscores.rb "+
"--prepend-text '\\include \"../../spolecne_antifonar.ly\"\n \\include \"../../../dilyresponsorii.ly\"' "+
"--remove-headers "+
"--mode-info "+
"--ids "
desc "Delete LilyPond-Book's stored snippets"
task :snipclean do
cd 'vystup'
sh 'rm -rf tmp*'
sh 'rm -rf snippet*'
Dir['*'].each {|f| sh "rm -rf #{f}" if f.size == 2 }
cd '..'
end
require './rakefile_uplne.rb'
require './rakefile_vyberova.rb'
require './rakefile_zaltare.rb'
require './rakefile_mimorady.rb'