-
Notifications
You must be signed in to change notification settings - Fork 946
Fix and re-enable MSI build #1211
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9b9bd1c
Make MSI CustemAction DLL build script more robust
Boddlnagg ea75f6f
Select correct MSI target architecture
Boddlnagg 0d37856
Update outdated list of tools
Boddlnagg e0ce4c6
Re-enable MSI build on AppVeyor and add documentation
Boddlnagg cc6854e
Fix lockfile
Boddlnagg eaed698
Use the gcc crate's find_vs_version()
Boddlnagg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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,11 @@ | ||
# How to build | ||
|
||
Important: For all `cargo build` invocations, set `--target` (even if the target is the same as the host architecture), because that affects the output directory. Pass the same target also via `-Target` to `build.ps1` in step 3. | ||
|
||
## Steps | ||
|
||
1) Build the main project with the `--features "msi-installed"` flag, resulting in `rustup-init.exe` | ||
2) Build the CustomAction DLL in `src/rustup-win-installer` using `cargo build` | ||
3) Build the actual installer in `src/rustup-win-installer/msi` using `build.ps1` | ||
|
||
The resulting installer will be in `src/rustup-win-installer/msi/target`. |
This file contains hidden or 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,13 +1,38 @@ | ||
extern crate gcc; | ||
|
||
use std::env; | ||
use gcc::windows_registry::{self, VsVers}; | ||
|
||
fn main() { | ||
println!("cargo:rustc-link-lib=static=wcautil"); | ||
println!("cargo:rustc-link-lib=static=dutil"); | ||
println!("cargo:rustc-link-lib=dylib=msi"); | ||
println!("cargo:rustc-link-lib=dylib=user32"); | ||
println!("cargo:rustc-link-lib=dylib=mincore"); | ||
|
||
let wix_path = env::var("WIX").unwrap(); | ||
// x86 target is hard-coded because we only build an x86 installer (works just fine on x64) | ||
println!("cargo:rustc-link-search=native={}SDK\\VS2015\\lib\\x86", wix_path); | ||
// Part of WIX SDK | ||
println!("cargo:rustc-link-lib=static=wcautil"); | ||
println!("cargo:rustc-link-lib=static=dutil"); | ||
|
||
let wix_path = env::var("WIX").expect("WIX must be installed, and 'WIX' environment variable must be set"); | ||
|
||
// For the correct WIX library path, we need to know which VS version we are using. | ||
// We use the `gcc` crate's functionality to do this, which should always match what rustc is doing. | ||
let vs_version = windows_registry::find_vs_version().expect("Cannot find VS version"); | ||
let vs_version_string = match vs_version { | ||
VsVers::Vs14 => "VS2015", | ||
VsVers::Vs15 => "VS2017", | ||
VsVers::Vs12 => panic!("Unsupported VS version: Vs12"), | ||
_ => panic!("Unsupported VS version") // FIXME: should use {:?}, but `VsVers` does not yet implement `Debug` | ||
}; | ||
|
||
println!("cargo:warning=Using WIX libraries for VS version: {}", vs_version_string); | ||
|
||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("cannot read CARGO_CFG_TARGET_ARCH in build script"); | ||
let target_arch = match target_arch.as_str() { | ||
"x86" => "x86", | ||
"x86_64" => "x64", | ||
other => panic!("Target architecture {} not supported by WIX.", other) | ||
}; | ||
|
||
// Tell cargo about the WIX SDK path for `wcautil.lib` and `dutil.lib` | ||
println!("cargo:rustc-link-search=native={}SDK\\{}\\lib\\{}", wix_path, vs_version_string, target_arch); | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed now that BUILD_MSI is enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MSI version is nowhere near finished. I want to enable it on CI just so it won't break. Maybe it would make sense to also set
ALLOW_PR: 1
for it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, that makes sense and no worries! My only worry is that this'll conflict with the other i686 builder for the dist artifacts being produced. Enabling the MSI installer just builds more artifacts, right? It shouldn't change the existing binaries?
(if so we can probably just gate on the msi build)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No artifacts are being produced for MSI currently, see https://github.com/rust-lang-nursery/rustup.rs/blob/ac5bffad7ba126b2313692c3dfce83ec91cb7fea/ci/prepare-deploy-appveyor.ps1#L9-L12
Changing that situation was part of #661, but I didn't include it here. Will do in another PR.