Merge branch 'doug'

This commit is contained in:
wycats 2010-06-19 22:29:55 -07:00
commit 6a0942c9d5
5 changed files with 175 additions and 37 deletions

View file

@ -4,55 +4,81 @@
What you need to build your own jQuery What you need to build your own jQuery
--------------------------------------- ---------------------------------------
* Make sure that you have Java installed (if you want to build a minified version of jQuery). * Make sure that you have Java installed (if you want to build a minified version of jQuery).
If not, go to this page and download "Java Runtime Environment (JRE) 5.0" If not, [go to this page](http://java.sun.com/javase/downloads/index.jsp) and download "Java Runtime Environment (JRE) 5.0"
[http://java.sun.com/javase/downloads/index.jsp](http://java.sun.com/javase/downloads/index.jsp)
* You now have two options for building jQuery, if you have access to common UNIX commands (like `make`, `mkdir`, `rm`, `cat`, and `echo`) then simply type `make` to build all the components. Build Options
--------------
* The other option is if you have Ant installed (or are on Windows and don't have access to make). You can download Ant from here: [http://ant.apache.org/bindownload.cgi](http://ant.apache.org/bindownload.cgi) You now have **three** options for building jQuery:
If you do have Ant, everytime (in this README) that I say 'make', do 'ant' instead - it works identically (for all intents and purposes).
* **`make`**: If you have access to common UNIX commands (like `make`, `mkdir`, `rm`, `cat`, and `echo`) then simply type `make` to build all the components.
* **`rake`**: If you have Ruby Rake installed (on either Windows or UNIX/Linux), you can simply type `rake` to build all the components.
* **`ant`**: If you have Ant installed (or are on Windows and don't have access to make). You can download Ant from here: [http://ant.apache.org/bindownload.cgi].
How to build your own jQuery How to build your own jQuery
----------------------------- -----------------------------
*Note: If you are using either `rake` or `ant`, substitute your chosen method in place of `make` in the examples below. They work identically for all intents and purposes. Quick reference is also available for `rake` by typing `rake -T` in the `jquery` directory.*
In the main directory of the distribution (the one that this file is in), type In the main directory of the distribution (the one that this file is in), type
the following to make all versions of jQuery: the following to make all versions of jQuery:
`make` make
Here are each of the individual items that are buildable from the Makefile. *Here are the individual items that are buildable from the Makefile:*
`make init` make init
Pull in all the external dependencies (QUnit, Sizzle) for the project. Pull in all the external dependencies (QUnit, Sizzle) for the project.
`make jquery` make jquery
The standard, uncompressed, jQuery code. The standard, uncompressed, jQuery code.
Makes: ./dist/jquery.js Makes: `./dist/jquery.js`
`make min` make min
A compressed version of jQuery (made the Closure Compiler). A compressed version of jQuery (made the Closure Compiler).
Makes: ./dist/jquery.min.js Makes: `./dist/jquery.min.js`
`make lint` make lint
Tests a build of jQuery against JSLint, looking for potential errors or bits of confusing code. Tests a build of jQuery against JSLint, looking for potential errors or bits of confusing code.
`make selector` make selector
Builds the selector library for jQuery from Sizzle. Builds the selector library for jQuery from Sizzle.
Makes: ./src/selector.js Makes: `./src/selector.js`
Finally, you can remove all the built files using the command: Finally, you can remove all the built files using the command:
`make clean` make clean
Additionally, if you want to install jQuery to a location that is not this Building to a different directory
directory, you can specify the PREFIX directory, for example: ----------------------------------
`make PREFIX=/home/john/test/` If you want to build jQuery to a directory that is different from the default location, you can...
**Make only:** Specify the PREFIX directory, for example:
make PREFIX=/home/john/test/ [command]
With this example, the output files would be contained in `/home/john/test/dist/`
**Rake only:** Define the DIST_DIR directory, for example:
rake DIST_DIR=/home/john/test/ [command]
With this example, the output files would be contained in `/home/john/test/`
*In both examples, `[command]` is optional.*
**Ant only:** You cannot currently build to another directory when using Ant.
Questions?
----------
If you have any questions, please feel free to ask them on the jQuery If you have any questions, please feel free to ask them on the jQuery
mailing list, which can be found here: mailing list, which can be found here:

146
Rakefile
View file

@ -1,26 +1,138 @@
# Basic Rakefile for building jQuery prefix = File.dirname( __FILE__ )
files = [ "intro", "core", "support", "data", "queue", "event", "selector", "traversing", "attributes", "manipulation", "css", "ajax", "effects", "offset", "dimensions", "outro" ]
date = `git log -1 | grep Date: | sed 's/[^:]*: *//'`.gsub(/\n/, "") # Directory variables
version = `cat version.txt`.gsub(/\n/, "") 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 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" ) }
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" # Sizzle, QUnit and jQuery files/dirs
sh "cd src/sizzle && git pull origin master &> /dev/null" sizzle_dir = File.join( src_dir, "sizzle" )
sh "cd test/qunit && git pull origin master &> /dev/null" 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`[/^Date:\s+(.+)$/, 1]
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 => "all"
desc "Builds jQuery; Tests with JSLint; Minifies jQuery"
task :all => [:jquery, :lint, :min] do
puts "jQuery build complete."
end end
task :jquery => [:init, :selector] do desc "Builds jQuery: jquery.js (Default task)"
sh "mkdir -p dist" task :jquery => [:selector, jq]
sh "cat " + files.map {|file| "src/" + file + ".js"}.join(" ") + desc "Builds a minified version of jQuery: jquery.min.js"
" | sed 's/Date:./&" + date + "/' | " + task :min => jq_min
" sed s/@VERSION/" + version + "/ > dist/jquery.js"
task :init => [sizzle, qunit] do
sizzle_git = File.join(sizzle_dir, '.git')
qunit_git = File.join(qunit_dir, '.git')
puts "Updating SizzleJS with latest..."
sh "git --git-dir=#{sizzle_git} pull -q origin master"
puts "Updating QUnit with latest..."
sh "git --git-dir=#{qunit_git} pull -q origin master"
end end
task :selector do desc "Removes dist folder, selector.js, and Sizzle/QUnit"
sh "sed '/EXPOSE/r src/sizzle-jquery.js' src/sizzle/sizzle.js > src/selector.js" task :clean do
puts "Removing Distribution directory: #{dist_dir}..."
rm_rf dist_dir
puts "Removing built copy of Sizzle..."
rm_rf selector
puts "Removing cloned directories..."
rm_rf qunit_dir
rm_rf 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} " + File.join(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..."
File.open(jq, 'w') do |f|
f.write cat(base_files).gsub(/(Date:.)/, "\\1#{date}" ).gsub(/@VERSION/, version)
end
end
file jq_min => jq do
puts "Building jquery.min.js..."
sh "#{minfier} --js #{jq} --warning_level QUIET --js_output_file #{jq_min}"
min = File.read( jq_min )
# Equivilent of "head"
File.open(jq_min, 'w') do |f|
f.write File.readlines(jq)[0..14].join()
f.write min
end
end
file selector => [sizzle, :init] do
puts "Building selector code from Sizzle..."
File.open(selector, 'w') do |f|
f.write File.read(sizzle).gsub(
/^.+EXPOSE$\n/,
'\0' + File.read( File.join( src_dir, 'sizzle-jquery.js' ))
).gsub(
/^window.Sizzle.+$\n/, ''
)
end
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 QUnit from Github..."
sh "git clone git://github.com/jquery/qunit.git #{qunit_dir}"
end
def cat( files )
files.map do |file|
File.read(file)
end.join('')
end end

0
speed/benchmarker.css Executable file → Normal file
View file

0
speed/benchmarker.js Executable file → Normal file
View file

0
speed/index.html Executable file → Normal file
View file