-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
107 lines (84 loc) · 2.79 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
# ------------------------------------------------------------------------------
# Rake build script for oslic
# ------------------------------------------------------------------------------
require 'find'
require_relative 'to_oscad/oslic'
require_relative 'to_oscad/yaml_backend'
VERSION_NUMBER = IO.read("rel-number.tex").chomp
PROTECTED_DIRS=%w{license presentations}
AUX_EXTS = %w{url bbl blg aux dvi toc log lof nlo nls ilg ils ent out}
RES_EXTS = %w{ps pdf rtf} + AUX_EXTS
DIR_REGEX = %r{^(\./)?#{PROTECTED_DIRS.join('|')}}
AUX_REGEX = %r{\.(#{AUX_EXTS.join('|')})$}
RES_REGEX = %r{\.(#{RES_EXTS.join('|')})$}
# configuratioin parameters for the OSLiC -> YAML export
DATA_FILE = "oscad.xml"
AUX_FILE = "oslic.aux"
EXPORT_DIR = "to_oscad/oscad_data"
# ------------------------------------------------------------------------------
# Utilities for manipulating file names
# ------------------------------------------------------------------------------
def replace_ext(filename, new_ext)
filename.sub(/#{File.extname(filename)}$/, new_ext)
end
def no_ext(filename)
replace_ext(filename, "")
end
# ------------------------------------------------------------------------------
# Commands used in this file
# ------------------------------------------------------------------------------
def latex(filename)
sh "pdflatex #{no_ext(filename)}"
end
def make_bib_and_index(filename)
index_input = replace_ext(filename, '.nlo')
index_output = replace_ext(filename, '.nls')
sh "bibtex #{no_ext(filename)}"
sh "makeindex #{index_input} -s btexmat/nomencl.ist -o #{index_output}"
end
def fast_build(filename)
basename = no_ext(filename)
latex filename
cp "#{basename}.pdf", "#{basename}-#{VERSION_NUMBER}.pdf"
end
# filename - name of the LaTeX file, w/ or w/o extension
#
def full_build(filename)
latex filename
make_bib_and_index filename
latex filename
latex filename
fast_build filename
end
def remove_files
Find.find(".") do |f|
if yield(f) then
rm f
end
end
end
# ------------------------------------------------------------------------------
# Tasks
# ------------------------------------------------------------------------------
task :clean do
remove_files { |file| not(file =~ DIR_REGEX) && AUX_REGEX =~ file }
end
task :distclean do
remove_files { |file| not(file=~ DIR_REGEX) && RES_REGEX =~ file }
rm "oslic.pdf"
end
task :build do
full_build "oslic"
end
task "oslic.pdf" do
fast_build "oslic"
end
task :export_yaml do
Oslic::FormattedString::renderer(Oslic::HTMLRenderer.new)
YAMLBackend::Generator.new(DATA_FILE, AUX_FILE, EXPORT_DIR).generate
end
# ------------------------------------------------------------------------------
# Local Variables:
# mode: ruby
# End:
# ------------------------------------------------------------------------------