@@ -6,7 +6,7 @@ import * as semver from 'semver'
66import { VerifyingToolchainInstaller } from '../verify'
77import { WindowsToolchainSnapshot } from '../../snapshot'
88import { VisualStudio } from '../../utils'
9- import { Installation } from './installation'
9+ import { Installation , CustomInstallation } from './installation'
1010
1111export class WindowsToolchainInstaller extends VerifyingToolchainInstaller < WindowsToolchainSnapshot > {
1212 private get vsRequirement ( ) {
@@ -40,37 +40,47 @@ export class WindowsToolchainInstaller extends VerifyingToolchainInstaller<Windo
4040
4141 protected async unpack ( exe : string ) {
4242 const installation = await Installation . install ( exe )
43- return installation ? .location ?? ''
43+ return installation instanceof Installation ? installation . location : ''
4444 }
4545
4646 protected async add ( installLocation : string ) {
4747 const installation = await Installation . get ( installLocation )
48- if ( ! installation ) {
49- return
50- }
51- const sdkroot = installation . sdkroot
52- core . exportVariable ( 'SDKROOT' , sdkroot )
53- if ( installation . devdir ) {
54- core . exportVariable ( 'DEVELOPER_DIR' , installation . devdir )
55- }
56- const location = installation . location
57- const swiftPath = path . join ( installation . toolchain , 'usr' , 'bin' )
58- const swiftDev = path . join ( location , 'Swift-development' , 'bin' )
59- const icu67 = path . join ( location , 'icu-67' , 'usr' , 'bin' )
60- const tools = path . join ( location , 'Tools' )
61- const runtimePath = path . join ( installation . runtime , 'usr' , 'bin' )
62- const requirePaths = [ swiftPath , swiftDev , icu67 , tools , runtimePath ]
48+ const sdkrootKey = 'SDKROOT'
49+ let sdkroot : string | undefined
50+ if ( installation instanceof Installation ) {
51+ sdkroot = installation ?. sdkroot ?? core
52+ core . exportVariable ( sdkrootKey , sdkroot )
53+ if ( installation . devdir ) {
54+ core . exportVariable ( 'DEVELOPER_DIR' , installation . devdir )
55+ }
56+
57+ const location = installation . location
58+ const swiftPath = path . join ( installation . toolchain , 'usr' , 'bin' )
59+ const swiftDev = path . join ( location , 'Swift-development' , 'bin' )
60+ const icu67 = path . join ( location , 'icu-67' , 'usr' , 'bin' )
61+ const tools = path . join ( location , 'Tools' )
62+ const runtimePath = path . join ( installation . runtime , 'usr' , 'bin' )
63+ const requirePaths = [ swiftPath , swiftDev , icu67 , tools , runtimePath ]
6364
64- for ( const envPath of requirePaths ) {
65- try {
66- await fs . access ( envPath )
67- core . debug ( `Adding "${ envPath } " to PATH` )
68- core . addPath ( envPath )
69- } catch {
70- core . debug ( `"${ envPath } " doesn't exist. Skip adding to PATH` )
65+ for ( const envPath of requirePaths ) {
66+ try {
67+ await fs . access ( envPath )
68+ core . debug ( `Adding "${ envPath } " to PATH` )
69+ core . addPath ( envPath )
70+ } catch {
71+ core . debug ( `"${ envPath } " doesn't exist. Skip adding to PATH` )
72+ }
7173 }
74+ core . debug ( `Swift installed at "${ swiftPath } "` )
75+ } else if ( installation instanceof CustomInstallation ) {
76+ sdkroot = installation . variables [ sdkrootKey ]
7277 }
73- core . debug ( `Swift installed at "${ swiftPath } "` )
78+
79+ if ( ! sdkroot ) {
80+ core . warning ( `Failed VS enviroment after installation ${ installLocation } ` )
81+ return
82+ }
83+
7484 const visualStudio = await VisualStudio . setup ( this . vsRequirement )
7585 await visualStudio . update ( sdkroot )
7686 const swiftFlags = [
0 commit comments