Skip to content

Instantly share code, notes, and snippets.

@monkstone
Last active December 17, 2015 11:59
Show Gist options
  • Save monkstone/5606745 to your computer and use it in GitHub Desktop.
Save monkstone/5606745 to your computer and use it in GitHub Desktop.
ruby-processing Rakefile for linux (mock processing-2.0.2 / jruby-1.7.4)
require 'rake/clean'
JRUBY_VERSION = "1.7.4"
PROCESSING_VERSION = "2.0.2"
CLOBBER.include("processing-#{PROCESSING_VERSION}-linux64.tgz", "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}-linux64.tgz", "jruby-complete-#{JRUBY_VERSION}.jar"]
file "processing-#{PROCESSING_VERSION}-linux64.tgz" do
sh "wget http://download.processing.org/processing-#{PROCESSING_VERSION}-linux64.tgz"
check_sha1("processing-#{PROCESSING_VERSION}-linux64.tgz", "6709bbe97520a0a2d1d76a5cb9671136aa7215eb")
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", "a117e28e715184074980d6228962b9fb6b5607ac")
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}-linux64.tgz")
sh "cd ../lib/core && tar --wildcards --strip=3 -zvxf #{processing_zip} processing-#{PROCESSING_VERSION}/core/library/*.jar"
dirs = %w{dxf minim net pdf serial video}
Dir.chdir("../library/") do
sh "rm -rf processing-#{PROCESSING_VERSION}/ #{dirs.join(" ")}"
inside_zip_dirs = dirs.collect { |d| "processing-#{PROCESSING_VERSION}/modes/java/libraries/#{d}/library/*" }
sh "tar --wildcards -zxvf #{processing_zip} #{inside_zip_dirs.join(" ")}"
sh "mv processing-#{PROCESSING_VERSION}/modes/java/libraries/* ."
sh "rm -r processing-#{PROCESSING_VERSION}/"
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
@monkstone
Copy link
Author

removed javascript library reference, it is not included anymore, and probably made no sense anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment