Permalink
Browse files

Use Cakefile to streamline packaging

  • Loading branch information...
1 parent a76fe8d commit 6ff0e41e12d0d05f10b8581de81ddeecb2764d13 @mikepb mikepb committed with Feb 6, 2012
Showing with 53 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. +43 −0 Cakefile
  3. +6 −4 package.json
  4. +3 −2 wscript
View
@@ -1,3 +1,4 @@
+.DS_Store
.lock-wscript
.svn
*.o
View
@@ -0,0 +1,43 @@
+{spawn} = require 'child_process'
+path = require 'path'
+
+exec = (command, callback) ->
+ args = command.split /\s/
+ command = args.shift()
+ proc = spawn command, args
+ proc.stdout.on 'data', (chunk) -> process.stdout.write chunk
+ proc.stderr.on 'data', (chunk) -> process.stderr.write chunk
+ proc.on 'exit', (code, signal) ->
+ throw "#{command} exited with code #{code}" if code
+ throw "#{command} received signal #{signal}" if signal
+ callback?()
+
+configure = (callback) ->
+ exec 'node-waf configure', callback
+
+compileBinding = (callback) ->
+ exec 'node-waf build', callback
+
+compileCoffee = (callback) ->
+ exec 'coffee --bare --compile --output lib src', callback
+
+clean = (callback) ->
+ exec 'node-waf clean', callback
+
+task 'build', 'Configure and build native binding and coffeescript', ->
+ unless path.existsSync "#{__dirname}/deps/leveldb/build_config.mk"
+ configure -> compileBinding -> compileCoffee()
+ else
+ compileBinding -> compileCoffee()
+
+task 'build:configure', 'Configure files for building', ->
+ configure()
+
+task 'build:binding', 'Compile native binding', ->
+ compileBinding()
+
+task 'build:coffee', 'Compile coffee to js', ->
+ compileCoffee()
+
+task 'clean', 'Remove compiled files', ->
+ clean()
View
@@ -9,10 +9,12 @@
"version": "0.5.5",
"main": "lib",
"scripts": {
- "preinstall": "node-waf configure",
- "install": "node-waf build",
- "postinstall": "./node_modules/coffee-script/bin/coffee -b -c -o lib src",
- "test": "mkdir -p tmp && find tests -name '*-test.*' -print0 | xargs -0 mocha -R spec ; rm -r tmp"
+ "prepublish": "cake build",
+ "preinstall": "cake build",
+ "install": "cake build",
+ "pretest": "cake build && mkdir -p tmp",
+ "test": "find tests -name '*-test.*' -print0 | xargs -0 mocha -R spec",
+ "posttest": "rm -rf tmp"
},
"repository": {
"type": "git",
View
@@ -85,10 +85,11 @@ def configure(conf):
conf.check_tool("compiler_cc")
conf.check_tool("node_addon")
- Utils.exec_command('./configure', cwd = './deps/snappy')
+ if not exists('./deps/snappy/Makefile'):
+ Utils.exec_command('./configure', cwd = './deps/snappy')
if not exists(build_config):
- system('cd %s && sh build_detect_platform' % leveldb_dir)
+ system('cd %s && sh build_detect_platform' % leveldb_dir)
parse_build_config(conf.env)

0 comments on commit 6ff0e41

Please sign in to comment.