@@ -378,7 +378,7 @@ async function newClangFormatFile() {
378378
379379function checkBinFolder ( binFolder : File ) : boolean {
380380 return binFolder . IsDir ( ) &&
381- File . fromArray ( [ binFolder . path , File . ToLocalPath ( `builder/bin/unify_builder ${ platform . exeSuffix ( ) } ` ) ] ) . IsFile ( ) ;
381+ File . fromArray ( [ binFolder . path , 'VERSION' ] ) . IsFile ( ) ;
382382}
383383
384384async function checkAndInstallBinaries ( forceInstall ?: boolean ) : Promise < boolean > {
@@ -678,14 +678,57 @@ async function tryInstallBinaries(binFolder: File, binVersion: string): Promise<
678678 platform . DeleteDir ( binFolder ) ;
679679 }
680680
681- // chmod executable's permission
682681 if ( installedDone ) {
683- initBinariesExecutablePermission ( ) ;
682+ onBinariesInstallDone ( ) ;
684683 }
685684
686685 return installedDone ;
687686}
688687
688+ function onBinariesInstallDone ( ) {
689+
690+ const resManager = ResManager . GetInstance ( ) ;
691+
692+ // chmod +x for other executable files
693+ if ( os . platform ( ) != 'win32' ) {
694+
695+ const exeLi : string [ ] = [ ] ;
696+
697+ // get exe file list from folders
698+ for ( const dir of [
699+ File . fromArray ( [ resManager . GetBinDir ( ) . path , 'scripts' ] ) ,
700+ File . fromArray ( [ resManager . getLegacyBuilderDir ( ) . path , 'utils' ] ) ,
701+ File . fromArray ( [ resManager . getUnifyBuilderExe ( ) . dir ] )
702+ ] ) {
703+ dir . GetList ( undefined , File . EXCLUDE_ALL_FILTER )
704+ . forEach ( ( f ) => {
705+ if ( ! f . suffix ) { // nosuffix file is an exe file
706+ exeLi . push ( f . path ) ;
707+ }
708+ } ) ;
709+ }
710+
711+ for ( const path of exeLi ) {
712+ try {
713+ ChildProcess . execSync ( `chmod +x "${ path } "` ) ;
714+ GlobalEvent . emit ( 'globalLog' , newMessage ( 'Info' , `chmod +x "${ path } "` ) ) ;
715+ } catch ( error ) {
716+ GlobalEvent . emit ( 'globalLog' , ExceptionToMessage ( error , 'Error' ) ) ;
717+ }
718+ }
719+ }
720+
721+ // delete legacy builder dir
722+ const legacyDir = File . fromArray ( [ resManager . getLegacyBuilderDir ( ) . path , 'bin' ] ) ;
723+ if ( legacyDir . IsDir ( ) ) {
724+ platform . DeleteAllChildren ( legacyDir ) ;
725+ fs . writeFileSync ( legacyDir . path + '/' + 'NOTICE.TXT' ,
726+ [ `unify_builder has been moved to '${ resManager . getUnifyBuilderExe ( ) . dir } , this folder is deprecated'` ,
727+ `---` ,
728+ `unify_builder 的位置已被转移到 '${ resManager . getUnifyBuilderExe ( ) . dir } ',该位置已被弃用` ] . join ( os . EOL ) ) ;
729+ }
730+ }
731+
689732//////////////////////////////////////////////////
690733// environment sutup
691734//////////////////////////////////////////////////
@@ -696,13 +739,13 @@ function exportEnvToSysPath(context?: vscode.ExtensionContext) {
696739
697740 const settingManager = SettingManager . GetInstance ( ) ;
698741 const resManager = ResManager . GetInstance ( ) ;
699- const builderFolder = resManager . getBuilderDir ( ) ;
742+ const legacyBuilderDir = resManager . getLegacyBuilderDir ( ) ;
700743
701744 // export some eide binaries path to system env path
702745 const systemEnvPaths : string [ ] = [
703- File . normalize ( `${ builderFolder . path } /bin ` ) , // builder bin folder
704- File . normalize ( `${ builderFolder . path } /utils` ) , // utils tool folder
705- File . normalize ( `${ builderFolder . dir } /scripts` ) ,
746+ File . normalize ( `${ resManager . getUnifyBuilderExe ( ) . dir } ` ) ,
747+ File . normalize ( `${ legacyBuilderDir . path } /utils` ) , // utils tool folder
748+ File . normalize ( `${ legacyBuilderDir . dir } /scripts` ) ,
706749 File . normalize ( `${ resManager . Get7zDir ( ) . path } ` ) , // export built-in 7za tool
707750 File . normalize ( `${ resManager . getBuiltInToolsDir ( ) . path } /utils` ) // builtin utils tool folder
708751 ] ;
@@ -780,7 +823,7 @@ function exportEnvToSysPath(context?: vscode.ExtensionContext) {
780823 } ) ;
781824
782825 // search built-in tools and export path to system env
783- builderFolder . GetList ( File . EXCLUDE_ALL_FILTER ) . forEach ( ( subDir ) => {
826+ legacyBuilderDir . GetList ( File . EXCLUDE_ALL_FILTER ) . forEach ( ( subDir ) => {
784827 const binFolder = File . normalize ( `${ subDir . path } /bin` ) ;
785828 if ( File . IsDir ( binFolder ) ) {
786829 pathList . push ( {
@@ -965,40 +1008,6 @@ async function checkAndInstallRuntime() {
9651008 }
9661009}
9671010
968- function initBinariesExecutablePermission ( ) {
969-
970- const resManager = ResManager . GetInstance ( ) ;
971-
972- // chmod +x for other executable files
973- if ( os . platform ( ) != 'win32' ) {
974-
975- const exeLi : string [ ] = [ ] ;
976-
977- // get exe file list from folders
978- for ( const dir of [
979- File . fromArray ( [ resManager . GetBinDir ( ) . path , 'scripts' ] ) ,
980- File . fromArray ( [ resManager . getBuilderDir ( ) . path , 'utils' ] ) ,
981- File . fromArray ( [ resManager . getBuilderDir ( ) . path , 'bin' ] )
982- ] ) {
983- dir . GetList ( undefined , File . EXCLUDE_ALL_FILTER )
984- . forEach ( ( f ) => {
985- if ( ! f . suffix ) { // nosuffix file is an exe file
986- exeLi . push ( f . path ) ;
987- }
988- } ) ;
989- }
990-
991- for ( const path of exeLi ) {
992- try {
993- ChildProcess . execSync ( `chmod +x "${ path } "` ) ;
994- GlobalEvent . emit ( 'globalLog' , newMessage ( 'Info' , `chmod +x "${ path } "` ) ) ;
995- } catch ( error ) {
996- GlobalEvent . emit ( 'globalLog' , ExceptionToMessage ( error , 'Error' ) ) ;
997- }
998- }
999- }
1000- }
1001-
10021011async function InitComponents ( context : vscode . ExtensionContext ) : Promise < boolean | undefined > {
10031012
10041013 // init managers
@@ -1610,7 +1619,7 @@ class MapViewEditorProvider implements vscode.CustomTextEditorProvider {
16101619 . execSync ( `memap -t ${ memapTyp } -d ${ vInfo . treeDepth } "${ vInfo . mapPath } "` )
16111620 . toString ( ) . split ( / \r \n | \n / ) ;
16121621 } else {
1613- const memapRoot = ResManager . GetInstance ( ) . getBuilderDir ( ) . path + File . sep + 'utils' ;
1622+ const memapRoot = ResManager . GetInstance ( ) . getLegacyBuilderDir ( ) . path + File . sep + 'utils' ;
16141623 const command = `python memap -t ${ memapTyp } -d ${ vInfo . treeDepth } "${ vInfo . mapPath } "` ;
16151624 lines = ChildProcess
16161625 . execSync ( command , { cwd : memapRoot } )
0 commit comments