Skip to content

Commit

Permalink
Merge pull request #482 from luuse/choose_platform
Browse files Browse the repository at this point in the history
Toggle platforms to build with grunt cli option
  • Loading branch information
GonzaGonza committed Mar 14, 2014
2 parents 1582403 + e482955 commit ecd85d7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
34 changes: 28 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = function(grunt) {
module.exports = function(grunt) {
var buildPlatforms = parseBuildPlatforms(grunt.option('platforms'));

grunt.initConfig({
compass: {
Expand All @@ -20,10 +21,10 @@
version: '0.9.2',
build_dir: './build', // Where the build version of my node-webkit app is saved
mac_icns: './images/popcorntime.icns', // Path to the Mac icon file
mac: true, // We want to build it for mac
win: true, // We want to build it for win
linux32: false, // We don't need linux32
linux64: true // We don't need linux64
mac: buildPlatforms.mac,
win: buildPlatforms.win,
linux32: buildPlatforms.linux32,
linux64: buildPlatforms.linux64
},
src: ['./css/**', './fonts/**', './images/**', './js/**', './language/**', './node_modules/**', '!./node_modules/grunt*/**', './rc/**', './Config.rb', './index.html', './package.json', './README.md' ] // Your node-webkit app './**/*'
},
Expand Down Expand Up @@ -60,4 +61,25 @@
grunt.registerTask('nodewkbuild', ['nodewebkit', 'copy']);


};
};

var parseBuildPlatforms = function(argumentPlatform) {
// this will make it build no platform when the platform option is specified
// without a value which makes argumentPlatform into a boolean
var inputPlatforms = argumentPlatform || process.platform + ";" + process.arch;

// Do some scrubbing to make it easier to match in the regexes bellow
inputPlatforms = inputPlatforms.replace("darwin", "mac");
inputPlatforms = inputPlatforms.replace(/;ia|;x|;arm/, "");

var buildAll = /^all$/.test(inputPlatforms);

var buildPlatforms = {
mac: /mac/.test(inputPlatforms) || buildAll,
win: /win/.test(inputPlatforms) || buildAll,
linux32: /linux32/.test(inputPlatforms) || buildAll,
linux64: /linux64/.test(inputPlatforms) || buildAll
};

return buildPlatforms;
}
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,25 @@ You will need nodejs and grunt:

$ npm install -g grunt-cli

### Select your OS

Enable your Operating System in `Gruntfile.js` and disable all the others:

nodewebkit: {
options: {
mac: false,
win: false,
linux32: false,
linux64: true
},

### Build

Install the node modules:

$ npm install

Built with:
Build with:

$ grunt nodewkbuild

By default it will build for your current platform however you can control that
by specifying a comma separated list of platforms in the `platforms` option to
grunt:

$ grunt nodewkbuild --platforms=linux32,linux64,mac,win

You can also build for all platforms with:

$ grunt nodewkbuild --platforms=all

## Any problem?

Expand All @@ -82,4 +76,4 @@ Replace `node_modules/moviedb/node_modules/superagent/index.js` contents with:
- Run `compass watch` in Terminal for CSS compiling and listen to future changes.
- [How to build with SublimeText](https://github.com/rogerwang/node-webkit/wiki/Debugging-with-Sublime-Text-2-and-3)
- Currently Gaze to watch all files and reload the app is disabled due to memory leaks and unstability.
- Run node-webkit from the root directory with --debug to enable debugging mode like so ```node-webkit . --debug```
- Run node-webkit from the root directory with --debug to enable debugging mode like so ```node-webkit . --debug```

0 comments on commit ecd85d7

Please sign in to comment.