This repository has been archived by the owner on Jun 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
70 lines (55 loc) · 1.65 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
require 'fileutils'
# Find the type of OS being used
module OS
def self.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def self.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def self.unix?
!OS.windows?
end
def self.linux?
OS.unix? && !OS.mac?
end
def self.arch
if !(/x64|x86_64/ =~ RUBY_PLATFORM).nil?
64
else
32
end
end
end
task default: [:build_osx, :build_win]
SOURCE = Rake::FileList.new('src/*.rb', 'img')
task :build_osx do
MAC_WRAPPER = Rake::FileList.new('wrappers/Ruby.app/**') do |fl|
fl.exclude('Contents/Resources/main.rb')
end
build_dir = File.join('bin', 'OS_X')
app_dir = File.join(build_dir, 'MonsterMaze.app')
app_src_dir = File.join(app_dir, 'Contents', 'Resources')
infoplist_filename = File.join(app_dir, 'Contents', 'Info.plist')
mkdir_p app_dir
FileUtils.cp_r MAC_WRAPPER, app_dir
infoplist = File.read(infoplist_filename)
new_infoplist_text = infoplist.gsub(/com.example.Ruby/, 'com.martoko.MonsterMaze')
File.open(infoplist_filename, 'w') { |file| file.puts new_infoplist_text }
FileUtils.cp_r SOURCE, app_src_dir
end
task :build_win do
unless OS.windows?
puts 'Skipping windows build since we are not on a windows platform'
end
build_dir = File.join('bin', 'win' + OS.arch.to_s)
mkdir_p build_dir
FileUtils.cp_r Rake::FileList.new('img'), build_dir
exe_path = File.join('bin', 'win' + OS.arch.to_s, 'MonsterMaze.exe')
puts %x(ocra --windows --output #{exe_path} #{File.join 'src', 'main.rb'})
end
task :build_ruby do
build_dir = File.join('bin', 'ruby')
mkdir_p build_dir
FileUtils.cp_r SOURCE, build_dir
end