Skip to content

Commit 9858668

Browse files
committed
Merge branch 'feature/node-pre-gyp-support' into develop
2 parents 74b65aa + e33c712 commit 9858668

File tree

15 files changed

+461
-151
lines changed

15 files changed

+461
-151
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ npm-debug.log
55
examples/cacert*
66
docs
77
wallaby.json
8-
debug/
8+
lib/binding
9+
debug

.npmignore

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
.lock-wscript
2-
raw/
1+
.eslintrc
2+
.eslintignore
3+
.codeclimate.yml
4+
.idea
5+
.travis.yml
6+
appveyor.yml
7+
jsdoc-tmpl.config.json
8+
jsdoc.json
9+
wallaby.json
310
build/
411
deps/
512
docs/
613
lib/binding/
7-
.idea
14+
debug/
815
*.tgz
9-
debug/

.travis.yml

Lines changed: 101 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,101 @@
1-
# language: node_js removed due to https://github.com/travis-ci/travis-ci/issues/2311
2-
os:
3-
- linux
4-
- osx
5-
6-
language: cpp
7-
8-
sudo: false
9-
10-
addons:
11-
apt:
12-
sources:
13-
- ubuntu-toolchain-r-test
14-
packages:
15-
- gcc-4.8
16-
- g++-4.8
17-
- openssl
18-
env:
19-
global:
20-
- GCC_VERSION=4.8
21-
- DEBUG="node-libcurl"
22-
matrix:
23-
- TRAVIS_NODE_VERSION="0.10" LIBCURL_VERSION_TAG=LATEST
24-
- TRAVIS_NODE_VERSION="0.12" LIBCURL_VERSION_TAG=LATEST
25-
- TRAVIS_NODE_VERSION="iojs-3" LIBCURL_VERSION_TAG=LATEST
26-
- TRAVIS_NODE_VERSION="4" LIBCURL_VERSION_TAG=LATEST
27-
# repeat again but for curl-7_35_0
28-
- TRAVIS_NODE_VERSION="0.10" LIBCURL_VERSION_TAG="curl-7_35_0"
29-
- TRAVIS_NODE_VERSION="0.12" LIBCURL_VERSION_TAG="curl-7_35_0"
30-
- TRAVIS_NODE_VERSION="iojs-3" LIBCURL_VERSION_TAG="curl-7_35_0"
31-
- TRAVIS_NODE_VERSION="4" LIBCURL_VERSION_TAG="curl-7_35_0"
32-
33-
cache:
34-
directories:
35-
- $HOME/curl-source
36-
37-
git:
38-
submodules: false
39-
40-
before_install:
41-
42-
install:
43-
- rm -rf ~/.nvm
44-
- git clone https://github.com/creationix/nvm.git ~/.nvm
45-
- source ~/.nvm/nvm.sh
46-
- nvm install $TRAVIS_NODE_VERSION
47-
# always use the latest npm
48-
- npm install npm
49-
- mv node_modules npm
50-
# https://github.com/travis-ci/travis-ci/issues/3668
51-
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CC=/usr/bin/gcc-${GCC_VERSION} CXX=/usr/bin/g++-${GCC_VERSION}; fi;
52-
- export PATH=$HOME/curl/bin:$PATH
53-
# output helpful info
54-
- node --version
55-
- npm/.bin/npm --version
56-
- gcc --version && g++ --version
57-
# grab libcurl
58-
- if [[ ${LIBCURL_VERSION_TAG} == 'LATEST' ]]; then
59-
TAG=$(git ls-remote --tags https://github.com/bagder/curl.git | awk '{print $2}' | grep "curl-" | grep -v "[0-9][_-][abp]" | grep -v "{" | sort -t_ -k 1.16,1n -k 2,2n -k 3,3n -k 4,4n | sed -n "s@.*\(curl-[0-9_]\)@\1@p" | tail -n1);
60-
else
61-
TAG=${LIBCURL_VERSION_TAG};
62-
fi;
63-
- mkdir -p $HOME/curl-source
64-
- cd $HOME/curl-source
65-
- if [[ ! -d "$TAG" ]]; then
66-
git clone --branch "$TAG" --depth 1 https://github.com/bagder/curl.git "$TAG";
67-
fi;
68-
- cd "$TAG"
69-
- ./buildconf && ./configure --prefix=$HOME/curl && make && make install
70-
- curl-config --version
71-
- curl-config --features
72-
- curl-config --protocols
73-
- cd $TRAVIS_BUILD_DIR
74-
- node tools/curl-config.js
75-
- npm/.bin/npm install
76-
77-
script:
78-
- npm/.bin/npm test
1+
os:
2+
- linux
3+
- osx
4+
language: cpp
5+
sudo: false
6+
addons:
7+
apt:
8+
sources:
9+
- ubuntu-toolchain-r-test
10+
packages:
11+
- gcc-4.8
12+
- g++-4.8
13+
- openssl
14+
env:
15+
global:
16+
- GCC_VERSION=4.8
17+
- DEBUG="node-libcurl"
18+
- secure: d64E8XbVGHuQ0kls1oVUF1y6pnj3iqZB34roKBHAFTyWBXReC1FWLb+qEShCJicUDkeK2At7vQUz7ohMn2mL/hVXiRbuSaYuDKFx8iDeei9mTgE+iy258mSovnNvXfG72EP5+LB+UOhgmTGe0qyTALOQ6ceCgjdscul3IGWE8lw=
19+
matrix:
20+
- TRAVIS_NODE_VERSION="0.10" LIBCURL_VERSION_TAG=LATEST
21+
- TRAVIS_NODE_VERSION="0.12" LIBCURL_VERSION_TAG=LATEST
22+
- TRAVIS_NODE_VERSION="iojs-3" LIBCURL_VERSION_TAG=LATEST
23+
- TRAVIS_NODE_VERSION="4" LIBCURL_VERSION_TAG=LATEST
24+
- TRAVIS_NODE_VERSION="0.10" LIBCURL_VERSION_TAG="curl-7_30_0"
25+
- TRAVIS_NODE_VERSION="0.12" LIBCURL_VERSION_TAG="curl-7_30_0"
26+
- TRAVIS_NODE_VERSION="iojs-3" LIBCURL_VERSION_TAG="curl-7_30_0"
27+
- TRAVIS_NODE_VERSION="4" LIBCURL_VERSION_TAG="curl-7_30_0"
28+
cache:
29+
directories:
30+
- $HOME/curl-source
31+
git:
32+
submodules: false
33+
before_install:
34+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then
35+
export CC=/usr/bin/gcc-${GCC_VERSION};
36+
export CXX=/usr/bin/g++-${GCC_VERSION};
37+
fi;
38+
# update openssl on mac
39+
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then
40+
brew update;
41+
brew install openssl;
42+
brew link --force openssl;
43+
fi;
44+
- export PATH=$HOME/bin:$PATH
45+
- rm -rf ~/.nvm
46+
- git clone https://github.com/creationix/nvm.git ~/.nvm
47+
- source ~/.nvm/nvm.sh
48+
- nvm install $TRAVIS_NODE_VERSION
49+
- npm install npm
50+
- mv node_modules npm
51+
- export PATH="./node_modules/.bin/:$PATH"
52+
# output versions
53+
- npm/.bin/npm --version
54+
- node --version
55+
- node tools/curl-config.js
56+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then apt-cache policy openssl; fi;
57+
- openssl version -a
58+
- if [[ $LIBCURL_VERSION_TAG == 'LATEST' ]]; then
59+
TAG=$( git ls-remote --tags https://github.com/bagder/curl.git |
60+
awk '{print $2}' | grep 'curl-' | grep -v '[0-9][_-][abp]' |
61+
grep -v '{' | sort -t_ -k 1.16,1n -k 2,2n -k 3,3n -k 4,4n |
62+
sed -n 's@.*\(curl-[0-9_]\)@\1@p' | tail -n1 );
63+
else
64+
TAG=${LIBCURL_VERSION_TAG};
65+
fi;
66+
- mkdir -p $HOME/curl-source
67+
- cd $HOME/curl-source
68+
- if [[ ! -d "$TAG" ]]; then
69+
git clone --branch "$TAG" --depth 1 https://github.com/bagder/curl.git "$TAG";
70+
fi;
71+
- cd "$TAG"
72+
- ./buildconf && ./configure --prefix=$HOME && make && make install
73+
- cd $TRAVIS_BUILD_DIR
74+
# output curl version info
75+
- curl --version
76+
- curl-config --version
77+
- curl-config --features
78+
- curl-config --protocols
79+
- PUBLISH_BINARY=false
80+
- COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n')
81+
- if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` || ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then
82+
PUBLISH_BINARY=true;
83+
fi;
84+
install:
85+
- npm/.bin/npm install --build-from-source --loglevel=http
86+
- npm/.bin/npm test
87+
before_script:
88+
- if [[ $PUBLISH_BINARY == true && $LIBCURL_VERSION_TAG == LATEST ]]; then
89+
node-pre-gyp package testpackage --verbose;
90+
node scripts/module-packaging.js --publish "$(node-pre-gyp reveal staged_tarball --silent)";
91+
fi;
92+
script:
93+
- INSTALL_RESULT=0
94+
- if [[ $PUBLISH_BINARY == true ]]; then
95+
INSTALL_RESULT=$(npm/.bin/npm install --fallback-to-build=false > /dev/null)$? || true;
96+
fi;
97+
- if [[ $INSTALL_RESULT != 0 ]]; then
98+
node scripts/module-packaging.js --unpublish "$(node-pre-gyp reveal hosted_tarball --silent)";
99+
false;
100+
fi
101+
- node-pre-gyp clean

README.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,41 @@ For more examples check the [examples folder](examples).
8585

8686
Check the [API Docs](api.md)
8787

88-
## Installing on Windows
88+
## Detailed Installation
8989

90-
#### What you need to have installed:
90+
This package has prebuilt binaries available for the following platforms:
91+
* Linux 64 bits
92+
* Mac OS X 64 bits
93+
* Windows 32 and 64 bits
9194

92-
* [Python 2.7](https://www.python.org/download/releases/2.7)
93-
* [Visual Studio >= 2013](http://www.visualstudio.com/downloads/download-visual-studio-vs)
94-
* [git](https://desktop.github.com/)
95+
Just running ``npm install node-libcurl`` should install a prebuilt binary and no compilation will be needed.
96+
97+
If there is no prebuilt binary available that matches your system, or if the installation fails, then you will
98+
need an environment capable of compilling nodejs addons, which means [python 2.7](https://www.python.org/download/releases/2.7)
99+
installed and an updated C++ compiler able to compile C++11.
100+
101+
If you don't want to use a prebuilt binary you can pass ``--build-from-source`` to the arguments list.
102+
103+
### Linux
104+
105+
The only compiler supported on linux is gcc >=4.8, also you need to have the libcurl development files available,
106+
if you are running debian for example, you must install the ``libcurl4-openssl-dev`` package.
107+
108+
If you don't want to use the libcurl version shipped with your system, since it's probably very old
109+
(debian 7 uses libcurl 7.26 which is more than 3 years old, and had more than 1000 bugfixes already),
110+
you can install libcurl from source, the addon will pick the libcurl info using the ``curl-config`` tool,
111+
that way you only need to make sure that the libcurl you installed is in the path and in higher priority
112+
than the system one.
113+
114+
### OS X
115+
116+
You need to have installed OS X >=10.8 and xcode >=4.5
117+
118+
If you want to install using a different version of libcurl, the same instructions for linux applies.
119+
120+
### Windows
121+
122+
If installing using a prebuilt binary you only need to have the [visual c++ 2013 runtime library](https://www.microsoft.com/en-us/download/details.aspx?id=40784).
123+
If building from source, you need to have Python 2.7, [Visual Studio >=2013](http://www.visualstudio.com/downloads/download-visual-studio-vs) and [git](https://desktop.github.com/)
124+
125+
Currently there is no support to use other libcurl version than the one provided by the [curl-for-windows](https://github.com/JCMais/curl-for-windows) submodule.

appveyor.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# http://www.appveyor.com/docs/appveyor-yml
22
# mostly copied from nan appveyor.yml
3-
os: Visual Studio 2015
4-
53
environment:
64
DEBUG: "node-libcurl"
5+
NODE_LIBCURL_GITHUB_TOKEN:
6+
secure: o8iCZIMbaOR5HKy9Q/ArQ6N+5LRepyRVYRtLTrxyCo2gCEXUp8xhUYjLMJmZgNu9
77
matrix:
88
# node.js
99
- nodejs_version: 0.10
@@ -26,21 +26,42 @@ install:
2626
# Update nodejs for versions < 1
2727
- IF %nodejs_version% LSS 1 npm -g install npm
2828
- IF %nodejs_version% LSS 1 set PATH=%APPDATA%\npm;%PATH%
29+
- SET PATH=%cd%\node_modules\.bin\;%PATH%
2930
# Output useful info for debugging.
3031
- node --version
3132
- npm --version
32-
# Install the package.
33+
# Check if we need to publish the package
34+
- SET PUBLISH_BINARY=false
35+
# we are creating a empty file named publish
36+
- ps: if ( $env:APPVEYOR_REPO_COMMIT_MESSAGE.ToLower().Contains('[publish binary]') -OR $(git describe --tags --always HEAD) -eq $env:APPVEYOR_REPO_BRANCH ) { echo $null >> publish }
37+
- IF EXIST "publish" SET PUBLISH_BINARY=true
38+
# Install the curl-for-windows dependencies.
3339
- git submodule update --init --recursive
3440
- python deps\curl-for-windows\configure.py
35-
- npm install --loglevel=http
41+
42+
build_script:
43+
- node tools\retrieve-win-deps.js
44+
- npm install --build-from-source --msvs_version=2013 --loglevel=http
3645

3746
# Post-install test scripts.
3847
test_script:
3948
# run tests
40-
- IF %nodejs_version% LSS 1 (npm test) ELSE (IF %nodejs_version% LSS 4 (iojs node_modules\mocha\bin\mocha test --reporter spec) ELSE (node node_modules\mocha\bin\mocha test --reporter spec))
49+
- IF %nodejs_version% LSS 1 (npm test) ELSE (IF %nodejs_version% LSS 4 (iojs node_modules\mocha\bin\mocha test --reporter spec) ELSE (npm test))
50+
51+
after_test:
52+
- IF "%PUBLISH_BINARY%" == "true" (node-pre-gyp package testpackage --verbose)
53+
- IF "%PUBLISH_BINARY%" == "true" (for /f "usebackq delims=" %%x in (`node-pre-gyp reveal staged_tarball --silent`) do node scripts\module-packaging.js --publish %%x)
54+
55+
on_success:
56+
- SET INSTALL_RESULT=0
57+
- IF "%PUBLISH_BINARY%" == "true" (npm install --fallback-to-build=false)
58+
- IF "%PUBLISH_BINARY%" == "true" (SET INSTALL_RESULT=%ERRORLEVEL%)
59+
- IF NOT %INSTALL_RESULT% == 0 (for /f "usebackq delims=" %%x in (`node-pre-gyp reveal hosted_tarball --silent`) do node scripts\module-packaging.js --unpublish %%x)
60+
- IF NOT %INSTALL_RESULT% == 0 (echo "Package unpublished since we got an error while installing it.")
61+
- node-pre-gyp clean
4162

42-
# Don't actually build.
43-
build: off
63+
# Don't actually deploy.
64+
deploy: off
4465

4566
# Set build version format here instead of in the admin panel.
4667
version: "{build}"

binding.gyp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
'targets': [
33
{
4-
'target_name': 'node-libcurl',
4+
'target_name': '<(module_name)',
55
'sources': [
66
'src/node_libcurl.cc',
77
'src/Easy.cc',
@@ -12,7 +12,7 @@
1212
'src/string_format.cc',
1313
'src/strndup.cc'
1414
],
15-
"include_dirs" : [
15+
'include_dirs' : [
1616
"<!(node -e \"require('nan')\")"
1717
],
1818
'msvs_settings': {
@@ -46,10 +46,10 @@
4646
},
4747
'cflags' : ['-std=c++11', '-O2', '-Wno-narrowing'],
4848
'cflags!': [ '-fno-exceptions', '-O3' ], # enable exceptions, remove level 3 optimization
49-
"xcode_settings": {
49+
'xcode_settings': {
5050
'OTHER_CPLUSPLUSFLAGS' : ['-std=c++11','-stdlib=libc++'],
5151
'OTHER_LDFLAGS': ['-stdlib=libc++'],
52-
'MACOSX_DEPLOYMENT_TARGET': '10.7',
52+
'MACOSX_DEPLOYMENT_TARGET': '10.8',
5353
'WARNING_CFLAGS':[
5454
'-Wno-c++11-narrowing',
5555
'-Wno-constant-conversion'
@@ -58,7 +58,7 @@
5858
'conditions': [
5959
['OS=="win"', {
6060
'dependencies': [
61-
'deps/curl-for-windows/curl.gyp:libcurl'
61+
'<!@(node "<(module_root_dir)/tools/retrieve-win-deps.js")'
6262
],
6363
'defines' : [
6464
'CURL_STATICLIB'
@@ -72,6 +72,17 @@
7272
]
7373
}]
7474
]
75+
},
76+
{
77+
'target_name': 'action_after_build',
78+
'type': 'none',
79+
'dependencies': [ '<(module_name)' ],
80+
'copies': [
81+
{
82+
'files': [ '<(PRODUCT_DIR)/<(module_name).node' ],
83+
'destination': '<(module_path)'
84+
}
85+
]
7586
}
7687
]
7788
}

lib/Curl.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@
2121
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2222
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323
*/
24-
var _Curl = require( 'bindings' )( 'node-libcurl' ).Curl,
25-
Easy = require( './Easy' ),
26-
Multi = require( './Multi' ),
27-
util = require( 'util' ),
28-
assert= require( 'assert' ),
24+
var binary = require( 'node-pre-gyp' ),
25+
path = require('path' ),
26+
bindingPath = binary.find( path.resolve( path.join( __dirname,'./../package.json' ) ) ),
27+
_Curl = require( bindingPath ).Curl,
28+
Easy = require( './Easy' ),
29+
Multi = require( './Multi' ),
30+
util = require( 'util' ),
31+
assert = require( 'assert' ),
2932
StringDecoder = require( 'string_decoder' ).StringDecoder,
3033
EventEmitter = require( 'events' ).EventEmitter,
31-
decoder = new StringDecoder( 'utf8' ),
34+
decoder = new StringDecoder( 'utf8' ),
3235
multiHandle = new Multi(),
3336
curls = {};
3437

0 commit comments

Comments
 (0)