Skip to content
This repository was archived by the owner on Apr 25, 2019. It is now read-only.

Commit 59f81a7

Browse files
committed
Add Prettier configuration file and format Gruntfile.js
1 parent 5f9c6e4 commit 59f81a7

File tree

2 files changed

+174
-121
lines changed

2 files changed

+174
-121
lines changed

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5"
4+
}

Gruntfile.js

+170-121
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,183 @@
11
module.exports = function(grunt) {
2-
var emscriptenPath = process.env.EMSCRIPTEN;
3-
var emscriptenMemoryProfiler = emscriptenPath + "/src/memoryprofiler.js";
4-
var cmakeToolchainpath = emscriptenPath + "/cmake/Modules/Platform/Emscripten.cmake";
5-
var buildOutputPath = "../Binaries/Output/libGD.js/Release/";
6-
var buildPath = "../Binaries/embuild";
2+
var emscriptenPath = process.env.EMSCRIPTEN;
3+
var emscriptenMemoryProfiler = emscriptenPath + '/src/memoryprofiler.js';
4+
var cmakeToolchainpath =
5+
emscriptenPath + '/cmake/Modules/Platform/Emscripten.cmake';
6+
var buildOutputPath = '../Binaries/Output/libGD.js/Release/';
7+
var buildPath = '../Binaries/embuild';
78

8-
var isWin = /^win/.test(process.platform);
9-
var cmakeBinary = isWin ? "\"C:\\Program Files (x86)\\CMake\\bin\\cmake\"" : "cmake";
10-
var cmakeArgs = isWin ? "-G \"MinGW Makefiles\"" : "";
9+
var isWin = /^win/.test(process.platform);
10+
var cmakeBinary = isWin
11+
? '"C:\\Program Files (x86)\\CMake\\bin\\cmake"'
12+
: 'cmake';
13+
var cmakeArgs = isWin ? '-G "MinGW Makefiles"' : '';
1114

12-
var makeBinary = isWin ? "mingw32-make" : "make";
15+
var makeBinary = isWin ? 'mingw32-make' : 'make';
1316

14-
//Sanity checks
15-
var fs = require('fs');
16-
if (!process.env.EMSCRIPTEN) {
17-
console.error("🔴 EMSCRIPTEN env. variable is not set");
18-
console.log("⚠️ Please set Emscripten environment by launching `emsdk_env` script");
19-
}
20-
if (!fs.existsSync(emscriptenMemoryProfiler)) {
21-
console.error("🔴 Unable to find memoryprofiler.js inside Emscripten sources");
22-
console.log("⚠️ Building with profiler (build:with-profiler task) won't work");
23-
}
17+
//Sanity checks
18+
var fs = require('fs');
19+
if (!process.env.EMSCRIPTEN) {
20+
console.error('🔴 EMSCRIPTEN env. variable is not set');
21+
console.log(
22+
'⚠️ Please set Emscripten environment by launching `emsdk_env` script'
23+
);
24+
}
25+
if (!fs.existsSync(emscriptenMemoryProfiler)) {
26+
console.error(
27+
'🔴 Unable to find memoryprofiler.js inside Emscripten sources'
28+
);
29+
console.log(
30+
"⚠️ Building with profiler (build:with-profiler task) won't work"
31+
);
32+
}
2433

25-
grunt.initConfig({
26-
mochacli: {
27-
options: {
28-
require: ['expect.js'],
29-
bail: true
30-
},
31-
all: ['test/**/*.js']
34+
grunt.initConfig({
35+
mochacli: {
36+
options: {
37+
require: ['expect.js'],
38+
bail: true,
39+
},
40+
all: ['test/**/*.js'],
41+
},
42+
concat: {
43+
options: {
44+
separator: ';',
45+
},
46+
'without-profiler': {
47+
src: [
48+
'Bindings/prejs.js',
49+
buildOutputPath + 'libGD.raw.js',
50+
'Bindings/glue.js',
51+
'Bindings/postjs.js',
52+
],
53+
dest: buildOutputPath + 'libGD.js',
54+
},
55+
'with-profiler': {
56+
src: [
57+
'Bindings/prejs.js',
58+
buildOutputPath + 'libGD.raw.js',
59+
'Bindings/glue.js',
60+
emscriptenMemoryProfiler,
61+
'Bindings/postjs.js',
62+
],
63+
dest: buildOutputPath + 'libGD.js',
64+
},
65+
},
66+
mkdir: {
67+
embuild: {
68+
options: {
69+
create: [buildPath],
3270
},
33-
concat: {
34-
options: {
35-
separator: ';',
36-
},
37-
'without-profiler': {
38-
src: ['Bindings/prejs.js', buildOutputPath+'libGD.raw.js', 'Bindings/glue.js', 'Bindings/postjs.js'],
39-
dest: buildOutputPath+'libGD.js',
40-
},
41-
'with-profiler': {
42-
src: ['Bindings/prejs.js', buildOutputPath+'libGD.raw.js', 'Bindings/glue.js', emscriptenMemoryProfiler, 'Bindings/postjs.js'],
43-
dest: buildOutputPath+'libGD.js',
71+
},
72+
},
73+
shell: {
74+
//Launch CMake if needed
75+
cmake: {
76+
src: [buildPath + '/CMakeCache.txt', 'CMakeLists.txt'],
77+
command:
78+
cmakeBinary +
79+
' ' +
80+
cmakeArgs +
81+
' ../.. -DCMAKE_TOOLCHAIN_FILE="' +
82+
cmakeToolchainpath +
83+
'" -DFULL_VERSION_NUMBER=FALSE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
84+
options: {
85+
execOptions: {
86+
cwd: buildPath,
87+
env: process.env,
88+
maxBuffer: Infinity,
4489
},
4590
},
46-
mkdir: {
47-
embuild: {
48-
options: {
49-
create: [buildPath]
50-
}
91+
},
92+
//Generate glue.cpp and glue.js file using Bindings.idl, and patch them
93+
updateGDBindings: {
94+
src: 'Bindings/Bindings.idl',
95+
command: 'node update-bindings.js',
96+
},
97+
//Compile GDevelop with emscripten
98+
make: {
99+
command: makeBinary + ' -j 4',
100+
options: {
101+
execOptions: {
102+
cwd: buildPath,
103+
env: process.env,
51104
},
52105
},
53-
shell: {
54-
//Launch CMake if needed
55-
cmake: {
56-
src: [buildPath + "/CMakeCache.txt", "CMakeLists.txt"],
57-
command: cmakeBinary + " " + cmakeArgs + " ../.. -DCMAKE_TOOLCHAIN_FILE=\"" + cmakeToolchainpath + "\" -DFULL_VERSION_NUMBER=FALSE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
58-
options: {
59-
execOptions: {
60-
cwd: buildPath,
61-
env: process.env,
62-
maxBuffer: Infinity
63-
}
64-
}
65-
},
66-
//Generate glue.cpp and glue.js file using Bindings.idl, and patch them
67-
updateGDBindings: {
68-
src: "Bindings/Bindings.idl",
69-
command: 'node update-bindings.js',
70-
},
71-
//Compile GDevelop with emscripten
72-
make: {
73-
command: makeBinary + ' -j 4',
74-
options: {
75-
execOptions: {
76-
cwd: buildPath,
77-
env: process.env
78-
}
79-
}
80-
}
81-
},
82-
uglify: {
83-
build: {
84-
files: [
85-
{src: [ buildOutputPath+'libGD.js' ], dest:buildOutputPath+'libGD.min.js'}
86-
]
87-
}
88-
},
89-
clean: {
90-
options: { force: true },
91-
build: {
92-
src: [ buildOutputPath+'libGD.js', buildOutputPath+'libGD.min.js' ]
93-
}
94-
},
95-
compress: {
96-
main: {
97-
options: {
98-
mode: 'gzip'
99-
},
100-
files: [
101-
{expand: true, src: [buildOutputPath+'/libGD.js'], dest: '.', ext: '.js.gz'}
102-
]
103-
}
104-
},
105-
copy: {
106-
newIDE: {
107-
files: [
108-
{expand: true, src: [buildOutputPath+'/libGD.js'], dest: '../newIDE/app/public', flatten: true},
109-
],
110-
}
106+
},
107+
},
108+
uglify: {
109+
build: {
110+
files: [
111+
{
112+
src: [buildOutputPath + 'libGD.js'],
113+
dest: buildOutputPath + 'libGD.min.js',
114+
},
115+
],
116+
},
117+
},
118+
clean: {
119+
options: { force: true },
120+
build: {
121+
src: [buildOutputPath + 'libGD.js', buildOutputPath + 'libGD.min.js'],
122+
},
123+
},
124+
compress: {
125+
main: {
126+
options: {
127+
mode: 'gzip',
111128
},
112-
});
129+
files: [
130+
{
131+
expand: true,
132+
src: [buildOutputPath + '/libGD.js'],
133+
dest: '.',
134+
ext: '.js.gz',
135+
},
136+
],
137+
},
138+
},
139+
copy: {
140+
newIDE: {
141+
files: [
142+
{
143+
expand: true,
144+
src: [buildOutputPath + '/libGD.js'],
145+
dest: '../newIDE/app/public',
146+
flatten: true,
147+
},
148+
],
149+
},
150+
},
151+
});
113152

114-
grunt.loadNpmTasks('grunt-mocha-cli');
115-
grunt.loadNpmTasks('grunt-contrib-clean');
116-
grunt.loadNpmTasks('grunt-contrib-copy');
117-
grunt.loadNpmTasks('grunt-contrib-concat');
118-
grunt.loadNpmTasks('grunt-contrib-uglify');
119-
grunt.loadNpmTasks('grunt-contrib-compress');
120-
grunt.loadNpmTasks('grunt-string-replace');
121-
grunt.loadNpmTasks('grunt-shell');
122-
grunt.loadNpmTasks('grunt-newer');
123-
grunt.loadNpmTasks('grunt-mkdir');
124-
grunt.registerTask('build:raw', [
125-
'clean',
126-
'mkdir:embuild',
127-
'newer:shell:cmake',
128-
'newer:shell:updateGDBindings',
129-
'shell:make',
130-
]);
131-
grunt.registerTask('build', ['build:raw', 'concat:without-profiler', 'compress', 'copy:newIDE']);
132-
grunt.registerTask('build:with-profiler', ['build:raw', 'concat:with-profiler', 'compress', 'copy:newIDE']);
133-
grunt.registerTask('test', ['mochacli']);
153+
grunt.loadNpmTasks('grunt-mocha-cli');
154+
grunt.loadNpmTasks('grunt-contrib-clean');
155+
grunt.loadNpmTasks('grunt-contrib-copy');
156+
grunt.loadNpmTasks('grunt-contrib-concat');
157+
grunt.loadNpmTasks('grunt-contrib-uglify');
158+
grunt.loadNpmTasks('grunt-contrib-compress');
159+
grunt.loadNpmTasks('grunt-string-replace');
160+
grunt.loadNpmTasks('grunt-shell');
161+
grunt.loadNpmTasks('grunt-newer');
162+
grunt.loadNpmTasks('grunt-mkdir');
163+
grunt.registerTask('build:raw', [
164+
'clean',
165+
'mkdir:embuild',
166+
'newer:shell:cmake',
167+
'newer:shell:updateGDBindings',
168+
'shell:make',
169+
]);
170+
grunt.registerTask('build', [
171+
'build:raw',
172+
'concat:without-profiler',
173+
'compress',
174+
'copy:newIDE',
175+
]);
176+
grunt.registerTask('build:with-profiler', [
177+
'build:raw',
178+
'concat:with-profiler',
179+
'compress',
180+
'copy:newIDE',
181+
]);
182+
grunt.registerTask('test', ['mochacli']);
134183
};

0 commit comments

Comments
 (0)