@@ -50,15 +50,53 @@ export async function install(platform, engine, version) {
5050
5151 let toolchainPaths = ( version === 'mswin' ) ? await setupMSWin ( ) : await setupMingw ( version )
5252
53- common . setupPath ( [ `${ rubyPrefix } \\bin` , ...toolchainPaths ] )
54-
5553 if ( ! inToolCache ) {
5654 await downloadAndExtract ( engine , version , url , base , rubyPrefix ) ;
5755 }
5856
57+ const winMSYS2Type = common . setupPath ( [ `${ rubyPrefix } \\bin` , ...toolchainPaths ] )
58+
59+ const virtualEnv = common . getVirtualEnvironmentName ( )
60+
61+ if ( ( winMSYS2Type === 'ucrt64' ) || ! [ 'windows-2019' , 'windows-2016' ] . includes ( virtualEnv ) ) {
62+ await installGCCTools ( winMSYS2Type )
63+
64+ if ( ! [ 'windows-2019' , 'windows-2016' ] . includes ( virtualEnv ) ) {
65+ await installMSY2Tools ( )
66+ }
67+ }
68+
5969 return rubyPrefix
6070}
6171
72+ // Actions windows-2022 image does not contain any mingw or ucrt build tools. Install tools for it,
73+ // and also install ucrt tools on earlier versions, which have msys2 and mingw tools preinstalled.
74+ async function installGCCTools ( type ) {
75+ const downloadPath = await common . measure ( `Download ${ type } build tools` , async ( ) => {
76+ let url = `https://github.com/MSP-Greg/setup-msys2-gcc/releases/download/msys2-gcc-pkgs/${ type } .7z`
77+ console . log ( url )
78+ return await tc . downloadTool ( url )
79+ } )
80+
81+ await common . measure ( `Extracting ${ type } build tools` , async ( ) =>
82+ // -aoa overwrite existing, -bd disable progress indicator
83+ exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , '-oC:\\msys64' ] , { silent : true } ) )
84+ }
85+
86+ // Actions windows-2022 image does not contain any MSYS2 build tools. Install tools for it.
87+ // A subset of the MSYS2 base-devel group
88+ async function installMSY2Tools ( ) {
89+ const downloadPath = await common . measure ( `Download msys2 build tools` , async ( ) => {
90+ let url = `https://github.com/MSP-Greg/setup-msys2-gcc/releases/download/msys2-gcc-pkgs/msys2.7z`
91+ console . log ( url )
92+ return await tc . downloadTool ( url )
93+ } )
94+
95+ await common . measure ( `Extracting msys2 build tools` , async ( ) =>
96+ // -aoa overwrite existing, -bd disable progress indicator
97+ exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , '-oC:\\msys64' ] , { silent : true } ) )
98+ }
99+
62100async function downloadAndExtract ( engine , version , url , base , rubyPrefix ) {
63101 const parentDir = path . dirname ( rubyPrefix )
64102
@@ -68,7 +106,7 @@ async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
68106 } )
69107
70108 await common . measure ( 'Extracting Ruby' , async ( ) =>
71- exec . exec ( '7z' , [ 'x' , downloadPath , `-xr!${ base } \\share\\doc` , `-o${ parentDir } ` ] , { silent : true } ) )
109+ exec . exec ( '7z' , [ 'x' , downloadPath , '-bd' , `-xr!${ base } \\share\\doc` , `-o${ parentDir } ` ] , { silent : true } ) )
72110
73111 if ( base !== path . basename ( rubyPrefix ) ) {
74112 await io . mv ( path . join ( parentDir , base ) , rubyPrefix )
0 commit comments