@@ -450,7 +450,7 @@ function deleteFile(filePath) {
450450}
451451
452452function runCMake ( buildDir ) {
453- let cmakeCommand = `cmake -S . -B ../tempBuild -DBABYLON_NATIVE_BUILD_SOURCETREE=ON` ;
453+ let cmakeCommand = `cmake -S . -B ../tempBuild -DBABYLON_NATIVE_BUILD_SOURCETREE=ON -DBABYLON_NATIVE_BUILD_APPS=OFF ` ;
454454
455455 exec ( cmakeCommand , buildDir ) ;
456456}
@@ -460,10 +460,32 @@ function writeCMakeListsFile(commitId, cmakePath) {
460460 fs . writeFileSync ( cmakePath , content , 'utf8' ) ;
461461}
462462
463- function deleteFolderRecursive ( folderPath ) {
464- if ( fs . existsSync ( folderPath ) ) {
465- fs . rmSync ( folderPath , { recursive : true , force : true } ) ;
466- console . log ( `Deleted folder: ${ folderPath } ` ) ;
463+ function deleteFolderRecursive ( folderPath , excludeSubFolders = [ ] ) {
464+ if ( ! fs . existsSync ( folderPath ) ) return ;
465+
466+ const entries = fs . readdirSync ( folderPath , { withFileTypes : true } ) ;
467+
468+ for ( const entry of entries ) {
469+ const fullPath = path . join ( folderPath , entry . name ) ;
470+
471+ if ( entry . isDirectory ( ) ) {
472+ if ( excludeSubFolders . includes ( entry . name ) ) {
473+ continue ; // Skip this folder
474+ }
475+ deleteFolderRecursive ( fullPath , excludeSubFolders ) ;
476+ } else {
477+ fs . unlinkSync ( fullPath ) ;
478+ }
479+ }
480+
481+ // After deleting contents, delete the root folder if it's not in the excluded list
482+ const folderName = path . basename ( folderPath ) ;
483+ if ( ! excludeSubFolders . includes ( folderName ) ) {
484+ const remaining = fs . readdirSync ( folderPath ) ;
485+ if ( remaining . length === 0 ) {
486+ fs . rmdirSync ( folderPath ) ;
487+ console . log ( `Deleted folder: ${ folderPath } ` ) ;
488+ }
467489 }
468490}
469491
@@ -533,7 +555,21 @@ const buildBabylonNativeSourceTree = async () => {
533555 deleteFolderRecursive ( `${ UNZIP_FOLDER } /Apps` ) ;
534556 deleteFolderRecursive ( `${ UNZIP_FOLDER } /Documentation` ) ;
535557 deleteFolderRecursive ( `${ UNZIP_FOLDER } /Install` ) ;
536- //deleteFolderRecursive(`${DEPS_OUTPUT_DIR}/bgfx.cmake-src/bgfx`);
558+
559+ // dependencies cleanup
560+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /bgfx.cmake-src/bgfx/3rdparty` , [ 'renderdoc' ] ) ;
561+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /bgfx.cmake-src/bgfx/examples` , [ 'common' ] ) ;
562+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /bgfx.cmake-src/bgfx/bindings` ) ;
563+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /bgfx.cmake-src/bgfx/docs` ) ;
564+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /bgfx.cmake-src/bgfx/scripts` ) ;
565+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /bgfx.cmake-src/bgfx/tools` ) ;
566+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /spirv-cross-src/reference` ) ;
567+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /spirv-cross-src/shaders` ) ;
568+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /spirv-cross-src/shaders-msl` ) ;
569+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /spirv-cross-src/shaders-hlsl` ) ;
570+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /spirv-cross-src/shaders-hlsl-no-opt` ) ;
571+ deleteFolderRecursive ( `${ DEPS_OUTPUT_DIR } /glslang-src/Test` ) ;
572+
537573}
538574
539575const copyFiles = gulp . parallel ( copyCommonFiles , copySharedFiles , copyIOSFiles , copyAndroidFiles , copyWindowsFiles ) ;
0 commit comments