-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This new rakefile will be invoked from the main one.
- Loading branch information
Showing
2 changed files
with
114 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
require 'rake/clean' | ||
require 'tasks/tools' | ||
require 'tasks/prepare' | ||
|
||
include Opaz::Tools | ||
plugin_name = ENV['plugin'] | ||
message = "Specify a plugin with 'rake 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' | ||
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 |