Skip to content

Commit 8573d06

Browse files
authored
feat: expand SWIFTFLAGS with full paths ensure CMD and PowerShell compatibility (#74)
* feat: expand SWIFTFLAGS with full paths * test: assert SWIFTFLAGS on Windows
1 parent b939b08 commit 8573d06

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

__tests__/installer/windows.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ describe('windows toolchain installation verification', () => {
184184
'SDKs',
185185
'Windows.sdk'
186186
)
187+
const swiftLibs = path.join(sdkroot, 'usr', 'lib', 'swift')
187188
const swiftPath = path.join(toolPath, 'usr', 'bin')
188189
const swiftDev = path.join(installation, 'Swift-development', 'bin')
189190
const icu67 = path.join(installation, 'icu-67', 'usr', 'bin')
@@ -192,6 +193,11 @@ describe('windows toolchain installation verification', () => {
192193
expect(process.env.PATH?.includes(swiftDev)).toBeTruthy()
193194
expect(process.env.PATH?.includes(icu67)).toBeTruthy()
194195
expect(process.env.SDKROOT).toBe(sdkroot)
196+
expect(process.env.SWIFTFLAGS).toContain(`-sdk ${sdkroot}`)
197+
expect(process.env.SWIFTFLAGS).toContain(`-I ${swiftLibs}`)
198+
expect(process.env.SWIFTFLAGS).toContain(
199+
`-L ${path.join(swiftLibs, 'windows')}`
200+
)
195201
})
196202

197203
it('tests installation with cache', async () => {

dist/index.js

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/installer/windows/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export class WindowsToolchainInstaller extends VerifyingToolchainInstaller<Windo
4848
if (!installation) {
4949
return
5050
}
51-
core.exportVariable('SDKROOT', installation.sdkroot)
51+
const sdkroot = installation.sdkroot
52+
core.exportVariable('SDKROOT', sdkroot)
5253
if (installation.devdir) {
5354
core.exportVariable('DEVELOPER_DIR', installation.devdir)
5455
}
@@ -71,8 +72,15 @@ export class WindowsToolchainInstaller extends VerifyingToolchainInstaller<Windo
7172
}
7273
core.debug(`Swift installed at "${swiftPath}"`)
7374
const visualStudio = await VisualStudio.setup(this.vsRequirement)
74-
await visualStudio.update(installation.sdkroot)
75-
const swiftFlags = `-sdk %SDKROOT% -I %SDKROOT%/usr/lib/swift -L %SDKROOT%/usr/lib/swift/windows`
75+
await visualStudio.update(sdkroot)
76+
const swiftFlags = [
77+
'-sdk',
78+
sdkroot,
79+
'-I',
80+
path.join(sdkroot, 'usr', 'lib', 'swift'),
81+
'-L',
82+
path.join(sdkroot, 'usr', 'lib', 'swift', 'windows')
83+
].join(' ')
7684
core.exportVariable('SWIFTFLAGS', swiftFlags)
7785
}
7886
}

0 commit comments

Comments
 (0)