From a11332e419dba6e2da400a77d670b4fc7bc198cc Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 7 Jul 2015 17:25:12 -0400 Subject: [PATCH] use mason to handle dependencies --- .gitignore | 1 + .gitmodules | 3 + .mason | 1 + .travis.yml | 140 +++++++++++++++++----------- binding.gyp | 53 ++++++++--- deps/build_boost.sh | 23 ----- deps/build_freetype.sh | 40 -------- deps/build_protobuf.sh | 31 ------ deps/travis_build.sh | 10 -- package.json | 2 +- scripts/install_mason.sh | 29 ++++++ scripts/install_node.sh | 12 +++ {deps => scripts}/travis_publish.sh | 0 13 files changed, 175 insertions(+), 170 deletions(-) create mode 100644 .gitmodules create mode 160000 .mason delete mode 100755 deps/build_boost.sh delete mode 100755 deps/build_freetype.sh delete mode 100755 deps/build_protobuf.sh delete mode 100755 deps/travis_build.sh create mode 100755 scripts/install_mason.sh create mode 100755 scripts/install_node.sh rename {deps => scripts}/travis_publish.sh (100%) diff --git a/.gitignore b/.gitignore index a75e43e..8beffe2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ lib glyphs spec node_modules +mason_packages diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..44fba9a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".mason"] + path = .mason + url = https://github.com/mapbox/mason.git diff --git a/.mason b/.mason new file mode 160000 index 0000000..4c71c86 --- /dev/null +++ b/.mason @@ -0,0 +1 @@ +Subproject commit 4c71c8614fd888058408994841a470271268821a diff --git a/.travis.yml b/.travis.yml index 48b9905..d66b3e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,69 +1,105 @@ -language: cpp +# Prevent Travis from exporting CXX after matrix env +language: c + +sudo: false matrix: include: - # Coverage - - os: osx - 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" +# Coverage + - os: osx + compiler: clang + env: + - NODE_EXE: "node" + - NODE_VERSION: 0.10 + - COVERAGE: true + - CXXFLAGS: "--coverage" + - LDFLAGS: "--coverage" +# Linux + - os: linux + compiler: clang + env: + - CXX: clang++-3.5 + - NODE_EXE: "node" + - NODE_VERSION: 0.10 + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ] + packages: [ 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6' ] + - os: linux + compiler: clang + env: + - CXX: clang++-3.5 + - NODE_EXE: "node" + - NODE_VERSION: 0.12 + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ] + packages: [ 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6' ] + - os: linux + compiler: clang + env: + - CXX: clang++-3.5 + - NODE_EXE: "iojs" + - NODE_VERSION: 2.3 + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ] + packages: [ 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6' ] +# OS X + - os: osx + compiler: clang + env: + - NODE_EXE: "node" + - NODE_VERSION: 0.10 + - os: osx + compiler: clang + env: + - NODE_EXE: "node" + - NODE_VERSION: 0.12 + - os: osx + compiler: clang + env: + - NODE_EXE: "iojs" + - NODE_VERSION: 2.3 env: global: - - 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=" + - secure: "XV0lekmfgT+D9t0ZTIU+UJF6g+p3cBQMO6T6C9lkoKTC0YbtLtxSFtBahD/4PjL86DMJgTaf1nBmxqOxbrfkcpJUxnLe3r8u4Z2L/+7+QSACLNktlIfWNSO+33WxKNb4mVw6jMFZIo4ZurF016MXYzLzjpxRELW2oO2STUs2m44=" + - secure: "CQNHbxw8yHlAdUVbKokHzHmj7C+duXP3mifWOkZm9GKw4myWsRFhhoSYZmOSkgj9EWfYYkedrqEr9+GaMg9rkVJuO/7jzn6S+M7CFXKJju6MoZEDO6WcFva4M8pw6IFb9q22GcQ+OsE8/i0DwchTokyFkNb3fpwWuwROUPQ/nWg=" before_install: - - 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 +- export COVERAGE=${COVERAGE:-false} +- 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; +- ./scripts/install_node.sh install: - - if [[ ${COVERAGE} == true ]]; then - export LDFLAGS="--coverage" && export CXXFLAGS="--coverage" && npm install --build-from-source --debug --clang=1; +- if [[ ${COVERAGE} == true ]]; then + npm install --build-from-source --debug --clang; else - npm install --build-from-source --clang=1; + npm install --build-from-source --clang; fi; +before_script: +- ulimit -c unlimited -S +- ulimit -a + script: - - 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; +- 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 +- ./scripts/travis_publish.sh +git: + submodules: true diff --git a/binding.gyp b/binding.gyp index 854cf0d..5593abf 100644 --- a/binding.gyp +++ b/binding.gyp @@ -30,23 +30,50 @@ './include', './vendor/agg/include', '<(SHARED_INTERMEDIATE_DIR)/', - '> build.log -./deps/build_freetype.sh 1>> build.log diff --git a/package.json b/package.json index 7bbf495..8bc3f31 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "font-inspect": "./bin/font-inspect" }, "scripts": { - "install": "node-pre-gyp install --fallback-to-build", + "install": ". ./scripts/install_mason.sh && node-pre-gyp install --fallback-to-build", "test": "node_modules/.bin/mocha -R spec" }, "binary": { diff --git a/scripts/install_mason.sh b/scripts/install_mason.sh new file mode 100755 index 0000000..79faabd --- /dev/null +++ b/scripts/install_mason.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# This script is sourced, so do not set -e or -o pipefail here. Doing so would +# bleed into Travis' wrapper script, which messes with their workflow, e.g. +# preventing after_failure scripts to be triggered. + +case `uname -s` in + 'Darwin') JOBS=$((`sysctl -n hw.ncpu` + 2)) ;; + 'Linux') JOBS=$((`nproc` + 2)) ;; + *) JOBS=2 ;; +esac + +export JOBS + +git submodule update --init .mason + +export PATH="`pwd`/.mason:${PATH}" +export MASON_DIR="`pwd`/.mason" + +export BOOST_VERSION=1.58.0 +export FREETYPE_VERSION=2.6 +export PROTOBUF_VERSION=2.6.1 + +mason install boost ${BOOST_VERSION} +mason install freetype ${FREETYPE_VERSION} +mason install protobuf ${PROTOBUF_VERSION} + +# Add protoc to $PATH +export PATH="`mason prefix protobuf ${PROTOBUF_VERSION}`/bin:${PATH}" diff --git a/scripts/install_node.sh b/scripts/install_node.sh new file mode 100755 index 0000000..95d5d3e --- /dev/null +++ b/scripts/install_node.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +git clone https://github.com/creationix/nvm.git ../.nvm +source ../.nvm/nvm.sh + +nvm install ${NODE_EXE} ${NODE_VERSION} + +${NODE_EXE} --version +npm --version diff --git a/deps/travis_publish.sh b/scripts/travis_publish.sh similarity index 100% rename from deps/travis_publish.sh rename to scripts/travis_publish.sh