Skip to content

Commit

Permalink
Merge pull request #104 from megawac/umd-modules
Browse files Browse the repository at this point in the history
Full nodejs support
  • Loading branch information
rctoris committed Oct 1, 2014
2 parents 7e130f9 + 3b27edf commit 4894b08
Show file tree
Hide file tree
Showing 62 changed files with 1,269 additions and 1,161 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.vagrant
doc
node_modules
*.out
*.log
6 changes: 2 additions & 4 deletions utils/.jshintrc → .jshintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"globals": {
"module": true,
"EventEmitter2" : true
"global": true
},
"curly": true,
"eqeqeq": true,
Expand All @@ -13,9 +12,8 @@
"undef": true,
"boss": false,
"eqnull": false,
"browser": true,
"node": true,
"devel": true,
"es5": true,
"strict": false,
"trailing": true,
"quotmark": "single",
Expand Down
33 changes: 22 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
language: node_js

node_js:
- "0.10"
addons:
firefox: "31.0" # 3.4->31.0
os:
- linux
before_install:
# node-canvas dependency
- sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
# ROS deps for examples
- sudo sh -c 'echo "deb http://packages.ros.org/ros-shadow-fixed/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
- sudo apt-get update -qq
- sudo apt-get install ros-hydro-ros-base
- sudo apt-get install ros-hydro-rosbridge-server ros-hydro-tf2-web-republisher ros-hydro-common-tutorials ros-hydro-rospy-tutorials ros-hydro-actionlib-tutorials
- npm install -g grunt-cli karma-cli

branches:
only:
- master
- develop

# Set up Xfvb for Firefox headless testing
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
before_script:
- npm install -g karma grunt-cli
- cd utils
- npm install .

- source /opt/ros/hydro/setup.bash
- sh test/examples/setup_examples.sh
script:
- grunt build
- rostopic list
- npm test
- npm run test-examples
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
roslibjs Build Setup
====================

[Grunt](http://gruntjs.com/) is used for building, including concatenating, minimizing, documenting, linting, and testing.

### Install Grunt and its Dependencies

1. Install [Node.js](http://nodejs.org/) for your environment
2. Install the build task runner, [Grunt](http://gruntjs.com/)

```sh
$ [sudo] npm install -g grunt
```

3. Install the [Cario](http://cairographics.org/) graphics library
- [System specific instaructions](https://github.com/Automattic/node-canvas/wiki/_pages)
4. Install the dependencies and build dependencies

```sh
$ cd /path/to/roslibjs/
$ [sudo] npm install
```


Easy installation for Ubuntu. `cd` to your local copy of this project.

```sh
# Install Node.js and NPM
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs

# Install Cario
sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

# Install this projects Deps
sudo npm install
```

### Build with Grunt

Before proceeding, please confirm you have installed the dependencies above.

To run the build tasks:

1. `cd /path/to/roslibjs/`
2. `grunt build`

`grunt build` will concatenate and minimize the files under src and replace roslib.js and roslib.min.js in the build directory. It will also run the linter and test cases. This is what [Travis CI](https://travis-ci.org/RobotWebTools/roslibjs) runs when a Pull Request is submitted.

`grunt dev` will watch for any changes to any of the src/ files and automatically concatenate and minimize the files. This is ideal for those developing as you should only have to run `grunt dev` once.

`grunt doc` will rebuild all JSDoc for the project.
52 changes: 33 additions & 19 deletions utils/Gruntfile.js → Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
build: {
src : ['../src/*.js', '../src/**/*.js'],
dest : '../build/roslib.js'
browserify: {
dist: {
src: ['./src/RosLibBrowser.js'],
dest: './build/roslib.js'
}
},
jshint: {
Expand All @@ -14,23 +14,35 @@ module.exports = function(grunt) {
},
files: [
'Gruntfile.js',
'../build/roslib.js'
'./src/**/*.js'
]
},
karma: {
build: {
configFile: '../test/karma.conf.js',
configFile: './test/karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
browsers: ['Firefox']
}
},
mochaTest: {
options: {
reporter: 'spec',
timeout: 5000
},
test: {
src: ['test/*.test.js']
},
examples: {
src: ['test/examples/*.js']
}
},
uglify: {
options: {
report: 'min'
},
build: {
src: '../build/roslib.js',
dest: '../build/roslib.min.js'
src: './build/roslib.js',
dest: './build/roslib.min.js'
}
},
watch: {
Expand All @@ -42,7 +54,7 @@ module.exports = function(grunt) {
'../src/*.js',
'../src/**/*.js'
],
tasks: ['concat']
tasks: ['browserify']
},
build_and_watch: {
options: {
Expand All @@ -51,8 +63,8 @@ module.exports = function(grunt) {
files: [
'Gruntfile.js',
'.jshintrc',
'../src/*.js',
'../src/**/*.js'
'./src/*.js',
'./src/**/*.js'
],
tasks: ['build']
}
Expand All @@ -66,27 +78,29 @@ module.exports = function(grunt) {
jsdoc: {
doc: {
src: [
'../src/*.js',
'../src/**/*.js'
'./src/*.js',
'./src/**/*.js'
],
options: {
destination: '../doc'
destination: './doc'
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-mocha-test');


grunt.registerTask('dev', ['concat', 'watch']);
grunt.registerTask('build', ['concat', 'jshint', 'karma', 'uglify']);
grunt.registerTask('dev', ['browserify', 'watch']);
grunt.registerTask('test', ['jshint', 'mochaTest:test', 'browserify', 'karma']);
grunt.registerTask('build', ['test', 'uglify']);
grunt.registerTask('build_and_watch', ['watch']);
grunt.registerTask('doc', ['clean', 'jsdoc']);
};

Loading

0 comments on commit 4894b08

Please sign in to comment.