Skip to content

Commit

Permalink
Merge pull request #3 from pidupuis/develop
Browse files Browse the repository at this point in the history
Add arguments for CMake
  • Loading branch information
pidupuis committed Feb 9, 2015
2 parents 8f8d072 + 14c5c61 commit 800be6c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = function(grunt) {
},
cmake: {
options: {
cmake: true
cmake: ['.']
},
projects: [
'test/fixtures/cmake'
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Description

If your project integrates subprojects using GNU Make, this plugin is made for you! With this plugin you will be able to run any Make rules from any Makefile inside any Grunt task.
If your project integrates subprojects using [GNU Make](http://www.gnu.org/software/make/), this plugin is made for you! With this plugin you will be able to run any Make rules from any Makefile inside any Grunt task.

Numerous use cases including:
* Build your Make-based subprojects during the build of your Grunt-based parent project,
Expand Down Expand Up @@ -58,10 +58,9 @@ grunt.initConfig({
### Options

#### options.cmake
Type: `bool`
Default value: `true`
Type: `Array`

Determines if you want to run `cmake` before `make` to generate the Makefile.
Determines if you want to run `cmake` before `make` to generate the Makefile. The array contains the list of arguments (including the working path directory !).

### Usage Examples

Expand All @@ -70,13 +69,13 @@ grunt.initConfig({
submake: {
target1: {
projects: {
// For each of these projects, the specified make tasks will be executed:
// For each of these projects, the specified make rules will be executed:
'sub-projects/module': '',
'sub-projects/module2': 'build'
}
},
target2: {
// Use an array to run multiple tasks:
// Use an array to run multiple rules:
'sub-projects/module': [ 'clean', 'test' ]
},
target3: {
Expand All @@ -89,9 +88,9 @@ grunt.initConfig({
'sub-projects/module2'
],
target5: {
// you can run cmake before make tasks:
// you can run cmake (with arguments) before make:
options: {
cmake: true
cmake: ['.']
},
projects: [
'sub-projects/module'
Expand All @@ -113,5 +112,5 @@ Do not hesitate to open an [issue](https://github.com/pidupuis/grunt-submake/iss

## Release History

* Coming soon: CMake arguments
* 0.1.0: Run `make` rules (with arguments or not) for specific paths; Can also run CMake beforehand to generate the Makefile
* ~0.2.0: CMake command can now be run with arguments
* ~0.1.0: Run `make` rules (with arguments or not) for specific paths; Can also run CMake beforehand to generate the Makefile
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-submake",
"description": "Run Make rules through Grunt tasks (by just specifying the Makefile path and the rules!)",
"version": "0.1.1",
"version": "0.2.0",
"homepage": "https://github.com/pidupuis/grunt-submake",
"author": {
"name": "pidupuis",
Expand Down
14 changes: 9 additions & 5 deletions tasks/submake.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var async = require('async');

module.exports = function(grunt) {

var runCMake = function(path, next) {
var runCMake = function(path, args, next) {
grunt.util.spawn({
cmd: 'cmake',
args: ['.'],
args: args,
opts: {
cwd: path
}
Expand Down Expand Up @@ -50,7 +50,7 @@ module.exports = function(grunt) {
}
next();
});

});
};

Expand All @@ -61,6 +61,10 @@ module.exports = function(grunt) {
if (this.data.options) {
if (this.data.options.cmake) {
cmake = true;
var cmakeArgs = this.data.options.cmake;
if (!(cmakeArgs instanceof Array)) {
cmakeArgs = [cmakeArgs];
}
}
}

Expand All @@ -81,9 +85,9 @@ module.exports = function(grunt) {
if (!(tasks instanceof Array)) {
tasks = [tasks];
}

if (cmake) {
runCMake(path, function() {
runCMake(path, cmakeArgs, function() {
runMake(path, tasks, function() {
callback();
});
Expand Down

0 comments on commit 800be6c

Please sign in to comment.