diff --git a/.travis.yml b/.travis.yml index c7eb27c..63ea690 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,30 @@ +sudo: false branches: only: - - staging - - trying - - master -dist: trusty -sudo: false + - staging + - trying + - master os: - - linux - - osx + - windows language: rust rust: - - stable - - beta - - nightly + - stable-x86_64-pc-windows-msvc + - stable-x86_64-pc-windows-gnu + - beta-x86_64-pc-windows-msvc + - beta-x86_64-pc-windows-gnu + - nightly-x86_64-pc-windows-msvc + - nightly-x86_64-pc-windows-gnu matrix: allow_failures: - - beta - - nightly + - rust: beta-x86_64-pc-windows-msvc + - rust: beta-x86_64-pc-windows-gnu + - rust: nightly-x86_64-pc-windows-msvc + - rust: nightly-x86_64-pc-windows-gnu + fast_finish: true +install: + - rustup component add clippy rustfmt +script: + - cargo clippy + - cargo build -p windres-test + - cargo doc --no-deps + - cargo fmt --all -- --check diff --git a/CHANGES.md b/CHANGES.md index d56ef22..50a6ee0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ # windres-rs Changelog +## 0.2.2 (27/02/2021) + +* Previous versions of this crate were broken for MSVC targets by a breaking change in Rust (see + https://github.com/rust-lang/rust/pull/72785). This version adds a workaround for the breakage. +* To prevent future breakage, trivial changes were made to parts of the code. This is a refactor, + i.e. no change in behaviour from the previous version, but the minimum working Rust version may + have increased as a result. + ## 0.2.1 (18/08/2018) * Update find-winsdk to 0.2. This fixes Windows 8.1A SDK support and adds support for earlier diff --git a/Cargo.toml b/Cargo.toml index 952b641..abb724d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["windres-test"] [package] name = "windres" -version = "0.2.1" +version = "0.2.2" authors = ["FaultyRAM "] description = "Compiles Windows resource files (.rc) into a Rust program." repository = "https://github.com/FaultyRAM/windres-rs" diff --git a/LICENSE-MIT b/LICENSE-MIT index 328ee41..270e0fc 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2017-2018 FaultyRAM +Copyright (c) 2017-2021 FaultyRAM Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index d008b61..33b036a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # windres-rs [![Travis CI](https://travis-ci.org/FaultyRAM/windres-rs.svg)][1] -[![AppVeyor](https://ci.appveyor.com/api/projects/status/ffj632w0xqh98c83?retina=true&svg=true)][2] -[![Crates.io](https://img.shields.io/crates/v/windres.svg)][3] -[![Docs.rs](https://docs.rs/windres/badge.svg)][4] +[![Crates.io](https://img.shields.io/crates/v/windres.svg)][2] +[![Docs.rs](https://docs.rs/windres/badge.svg)][3] -`windres` is a [Rust][5] library crate for compiling [Windows resource (.rc) files][6] into object +`windres` is a [Rust][4] library crate for compiling [Windows resource (.rc) files][5] into object files at build time, which are then forwarded to the linker. This allows for embedding icons, version information, native UI data, etc. in binaries compiled from Rust code. @@ -36,7 +35,7 @@ fn main() { You need to install the resource compiler for your target ABI in order for `windres` to work. Currently the following compilers are supported: -* `windres.exe` for GNU targets (included in the [mingw-w64][7] toolchain) +* `windres.exe` for GNU targets (included in the [mingw-w64][6] toolchain) * `rc.exe` for MSVC targets (included in the Windows SDK, which can be installed via Visual Studio Installer) @@ -73,10 +72,8 @@ license, shall be dual licensed as above, without any additional terms or conditions. [1]: https://travis-ci.org/FaultyRAM/windres-rs -[2]: https://ci.appveyor.com/project/FaultyRAM/windres-rs -[3]: https://crates.io/crates/windres -[4]: https://docs.rs/windres -[5]: https://www.rust-lang.org -[6]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa380599(v=vs.85).aspx -[7]: https://mingw-w64.org -[8]: https://www.visualstudio.com +[2]: https://crates.io/crates/windres +[3]: https://docs.rs/windres +[4]: https://www.rust-lang.org +[5]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa380599(v=vs.85).aspx +[6]: https://mingw-w64.org diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5fee2b0..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,72 +0,0 @@ -image: Visual Studio 2017 -branches: - only: - - staging - - trying - - master -environment: - matrix: - - TARGET: x86_64-pc-windows-gnu - CHANNEL: stable - CARGO_CHECK: cargo check - CARGO_FMT: cargo fmt -- --write-mode diff - - TARGET: x86_64-pc-windows-gnu - CHANNEL: beta - CARGO_CHECK: cargo check - CARGO_FMT: cargo fmt -- --check - - TARGET: x86_64-pc-windows-gnu - CHANNEL: nightly - CARGO_CHECK: cargo clippy - CARGO_FMT: cargo fmt -- --check - - TARGET: x86_64-pc-windows-msvc - CHANNEL: stable - CARGO_CHECK: cargo check - CARGO_FMT: cargo fmt -- --write-mode diff - WINSDK: v10.0 - - TARGET: x86_64-pc-windows-msvc - CHANNEL: beta - CARGO_CHECK: cargo check - CARGO_FMT: cargo fmt -- --check - WINSDK: v10.0 - - TARGET: x86_64-pc-windows-msvc - CHANNEL: nightly - CARGO_CHECK: cargo clippy - CARGO_FMT: cargo fmt -- --check - WINSDK: v10.0 - - TARGET: x86_64-pc-windows-msvc - CHANNEL: stable - CARGO_CHECK: cargo check - CARGO_FMT: cargo fmt -- --write-mode diff - WINSDK: v8.1 - - TARGET: x86_64-pc-windows-msvc - CHANNEL: beta - CARGO_CHECK: cargo check - CARGO_FMT: cargo fmt -- --check - WINSDK: v8.1 - - TARGET: x86_64-pc-windows-msvc - CHANNEL: nightly - CARGO_CHECK: cargo clippy - CARGO_FMT: cargo fmt -- --check - WINSDK: v8.1 -matrix: - allow_failures: - - CHANNEL: beta - - CHANNEL: nightly -install: - - SET PATH=%USERPROFILE%\.cargo\bin;%PATH% - - IF "%TARGET%"=="x86_64-pc-windows-gnu" set PATH=C:\msys64\mingw64\bin;%PATH% - - IF NOT "%WINSDK%"=="v10.0" REG DELETE "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0" /va /f /reg:32 - - ps: Start-FileDownload "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe" - - rustup-init.exe -y --no-modify-path --default-host %TARGET% --default-toolchain %CHANNEL% - - rustup -vV - - rustc -vV - - cargo -vV - - rustup component add rustfmt-preview - - cargo fmt -v --version - - IF "%CHANNEL%"=="nightly" cargo install --git https://github.com/rust-lang-nursery/rust-clippy.git clippy && cargo clippy -V -build_script: - - "%CARGO_FMT%" - - "%CARGO_CHECK%" - - cargo doc -p windres --target=%TARGET% -test_script: - - cargo run -p windres-test -vv --target=%TARGET% diff --git a/bors.toml b/bors.toml index 661782e..2ce6b39 100644 --- a/bors.toml +++ b/bors.toml @@ -1,4 +1,3 @@ status = [ - "continuous-integration/travis-ci/push", - "continuous-integration/appveyor/branch" + "continuous-integration/travis-ci/push" ] diff --git a/src/gnu.rs b/src/gnu.rs index 0b1cc76..31387c2 100644 --- a/src/gnu.rs +++ b/src/gnu.rs @@ -1,34 +1,35 @@ -// Copyright (c) 2017-2018 FaultyRAM +// Copyright (c) 2017-2021 FaultyRAM // // Licensed under the Apache License, Version 2.0 or the MIT license , at your option. This file may not be copied, modified, or // distributed except according to those terms. -//! GNU implementation details. - +use super::Build; use std::env; use std::ffi::{OsStr, OsString}; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::process::Command; -use Build; impl Build { /// Locates the tool used to compile resources. pub(crate) fn find_resource_compiler() -> io::Result { - if let Some(p) = env::var_os("PATH").and_then(|path| { - env::split_paths(&path) - .map(|p| p.join("windres.exe")) - .find(|p| p.exists()) - }) { - Ok(p) - } else { - Err(io::Error::new( - io::ErrorKind::NotFound, - "could not locate windres.exe", - )) - } + env::var_os("PATH") + .and_then(|path| { + env::split_paths(&path) + .map(|p| p.join("windres.exe")) + .find(|p| p.exists()) + }) + .map_or_else( + || { + Err(io::Error::new( + io::ErrorKind::NotFound, + "could not locate windres.exe", + )) + }, + Ok, + ) } /// Invokes the resource compiler using the current arguments. @@ -87,7 +88,8 @@ impl Build { "cargo:rerun-if-changed=", rc_file.as_ref().to_string_lossy(), "\n" - ).as_bytes(), + ) + .as_bytes(), ); } let e = if let Some(code) = status.code() { diff --git a/src/lib.rs b/src/lib.rs index 1e11432..751f813 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 FaultyRAM +// Copyright (c) 2017-2021 FaultyRAM // // Licensed under the Apache License, Version 2.0 or the MIT license >>(&mut self, name: &str, value: V) -> &mut Self { self.extra_cpp_defs - .push((name.to_owned(), value.into().map(|s| s.to_owned()))); + .push((name.to_owned(), value.into().map(ToOwned::to_owned))); self } @@ -89,6 +90,11 @@ impl Build { } /// Compiles a Windows resource file (.rc). + /// + /// # Errors + /// + /// This method returns a `std::io::Error` if it either cannot locate a resource compiler or + /// fails to compile the resource. pub fn compile>(&mut self, rc_file: P) -> io::Result<()> { Self::find_resource_compiler().and_then(|compiler| self.compile_resource(rc_file, compiler)) } diff --git a/src/msvc.rs b/src/msvc.rs index 1f557c2..5cc8e7c 100644 --- a/src/msvc.rs +++ b/src/msvc.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 FaultyRAM +// Copyright (c) 2017-2021 FaultyRAM // // Licensed under the Apache License, Version 2.0 or the MIT license or the MIT license or the MIT license