Skip to content

Commit a7a811b

Browse files
committed
Merge master
2 parents 0ded9fb + 4bbfb84 commit a7a811b

File tree

3 files changed

+34
-305
lines changed

3 files changed

+34
-305
lines changed

Package/gulpfile.js

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,59 @@
11
const util = require('util');
22
const fs = require('fs');
3-
const spawn = require('child_process').spawn;
43
const readdirAsync = util.promisify(fs.readdir);
54
const log = require('fancy-log');
6-
const del = require('del');
75
const gulp = require('gulp');
8-
const parseArgsStringToArgv = require('string-argv').parseArgsStringToArgv;
6+
const shelljs = require('shelljs');
97

10-
async function exec(command, options = {}, logCommand = true) {
8+
function exec(command, workingDirectory = '.', logCommand = true) {
119
if (logCommand) {
1210
log(command);
1311
}
1412

15-
const arguments = parseArgsStringToArgv(command);
16-
command = arguments.shift();
17-
18-
await new Promise((resolve, reject) => {
19-
const process = spawn(command, arguments, options);
20-
21-
process.on('close', code => code ? reject(code) : resolve());
22-
23-
process.stdout.on('data', data => {
24-
const message = data.toString();
25-
if (message !== '\n') {
26-
log(message);
27-
}
28-
});
29-
30-
process.stderr.on('data', data => {
31-
log.error(data.toString());
32-
})
33-
});
13+
shelljs.pushd('-q', workingDirectory);
14+
try {
15+
if (shelljs.exec(command, {fatal: true}).code) {
16+
throw `'${command}' finished with non-zero exit code.`;
17+
}
18+
} finally {
19+
shelljs.popd('-q');
20+
}
3421
}
3522

3623
const clean = async () => {
37-
await del('Assembled', {force:true});
24+
if (shelljs.test('-d', 'Assembled')) {
25+
shelljs.rm('-r', 'Assembled');
26+
}
3827
};
3928

4029
const makeXCodeProj = async () => {
41-
await exec('mkdir -p iOS/Build');
42-
await exec('cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../../Apps/Playground/node_modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/ios-cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED -DENABLE_ARC=0 -DDEPLOYMENT_TARGET=12 -DENABLE_GLSLANG_BINARIES=OFF -DSPIRV_CROSS_CLI=OFF ..', {cwd: 'iOS/Build'});
30+
shelljs.mkdir('-p', 'iOS/Build');
31+
exec('cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../../Apps/Playground/node_modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/ios-cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED -DENABLE_ARC=0 -DDEPLOYMENT_TARGET=12 -DENABLE_GLSLANG_BINARIES=OFF -DSPIRV_CROSS_CLI=OFF ..', 'iOS/Build');
4332
};
4433

4534
const buildIphoneOS = async () => {
46-
await exec('xcodebuild -sdk iphoneos -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', {cwd: 'iOS/Build'});
35+
exec('xcodebuild -sdk iphoneos -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', 'iOS/Build');
4736
};
4837

4938
const buildIphoneSimulator = async () => {
50-
await exec('xcodebuild -sdk iphonesimulator -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', {cwd: 'iOS/Build'});
39+
exec('xcodebuild -sdk iphonesimulator -configuration Release -project ReactNativeBabylon.xcodeproj -scheme BabylonNative build CODE_SIGNING_ALLOWED=NO', 'iOS/Build');
5140
};
5241

5342
const buildIOS = gulp.series(makeXCodeProj, buildIphoneOS, buildIphoneSimulator);
5443

5544
const buildAndroid = async () => {
56-
await exec('./gradlew babylonjs_react-native:assembleRelease', {cwd: '../Apps/Playground/android'});
45+
exec('./gradlew babylonjs_react-native:assembleRelease', '../Apps/Playground/android');
5746
};
5847

59-
const copyCommonFiles = async () => {
48+
const copyCommonFiles = () => {
6049
return gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/package.json')
6150
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/README.md'))
6251
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/*.ts*'))
6352
.pipe(gulp.src('react-native-babylon.podspec'))
6453
.pipe(gulp.dest('Assembled'));
6554
};
6655

67-
const copyIOSFiles = async () => {
56+
const copyIOSFiles = () => {
6857
return gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/ios/*.h')
6958
.pipe(gulp.src('../Apps/Playground/node_modules/@babylonjs/react-native/ios/*.mm'))
7059
// This xcodeproj is garbage that we don't need in the package, but `pod install` ignores the package if it doesn't contain at least one xcodeproj. 🤷🏼‍♂️
@@ -73,9 +62,9 @@ const copyIOSFiles = async () => {
7362
};
7463

7564
const createIOSUniversalLibs = async () => {
76-
await exec('mkdir -p Assembled/ios/libs');
65+
shelljs.mkdir('-p', 'Assembled/ios/libs');
7766
const libs = await readdirAsync('iOS/Build/Release-iphoneos');
78-
await Promise.all(libs.map(lib => exec(`lipo -create iOS/Build/Release-iphoneos/${lib} iOS/Build/Release-iphonesimulator/${lib} -output Assembled/ios/libs/${lib}`)));
67+
libs.map(lib => exec(`lipo -create iOS/Build/Release-iphoneos/${lib} iOS/Build/Release-iphonesimulator/${lib} -output Assembled/ios/libs/${lib}`));
7968
};
8069

8170
const copyAndroidFiles = async () => {
@@ -95,7 +84,7 @@ const copyAndroidFiles = async () => {
9584
};
9685

9786
const createPackage = async () => {
98-
await exec('npm pack', {cwd: 'Assembled'});
87+
exec('npm pack', 'Assembled');
9988
};
10089

10190
const copyFiles = gulp.parallel(copyCommonFiles, copyIOSFiles, copyAndroidFiles);

0 commit comments

Comments
 (0)