Updated Rakefile to mirror the functionality of the Makefile
The Rakefile now supports all the functionality of the Makefile including only rebuilding files when dependent files change. To see availible tasks, run: rake -T
This commit is contained in:
parent
ef8df7f55c
commit
3e1ac2aaac
1 changed files with 102 additions and 17 deletions
119
Rakefile
119
Rakefile
|
@ -1,26 +1,111 @@
|
|||
# Basic Rakefile for building jQuery
|
||||
files = [ "intro", "core", "support", "data", "queue", "event", "selector", "traversing", "attributes", "manipulation", "css", "ajax", "effects", "offset", "dimensions", "outro" ]
|
||||
prefix = File.dirname( __FILE__ )
|
||||
|
||||
date = `git log -1 | grep Date: | sed 's/[^:]*: *//'`.gsub(/\n/, "")
|
||||
version = `cat version.txt`.gsub(/\n/, "")
|
||||
# Directory variables
|
||||
src_dir = File.join( prefix, 'src' )
|
||||
build_dir = File.join( prefix, 'build' )
|
||||
test_dir = File.join( prefix, 'test' )
|
||||
|
||||
task :default => :jquery
|
||||
# A different destination directory can be set by
|
||||
# setting DIST_DIR before calling rake
|
||||
dist_dir = ENV['DIST_DIR'] || File.join( prefix, 'dist' )
|
||||
|
||||
task :init do
|
||||
sh "if test ! -d test/qunit; then git clone git://github.com/jquery/qunit.git test/qunit; fi"
|
||||
sh "if test ! -d src/sizzle; then git clone git://github.com/jeresig/sizzle.git src/sizzle; fi"
|
||||
sh "cd src/sizzle && git pull origin master &> /dev/null"
|
||||
sh "cd test/qunit && git pull origin master &> /dev/null"
|
||||
base_files = %w{intro core support data queue attributes event selector traversing manipulation css ajax effects offset dimensions outro}.map { |js| File.join( src_dir, "#{js}.js" ) }
|
||||
|
||||
# Sizzle, QUnit and jQuery files/dirs
|
||||
sizzle_dir = File.join( src_dir, "sizzle" )
|
||||
sizzle = File.join( sizzle_dir, "sizzle.js" )
|
||||
selector = File.join( src_dir, "selector.js" )
|
||||
|
||||
qunit_dir = File.join( test_dir, "qunit" )
|
||||
qunit = File.join( qunit_dir, "qunit", "qunit.js" )
|
||||
|
||||
jq = File.join( dist_dir, "jquery.js" )
|
||||
jq_min = File.join( dist_dir, "jquery.min.js" )
|
||||
|
||||
# General Variables
|
||||
date = `git log -1 | grep Date: | sed 's/[^:]*: *//'`.strip
|
||||
version = File.read( File.join( prefix, 'version.txt' ) ).strip
|
||||
|
||||
# Build tools
|
||||
rhino = "java -jar #{build_dir}/js.jar"
|
||||
minfier = "java -jar #{build_dir}/google-compiler-20091218.jar"
|
||||
|
||||
# Turn off output other than needed from `sh` and file commands
|
||||
verbose(false)
|
||||
|
||||
|
||||
# Tasks
|
||||
task :default => "jquery"
|
||||
|
||||
desc "Builds jQuery; Tests with JSLint; Minifies jQuery"
|
||||
task :all => [:jquery, :lint, :min] do
|
||||
puts "jQuery build complete."
|
||||
end
|
||||
|
||||
task :jquery => [:init, :selector] do
|
||||
sh "mkdir -p dist"
|
||||
desc "Builds jQuery: jquery.js (Default task)"
|
||||
task :jquery => [:selector, jq]
|
||||
|
||||
sh "cat " + files.map {|file| "src/" + file + ".js"}.join(" ") +
|
||||
" | sed 's/Date:./&" + date + "/' | " +
|
||||
" sed s/@VERSION/" + version + "/ > dist/jquery.js"
|
||||
desc "Builds a minified version of jQuery: jquery.min.js"
|
||||
task :min => jq_min
|
||||
|
||||
|
||||
task :init => [sizzle, qunit] do
|
||||
puts "Updating SizzleJS with latest..."
|
||||
sh "cd #{sizzle_dir} && git pull origin master &> /dev/null"
|
||||
|
||||
puts "Updating QUnit with latest..."
|
||||
sh "cd #{qunit_dir} && git pull origin master &> /dev/null"
|
||||
end
|
||||
|
||||
task :selector do
|
||||
sh "sed '/EXPOSE/r src/sizzle-jquery.js' src/sizzle/sizzle.js > src/selector.js"
|
||||
desc "Removes dist folder, selector.js, and Sizzle/QUnit"
|
||||
task :clean do
|
||||
puts "Removing Distribution directory: #{dist_dir}..."
|
||||
rm_r dist_dir
|
||||
|
||||
puts "Removing built copy of Sizzle..."
|
||||
rm_r selector
|
||||
|
||||
puts "Removing cloned directories..."
|
||||
rm_r qunit_dir
|
||||
rm_r sizzle_dir
|
||||
end
|
||||
|
||||
desc "Rebuilds selector.js from SizzleJS"
|
||||
task :selector => [:init, selector]
|
||||
|
||||
desc "Tests built jquery.js against JSLint"
|
||||
task :lint => jq do
|
||||
puts "Checking jQuery against JSLint..."
|
||||
sh "#{rhino} #{build_dir}/jslint-check.js"
|
||||
end
|
||||
|
||||
|
||||
# File and Directory Dependencies
|
||||
directory dist_dir
|
||||
|
||||
file jq => [dist_dir, base_files].flatten do
|
||||
puts "Building jquery.js..."
|
||||
sh "cat #{base_files.join(' ')} | sed 's/Date:./&#{date}/' | sed s/@VERSION/#{version}/ > #{jq}"
|
||||
end
|
||||
|
||||
file jq_min => jq do
|
||||
puts "Building jquery.min.js..."
|
||||
|
||||
sh "head -15 #{jq} > #{jq_min}"
|
||||
sh "#{minfier} --js #{jq} --warning_level QUIET >> #{jq_min}"
|
||||
end
|
||||
|
||||
file selector => [sizzle] do
|
||||
puts "Building selector code from Sizzle..."
|
||||
sh "sed '/EXPOSE/r #{src_dir}/sizzle-jquery.js' #{sizzle} > #{selector}"
|
||||
end
|
||||
|
||||
file sizzle do
|
||||
puts "Retrieving SizzleJS from Github..."
|
||||
sh "git clone git://github.com/jeresig/sizzle.git #{sizzle_dir}"
|
||||
end
|
||||
|
||||
file qunit do
|
||||
puts "Retrieving SizzleJS from Github..."
|
||||
sh "git clone git://github.com/jquery/qunit.git #{qunit_dir}"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue