-
Notifications
You must be signed in to change notification settings - Fork 17
/
Gruntfile.js
117 lines (101 loc) · 4.34 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
/*!
GPII Linux Personalization Framework Node.js Bootstrap
Copyright 2014 RTF-US
Copyright 2014 Emergya
Copyright 2017 Raising the Floor International
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/linux/blob/master/LICENSE.txt
*/
"use strict";
module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-jsonlint");
grunt.loadNpmTasks("grunt-shell");
grunt.loadNpmTasks("fluid-grunt-eslint");
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.registerTask("lint", "Apply eslint and jsonlint", ["eslint", "jsonlint"]);
grunt.initConfig({
eslint: {
src: ["./gpii/**/*.js", "./tests/**/*.js", "./*.js"]
},
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("&&")
}
}
});
grunt.registerTask("build", "Build the entire GPII", function () {
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");
});
};