diff --git a/.gitignore b/.gitignore index 5057f39..20553f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.zip -nTPL.native/build -nTPL.native/build/* -nTPL.native/.lock-wscript +build +build/* +.lock-wscript lib/nTPL.native.node \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c7be9f5 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +LIB_PREFIX = $(HOME)/.node_libraries +NODE = node + +build: + @echo "Building nTPL ..." + @rm -rf build/ && node-waf configure && node-waf build + @rm .lock-wscript + @rm -rf build/ + +install: + @echo "Installing nTPL ..." + @cp -fr lib/ $(LIB_PREFIX)/ + +uninstall: + @echo "Uninstalling nTPL ..." + @rm -f $(LIB_PREFIX)/nTPL.js + @rm -f $(LIB_PREFIX)/nTPL.native.node + @rm -f $(LIB_PREFIX)/nTPL.block.js + @rm -f $(LIB_PREFIX)/nTPL.filter.js + +test: + @cd ./tests && $(NODE) run.js && cd .. + +.PHONY : build install uninstall test \ No newline at end of file diff --git a/README.rdoc b/README.rdoc index 1b83406..0f56ce2 100644 --- a/README.rdoc +++ b/README.rdoc @@ -24,10 +24,9 @@ After that all nTPL module will be stored in lib folder: git clone git@github.com:donnerjack13589/nTPL.git cd nTPL - cd nTPL.native - ./build.sh - cd ../tests/ - node run.js + make + make install + make test ==Basic examples: diff --git a/benchmarks/million_complex.js b/benchmarks/million_complex.js index 9438aa5..4953649 100644 --- a/benchmarks/million_complex.js +++ b/benchmarks/million_complex.js @@ -1,4 +1,4 @@ -require("../lib/nTPL"); +require("nTPL"); var tpl = nTPL({ template: "./complex.html", diff --git a/example.js b/example.js index bf16b00..a432591 100644 --- a/example.js +++ b/example.js @@ -1,6 +1,6 @@ -require("./lib/nTPL"); -require("./lib/nTPL.block"); -require("./lib/nTPL.filter"); +require("nTPL"); +require("nTPL.block"); +require("nTPL.filter"); var base = nTPL({ template: "./tpl/base.html", diff --git a/lib/nTPL.js b/lib/nTPL.js index b334ed6..ec16f40 100644 --- a/lib/nTPL.js +++ b/lib/nTPL.js @@ -31,7 +31,7 @@ this.nTPL = nTPL = (function() { var fs = require('fs'); var path = require('path'); - var nTPL_native = require('./nTPL.native'); + var nTPL_native = require('nTPL.native'); var compile = process.compile; diff --git a/nTPL.native/build.sh b/nTPL.native/build.sh deleted file mode 100644 index 31a2b8c..0000000 --- a/nTPL.native/build.sh +++ /dev/null @@ -1 +0,0 @@ -rm -rf build/ && node-waf configure && node-waf build \ No newline at end of file diff --git a/tests/run.js b/tests/run.js index 0d94488..c39d4ad 100644 --- a/tests/run.js +++ b/tests/run.js @@ -2,9 +2,9 @@ var fs = require("fs"); var path = require("path"); var test = require("assert"); -require("../lib/nTPL"); -require("../lib/nTPL.block"); -require("../lib/nTPL.filter"); +require("nTPL"); +require("nTPL.block"); +require("nTPL.filter"); var tests = []; diff --git a/nTPL.native/wscript b/wscript similarity index 69% rename from nTPL.native/wscript rename to wscript index 36a00e7..3b54ddb 100644 --- a/nTPL.native/wscript +++ b/wscript @@ -17,10 +17,10 @@ def build(bld): cargo = bld.new_task_gen('cxx', 'shlib', 'node_addon') cargo.cxxflags = ["-g",] cargo.target = 'nTPL.native' - cargo.source = 'nTPL.native.cc' + cargo.source = 'nTPL.native/nTPL.native.cc' def shutdown(): - if exists('../lib/nTPL.native.node'): - unlink('../lib/nTPL.native.node'); + if exists('./lib/nTPL.native.node'): + unlink('./lib/nTPL.native.node'); if exists('./build/default/nTPL.native.node'): - copy('./build/default/nTPL.native.node', '../lib/nTPL.native.node') \ No newline at end of file + copy('./build/default/nTPL.native.node', './lib/nTPL.native.node') \ No newline at end of file