Created
March 23, 2013 11:07
-
-
Save monkstone/5227322 to your computer and use it in GitHub Desktop.
Rakefile uses macosx processing as download (is smallest)
This file contains hidden or 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
require 'rake/clean' | |
JRUBY_VERSION = "1.7.3" | |
PROCESSING_VERSION = "2.0b8" | |
CLOBBER.include("processing-#{PROCESSING_VERSION}-macosx.zip", "jruby-complete-#{JRUBY_VERSION}.jar") | |
desc "download, and copy to ruby-processing" | |
task :default => [:download, :copy] | |
desc "download Processing & JRuby upstream sources" | |
task :download => ["processing-#{PROCESSING_VERSION}-macosx.zip", "jruby-complete-#{JRUBY_VERSION}.jar"] | |
file "processing-#{PROCESSING_VERSION}-macosx.zip" do | |
sh "wget http://processing.googlecode.com/files/processing-#{PROCESSING_VERSION}-macosx.zip" | |
check_sha1("processing-#{PROCESSING_VERSION}-macosx.zip", "1367fa8eb3f9692b8bbbfa1c4c3d6d437ee3a86d") | |
end | |
file "jruby-complete-#{JRUBY_VERSION}.jar" do | |
sh "wget http://jruby.org.s3.amazonaws.com/downloads/#{JRUBY_VERSION}/jruby-complete-#{JRUBY_VERSION}.jar" | |
check_sha1("jruby-complete-#{JRUBY_VERSION}.jar", "fafe20bce6f70ce295f24160a1e470823edba3e7") | |
end | |
directory "../lib/core" | |
desc "copy libs & jars" | |
task :copy => ["../lib/core"] do | |
sh "cp -v jruby-complete-#{JRUBY_VERSION}.jar ../lib/core/jruby-complete.jar" | |
processing_zip = File.expand_path("processing-#{PROCESSING_VERSION}-macosx.zip") | |
sh "cd ../lib/core && unzip -qoj #{processing_zip} Processing.app/Contents/Resources/Java/core/library/*.jar" | |
dirs = %w{dxf minim net pdf serial video} | |
Dir.chdir("../library/") do | |
sh "rm -rf Processing.app/ #{dirs.join(" ")}" | |
inside_zip_dirs = dirs.collect { |d| "Processing.app/Contents/Resources/Java/modes/java/libraries/#{d}/library/*" } | |
sh "unzip -q #{processing_zip} #{inside_zip_dirs.join(" ")}" | |
sh "mv Processing.app/Contents/Resources/Java/modes/java/libraries/* ." | |
sh "rm -r Processing.app/" | |
end | |
end | |
def check_sha1(filename, expected_hash) | |
require "digest/sha1" | |
sha1 = Digest::SHA1.new | |
File.open(filename, "r") do |f| | |
while buf = f.read(4096) | |
sha1.update(buf) | |
end | |
end | |
if sha1.hexdigest != expected_hash | |
raise "bad sha1 checksum for #{filename} (expected #{expected_hash} got #{sha1.hexdigest})" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment