Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put cl.exe and link.exe on PATH on Windows? #13

Open
ecstatic-morse opened this issue Jul 24, 2019 · 2 comments
Open

Put cl.exe and link.exe on PATH on Windows? #13

ecstatic-morse opened this issue Jul 24, 2019 · 2 comments
Labels

Comments

@ecstatic-morse
Copy link
Contributor

The vast majority of crates use the cc crate for building native libraries. However, a few want the compiler and/or linker on the PATH (see https://github.com/blt/mond). This seems pretty standard coming from the UNIX world, but the normal workflow on Windows seems to be sourcing a vcvars.bat file before you build something. I'm not sure if this should be the crate's responsibility or ours. This is complicated by the fact that powershell doesn't have a source equivalent, so one has to do a contrived workaround to permanently save the configuration in vcvars.bat.

@ecstatic-morse ecstatic-morse changed the title Put cl.exe and link.exe on PATH Put cl.exe and link.exe on PATH on Windows? Jul 24, 2019
@ecstatic-morse
Copy link
Contributor Author

The github repo timvisee.cant-touch-this is a good test case for this. It uses the cmake crate to build a dependency and fails with:

couldn't determine visual studio generator
if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate

ecstatic-morse added a commit to ecstatic-morse/crates-build-env that referenced this issue Aug 5, 2019
Resolves rust-lang#13.

Some build scripts want to have the compiler and/or linker on the `PATH`
(such as `blt.mond`). On Windows, this is usually achieved by running a
Visual Studio `cmd` shell which sets the appropriate environement.
However, I didn't see a simple way to do this in the `Dockerfile` for
`powershell` (Windows has no equivalent of `source` in `bash`). Instead,
we use a variant of a hack described on [Stack
Overflow](https://stackoverflow.com/a/2124759).

Note the call to `[Environment]::SetEnvironmentVariable`. Simply setting
variables in `$env:` will not persist beyond a single `RUN` command.
ecstatic-morse added a commit to ecstatic-morse/crates-build-env that referenced this issue Aug 5, 2019
Resolves rust-lang#13.

Some build scripts want to have the compiler and/or linker on the `PATH`
(such as `blt.mond`). On Windows, this is usually achieved by running a
Visual Studio `cmd` shell which sets the appropriate environment.
However, I didn't see a simple way to do this in the `Dockerfile` for
`powershell` (Windows has no equivalent of `source` in `bash`). Instead,
we use a variant of a hack described on [Stack
Overflow](https://stackoverflow.com/a/2124759).

Note the call to `[Environment]::SetEnvironmentVariable`. Simply setting
variables in `$env:` will not persist beyond a single `RUN` command.
@danilaml
Copy link

Note that with VS 2019 you could also try to use Developer PowerShell although it seems that's only available for x86 toolset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants