forked from GPII/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
139 lines (121 loc) · 5.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*!
GPII Linux Personalization Framework Node.js Bootstrap
Copyright 2014 RTF-US
Copyright 2014 Emergya
Licensed under the New BSD license. You may not use this file except in
compliance with this License.
You may obtain a copy of the License at
https://github.com/gpii/universal/LICENSE.txt
*/
"use strict";
module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-shell");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-jsonlint");
grunt.loadNpmTasks("grunt-gpii");
var usbListenerDir = "./usbDriveListener";
var gypCompileCmd = "node-gyp configure build";
var gypCleanCmd = "node-gyp clean";
function nodeGypShell(cmd, cwd) {
return {
options: {
execOptions: {
cwd: cwd
}
},
command: cmd
};
}
grunt.initConfig({
jshint: {
src: ["gpii/**/*.js", "tests/**/*.js"],
buildScripts: ["Gruntfile.js"],
options: {
jshintrc: true
}
},
jsonlint: {
src: ["gpii/**/*.json"]
},
shell: {
options: {
stdout: true,
stderr: true,
failOnError: true,
// A large maxBuffer value is required for the 'runAcceptanceTests' task otherwise
// a 'stdout maxBuffer exceeded' warning is generated.
execOptions: {
maxBuffer: 1000 * 1024
}
},
compileGSettings: nodeGypShell(gypCompileCmd, "gpii/node_modules/gsettingsBridge/nodegsettings"),
cleanGSettings: nodeGypShell(gypCleanCmd, "gpii/node_modules/gsettingsBridge/nodegsettings"),
compileAlsaBridge: nodeGypShell(gypCompileCmd, "gpii/node_modules/alsa/nodealsa"),
cleanAlsaBridge: nodeGypShell(gypCleanCmd, "gpii/node_modules/alsa/nodealsa"),
compileXrandrBridge: nodeGypShell(gypCompileCmd, "gpii/node_modules/xrandr/nodexrandr"),
cleanXrandrBridge: nodeGypShell(gypCleanCmd, "gpii/node_modules/xrandr/nodexrandr"),
compilePackageKitBridge: nodeGypShell(gypCompileCmd, "gpii/node_modules/packagekit/nodepackagekit"),
cleanPackageKitBridge: nodeGypShell(gypCleanCmd, "gpii/node_modules/packagekit/nodepackagekit"),
installUsbLib: {
command: [
"sudo cp " + usbListenerDir + "/gpii-usb-user-listener /usr/bin/",
"sudo cp " + usbListenerDir +
"/gpii-usb-user-listener.desktop /usr/share/applications/",
"sudo mkdir -p /var/lib/gpii",
"sudo touch /var/lib/gpii/log.txt",
"sudo chmod a+rw /var/lib/gpii/log.txt"
].join("&&")
},
uninstallUsbLib: {
command: [
"sudo rm -f /usr/bin/gpii-usb-user-listener",
"sudo rm -f /usr/share/applications/gpii-usb-user-listener.desktop",
"sudo rm -f -r /var/lib/gpii"
].join("&&")
},
runAcceptanceTests: {
command: "vagrant ssh -c 'DISPLAY=:0 node /home/vagrant/sync/tests/AcceptanceTests.js'"
},
runUnitTests: {
command: "vagrant ssh -c 'cd /home/vagrant/sync/tests/; DISPLAY=:0 ./UnitTests.sh'"
}
}
});
grunt.registerTask("build", "Build the entire GPII", function () {
grunt.task.run("gpii-universal");
grunt.task.run("build-addons");
grunt.task.run("shell:installUsbLib");
});
grunt.registerTask("build-addons", "Build the native addons", function () {
grunt.task.run("shell:compileGSettings");
grunt.task.run("shell:compileAlsaBridge");
grunt.task.run("shell:compileXrandrBridge");
grunt.task.run("shell:compilePackageKitBridge");
});
grunt.registerTask("clean-addons", "Clean the native addons", function () {
grunt.task.run("shell:cleanGSettings");
grunt.task.run("shell:cleanAlsaBridge");
grunt.task.run("shell:cleanXrandrBridge");
grunt.task.run("shell:cleanPackageKitBridge");
});
grunt.registerTask("clean", "Clean the GPII binaries and uninstall", function () {
grunt.task.run("clean-addons");
grunt.task.run("shell:uninstallUsbLib");
});
grunt.registerTask("install", "Install system level GPII Components", function () {
grunt.task.run("shell:installUsbLib");
});
grunt.registerTask("uninstall", "Uninstall system level GPII Components", function () {
grunt.task.run("shell:uninstallUsbLib");
});
grunt.registerTask("unit-tests", "Run GPII unit tests", function () {
grunt.task.run("shell:runUnitTests");
});
grunt.registerTask("acceptance-tests", "Run GPII acceptance tests", function () {
grunt.task.run("shell:runAcceptanceTests");
});
grunt.registerTask("tests", "Run GPII unit and acceptance tests", function () {
grunt.task.run("shell:runUnitTests");
grunt.task.run("shell:runAcceptanceTests");
});
};