-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathRakefile
More file actions
161 lines (142 loc) · 4.93 KB
/
Rakefile
File metadata and controls
161 lines (142 loc) · 4.93 KB
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
require "pathname"
require 'rake/clean'
CLEAN.include("publisher.pdf","publisher.log","publisher.protocol","publisher.vars")
CLOBBER.include("build/sourcedoc","src/go/sp/sp","src/go/sp/docgo", "src/go/sp/bin","src/go/sp/pkg")
installdir = Pathname.new(__FILE__).join("..")
srcdir = installdir.join("src")
builddir = installdir.join("build")
ENV['GOBIN'] = installdir.join("bin").to_s
@versions = {}
File.read("version").each_line do |line|
product,versionnumber = line.chomp.split(/=/) # / <-- ignore this slash
@versions[product]=versionnumber
end
desc "Show rake description"
task :default do
puts
puts "Run 'rake -T' for a list of tasks."
puts
puts "1: Use 'rake build' to build the 'sp' binary. That should be\n the starting point."
puts "2: Then try to build the documentation by running 'rake doc'\n followed by 'sp doc' to read the documentation."
puts
end
desc "Build sphelper program"
task :sphelper do
Dir.chdir(srcdir.join("go")) do
sh "go install -ldflags \"-X main.basedir=#{installdir} -s\" speedatapublisher/sphelper/sphelper"
end
end
desc "Compile and install necessary software"
task :build => [:sphelper] do
sh "#{installdir}/bin/sphelper build"
end
desc "Compile and install helper library"
task :buildlib => [:sphelper] do
sh "#{installdir}/bin/sphelper buildlib"
FileUtils.cp_r("#{builddir}/dylib/.","#{installdir}/lib/")
end
desc "Generate documentation (reference docs and changelog for Hugo)"
task :doc => [:sphelper] do
sh "#{installdir}/bin/sphelper doc"
puts "done"
end
desc "Generate schema from master"
task :schema => [:sphelper] do
# generate the lua translation + schema
sh "#{installdir}/bin/sphelper genschema"
end
desc "Source documentation"
task :sourcedoc => [:sphelper] do
sh "#{installdir}/bin/sphelper sourcedoc"
if RUBY_PLATFORM =~ /darwin/
sh "open #{builddir}/sourcedoc/publisher.html"
else
puts "Generated source documentation in \n#{builddir}/sourcedoc/publisher.html"
end
end
# For now: only a small test
desc "Test source code"
task :test do
ENV["LUA_PATH"] = "#{srcdir}/lua/?.lua;#{installdir}/lib/?.lua;#{installdir}/test/?.lua"
ENV["PUBLISHER_BASE_PATH"] = installdir.to_s
ENV["LD_LIBRARY_PATH"] = "#{installdir}/lib"
inifile = srcdir.join("lua/sdini.lua")
sh "bin/sdluatex --luaonly --lua=#{inifile} --ini --shell-escape #{installdir}/bin/luatest tc_xpath.lua"
end
desc "Run quality assurance"
task :qa do
sh "#{installdir}/bin/sp compare #{installdir}/qa"
end
desc "Clean QA intermediate files"
task :cleanqa do
FileUtils.rm Dir.glob("qa/**/pagediff-*.png")
FileUtils.rm Dir.glob("qa/**/reference-*.png")
FileUtils.rm Dir.glob("qa/**/source-*.png")
FileUtils.rm Dir.glob("qa/**/publisher.vars")
FileUtils.rm Dir.glob("qa/**/publisher.status")
FileUtils.rm Dir.glob("qa/**/publisher.finished")
FileUtils.rm Dir.glob("qa/**/publisher-protocol.xml")
FileUtils.rm Dir.glob("qa/**/publisher-aux.xml")
FileUtils.rm Dir.glob("qa/**/publisher.protocol")
FileUtils.rm Dir.glob("qa/**/publisher.pdf")
FileUtils.rm Dir.glob("qa/**/publisher-struct.xml")
FileUtils.rm Dir.glob("qa/**/compare-report.html")
end
desc "Regenerate reference.pdf for qa"
task :regenerateqa do
Dir.glob("qa/**/") do |d|
Dir.chdir(d) do
if test(?f,"layout.xml") then
puts "=== #{d} ==="
sh "sp -s --jobname reference"
sh "sp --jobname reference clean"
end
end
end
end
# The environment variable LUATEX_BIN must point to a directory with the following structure
# ├── darwin
# │ ├── amd64
# │ └── 386
# ├── linux
# │ ├── amd64
# │ └── 386
# └── windows
# ├── amd64
# └── 386
#
# and each of these amd64/386 directories look like this:
# ├── 0_79_1
# │ ├── kpathsea620w64.dll
# │ ├── lua52w64.dll
# │ ├── luatex.dll
# │ ├── luatex.exe
# │ └── msvcr100.dll
# └── default -> 0_79_1/
#
# The task looks for a directory named "default" and uses the binary files in that directory
desc "Make ZIP files for all platforms and installer for windows"
task :dist => [:sphelper] do
sh "#{installdir}/bin/sphelper dist windows/amd64 linux/amd64 linux/arm64"
end
desc "Create a customized directory strcuture for distribution"
task :distcustom => [:sphelper] do
# This should be taken as a blueprint for creating your own directory
# structure. Instructions: build the sphelper binary,
# then set the environment variables, and run
# sphelper distcutom linux/amd64
# (replace the target of course)
# for building the source tree
ENV['SP_BUILDDIR_SW'] = "/tmp/build/sw"
ENV['SP_BUILDDIR_SHARE'] = "/tmp/build/share"
ENV['SP_BUILDDIR_BIN'] = "/tmp/build/bin"
# lookup paths for the executable
ENV['SP_DESTDIR_SW'] = "/usr/src/speedata-publisher"
ENV['SP_DESTDIR_SHARE'] = "/usr/share"
ENV['SP_DESTDIR_BIN'] = "/usr/bin"
sh "#{installdir}/bin/sphelper distcustom linux/amd64"
end
desc "Show the version number"
task :publisherversion do
puts @versions['publisher_version']
end