Skip to content

Commit b28812c

Browse files
committed
Fixed build platform dependency, updated version.
1 parent d640c9c commit b28812c

File tree

3 files changed

+101
-84
lines changed

3 files changed

+101
-84
lines changed

gulpfile.js

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
var pkg = require('./package.json');
4+
35
var child_process = require('child_process');
46
var fs = require('fs');
57
var path = require('path');
@@ -11,6 +13,7 @@ var NwBuilder = require('nw-builder');
1113
var gulp = require('gulp');
1214
var concat = require('gulp-concat');
1315
var runSequence = require('run-sequence');
16+
var os = require('os');
1417

1518
var distDir = './dist/';
1619
var appsDir = './apps/';
@@ -23,29 +26,48 @@ var releaseDir = './release/';
2326

2427
// Get platform from commandline args
2528
// #
26-
// # gulp <task> --osx64 to execute task only for macOS platform (--osx64, --win32 or --linux64)
29+
// # gulp <task> [<platform>]+ Run only for platform(s) (with <platform> one of --linux64, --osx64, or --win32)
2730
// #
28-
function get_platform_from_args() {
29-
var supportedPlatforms = ['osx64', 'win32', 'linux64'];
31+
function getPlatforms() {
32+
var supportedPlatforms = ['linux64', 'osx64', 'win32'];
3033
var platforms = [];
31-
if (process.argv.length > 3) {
32-
for (var i = 3; i < process.argv.length; i++) {
33-
var arg = process.argv[i].split('-')[2];
34-
if (supportedPlatforms.indexOf(arg) > -1) {
35-
platforms.push(arg);
36-
}
37-
else {
38-
console.log('Unknown platform: ' + arg);
39-
process.exit();
40-
}
34+
var regEx = /--(\w+)/;
35+
for (var i = 3; i < process.argv.length; i++) {
36+
var arg = process.argv[i].match(regEx)[1];
37+
if (supportedPlatforms.indexOf(arg) > -1) {
38+
platforms.push(arg);
39+
} else {
40+
console.log('Unknown platform: ' + arg);
41+
process.exit();
4142
}
42-
return platforms;
4343
}
44-
return supportedPlatforms;
44+
45+
if (platforms.length === 0) {
46+
switch (os.platform()) {
47+
case 'darwin':
48+
platforms.push('osx64');
49+
50+
break;
51+
case 'linux':
52+
platforms.push('linux64');
53+
54+
break;
55+
case 'win32':
56+
platform.push('win32');
57+
58+
break;
59+
60+
default:
61+
break;
62+
}
63+
}
64+
65+
console.log('Building for platform(s): ' + platforms + '.');
66+
67+
return platforms;
4568
}
4669

4770
function get_release_filename(platform, ext) {
48-
var pkg = require('./package.json');
4971
return 'Betaflight-Configurator_' + platform + '_' + pkg.version + '.' + ext;
5072
}
5173

@@ -207,13 +229,13 @@ gulp.task('dist', ['clean-dist'], function () {
207229

208230
// Create runable app directories in ./apps
209231
gulp.task('apps', ['dist', 'clean-apps'], function (done) {
210-
var platform = get_platform_from_args();
211-
console.log('Building app for platform(s): ' + platform);
232+
var platforms = getPlatforms();
233+
console.log('Release build.');
212234

213235
var builder = new NwBuilder({
214236
files: './dist/**/*',
215237
buildDir: appsDir,
216-
platforms: platform,
238+
platforms: platforms,
217239
flavor: 'normal',
218240
macIcns: './images/bf_icon.icns',
219241
macPlist: { 'CFBundleDisplayName': 'Betaflight Configurator'},
@@ -233,13 +255,13 @@ gulp.task('apps', ['dist', 'clean-apps'], function (done) {
233255

234256
// Create debug app directories in ./debug
235257
gulp.task('debug', ['dist', 'clean-debug'], function (done) {
236-
var platform = get_platform_from_args();
237-
console.log('Building debug for platform: ' + platform);
258+
var platforms = getPlatforms();
259+
console.log('Debug build.');
238260

239261
var builder = new NwBuilder({
240262
files: './dist/**/*',
241263
buildDir: debugDir,
242-
platforms: platform,
264+
platforms: platforms,
243265
flavor: 'sdk',
244266
macIcns: './images/bf_icon.icns',
245267
macPlist: { 'CFBundleDisplayName': 'Betaflight Configurator'},
@@ -259,7 +281,6 @@ gulp.task('debug', ['dist', 'clean-debug'], function (done) {
259281

260282
// Create distribution package for windows platform
261283
function release_win32() {
262-
var pkg = require('./package.json');
263284
var src = path.join(appsDir, pkg.name, 'win32');
264285
var output = fs.createWriteStream(path.join(releaseDir, get_release_filename('win32', 'zip')));
265286
var archive = archiver('zip', {
@@ -274,7 +295,6 @@ function release_win32() {
274295

275296
// Create distribution package for linux platform
276297
function release_linux64() {
277-
var pkg = require('./package.json');
278298
var src = path.join(appsDir, pkg.name, 'linux64');
279299
var output = fs.createWriteStream(path.join(releaseDir, get_release_filename('linux64', 'zip')));
280300
var archive = archiver('zip', {
@@ -290,7 +310,6 @@ function release_linux64() {
290310
// Create distribution package for macOS platform
291311
function release_osx64() {
292312
var appdmg = require('gulp-appdmg');
293-
var pkg = require('./package.json');
294313

295314
return gulp.src([])
296315
.pipe(appdmg({
@@ -318,30 +337,16 @@ gulp.task('release', ['apps', 'clean-release'], function () {
318337
}
319338
});
320339

321-
var platform = get_platform_from_args();
322-
console.log('Building release for platform: ' + platform);
323-
324-
if (platform.length == 1) {
325-
switch (platform[0]) {
326-
case 'osx64':
327-
return release_osx64();
328-
break;
329-
case 'linux64':
330-
return release_linux64();
331-
break;
332-
case 'win32':
333-
return release_win32();
334-
break;
335-
default:
336-
console.log('Unknown platform');
337-
break;
338-
}
339-
}
340-
else {
341-
release_osx64();
340+
var platforms = getPlatforms();
341+
console.log('Packing release.');
342+
343+
if (platforms.indexOf('linux64') !== -1) {
342344
release_linux64();
345+
} else if (platforms.indexOf('osx64') !== -1) {
346+
release_osx64();
347+
} else if (platforms.indexOf('win32') !== -1) {
343348
release_win32();
344349
}
345350
});
346351

347-
gulp.task('default', ['apps']);
352+
gulp.task('default', ['debug']);

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"minimum_chrome_version": "38",
4-
"version": "10.0.0-RC1",
4+
"version": "10.0.0-RC2",
55
"author": "Betaflight Squad",
66
"name": "Betaflight - Configurator",
77
"short_name": "Betaflight",

package.json

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
11
{
2-
"name": "betaflight-configurator",
3-
"description": "Crossplatform configuration tool for Betaflight flight control system.",
4-
"version": "10.0.0-RC1",
5-
"main": "main.html",
6-
"default_locale": "en",
7-
"scripts": {
8-
"start": "node_modules/gulp/bin/gulp.js dist && node_modules/nw/bin/nw ."
9-
},
10-
"window": {
11-
"title": "Betaflight Configurator",
12-
"icon": "images/bf_icon_128.png",
13-
"toolbar": true,
14-
"width": 1280,
15-
"height": 800
16-
},
17-
"repository": {
18-
"type": "git",
19-
"url": "github.com/betaflight/betaflight-configurator"
20-
},
21-
"author": "The Betaflight open source project.",
22-
"license": "GPL-3.0",
23-
"dependencies": {
24-
"archiver": "^2.0.3",
25-
"bluebird": "3.4.1",
26-
"del": "^3.0.0",
27-
"gulp": "~3.9.1",
28-
"gulp-concat": "~2.6.1",
29-
"inflection": "1.12.0",
30-
"jquery": "2.1.4",
31-
"jquery-ui-npm": "1.12.0",
32-
"nw": "^0.25.4-sdk",
33-
"nw-builder": "^3.4.1",
34-
"run-sequence": "^2.2.0",
35-
"temp": "^0.8.3",
36-
"three": "0.72.0",
37-
"gulp-appdmg": "1.0.3"
2+
"name": "betaflight-configurator",
3+
"description": "Crossplatform configuration tool for Betaflight flight control system.",
4+
"version": "10.0.0-RC2",
5+
"main": "main.html",
6+
"default_locale": "en",
7+
"scripts": {
8+
"start": "node_modules/gulp/bin/gulp.js dist && node_modules/nw/bin/nw .",
9+
"_postinstall": "node ./node_modules/platform-dependent-modules/cli.js",
10+
"postinstall": "npm run _postinstall"
11+
},
12+
"window": {
13+
"title": "Betaflight Configurator",
14+
"icon": "images/bf_icon_128.png",
15+
"toolbar": true,
16+
"width": 1280,
17+
"height": 800
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "github.com/betaflight/betaflight-configurator"
22+
},
23+
"author": "The Betaflight open source project.",
24+
"license": "GPL-3.0",
25+
"dependencies": {
26+
"bluebird": "3.4.1",
27+
"jquery": "2.1.4",
28+
"nw": "^0.25.4-sdk",
29+
"three": "0.72.0"
30+
},
31+
"devDependencies": {
32+
"archiver": "^2.0.3",
33+
"del": "^3.0.0",
34+
"gulp": "~3.9.1",
35+
"gulp-concat": "~2.6.1",
36+
"inflection": "1.12.0",
37+
"jquery-ui-npm": "1.12.0",
38+
"nw-builder": "^3.4.1",
39+
"os": "^0.1.1",
40+
"platform-dependent-modules": "0.0.14",
41+
"run-sequence": "^2.2.0",
42+
"temp": "^0.8.3"
43+
},
44+
"config": {
45+
"platformDependentModules": {
46+
"darwin": [
47+
48+
]
3849
}
50+
}
3951
}

0 commit comments

Comments
 (0)