Skip to content

Commit

Permalink
Merge #16
Browse files Browse the repository at this point in the history
16: Update to 0.2.2 r=FaultyRAM a=FaultyRAM

Addresses #15

Co-authored-by: FaultyRAM <316014+FaultyRAM@users.noreply.github.com>
  • Loading branch information
bors[bot] and FaultyRAM authored Feb 26, 2021
2 parents 2b34012 + 2e2b497 commit dd8af81
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 144 deletions.
35 changes: 23 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["windres-test"]

[package]
name = "windres"
version = "0.2.1"
version = "0.2.2"
authors = ["FaultyRAM <explodingpsu@gmail.com>"]
description = "Compiles Windows resource files (.rc) into a Rust program."
repository = "https://github.com/FaultyRAM/windres-rs"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
72 changes: 0 additions & 72 deletions appveyor.yml

This file was deleted.

3 changes: 1 addition & 2 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
status = [
"continuous-integration/travis-ci/push",
"continuous-integration/appveyor/branch"
"continuous-integration/travis-ci/push"
]
36 changes: 19 additions & 17 deletions src/gnu.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
// Copyright (c) 2017-2018 FaultyRAM
// Copyright (c) 2017-2021 FaultyRAM
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, 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<PathBuf> {
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.
Expand Down Expand Up @@ -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() {
Expand Down
48 changes: 27 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 FaultyRAM
// Copyright (c) 2017-2021 FaultyRAM
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
Expand All @@ -13,25 +13,26 @@
//! files, so this crate must be used instead to achieve the same effect.
#![cfg(target_os = "windows")]
#![forbid(warnings)]
#![deny(unused)]
#![forbid(box_pointers)]
#![forbid(missing_copy_implementations)]
#![forbid(missing_debug_implementations)]
#![forbid(missing_docs)]
#![forbid(trivial_casts)]
#![forbid(trivial_numeric_casts)]
#![forbid(unused_extern_crates)]
#![forbid(unused_import_braces)]
#![deny(unused_qualifications)]
#![forbid(unused_results)]
#![forbid(variant_size_differences)]
#![cfg_attr(feature = "cargo-clippy", forbid(clippy))]
#![cfg_attr(feature = "cargo-clippy", forbid(clippy_pedantic))]
#![cfg_attr(feature = "cargo-clippy", forbid(clippy_complexity))]
#![cfg_attr(feature = "cargo-clippy", forbid(clippy_correctness))]
#![cfg_attr(feature = "cargo-clippy", forbid(clippy_perf))]
#![cfg_attr(feature = "cargo-clippy", forbid(clippy_style))]
#![deny(
clippy::all,
clippy::pedantic,
warnings,
future_incompatible,
rust_2018_idioms,
rustdoc,
unused,
deprecated_in_future,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_import_braces,
unused_lifetimes,
unused_results
)]
#![allow(clippy::must_use_candidate, missing_doc_code_examples)]

#[macro_use(concat_string)]
extern crate concat_string;
Expand Down Expand Up @@ -78,7 +79,7 @@ impl Build {
/// Specifies an additional preprocessor definition to use during preprocessing.
pub fn define<'a, V: Into<Option<&'a str>>>(&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
}

Expand All @@ -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<P: AsRef<Path>>(&mut self, rc_file: P) -> io::Result<()> {
Self::find_resource_compiler().and_then(|compiler| self.compile_resource(rc_file, compiler))
}
Expand Down
9 changes: 5 additions & 4 deletions src/msvc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 FaultyRAM
// Copyright (c) 2017-2021 FaultyRAM
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
Expand All @@ -7,13 +7,13 @@

//! MSVC implementation details.
use super::Build;
use find_winsdk::{SdkInfo, SdkVersion};
use std::env;
use std::ffi::{OsStr, OsString};
use std::io::{self, ErrorKind, Write};
use std::path::{Path, PathBuf};
use std::process::Command;
use Build;

#[cfg(target_arch = "x86")]
const RC_EXE: &str = "x86/rc.exe";
Expand Down Expand Up @@ -96,7 +96,7 @@ impl Build {
"cargo:rustc-link-search=native=",
out_file.parent().expect("empty parent").to_string_lossy(),
"\n",
"cargo:rustc-link-lib=static=",
"cargo:rustc-link-lib=",
out_file
.file_stem()
.expect("empty filename")
Expand All @@ -105,7 +105,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() {
Expand Down
2 changes: 1 addition & 1 deletion windres-test/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 FaultyRAM
// Copyright (c) 2017-2021 FaultyRAM
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
Expand Down
2 changes: 1 addition & 1 deletion windres-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 FaultyRAM
// Copyright (c) 2017-2021 FaultyRAM
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
Expand Down

0 comments on commit dd8af81

Please sign in to comment.