Refactor the build tasks to be more foolproof, including the parser unless it’s explicitly excluded
This commit is contained in:
parent
c06a0584ff
commit
8a271995c7
81
Cakefile
81
Cakefile
|
@ -24,44 +24,12 @@ header = """
|
|||
*/
|
||||
"""
|
||||
|
||||
# Used in folder names like docs/v1
|
||||
# Used in folder names like `docs/v1`.
|
||||
majorVersion = parseInt CoffeeScript.VERSION.split('.')[0], 10
|
||||
|
||||
|
||||
# Build the CoffeeScript language from source.
|
||||
build = (cb) ->
|
||||
files = fs.readdirSync 'src'
|
||||
files = ('src/' + file for file in files when file.match(/\.(lit)?coffee$/))
|
||||
run ['-c', '-o', 'lib/coffee-script'].concat(files), cb
|
||||
|
||||
# Run a CoffeeScript through our node/coffee interpreter.
|
||||
run = (args, cb) ->
|
||||
proc = spawn 'node', ['bin/coffee'].concat(args)
|
||||
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
|
||||
proc.on 'exit', (status) ->
|
||||
process.exit(1) if status isnt 0
|
||||
cb() if typeof cb is 'function'
|
||||
|
||||
# Log a message with a color.
|
||||
log = (message, color, explanation) ->
|
||||
console.log color + message + reset + ' ' + (explanation or '')
|
||||
|
||||
|
||||
task 'build', 'build the CoffeeScript language from source', build
|
||||
|
||||
task 'build:full', 'rebuild the source twice, and run the tests', ->
|
||||
build ->
|
||||
build ->
|
||||
csPath = './lib/coffee-script'
|
||||
csDir = path.dirname require.resolve csPath
|
||||
|
||||
for mod of require.cache when csDir is mod[0 ... csDir.length]
|
||||
delete require.cache[mod]
|
||||
|
||||
unless runTests require csPath
|
||||
process.exit 1
|
||||
|
||||
|
||||
task 'build:parser', 'rebuild the Jison parser (run build first)', ->
|
||||
buildParser = ->
|
||||
helpers.extend global, require 'util'
|
||||
require 'jison'
|
||||
parser = require('./lib/coffee-script/grammar').parser.generate()
|
||||
|
@ -74,8 +42,49 @@ task 'build:parser', 'rebuild the Jison parser (run build first)', ->
|
|||
source = fs"""
|
||||
fs.writeFileSync 'lib/coffee-script/parser.js', parser
|
||||
|
||||
buildExceptParser = (cb) ->
|
||||
files = fs.readdirSync 'src'
|
||||
files = ('src/' + file for file in files when file.match(/\.(lit)?coffee$/))
|
||||
run ['-c', '-o', 'lib/coffee-script'].concat(files), cb
|
||||
|
||||
task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
|
||||
build = (cb) ->
|
||||
buildParser()
|
||||
buildExceptParser cb
|
||||
|
||||
|
||||
# Run a CoffeeScript through our node/coffee interpreter.
|
||||
run = (args, cb) ->
|
||||
proc = spawn 'node', ['bin/coffee'].concat(args)
|
||||
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
|
||||
proc.on 'exit', (status) ->
|
||||
process.exit(1) if status isnt 0
|
||||
cb() if typeof cb is 'function'
|
||||
|
||||
|
||||
# Log a message with a color.
|
||||
log = (message, color, explanation) ->
|
||||
console.log color + message + reset + ' ' + (explanation or '')
|
||||
|
||||
|
||||
task 'build', 'build the CoffeeScript compiler from source', build
|
||||
|
||||
task 'build:parser', 'build the Jison parser only', buildParser
|
||||
|
||||
task 'build:except-parser', 'build the CoffeeScript compiler, except for the Jison parser', buildExceptParser
|
||||
|
||||
task 'build:full', 'build the CoffeeScript compiler from source twice, and run the tests', ->
|
||||
build ->
|
||||
build ->
|
||||
csPath = './lib/coffee-script'
|
||||
csDir = path.dirname require.resolve csPath
|
||||
|
||||
for mod of require.cache when csDir is mod[0 ... csDir.length]
|
||||
delete require.cache[mod]
|
||||
|
||||
unless runTests require csPath
|
||||
process.exit 1
|
||||
|
||||
task 'build:browser', 'build the merged script for inclusion in the browser', ->
|
||||
code = """
|
||||
require['../../package.json'] = (function() {
|
||||
return #{fs.readFileSync "./package.json"};
|
||||
|
|
|
@ -2584,9 +2584,9 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
|
|||
<li><p><a href="http://github.com/jashkenas/coffeescript/">Source Code</a><br>
|
||||
Use <code>bin/coffee</code> to test your changes,<br>
|
||||
<code>bin/cake test</code> to run the test suite,<br>
|
||||
<code>bin/cake build</code> to rebuild the CoffeeScript compiler, and<br>
|
||||
<code>bin/cake build:parser</code> to regenerate the Jison parser if you’re working on the grammar.</p>
|
||||
<p><code>git checkout lib && bin/cake build:full</code> is a good command to run when you’re working on the core language. It’ll refresh the lib directory (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.</p>
|
||||
<code>bin/cake build</code> to rebuild the full CoffeeScript compiler, and<br>
|
||||
<code>bin/cake build:except-parser</code> to recompile much faster if you’re not editing <code>grammar.coffee</code>.</p>
|
||||
<p><code>git checkout lib && bin/cake build:full</code> is a good command to run when you’re working on the core language. It’ll refresh the <code>lib</code> folder (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.</p>
|
||||
</li>
|
||||
<li><a href="v1/test.html">Browser Tests</a><br>
|
||||
Run CoffeeScript’s test suite in your current browser.</li>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* [Source Code](http://github.com/jashkenas/coffeescript/)<br>
|
||||
Use `bin/coffee` to test your changes,<br>
|
||||
`bin/cake test` to run the test suite,<br>
|
||||
`bin/cake build` to rebuild the CoffeeScript compiler, and<br>
|
||||
`bin/cake build:parser` to regenerate the Jison parser if you’re working on the grammar.
|
||||
`bin/cake build` to rebuild the full CoffeeScript compiler, and<br>
|
||||
`bin/cake build:except-parser` to recompile much faster if you’re not editing `grammar.coffee`.
|
||||
|
||||
`git checkout lib && bin/cake build:full` is a good command to run when you’re working on the core language. It’ll refresh the lib directory (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.
|
||||
`git checkout lib && bin/cake build:full` is a good command to run when you’re working on the core language. It’ll refresh the `lib` folder (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, there’s a good chance you’ve made a successful change.
|
||||
* [Browser Tests](v<%= majorVersion %>/test.html)<br>
|
||||
Run CoffeeScript’s test suite in your current browser.
|
||||
* [CoffeeScript Issues](http://github.com/jashkenas/coffeescript/issues)<br>
|
||||
|
|
Loading…
Reference in New Issue