Skip to content

Commit bfa4763

Browse files
committed
Add x86 MASM support, but x64 still default
1 parent 08ac7e4 commit bfa4763

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,35 @@ jobs:
1717
runs-on: windows-latest
1818
strategy:
1919
matrix:
20+
platform: [x86, x64]
2021
toolchain:
2122
- stable
2223
steps:
2324
- uses: actions/checkout@v4
24-
- uses: microsoft/setup-msbuild@v1.1
25+
- uses: microsoft/setup-msbuild@v2
26+
with:
27+
msbuild-architecture: ${{matrix.platform}}
2528
- uses: ./
2629
- name: Check MASM Path
2730
run: |
28-
$ml64Path = Get-Command ml64.exe -ErrorAction SilentlyContinue
29-
if ($ml64Path) {
30-
Write-Output "ml64.exe found in PATH: $($ml64Path.Source)"
31+
if ("${{matrix.platform}}" -eq "x64") {
32+
$ml64Path = Get-Command ml64.exe -ErrorAction SilentlyContinue
33+
if ($ml64Path) {
34+
Write-Output "ml64.exe found in PATH: $($ml64Path.Source)"
35+
} else {
36+
Write-Error "ml64.exe not found in PATH."
37+
exit 1
38+
}
39+
} elseif ("${{matrix.platform}}" -eq "x86") {
40+
$mlPath = Get-Command ml.exe -ErrorAction SilentlyContinue
41+
if ($mlPath) {
42+
Write-Output "ml.exe found in PATH: $($mlPath.Source)"
43+
} else {
44+
Write-Error "ml.exe not found in PATH."
45+
exit 1
46+
}
3147
} else {
32-
Write-Error "ml64.exe not found in PATH."
48+
Write-Error "Unknown platform ${{matrix.platform}} to get ml<XXX>.exe in PATH."
3349
exit 1
3450
}
51+

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# setup-masm [![Build Status](https://github.com/glslang/setup-masm/actions/workflows/ci.yaml/badge.svg)](https://github.com/glslang/setup-masm/actions) [![GitHub release](https://img.shields.io/github/v/release/glslang/setup-masm?logo=github)](https://github.com/marketplace/actions/setup-masm)
22

3-
A GitHub Action to facilitate configuring MASM (Microsoft Macro Assembler) in the workflow PATH to use x64 assembly in Win32 applications.
3+
A GitHub Action to facilitate configuring MASM (Microsoft Macro Assembler) in the workflow PATH to use x86 or x64 assembly in Win32 applications.
44

55
## Description
66

@@ -16,8 +16,9 @@ Add the following step to your workflow:
1616
1717
## Inputs
1818
19-
- `vs-version`: The version of Visual Studio to use. Defaults to 'latest'.
20-
- `vs-prerelease`: Whether to include prerelease versions of Visual Studio. Defaults to 'false'.
19+
- `vs-version`: The version of Visual Studio to use. Defaults to `'latest'`.
20+
- `vs-prerelease`: Whether to include prerelease versions of Visual Studio. Defaults to `'false'`.
21+
- `vs-architecture`: By default the action will use the x64 architecture for MASM, but it is possible to target the x86 versions instead. Valid input values are `'x64'` and `'x86'`. Note that the success of these will rely on the runner OS. Defaults to `'x64'`.
2122

2223
## Outputs
2324

@@ -41,11 +42,12 @@ jobs:
4142
runs-on: windows-latest
4243
steps:
4344
- uses: actions/checkout@v4
44-
- uses: microsoft/setup-msbuild@v1.1
45-
- uses: glslang/setup-masm@v1
45+
- uses: microsoft/setup-msbuild@v2
46+
- uses: glslang/setup-masm@v1.1
4647
with:
4748
vs-version: '2022'
4849
vs-prerelease: 'true'
50+
vs-architecture: 'x86'
4951
```
5052

5153
This example demonstrates how to set up MASM in a Windows-based workflow, ensuring that the necessary tools are available for building and testing your project.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-masm",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"main": "lib/main.js",
55
"private": true,
66
"description": "Helps set up specific MASM tool into PATH for later usage.",
@@ -20,6 +20,7 @@
2020
"visual studio",
2121
"masm",
2222
"assembler",
23+
"x86",
2324
"x64"
2425
],
2526
"author": "Gonçalo Carvalho",

src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const IS_WINDOWS = process.platform === 'win32'
99
const VS_VERSION = core.getInput('vs-version') || 'latest'
1010
const VSWHERE_PATH = core.getInput('vswhere-path')
1111
const ALLOW_PRERELEASE = core.getInput('vs-prerelease') || 'false'
12+
const VS_ARCHITECTURE = core.getInput('vs-architecture') || 'x64'
13+
14+
const VS_SUPPORTED_ARCHITECTURES = new Set(['x64', 'x86'])
1215

1316
// Use let for mutable variables
1417
let vswhereExec = '-products * -requires Microsoft.Component.MSBuild -property installationPath -latest '
@@ -31,6 +34,11 @@ async function run(): Promise<void> {
3134
return
3235
}
3336

37+
if (!VS_SUPPORTED_ARCHITECTURES.has(VS_ARCHITECTURE)) {
38+
core.setFailed(`setup-masm can only be run for x86 or x64 target CPU architectures, but got ${VS_ARCHITECTURE}`)
39+
return
40+
}
41+
3442
// check to see if we are using a specific path for vswhere
3543
let vswhereToolExe = ''
3644

@@ -77,9 +85,10 @@ async function run(): Promise<void> {
7785
.trim()
7886
)
7987

88+
const asmExeName = VS_ARCHITECTURE == 'x64' ? 'ml64.exe' : 'ml.exe'
8089
const toolPath = path.join(
8190
installationPath,
82-
`VC\\Tools\\MSVC\\${vcToolsVersion}\\bin\\Hostx64\\x64\\ml64.exe`
91+
`VC\\Tools\\MSVC\\${vcToolsVersion}\\bin\\Host${VS_ARCHITECTURE}\\${VS_ARCHITECTURE}\\${asmExeName}`
8392
)
8493
core.debug(`Checking for path: ${toolPath}`)
8594
if (fs.existsSync(toolPath)) {

0 commit comments

Comments
 (0)