mirror of
https://github.com/ilammy/msvc-dev-cmd.git
synced 2026-09-07 06:07:19 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5611a7cba9 | |||
| 08b850b4d0 | |||
| ff72ae9ce3 | |||
| 18f5f2cef4 | |||
| f5e8657374 | |||
| d39d8f7626 | |||
| 24b406e1cf | |||
| 376515093d | |||
| ed94116c4d | |||
| b44b596ee5 | |||
| 6bcb337df2 | |||
| 074eec8db2 | |||
| b5113e7e9d | |||
| 1eed9c1215 | |||
| 233eac407f |
@@ -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
|
|
||||||
+32
-20
@@ -6,42 +6,54 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- release/*
|
- release/*
|
||||||
- new-windows
|
|
||||||
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: Enable Developer Command Prompt
|
- name: Enable Developer Command Prompt (amd64)
|
||||||
uses: ./
|
uses: ./
|
||||||
- name: Compile and run some C code
|
with:
|
||||||
|
arch: amd64
|
||||||
|
- name: Compile and run some C code (amd64)
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
cl.exe hello.c
|
cl.exe hello.c
|
||||||
hello.exe
|
hello.exe
|
||||||
|
- name: Enable Developer Command Prompt (amd64_x86)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
arch: amd64_x86
|
||||||
|
- name: Compile and run some C code (x86)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cl.exe hello.c
|
||||||
|
hello.exe
|
||||||
|
- name: Enable Developer Command Prompt (amd64_arm)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
arch: amd64_arm
|
||||||
|
- name: Compile some C code (arm)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cl.exe hello.c
|
||||||
|
dumpbin /headers hello.exe
|
||||||
|
- name: Enable Developer Command Prompt (amd64_arm64)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
arch: amd64_arm64
|
||||||
|
- name: Compile some C code (arm64)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cl.exe hello.c
|
||||||
|
dumpbin /headers hello.exe
|
||||||
audit:
|
audit:
|
||||||
name: npm audit
|
name: npm audit
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
node_modules
|
|
||||||
|
|||||||
@@ -8,14 +8,57 @@ This sets up the environment for compiling C/C++ code from command line.
|
|||||||
|
|
||||||
Supports Windows. Does nothing on Linux and macOS.
|
Supports Windows. Does nothing on Linux and macOS.
|
||||||
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
|
Basic usage for default compilation settings is like this:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
- name: Build something requiring CL.EXE
|
||||||
|
run: |
|
||||||
|
cmake -G "NMake Makefiles" .
|
||||||
|
nmake
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want something non-default,
|
||||||
|
like using a specific version of Visual Studio,
|
||||||
|
or cross-compling for a differen target,
|
||||||
|
you will need to configure those settings via inputs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
# Run a job for each of the specified target architectures:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch:
|
||||||
|
- amd64
|
||||||
|
- amd64_x86
|
||||||
|
- amd64_arm64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: ${{ matrix.arch }}
|
||||||
|
- name: Build something requiring CL.EXE
|
||||||
|
run: |
|
||||||
|
cmake -G "NMake Makefiles" .
|
||||||
|
nmake
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
- `arch` – target architecture
|
- `arch` – target architecture
|
||||||
- native compilation:
|
- native compilation:
|
||||||
- `x64` (default) or its synonyms: `amd64`, `win64`
|
- `x64` (default) or its synonyms: `amd64`, `win64`
|
||||||
- `x86` or its synonyms: `win32`
|
- `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
|
||||||
- do not specify to use the default SDK
|
- do not specify to use the default SDK
|
||||||
- or specify full Windows 10 SDK number (e.g, `10.0.10240.0`)
|
- or specify full Windows 10 SDK number (e.g, `10.0.10240.0`)
|
||||||
@@ -28,20 +71,6 @@ Supports Windows. Does nothing on Linux and macOS.
|
|||||||
- `uwp` – set `true` to build for Universal Windows Platform (i.e., for Windows Store)
|
- `uwp` – set `true` to build for Universal Windows Platform (i.e., for Windows Store)
|
||||||
- `spectre` – set `true` to use Visual Studio libraries with [Spectre](https://meltdownattack.com) mitigations
|
- `spectre` – set `true` to use Visual Studio libraries with [Spectre](https://meltdownattack.com) mitigations
|
||||||
|
|
||||||
## Example usage
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- uses: ilammy/msvc-dev-cmd@v1
|
|
||||||
- name: Build something requiring CL.EXE
|
|
||||||
run: |
|
|
||||||
cmake -G "NMake Makefiles" .
|
|
||||||
nmake
|
|
||||||
# ...
|
|
||||||
```
|
|
||||||
|
|
||||||
## Caveats
|
## Caveats
|
||||||
|
|
||||||
### Name conflicts with `shell: bash`
|
### Name conflicts with `shell: bash`
|
||||||
@@ -58,6 +87,48 @@ If you experience compilation errors where `link` complains about unreasonable c
|
|||||||
Recommended workaround is to remove `/usr/bin/link` if that interferes with your builds.
|
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.
|
If this is not acceptable, please file an issue, then we'll figure out something better.
|
||||||
|
|
||||||
|
### Reconfiguration
|
||||||
|
|
||||||
|
You can invoke `ilammy/msvc-dev-cmd` multiple times during your jobs with different inputs
|
||||||
|
to reconfigure the environment for building with different settings
|
||||||
|
(e.g., to target multiple architectures).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
steps:
|
||||||
|
# ...
|
||||||
|
- name: Configure build for amd64
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
- run: build # (for amd64)
|
||||||
|
|
||||||
|
- name: Configure build for x86
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: amd64_x86
|
||||||
|
|
||||||
|
- run: build # (for x86)
|
||||||
|
|
||||||
|
- name: Configure build for ARM64
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: amd64_arm64
|
||||||
|
|
||||||
|
- run: build # (for ARM64)
|
||||||
|
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
This mostly works but it's not really recommended
|
||||||
|
since Developer Command Prompt was not meant for recursive reconfiguration.
|
||||||
|
That said, if it does not work for you, please file an issue.
|
||||||
|
|
||||||
|
Consider using [`strategy.matrix`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)
|
||||||
|
to execute different build configuration in parallel, independent environments.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT, see [LICENSE](LICENSE).
|
MIT, see [LICENSE](LICENSE).
|
||||||
|
|||||||
@@ -55,6 +55,21 @@ function findVcvarsall() {
|
|||||||
throw new Error('Microsoft Visual Studio not found')
|
throw new Error('Microsoft Visual Studio not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPathVariable(name) {
|
||||||
|
const pathLikeVariables = ['PATH', 'INCLUDE', 'LIB', 'LIBPATH']
|
||||||
|
return pathLikeVariables.indexOf(name.toUpperCase()) != -1
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterPathValue(path) {
|
||||||
|
let paths = path.split(';')
|
||||||
|
// Remove duplicates by keeping the first occurance and preserving order.
|
||||||
|
// This keeps path shadowing working as intended.
|
||||||
|
function unique(value, index, self) {
|
||||||
|
return self.indexOf(value) === index
|
||||||
|
}
|
||||||
|
return paths.filter(unique).join(';')
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
if (process.platform != 'win32') {
|
if (process.platform != 'win32') {
|
||||||
core.info('This is not a Windows virtual environment, bye!')
|
core.info('This is not a Windows virtual environment, bye!')
|
||||||
@@ -139,11 +154,18 @@ function main() {
|
|||||||
if (!string.includes('=')) {
|
if (!string.includes('=')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const [name, new_value] = string.split('=')
|
let [name, new_value] = string.split('=')
|
||||||
const old_value = old_env_vars[name]
|
let old_value = old_env_vars[name]
|
||||||
// For new variables "old_value === undefined".
|
// For new variables "old_value === undefined".
|
||||||
if (new_value !== old_value) {
|
if (new_value !== old_value) {
|
||||||
core.info(`Setting ${name}`)
|
core.info(`Setting ${name}`)
|
||||||
|
// Special case for a bunch of PATH-like variables: vcvarsall.bat
|
||||||
|
// just prepends its stuff without checking if its already there.
|
||||||
|
// This makes repeated invocations of this action fail after some
|
||||||
|
// point, when the environment variable overflows. Avoid that.
|
||||||
|
if (isPathVariable(name)) {
|
||||||
|
new_value = filterPathValue(new_value)
|
||||||
|
}
|
||||||
core.exportVariable(name, new_value)
|
core.exportVariable(name, new_value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+1412
-74
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "msvc-dev-cmd",
|
"name": "msvc-dev-cmd",
|
||||||
"version": "1.1.1",
|
"version": "1.8.0",
|
||||||
"description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++",
|
"description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user