-
Notifications
You must be signed in to change notification settings - Fork 20
/
Gruntfile.js
120 lines (111 loc) · 4.13 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var arduino = process.env.ARDUINO_PATH;
// these are the main target boards for the SimpleBot.
var boards = {
"uno" :{
package: "arduino:avr:uno",
},
"nano": {
cpu: "atmega328",
package: "arduino:avr:nano:cpu=atmega328",
},
};
// use this so we can expand it later.
var boardlist = Object.keys(boards).toString();
module.exports = function(grunt) {
// configure the tasks
grunt.initConfig({
clean: {
firmware_build: {
src: [
'firmware/build/standard/simplebot_firmata',
'firmware/build/sbs/sbs_firmata',
'firmware/build/network/simplebot_firmata',
]
},
compiled_bins: {
src: [
'firmware/bin/*'
]
},
post_compile: {
src: [
'firmware/bin/standard/{' + boardlist + '}/!(*ino.hex)',
'firmware/bin/network/{' + boardlist + '}/!(*ino.hex)',
]
},
},
copy: {
options: {
timestamp: true,
},
simplebot_firmata: {
cwd: 'firmware/src/',
flatten: true,
src: [ 'libs/firmata/**', 'controller_src/simplebot_firmata/*' ],
dest: 'firmware/build/standard/simplebot_firmata/',
expand: true,
filter: 'isFile',
},
sbs_firmata: {
cwd: './',
flatten: true,
src: [ 'firmware/src/libs/firmata/**',
'firmware/src/controller_src/sbs_firmata/*',
'node_modules/node-pixel/firmware/src/libs/neopixel/*',
'node_modules/node-pixel/firmware/src/libs/ws2812/*'
],
dest: 'firmware/build/sbs/sbs_firmata/',
expand: true,
filter: 'isFile',
},
network_simplebot_firmata: {
cwd: 'firmware/src/',
flatten: true,
src: [ 'libs/firmata/**', 'controller_src/simplebot_firmata/*' ],
dest: 'firmware/build/network/simplebot_firmata/',
expand: true,
filter: 'isFile',
},
},
'string-replace': {
precompile: {
files: [{
src: 'firmware/build/network/simplebot_firmata/simplebot_firmata.ino',
dest: 'firmware/build/network/simplebot_firmata/simplebot_firmata.ino',
}],
options: {
replacements: [{
pattern: /57600/,
replacement: '115200',
}],
},
},
},
});
// load the tasks
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-exec');
// build the bins for the target
// dynamically create the compile targets for the various boards
Object.keys(boards).forEach(function(board) {
var cwd = 'firmware/build/';
grunt.config(["exec", board + "_standard"], {
command:function() {
return arduino + " --verify --verbose-build --board " + boards[board].package +
" --pref build.path=firmware/bin/standard/" + board + " " + cwd +
"standard/simplebot_firmata/simplebot_firmata.ino";
},
});
grunt.config(["exec", board + "_network"], {
command:function() {
return arduino + " --verify --verbose-build --board " + boards[board].package +
" --pref build.path=firmware/bin/network/" + board + " " + cwd +
"network/simplebot_firmata/simplebot_firmata.ino";
},
});
});
grunt.registerTask('build', ['clean:firmware_build', 'clean:compiled_bins', 'copy', 'string-replace']);
grunt.registerTask('compile', ['build', 'exec', 'clean:post_compile']);
};