Skip to content

Commit d9bcf3d

Browse files
committed
Fix GDevelop.js build on Windows when Visual Studio is installed and update README
1 parent 29577af commit d9bcf3d

File tree

4 files changed

+52
-40
lines changed

4 files changed

+52
-40
lines changed

GDevelop.js/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ WebIDLGrammar.pkl
99
examples/demo-generated-code.js
1010
examples/demo-generated-game.json
1111
**/.DS_Store
12+
emsdk

GDevelop.js/Gruntfile.js

+33-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,51 @@
11
module.exports = function(grunt) {
2-
var fs = require('fs');
3-
var isWin = /^win/.test(process.platform);
2+
const fs = require('fs');
3+
const isWin = /^win/.test(process.platform);
44

5-
var emscriptenPath = process.env.EMSCRIPTEN;
6-
var emscriptenMemoryProfiler = emscriptenPath + '/src/memoryprofiler.js';
7-
var cmakeToolchainpath =
5+
const buildOutputPath = '../Binaries/Output/libGD.js/Release/';
6+
const buildPath = '../Binaries/embuild';
7+
8+
const emscriptenPath = process.env.EMSCRIPTEN;
9+
const emscriptenMemoryProfiler = emscriptenPath + '/src/memoryprofiler.js';
10+
const cmakeToolchainpath =
811
emscriptenPath + '/cmake/Modules/Platform/Emscripten.cmake';
9-
var buildOutputPath = '../Binaries/Output/libGD.js/Release/';
10-
var buildPath = '../Binaries/embuild';
1112

12-
var cmakeBinary = 'emconfigure cmake';
13-
var makeBinary = 'emmake make';
13+
let cmakeBinary = 'emconfigure cmake';
14+
let makeBinary = 'emmake make';
15+
let cmakeArgs = '';
1416

15-
// Find CMake and make in default paths on Windows
17+
// Use more specific paths on Windows
1618
if (isWin) {
19+
// Use make from MinGW
20+
if (!fs.existsSync('C:\\MinGW\\bin\\mingw32-make.exe')) {
21+
console.error(
22+
"🔴 Can't find mingw32-make in C:\\MinGW. Make sure MinGW is installed."
23+
);
24+
return;
25+
}
1726
makeBinary = 'emmake "C:\\MinGW\\bin\\mingw32-make"';
18-
if (fs.existsSync('C:\\Program Files\\CMake\\bin\\cmake')) {
27+
28+
// Find CMake in usual folders or fallback to PATH.
29+
if (fs.existsSync('C:\\Program Files\\CMake\\bin\\cmake.exe')) {
1930
cmakeBinary = 'emconfigure "C:\\Program Files\\CMake\\bin\\cmake"';
20-
} else if (fs.existsSync('C:\\Program Files (x86)\\CMake\\bin\\cmake')) {
31+
} else if (fs.existsSync('C:\\Program Files (x86)\\CMake\\bin\\cmake.exe')) {
2132
cmakeBinary = 'emconfigure "C:\\Program Files (x86)\\CMake\\bin\\cmake"';
33+
} else {
34+
console.log(
35+
"⚠️ Can't find CMake in its usual Program Files folder. Make sure you have cmake in your PATH instead."
36+
);
2237
}
38+
39+
cmakeArgs = '-G "MinGW Makefiles"';
2340
}
2441

2542
//Sanity checks
2643
if (!process.env.EMSCRIPTEN) {
2744
console.error('🔴 EMSCRIPTEN env. variable is not set');
2845
console.log(
29-
'⚠️ Please set Emscripten environment by launching `emsdk_env` script (`emsdk_env.bat` on Windows)'
46+
'⚠️ Please set Emscripten environment by launching `emsdk_env` script (or `emsdk_env.bat` on Windows).'
3047
);
48+
return;
3149
}
3250
if (!fs.existsSync(emscriptenMemoryProfiler)) {
3351
console.error(
@@ -75,8 +93,7 @@ module.exports = function(grunt) {
7593
cmake: {
7694
src: [buildPath + '/CMakeCache.txt', 'CMakeLists.txt'],
7795
command:
78-
cmakeBinary +
79-
' ../.. -DFULL_VERSION_NUMBER=FALSE',
96+
cmakeBinary + ' ' + cmakeArgs + ' ../.. -DFULL_VERSION_NUMBER=FALSE',
8097
options: {
8198
execOptions: {
8299
cwd: buildPath,
@@ -114,7 +131,7 @@ module.exports = function(grunt) {
114131
clean: {
115132
options: { force: true },
116133
build: {
117-
src: [buildOutputPath + 'libGD.js', buildOutputPath + 'libGD.min.js'],
134+
src: [buildPath, buildOutputPath + 'libGD.js', buildOutputPath + 'libGD.min.js'],
118135
},
119136
},
120137
compress: {

GDevelop.js/Readme.md

+17-24
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
# GDevelop.js
22

3-
This is a port of some parts of **GDevelop** to Javascript using **[Emscripten]**.
3+
This is the port of GDevelop core classes to JavaScript. This allow [GDevelop Core libraries](https://github.com/4ian/GDevelop) to run in a browser or on Node.js.
44

5-
GDevelop is a full featured, cross-platform, open-source game creator software requiring no programming skills. Download it on [the official website](https://gdevelop-app.com).
5+
> 🎮 GDevelop is a full featured, cross-platform, open-source game development software requiring no programming skills. Download it on [the official website](https://gdevelop-app.com).
66
77
## How to build
88

9-
- Make sure you have [CMake 3.5+](http://www.cmake.org/)
9+
> 👋 Usually if you're working on GDevelop editor or extensions in JavaScript, you don't need rebuilding GDevelop.js. If you want to make changes in C++ extensions or classes, read this section.
1010
11-
- On Windows, install MinGW (only `mingw32-base-bin` is required).
11+
- Make sure you have [CMake 3.5+](http://www.cmake.org/) and [Node.js](nodejs.org/) installed.
1212

13-
- Install [Emscripten](https://github.com/kripken/emscripten), as explained on the [Emscripten installation instructions](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html):
14-
15-
```shell
16-
git clone https://github.com/juj/emsdk.git
17-
cd emsdk
18-
./emsdk update
19-
./emsdk install sdk-1.37.37-64bit
20-
./emsdk activate sdk-1.37.37-64bit
21-
source ./emsdk_env.sh
22-
```
13+
- On Windows, install [MinGW](https://osdn.net/projects/mingw/releases/) (only `mingw32-base-bin` package is required).
2314

24-
(on Windows run `emsdk` instead of `./emsdk`, and `emsdk_env.bat` instead of `source ./emsdk_env.sh`. For up-to-date information, check again [Emscripten installation instructions](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html)).
15+
- Install [Emscripten](https://github.com/kripken/emscripten), as explained on the [Emscripten installation instructions](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html):
2516

26-
- Make sure you have Node.js installed and grunt:
17+
| Linux/macOS | Windows |
18+
|-------------|---------|
19+
| `git clone https://github.com/juj/emsdk.git` | `git clone https://github.com/juj/emsdk.git` |
20+
| `cd emsdk` | `cd emsdk`|
21+
| `./emsdk update` | `emsdk update` |
22+
| `./emsdk install sdk-1.37.37-64bit` | `emsdk install sdk-1.37.37-64bit` |
23+
| `./emsdk activate sdk-1.37.37-64bit` | `emsdk activate sdk-1.37.37-64bit` |
24+
| `source ./emsdk_env.sh` | `emsdk_env.bat` |
2725

28-
```shell
29-
npm install -g grunt-cli
30-
```
26+
> For up-to-date information, check again [Emscripten installation instructions](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html).
3127
3228
- Launch the build from GDevelop.js folder:
3329

@@ -39,7 +35,7 @@ source ./emsdk_env.sh
3935

4036
Output is created in _/path/to/GD/Binaries/Output/libGD.js/_.
4137

42-
- You can then launch GDevelop 5 that will use your build of Gdevelop.js:
38+
- You can then launch GDevelop 5 that will use your build of GDevelop.js:
4339

4440
```shell
4541
cd ..
@@ -61,7 +57,6 @@ npm test
6157
The grunt _build_ task:
6258

6359
- create `Binaries/embuild` directory,
64-
- patch SFML `Config.hpp` file to make Emscripten recognized as a linux target,
6560
- launch CMake inside to compile GDevelop with _Emscripten toolchain file_,
6661
- update the glue.cpp and glue.js from Bindings.idl using _Emscripten WebIDL Binder_,
6762
- launch the compilation with _make_ and wrap the generated `libGD.js.raw` into the final `libGD.js` file.
@@ -70,7 +65,5 @@ It also create a compressed `libGD.js.gz` file which is handy for distributing t
7065

7166
## Documentation
7267

73-
- The file [Bindings.idl](https://github.com/4ian/GDevelop.js/blob/master/Bindings/Bindings.idl) describes all the classes available in GDevelop.js.
68+
- The file [Bindings.idl](https://github.com/4ian/GDevelop/blob/master/GDevelop.js/Bindings/Bindings.idl) describes all the classes available in GDevelop.js.
7469
- Refer to [GDevelop documentation](http://4ian.github.io/GD-Documentation/GDCore%20Documentation/) for detailed documentation of the original C++ classes.
75-
76-
[emscripten]: https://github.com/kripken/emscripten

GDevelop.js/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
],
1515
"scripts": {
1616
"build": "grunt build",
17+
"clean": "grunt clean",
1718
"test": "jest"
1819
},
1920
"license": "MIT",

0 commit comments

Comments
 (0)