-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.rakefile
113 lines (92 loc) · 3.9 KB
/
build.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
require 'rake/clean'
require 'tasks/tools'
include Opaz::Tools
plugin_name = ENV['plugin']
message = "Specify a plugin with 'rake -f build.rakefile compile package deploy plugin=Delay'"
abort(message) unless plugin_name || ARGV == []
puts "Remember: #{message}"
PLUGIN_NAME = plugin_name || ""
JAR_SEP = jar_separator(Config::CONFIG['host_os'])
BASE_JARS = FileList['libs/*.jar'].map { |e| File.expand_path(e) }
BASE_CLASSPATH = BASE_JARS.join(JAR_SEP)
PLUGIN_FOLDER = File.join('plugins',PLUGIN_NAME)
abort("Plugin folder #{PLUGIN_FOLDER} does not exist!") unless File.exist?(PLUGIN_FOLDER)
PLUGIN_BUILD_FOLDER = File.join(PLUGIN_FOLDER, 'build')
PLUGIN_TYPE = Dir["#{PLUGIN_FOLDER}/*.rb"].empty? ? 'java' : 'ruby'
CLEAN.include "src/build"
CLEAN.include PLUGIN_BUILD_FOLDER
CLEAN.include Dir[File.join(PLUGIN_FOLDER, "*.mirah")].map { |e| e.gsub('.mirah','.java')}
CLEAN.include File.join(PLUGIN_FOLDER, "compiled")
CLEAN.include File.join(PLUGIN_FOLDER, "*.class") # legacy - no more .class will be here once clean upgrade
# ====================== common =======================
file 'src/build' do |t|
FileUtils.mkdir t.name
end
file 'src/build/*.class' => 'src/build' do
in_folder('src') { system! "javac *.java -classpath #{BASE_CLASSPATH} -d build" }
end
file 'src/build/OpazPlug.jar' => 'src/build/*.class' do
in_folder('src/build') { system! "jar -cf OpazPlug.jar *.class" }
end
# ====================== plugin =======================
file PLUGIN_BUILD_FOLDER + '/common' do |t|
FileUtils.mkdir_p t.name
end
file "#{PLUGIN_FOLDER}/*.mirah" do |t|
Dir[t.name].each do |file|
in_folder(File.dirname(file)) { system!("#{mirahc_command} --java #{File.basename(file)}") }
end
end
file "#{PLUGIN_FOLDER}/*.java" => [PLUGIN_BUILD_FOLDER+'/common','src/build/OpazPlug.jar'] do |t|
unless Dir[t.name].empty?
classpath = (BASE_JARS + ['src/build/OpazPlug.jar']).join(JAR_SEP)
system! "javac #{t.name} -classpath #{classpath} -d #{PLUGIN_BUILD_FOLDER}/common"
end
end
file "#{PLUGIN_FOLDER}/*.fx" => PLUGIN_BUILD_FOLDER+'/common' do |t|
Dir[t.name].each do |file|
in_folder(File.dirname(file)) { system!("javafxc #{File.basename(file)} -d build/common") }
end
end
file "#{PLUGIN_FOLDER}/*.rb" => PLUGIN_BUILD_FOLDER+'/common' do |t|
Dir[t.name].each do |file|
cp(file, PLUGIN_BUILD_FOLDER + '/common')
end
end
file "#{PLUGIN_BUILD_FOLDER}/common/Plugin.jar" => ["#{PLUGIN_FOLDER}/*.mirah","#{PLUGIN_FOLDER}/*.java","#{PLUGIN_FOLDER}/*.fx"] do |t|
unless Dir[PLUGIN_BUILD_FOLDER + '/common/*.class'].empty?
in_folder(PLUGIN_BUILD_FOLDER + '/common') do
system! "jar -cf Plugin.jar *.class"
Dir["*.class"].each { |f| rm f }
end
end
end
task :default => :compile
task :compile => ["#{PLUGIN_BUILD_FOLDER}/common/Plugin.jar", PLUGIN_FOLDER+"/*.rb"] do
cp "src/build/OpazPlug.jar", PLUGIN_BUILD_FOLDER + '/common'
Dir["src/*.rb"].each { |f| cp f, PLUGIN_BUILD_FOLDER + '/common' }
end
desc "Package the plugin for each platform"
task :package => ['src/build/OpazPlug.jar', :compile] do
package_plugin(PLUGIN_NAME, PLUGIN_FOLDER, [running_platform]) do |config|
if PLUGIN_TYPE == 'ruby'
config << "# Do not change"
config << "PluginClass=JRubyVSTPluginProxy"
config << "RubyPlugin=#{PLUGIN_NAME}"
else
config << "PluginClass=#{PLUGIN_NAME}"
# TODO - tweak your GUI definition if it's not matching the convention
config << "PluginUIClass=#{PLUGIN_NAME}GUI"
end
end
end
desc "Deploy the plugin to ./deploy with others - point your vst host to ./deploy or symlink"
task :deploy => [:clean, :package] do
target_folder = File.dirname(__FILE__) + '/deploy'
FileUtils.mkdir(target_folder) unless File.exists?(target_folder)
Dir["#{PLUGIN_FOLDER}/build/#{running_platform}/*"].each do |plugin|
target_plugin = "#{target_folder}/#{plugin.split('/').last}"
rm_rf(target_plugin) if File.exist?(target_plugin)
cp_r plugin, target_plugin
end
end