-
Notifications
You must be signed in to change notification settings - Fork 8
/
rakefile
143 lines (111 loc) · 3.26 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
require 'tempfile'
require 'fileutils'
DEFAULT_PLATFORM = RUBY_PLATFORM =~ /darwin/ ? "osx" : "win"
NINJA_PREFIX = RUBY_PLATFORM =~ /darwin/ ? "" : "Tools/bin/"
BUILDS = (ENV["build"] || "debug").split(",")
TARGET_PLATFORM = ENV["platform"] || DEFAULT_PLATFORM
REGION = ENV["region"] || "JP"
VERBOSITY = ENV["verbosity"] || "normal"
PROJECT = ENV["project"] || "UsagiTest"
EMBED_DLP = ENV["embed_dlp"] || "false"
CURRENT_DIR = File.dirname(__FILE__)
RUBY = "ruby"
raise "USAGI_DIR environment variable not defined!" if ENV['USAGI_DIR'].nil?
if VERBOSITY == "verbose"
verbose(true)
VERBOSITY_FLAG="-v"
else
verbose(false)
VERBOSITY_FLAG=""
end
def build_dir(build_name)
File.join("_build", TARGET_PLATFORM, build_name)
end
def ninja_file(build_name)
File.join(build_dir(build_name), "build.ninja")
end
def protobuf_depfile
depfile = "_build/proto/deps.txt"
dir = File.dirname depfile
FileUtils.mkdir_p dir if ! File.directory? dir
depfile
end
def ninja(build_name, failed_job_limit=10)
"#{NINJA_PREFIX}ninja #{VERBOSITY_FLAG} -f #{ninja_file(build_name)} -k #{failed_job_limit}"
end
BUILDS.each{ |b| directory build_dir(b) }
task :default => :build
task :build => :ninja do |t|
BUILDS.each{ |b| sh ninja(b) }
end
task :cia => :ninja do
BUILDS.each{ |b| sh "#{ninja b} cia" }
end
task :dlp => :ninja do
end
task :data => :ninja do
BUILDS.each{ |b| sh "#{ninja b} data" }
end
task :libs => :ninja do
BUILDS.each{ |b| sh "#{ninja b} libs" }
end
task :id => :ninja do
BUILDS.each{ |b| sh "#{ninja b} id" }
end
task :includes => :ninja do
BUILDS.each{ |b| sh "#{ninja b} includes" }
end
task :pb => :ninja do
BUILDS.each{ |b| sh "#{ninja b} pb" }
end
task :projects => :ninja do
# the second parameter to the ninja function should be
# greater than the total number of project files we generate
BUILDS.each{ |b| sh "#{ninja(b, 30)} projects" }
end
task :ninja => BUILDS.map{|b|build_dir b} do |t|
BUILDS.each do |b|
sh "#{RUBY} Tools/build/deflist.rb Engine > #{protobuf_depfile}"
sh "#{RUBY} Tools/build/generator.rb #{b} #{TARGET_PLATFORM} #{REGION} #{PROJECT} #{CURRENT_DIR} #{ninja_file b} #{EMBED_DLP}"
end
end
task :clean do |t|
BUILDS.each{ |b| sh "#{ninja b} -t clean" }
end
task :clean_bp do |t|
BUILDS.map{|b| build_dir b}.each do |dir|
bp_files = FileList["#{dir}/**/*.bp.cpp"]
if TARGET_PLATFORM == 'win'
bp_files.include "#{dir.to_s.sub(Regexp.quote('/win/'), '/Win32/')}/**/*.bp.cpp"
end
FileUtils.rm bp_files
end
end
task :clean_code do |t|
BUILDS.map{|b| build_dir b}.each do |dir|
code_files = FileList["#{dir}/**/*.o"]
code_files.exclude("#{dir}/Data/**/*", "#{dir}/Effects/**/*")
FileUtils.rm code_files
end
end
task :clean_data do |t|
FileUtils.rm_rf FileList["_romfiles/#{TARGET_PLATFORM}/**"]
end
task :clean_includes do |t|
FileUtils.rm_rf FileList["_includes/**"]
end
task :clean_projects do
FileUtils.rm_rf FileList["_build/projects/**"]
end
task :run => :build do
case TARGET_PLATFORM
when "osx"
sh "_rom/#{TARGET_PLATFORM}/#{BUILDS[0]}/#{PROJECT}_#{REGION}.app/Contents/MacOS/#{PROJECT}_#{REGION}"
end
end
task :debug => :build do
case TARGET_PLATFORM
when "osx"
sh "lldb _rom/#{TARGET_PLATFORM}/#{BUILDS[0]}/#{PROJECT}_#{REGION}.app"
end
end