-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: skip visual studio components installation if not needed
- Loading branch information
1 parent
a01e266
commit 32576cd
Showing
5 changed files
with
287 additions
and
202 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import * as os from 'os' | ||
import * as path from 'path' | ||
import {getExecOutput} from '@actions/exec' | ||
|
||
export class VisualStudio { | ||
private constructor( | ||
readonly installationPath: string, | ||
readonly installationVersion: string, | ||
readonly catalog: VisualStudioCatalog, | ||
readonly properties: VisualStudioProperties | ||
) {} | ||
|
||
// eslint-disable-next-line no-explicit-any | ||
static createFromJSON(json: any) { | ||
return new VisualStudio( | ||
json.installationPath, | ||
json.installationVersion, | ||
json.catalog, | ||
json.properties | ||
) | ||
} | ||
|
||
async env() { | ||
/// https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170 | ||
const nativeToolsScriptx86 = path.join( | ||
this.installationPath, | ||
'Common7', | ||
'Tools', | ||
'VsDevCmd.bat' | ||
) | ||
const {stdout} = await getExecOutput( | ||
'cmd', | ||
[ | ||
'/k', | ||
nativeToolsScriptx86, | ||
`-arch=${os.arch()}`, | ||
'&&', | ||
'set', | ||
'&&', | ||
'exit' | ||
], | ||
{failOnStdErr: true} | ||
) | ||
return Object.fromEntries( | ||
stdout | ||
.split(os.EOL) | ||
.filter(s => s.indexOf('=')) | ||
.map(s => s.trim()) | ||
.map(s => s.split('=', 2)) | ||
.filter(s => s.length === 2) | ||
.map(s => [s[0].trim(), s[1].trim()] as const) | ||
) as VisualStudioEnv | ||
} | ||
} | ||
|
||
export interface VisualStudioCatalog { | ||
productDisplayVersion: string | ||
} | ||
|
||
export interface VisualStudioProperties { | ||
setupEngineFilePath: string | ||
} | ||
|
||
export interface VisualStudioRequirement { | ||
version: string | ||
components: string[] | ||
} | ||
|
||
export interface VisualStudioEnv { | ||
readonly UniversalCRTSdkDir?: string | ||
readonly UCRTVersion?: string | ||
readonly VCToolsInstallDir?: string | ||
readonly [name: string]: string | undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './base' | ||
export * from './setup' | ||
export * from './update' |
Oops, something went wrong.