-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
109 lines (87 loc) · 2.84 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
require 'rake/rdoctask'
require 'rake/clean'
require 'fileutils'
require 'yaml'
include FileUtils
RELEASE_VERSION = '0.3.0-beta2'
OCRA = 'ruby build/ocrasa.rb'
RDOC_DIR = File.join('doc', 'rdoc')
BINARY_DIR = 'bin'
SOURCE_DIR = 'lib'
APP = 'flipped'
APP_EXE = File.join(BINARY_DIR, "#{APP}.exe")
VERSION_FILE = File.join(SOURCE_DIR, APP, 'version.yml')
RELEASE_DIR = File.join("release", "#{APP}_v#{RELEASE_VERSION.gsub(/\./, '_')}")
RELEASE_PACKAGE_7Z = "#{RELEASE_DIR}.7z"
RELEASE_PACKAGE_ZIP = "#{RELEASE_DIR}.zip"
CLOBBER.include FileList[RDOC_DIR], RELEASE_PACKAGE_7Z, RELEASE_PACKAGE_ZIP
CLEAN.include APP_EXE, RELEASE_DIR
namespace :rdoc do
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = RDOC_DIR
rdoc.options << '--line-numbers'
rdoc.rdoc_files.add(%w(*.rdoc doc/*.rdoc lib/**/*.rb))
rdoc.title = 'Flipped - The SiD flip-book tool'
end
end
# Optional if you have rspec installed.
begin
gem 'rspec'
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
end
rescue LoadError
end
namespace :compile do
# ------------------------------------------------------------------------------
desc 'Compile #{APP} executable'
task APP => APP_EXE
prerequisites = FileList["lib/#{APP}.rb*", "lib/#{APP}/**/*.rb", "config/locales/*.yml", "media/icons/*.png"]
file APP_EXE => prerequisites do |t|
create_version_file VERSION_FILE
puts "Creating exe using #{OCRA}"
p "#{OCRA} #{(prerequisites + FileList[VERSION_FILE]).join(' ')}", VERSION_FILE
system "#{OCRA} #{(prerequisites + FileList[VERSION_FILE]).join(' ')}"
mkdir_p BINARY_DIR
move "lib/#{APP}.exe", APP_EXE
FileUtils.rm VERSION_FILE
puts 'Done.'
end
end
def create_version_file(file_name)
File.open(file_name, 'w') do |file|
file.print({ :version => RELEASE_VERSION, :build_date => Time.now }.to_yaml)
end
end
namespace :build do
file RELEASE_DIR do
mkdir_p RELEASE_DIR
end
desc "Release 7z"
task :"7z" => RELEASE_PACKAGE_7Z
file RELEASE_PACKAGE_7Z => RELEASE_DIR do
puts "Making #{RELEASE_PACKAGE_7Z}"
rm RELEASE_PACKAGE_7Z if File.exist? RELEASE_PACKAGE_7Z
cd 'release'
puts %x[7z a "#{RELEASE_PACKAGE_7Z.sub('release/', '')}" "#{RELEASE_DIR.sub('release/', '')}"]
cd '..'
end
desc "Release Zip"
task :zip => RELEASE_PACKAGE_ZIP
file RELEASE_PACKAGE_ZIP => RELEASE_DIR do
puts "Making #{RELEASE_PACKAGE_ZIP}"
rm RELEASE_PACKAGE_ZIP if File.exist? RELEASE_PACKAGE_ZIP
cd 'release'
puts %x[7z a -tzip "#{RELEASE_PACKAGE_ZIP.sub('release/', '')}" "#{RELEASE_DIR.sub('release/', '')}"]
cd '..'
end
task :compress => [:zip, :"7z"]
desc 'Make full #{APP.capitalize} release'
task :release => :compress
end
desc "Install libraries required by Flipped"
task :install_libraries do
load 'install_libraries.rb'
end
require 'build/package'