mirror of
https://github.com/ilammy/msvc-dev-cmd.git
synced 2026-09-06 21:57:19 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ac2ceb2811 | |||
| cdfca13739 |
@@ -1,19 +0,0 @@
|
|||||||
name: z5-build-env
|
|
||||||
channels:
|
|
||||||
- conda-forge
|
|
||||||
dependencies:
|
|
||||||
- cmake
|
|
||||||
- compilers
|
|
||||||
- bzip2
|
|
||||||
- lz4-c
|
|
||||||
- xz
|
|
||||||
- zlib
|
|
||||||
- boost-cpp>=1.63
|
|
||||||
- xtensor>=0.21,<0.22
|
|
||||||
- xtensor-python>=0.24,<0.25
|
|
||||||
- xsimd
|
|
||||||
- blosc
|
|
||||||
- imageio
|
|
||||||
- nlohmann_json
|
|
||||||
- zarr
|
|
||||||
- h5py
|
|
||||||
@@ -6,37 +6,27 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- release/*
|
- release/*
|
||||||
- new-windows
|
- wip/path-test
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 6 * * *'
|
- cron: '0 6 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: default
|
name: default
|
||||||
runs-on: ${{ matrix.windows }}
|
runs-on: windows-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
windows: [windows-2016, windows-2019]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source code
|
- name: Check out source code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup miniconda
|
|
||||||
uses: conda-incubator/setup-miniconda@v2
|
|
||||||
with:
|
|
||||||
activate-environment: z5-build-env
|
|
||||||
auto-update-conda: true
|
|
||||||
channels: conda-forge
|
|
||||||
environment-file: .github/workflows/environment.yaml
|
|
||||||
python-version: 3.7
|
|
||||||
auto-activate-base: false
|
|
||||||
env:
|
|
||||||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
|
|
||||||
|
|
||||||
- name: Download Internet
|
- name: Download Internet
|
||||||
run: npm install
|
run: npm install
|
||||||
|
- name: What's in the env?
|
||||||
|
shell: cmd
|
||||||
|
run: set
|
||||||
- name: Enable Developer Command Prompt
|
- name: Enable Developer Command Prompt
|
||||||
uses: ./
|
uses: ./
|
||||||
|
- name: What's in the env now?
|
||||||
|
shell: cmd
|
||||||
|
run: set
|
||||||
- name: Compile and run some C code
|
- name: Compile and run some C code
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
@@ -44,26 +34,10 @@ jobs:
|
|||||||
hello.exe
|
hello.exe
|
||||||
audit:
|
audit:
|
||||||
name: npm audit
|
name: npm audit
|
||||||
|
if: false
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source code
|
- name: Check out source code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm audit --audit-level=moderate
|
- run: npm audit --audit-level=moderate
|
||||||
alias-arch:
|
|
||||||
name: arch aliases
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out source code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Download Internet
|
|
||||||
run: npm install
|
|
||||||
- name: Enable Developer Command Prompt
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
arch: Win32
|
|
||||||
- name: Compile and run some C code
|
|
||||||
shell: cmd
|
|
||||||
run: |
|
|
||||||
cl.exe hello.c
|
|
||||||
hello.exe
|
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: release
|
name: release
|
||||||
runs-on: ${{ matrix.windows }}
|
runs-on: windows-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
windows: [windows-2016, windows-2019]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Developer Command Prompt
|
- name: Setup Developer Command Prompt
|
||||||
uses: ilammy/msvc-dev-cmd@v1
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ Supports Windows. Does nothing on Linux and macOS.
|
|||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
- `arch` – target architecture
|
- `arch` – target architecture
|
||||||
- native compilation:
|
- native compilation: `x86`, `x64` (default), `amd64` (synonym for x64)
|
||||||
- `x64` (default) or its synonyms: `amd64`, `win64`
|
|
||||||
- `x86` or its synonyms: `win32`
|
|
||||||
- cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`,
|
- cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`,
|
||||||
`amd64_x86`, `amd64_arm`, `amd64_arm64`
|
`amd64_x86`, `amd64_arm`, `amd64_arm64`
|
||||||
- `sdk` – Windows SDK to use
|
- `sdk` – Windows SDK to use
|
||||||
@@ -42,22 +40,6 @@ jobs:
|
|||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Caveats
|
|
||||||
|
|
||||||
### Name conflicts with `shell: bash`
|
|
||||||
|
|
||||||
Using `shell: bash` in Actions may shadow some of the paths added by MSVC.
|
|
||||||
In particular, `link.exe` (Microsoft C linker) is prone to be shadowed by `/usr/bin/link` (GNU filesystem link tool).
|
|
||||||
|
|
||||||
Unfortunately, this happens because GitHub Actions unconditionally *prepend* GNU paths when `shell: bash` is used,
|
|
||||||
on top of any paths set by `msvc-dev-cmd`, every time at the start of each new step.
|
|
||||||
Hence, there aren't many non-destructive options here.
|
|
||||||
|
|
||||||
If you experience compilation errors where `link` complains about unreasonable command-line arguments,
|
|
||||||
“extra operand *something-something*” – that's probably it.
|
|
||||||
Recommended workaround is to remove `/usr/bin/link` if that interferes with your builds.
|
|
||||||
If this is not acceptable, please file an issue, then we'll figure out something better.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT, see [LICENSE](LICENSE).
|
MIT, see [LICENSE](LICENSE).
|
||||||
|
|||||||
@@ -11,6 +11,19 @@ const VERSIONS = ['2019', '2017']
|
|||||||
|
|
||||||
const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
|
const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
|
||||||
|
|
||||||
|
const InterestingVariables = [
|
||||||
|
'INCLUDE',
|
||||||
|
'LIB',
|
||||||
|
'LIBPATH',
|
||||||
|
'VCINSTALLDIR',
|
||||||
|
'Path',
|
||||||
|
'Platform',
|
||||||
|
'VisualStudioVersion',
|
||||||
|
/^VCTools/,
|
||||||
|
/^VSCMD_/,
|
||||||
|
/^WindowsSDK/i,
|
||||||
|
]
|
||||||
|
|
||||||
function findWithVswhere(pattern) {
|
function findWithVswhere(pattern) {
|
||||||
try {
|
try {
|
||||||
let installationPath = child_process.execSync(`vswhere -products * -latest -prerelease -property installationPath`).toString().trim()
|
let installationPath = child_process.execSync(`vswhere -products * -latest -prerelease -property installationPath`).toString().trim()
|
||||||
@@ -64,23 +77,12 @@ function main() {
|
|||||||
// Add standard location of "vswhere" to PATH, in case it's not there.
|
// Add standard location of "vswhere" to PATH, in case it's not there.
|
||||||
process.env.PATH += path.delimiter + VSWHERE_PATH
|
process.env.PATH += path.delimiter + VSWHERE_PATH
|
||||||
|
|
||||||
var arch = core.getInput('arch')
|
const arch = core.getInput('arch')
|
||||||
const sdk = core.getInput('sdk')
|
const sdk = core.getInput('sdk')
|
||||||
const toolset = core.getInput('toolset')
|
const toolset = core.getInput('toolset')
|
||||||
const uwp = core.getInput('uwp')
|
const uwp = core.getInput('uwp')
|
||||||
const spectre = core.getInput('spectre')
|
const spectre = core.getInput('spectre')
|
||||||
|
|
||||||
// There are all sorts of way the architectures are called. In addition to
|
|
||||||
// values supported by Microsoft Visual C++, recognize some common aliases.
|
|
||||||
let arch_aliases = {
|
|
||||||
"win32": "x86",
|
|
||||||
"win64": "x64",
|
|
||||||
}
|
|
||||||
// Ignore case when matching as that's what humans expect.
|
|
||||||
if (arch.toLowerCase() in arch_aliases) {
|
|
||||||
arch = arch_aliases[arch.toLowerCase()]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Due to the way Microsoft Visual C++ is configured, we have to resort to the following hack:
|
// Due to the way Microsoft Visual C++ is configured, we have to resort to the following hack:
|
||||||
// Call the configuration batch file and then output *all* the environment variables.
|
// Call the configuration batch file and then output *all* the environment variables.
|
||||||
|
|
||||||
@@ -98,56 +100,19 @@ function main() {
|
|||||||
args.push('-vcvars_spectre_libs=spectre')
|
args.push('-vcvars_spectre_libs=spectre')
|
||||||
}
|
}
|
||||||
|
|
||||||
const vcvars = `"${findVcvarsall()}" ${args.join(' ')}`
|
const command = `"${findVcvarsall()}" ${args.join(' ')} && set`
|
||||||
core.debug(`vcvars command-line: ${vcvars}`)
|
core.debug(`Running: ${command}`)
|
||||||
|
const environment = child_process.execSync(command, {shell: "cmd"}).toString().split('\r\n')
|
||||||
|
|
||||||
const old_environment = child_process.execSync(`set`, {shell: "cmd"}).toString().split('\r\n')
|
for (let string of environment) {
|
||||||
const new_environment = child_process.execSync(`${vcvars} && set`, {shell: "cmd"}).toString().split('\r\n')
|
|
||||||
|
|
||||||
// If vsvars.bat is given an incorrect command line, it will print out
|
|
||||||
// an error and *still* exit successfully. Parse out errors from output
|
|
||||||
// which don't look like environment variables, and fail if appropriate.
|
|
||||||
var failed = false
|
|
||||||
for (let line of new_environment) {
|
|
||||||
if (line.match(/^\[ERROR.*\]/)) {
|
|
||||||
failed = true
|
|
||||||
// Don't print this particular line which will be confusing in output.
|
|
||||||
if (line.match(/Error in script usage. The correct usage is:$/)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
core.error(line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (failed) {
|
|
||||||
throw new Error('invalid parameters')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert old environment lines into a dictionary for easier lookup.
|
|
||||||
let old_env_vars = {}
|
|
||||||
for (let string of old_environment) {
|
|
||||||
const [name, value] = string.split('=')
|
const [name, value] = string.split('=')
|
||||||
old_env_vars[name] = value
|
for (let pattern of InterestingVariables) {
|
||||||
}
|
if (name.match(pattern)) {
|
||||||
|
core.exportVariable(name, value)
|
||||||
// Now look at the new environment and export everything that changed.
|
break
|
||||||
// These are the variables set by vsvars.bat. Also export everything
|
}
|
||||||
// that was not there during the first sweep: those are new variables.
|
|
||||||
core.startGroup('Environment variables')
|
|
||||||
for (let string of new_environment) {
|
|
||||||
// vsvars.bat likes to print some fluff at the beginning.
|
|
||||||
// Skip lines that don't look like environment variables.
|
|
||||||
if (!string.includes('=')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const [name, new_value] = string.split('=')
|
|
||||||
const old_value = old_env_vars[name]
|
|
||||||
// For new variables "old_value === undefined".
|
|
||||||
if (new_value !== old_value) {
|
|
||||||
core.info(`Setting ${name}`)
|
|
||||||
core.exportVariable(name, new_value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.endGroup()
|
|
||||||
|
|
||||||
core.info(`Configured Developer Command Prompt`)
|
core.info(`Configured Developer Command Prompt`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user