From 3e03612fbbca0ebcf70dcce90c91d9bf5babf853 Mon Sep 17 00:00:00 2001 From: PP Date: Thu, 14 Jan 2021 11:34:12 +0800 Subject: [PATCH] clean project after compiling simulator (#3218) --- native/gulpfile.js | 23 ++++++++++++++++++++++- native/package.json | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/native/gulpfile.js b/native/gulpfile.js index 91e4eed2ad..613bcb59ce 100644 --- a/native/gulpfile.js +++ b/native/gulpfile.js @@ -34,6 +34,7 @@ var spawn = require('child_process').spawn; var Path = require('path'); var fs = require('fs-extra'); const which = require('which'); +const del = require('del'); function absolutePath (relativePath) { return Path.join(__dirname, relativePath); @@ -130,6 +131,10 @@ function getCurrentBranch() { return output.stdout.toString().trim(); } +function formatPath (p) { + return p.replace(/\\/g, '/'); +} + gulp.task('update', function (cb) { const git = require('./utils/git'); var branch = git.getCurrentBranch('.'); @@ -149,6 +154,9 @@ gulp.task('gen-cocos2d-x', function(cb) { }); gulp.task('gen-simulator', async function () { + console.log('remove old simulator project\n'); + await del(Path.join(__dirname, './simulator')); + let isWin32 = process.platform === 'win32'; // get the cmake path let cmakeBin = await new Promise((resolve, reject) => { @@ -185,7 +193,6 @@ gulp.task('gen-simulator', async function () { }); }); - console.log('=====================================\n'); console.log('build project\n'); console.log('=====================================\n'); @@ -212,6 +219,20 @@ gulp.task('gen-simulator', async function () { }); }); + console.log('=====================================\n'); + console.log('clean project\n'); + console.log('=====================================\n'); + let delPatterns = [ + formatPath(Path.join(__dirname, './simulator/*')), + formatPath(`!${Path.join(__dirname, './simulator/Debug')}`), + ]; + if (!isWin32) { + delPatterns.push(formatPath(Path.join(__dirname, './simulator/Debug/libcocos2d.a'))); + delPatterns.push(formatPath(Path.join(__dirname, './simulator/Debug/libsimulator.a'))); + } + console.log('delete patterns: ', JSON.stringify(delPatterns, undefined, 2)); + await del(delPatterns, { force: true }); + console.log('done!'); }); diff --git a/native/package.json b/native/package.json index 7e37d72d4d..cc496307f9 100644 --- a/native/package.json +++ b/native/package.json @@ -8,6 +8,7 @@ "@types/fs-extra": "^9.0.1", "async": "^2.6.1", "chalk": "^2.4.1", + "del": "^6.0.0", "fs-extra": "^9.0.0", "ftp": "0.3.10", "tmp": "^0.2.1",