middleman/middleman-core/Rakefile

51 lines
1.9 KiB
Text
Raw Normal View History

# coding:utf-8
RAKE_ROOT = __FILE__
2012-01-06 05:34:24 +01:00
GEM_NAME = "middleman-core" + (ENV["WINDOWS"] ? "-x86-mingw32" : "")
require 'rubygems'
2012-01-02 23:33:28 +01:00
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
desc "Build vendored gems"
task :build_vendor do
raise unless File.exist?('Rakefile')
# Destroy vendor
sh "rm -rf lib/middleman-core/vendor/darwin"
sh "rm -rf lib/middleman-core/vendor/linux"
# Clone the correct gems
sh "git clone https://github.com/thibaudgg/rb-fsevent.git lib/middleman-core/vendor/darwin"
sh "cd lib/middleman-core/vendor/darwin && git checkout 1ca42b987596f350ee7b19d8f8210b7b6ae8766b"
sh "git clone https://github.com/nex3/rb-inotify.git lib/middleman-core/vendor/linux"
sh "cd lib/middleman-core/vendor/linux && git checkout 01e7487e7a8d8f26b13c6835a321390c6618ccb7"
# Strip out the .git directories
%w[darwin linux].each {|platform| sh "rm -rf lib/middleman-core/vendor/#{platform}/.git"}
# Move ext directory of darwin to root
sh "mkdir -p ext"
sh "cp -r lib/middleman-core/vendor/darwin/ext/* ext/"
# Alter darwin extconf.rb
extconf_path = File.expand_path("../ext/extconf.rb", __FILE__)
extconf_contents = File.read(extconf_path)
extconf_contents.sub!(/puts "Warning/, '#\0')
2012-01-15 18:12:28 +01:00
extconf_contents.gsub!(/bin\/fsevent_watch/, 'bin/fsevent_watch_m')
2012-01-02 23:33:28 +01:00
File.open(extconf_path, 'w') { |f| f << extconf_contents }
# Alter lib/middleman-core/vendor/darwin/lib/rb-fsevent/fsevent.rb
fsevent_path = File.expand_path("../lib/middleman-core/vendor/darwin/lib/rb-fsevent/fsevent.rb", __FILE__)
fsevent_contents = File.read(fsevent_path)
2012-01-15 18:12:28 +01:00
fsevent_contents.sub!(/fsevent_watch/, 'fsevent_watch_mm')
2012-01-02 23:33:28 +01:00
fsevent_contents.sub!(/'\.\.'/, "'..', '..', '..', '..', '..'")
File.open(fsevent_path, 'w') { |f| f << fsevent_contents }
end
desc "Compile mac executable"
task :build_mac_exec do
Dir.chdir(File.expand_path("../ext", __FILE__)) do
system("ruby extconf.rb") or raise
end
end