-
Notifications
You must be signed in to change notification settings - Fork 66
Overhaul [not ready] #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7934384
d4700c2
2101bef
9971b02
f598331
b5205b1
5cf9c94
b564fba
b6f8ab1
0bfaf03
6b62495
f177796
ac6f71f
c173e1d
76d1e0e
d93d777
937d148
41e3aa8
b1a1329
1456f23
3efecf0
f36a1b5
d87eb89
7bf1fce
0ca7fc8
b4ad2cf
90224b0
4b754af
c687172
8a32e55
b773cff
09d4ba1
43b3037
8c3b3b1
8f742e1
d67e56b
87fbd84
60593bd
7d39a04
d6035c4
1b408bd
c493204
7cda0dd
d66850d
064085f
a92a35b
feb4a46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,69 @@ | ||
| language: cpp | ||
| os: | ||
| - linux | ||
| - osx | ||
| compiler: | ||
| - clang | ||
| - gcc | ||
|
|
||
| matrix: | ||
| include: | ||
| # Coverage | ||
| - os: osx | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason this has to be
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the clang++ on OS X works but @flippmoke found that the clang on travis linux boxes did not play well with coverage (likely some missing libraries). So, running on OS X is my recommendation for now (even though its a bit slow). |
||
| compiler: clang | ||
| env: NODE_VERSION="0.10" COVERAGE=true | ||
| # Linux | ||
| - os: linux | ||
| compiler: clang | ||
| env: NODE_VERSION="0.10" | ||
| - os: linux | ||
| compiler: clang | ||
| env: NODE_VERSION="0.12" | ||
| # OS X | ||
| - os: osx | ||
| compiler: clang | ||
| env: NODE_VERSION="0.10" | ||
| - os: osx | ||
| compiler: clang | ||
| env: NODE_VERSION="0.12" | ||
|
|
||
| env: | ||
| matrix: | ||
| - NODE_NVM_VERSION="0.8.26" | ||
| - NODE_NVM_VERSION="0.10" | ||
| global: | ||
| - BUILD: '/tmp/fontnik-build' | ||
| - PKG_CONFIG_PATH: '/tmp/fontnik-build/lib/pkgconfig' | ||
| - secure: "XV0lekmfgT+D9t0ZTIU+UJF6g+p3cBQMO6T6C9lkoKTC0YbtLtxSFtBahD/4PjL86DMJgTaf1nBmxqOxbrfkcpJUxnLe3r8u4Z2L/+7+QSACLNktlIfWNSO+33WxKNb4mVw6jMFZIo4ZurF016MXYzLzjpxRELW2oO2STUs2m44=" | ||
| - secure: "CQNHbxw8yHlAdUVbKokHzHmj7C+duXP3mifWOkZm9GKw4myWsRFhhoSYZmOSkgj9EWfYYkedrqEr9+GaMg9rkVJuO/7jzn6S+M7CFXKJju6MoZEDO6WcFva4M8pw6IFb9q22GcQ+OsE8/i0DwchTokyFkNb3fpwWuwROUPQ/nWg=" | ||
| - JOBS: "8" | ||
| - BUILD: '/tmp/fontnik-build' | ||
| - PKG_CONFIG_PATH: '/tmp/fontnik-build/lib/pkgconfig' | ||
| - secure: "XV0lekmfgT+D9t0ZTIU+UJF6g+p3cBQMO6T6C9lkoKTC0YbtLtxSFtBahD/4PjL86DMJgTaf1nBmxqOxbrfkcpJUxnLe3r8u4Z2L/+7+QSACLNktlIfWNSO+33WxKNb4mVw6jMFZIo4ZurF016MXYzLzjpxRELW2oO2STUs2m44=" | ||
| - secure: "CQNHbxw8yHlAdUVbKokHzHmj7C+duXP3mifWOkZm9GKw4myWsRFhhoSYZmOSkgj9EWfYYkedrqEr9+GaMg9rkVJuO/7jzn6S+M7CFXKJju6MoZEDO6WcFva4M8pw6IFb9q22GcQ+OsE8/i0DwchTokyFkNb3fpwWuwROUPQ/nWg=" | ||
|
|
||
| before_install: | ||
| - export platform=$(uname -s | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/") | ||
| - export PATH="$BUILD/bin:$PATH" | ||
| - if [[ "$platform" == "linux" ]]; then export CXX=g++-4.8; export CC=gcc-4.8; fi | ||
| - ./deps/nvm_install.sh | ||
| - ./deps/travis_build.sh | ||
| - export COVERAGE=${COVERAGE:-false} | ||
| # here we set up the node version on the fly based on the matrix value. | ||
| # This is done manually so that it is easy to flip the 'language' to | ||
| # objective-c in another branch (to run the same travis.yml on OS X) | ||
| - git clone https://github.com/creationix/nvm.git ../.nvm | ||
| - source ../.nvm/nvm.sh | ||
| - nvm install $NODE_VERSION | ||
| - nvm use $NODE_VERSION | ||
| - node --version | ||
| - npm --version | ||
| - if [[ ${COVERAGE} == true ]]; then | ||
| brew update; | ||
| brew install pyenv; | ||
| eval "$(pyenv init -)"; | ||
| pyenv install 2.7.6; | ||
| pyenv global 2.7.6; | ||
| pyenv rehash; | ||
| pip install cpp-coveralls; | ||
| pyenv rehash; | ||
| fi; | ||
| - export PATH="$BUILD/bin:$PATH" | ||
| - ./deps/travis_build.sh | ||
|
|
||
| install: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we document why
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tracking at mapbox/node-pre-gyp#152 |
||
| - npm install --build-from-source | ||
| - if [[ ${COVERAGE} == true ]]; then | ||
| export LDFLAGS="--coverage" && export CXXFLAGS="--coverage" && npm install --build-from-source --debug --clang=1; | ||
| else | ||
| npm install --build-from-source --clang=1; | ||
| fi; | ||
|
|
||
| script: | ||
| - npm test | ||
| - npm test | ||
| - if [[ ${COVERAGE} == true ]]; then cpp-coveralls --exclude node_modules --exclude tests --build-root build --gcov-options '\-lp' --exclude doc --exclude build/Debug/obj/gen; fi; | ||
|
|
||
| after_success: | ||
| - ./deps/travis_publish.sh | ||
| - ./deps/travis_publish.sh | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| 'use strict'; | ||
|
|
||
| var path = require('path'); | ||
| var fontnik = require('../'); | ||
| var queue = require('queue-async'); | ||
| var fs = require('fs'); | ||
|
|
||
| // https://gist.github.com/mourner/96b1335c6a43e68af252 | ||
| // https://gist.github.com/fengmk2/4345606 | ||
| function now() { | ||
| var hr = process.hrtime(); | ||
| return hr[0] + hr[1] / 1e9; | ||
| } | ||
|
|
||
| function bench(opts,cb) { | ||
| var q = queue(opts.concurrency); | ||
| var start = now(); | ||
| for (var i = 1; i <= opts.iterations; i++) { | ||
| q.defer.apply({},opts.args); | ||
| } | ||
| q.awaitAll(function(error, results) { | ||
| var seconds = now() - start; | ||
| console.log(opts.name, Math.round(opts.iterations / (seconds)),'ops/sec',opts.iterations,opts.concurrency); | ||
| return cb(); | ||
| }); | ||
| } | ||
|
|
||
| function main() { | ||
| var opensans = fs.readFileSync(path.resolve(__dirname + '/../fonts/open-sans/OpenSans-Regular.ttf')); | ||
|
|
||
| var suite = queue(1); | ||
| suite.defer(bench, { | ||
| name:"fontnik.load", | ||
| args:[fontnik.load,opensans], | ||
| iterations: 10, | ||
| concurrency: 10 | ||
| }); | ||
| suite.defer(bench, { | ||
| name:"fontnik.range", | ||
| args:[fontnik.range,{font:opensans,start:0,end:256}], | ||
| iterations: 1000, | ||
| concurrency: 100 | ||
| }); | ||
| suite.awaitAll(function(err) { | ||
| if (err) throw err; | ||
| }) | ||
| } | ||
|
|
||
| main(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| 'use strict'; | ||
|
|
||
| var path = require('path'); | ||
| var fontnik = require('../'); | ||
| var Benchmark = require('benchmark'); | ||
| var fs = require('fs'); | ||
|
|
||
| var opensans = fs.readFileSync(path.resolve(__dirname + '/../fonts/open-sans/OpenSans-Regular.ttf')); | ||
|
|
||
| var suite = new Benchmark.Suite(); | ||
|
|
||
| suite | ||
| .add('fontnik.load', { | ||
| 'defer': true, | ||
| 'fn': function(deferred) { | ||
| // avoid test inlining | ||
| suite.name; | ||
| fontnik.load(opensans,function(err) { | ||
| if (err) throw err; | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('fontnik.range', { | ||
| 'defer': true, | ||
| 'fn': function(deferred) { | ||
| // avoid test inlining | ||
| suite.name; | ||
| fontnik.range({font:opensans,start:0,end:256},function(err) { | ||
| if (err) throw err; | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .on('cycle', function(event) { | ||
| console.log(String(event.target)); | ||
| }) | ||
| .run({async:true}); |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1 @@ | ||
| var zlib = require('zlib'); | ||
| var path = require('path'); | ||
| var util = require('util'); | ||
| var fontnik = require('./lib/fontnik.node'); | ||
|
|
||
| module.exports = fontnik; | ||
| module.exports.range = range; | ||
| module.exports.getRange = getRange; | ||
|
|
||
| // Retrieve a range of glyphs as a pbf. | ||
| function range(options, callback) { | ||
| 'use strict'; | ||
| options = options || {}; | ||
| options.fontstack = options.fontstack || 'Open Sans Regular'; | ||
|
|
||
| var glyphs = new fontnik.Glyphs(); | ||
| glyphs.range(options.fontstack, options.start + '-' + options.end, getRange(options.start, options.end), gzip); | ||
|
|
||
| function gzip(err) { | ||
| if (err) return callback(err); | ||
| var after = glyphs.serialize(); | ||
| zlib.gzip(after, callback); | ||
| } | ||
| } | ||
|
|
||
| function getRange(start, end) { | ||
| if (typeof start !== 'number') throw new Error('start must be a number from 0-65535'); | ||
| if (start < 0) throw new Error('start must be a number from 0-65535'); | ||
| if (typeof end !== 'number') throw new Error('end must be a number from 0-65535'); | ||
| if (end > 65535) throw new Error('end must be a number from 0-65535'); | ||
| if (start > end) throw new Error('start must be less than or equal to end'); | ||
| var range = []; | ||
| for (var i = start; i <= end; i++) range.push(i); | ||
| return range; | ||
| } | ||
|
|
||
| module.exports = require('./lib/fontnik.node'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gccbuild back in here somewhere?iojsbuild to close out Node.js v0.12 and iojs support #74 and Port to NAN #44? (feel free to copy code from https://github.com/mapbox/node-mapbox-gl-native/pull/88)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a lot of value in gcc. So, I intentionally left it out to keep the matrix tight. If you feel differently, then sure, add an entry to run gcc on linux.
wrt to iojs, feel free to add, but node v0.12 is already covered.