Skip to content

Commit

Permalink
Change xcoff to be an unstable feature
Browse files Browse the repository at this point in the history
The xcoff feature needs further work before being ready for release.

Also, the default resolver can be changed to "2" now that the MSRV is
at least 1.51. This works better with features in workspaces.
  • Loading branch information
philipc committed Nov 19, 2022
1 parent b7d879d commit 5105b4c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/rust.yml
Expand Up @@ -25,7 +25,9 @@ jobs:
rustup install ${{matrix.rust_channel}}
rustup default ${{matrix.rust_channel}}
- name: Test debug
run: cargo test --verbose --features all
run: |
cargo test --verbose --features all
cargo test --verbose --features unstable-all
- name: Test release
run: cargo test --verbose --features all --release

Expand All @@ -42,7 +44,7 @@ jobs:
- run: cargo build --no-default-features --features read_core,write_core,macho
- run: cargo build --no-default-features --features read_core,pe
- run: cargo build --no-default-features --features read_core,wasm
- run: cargo build --no-default-features --features read_core,xcoff
- run: cargo build --no-default-features --features read_core,xcoff,unstable
- run: cargo build --no-default-features --features doc

cross:
Expand Down
16 changes: 10 additions & 6 deletions Cargo.toml
@@ -1,6 +1,5 @@
[package]
name = "object"
# Note: disable resolver in workspace setting before releases.
version = "0.29.0"
edition = "2018"
exclude = ["/.github", "/testfiles"]
Expand Down Expand Up @@ -32,8 +31,8 @@ alloc = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-all

# Core read support. You will need to enable some file formats too.
read_core = []
# Read support for all file formats (including unaligned files).
read = ["read_core", "archive", "coff", "elf", "macho", "pe", "unaligned", "xcoff"]
# Read support for most file formats (including unaligned files).
read = ["read_core", "archive", "coff", "elf", "macho", "pe", "unaligned"]
# Core write support. You will need to enable some file formats too.
write_core = ["crc32fast", "indexmap", "hashbrown"]
# Core write support with libstd features. You will need to enable some file formats too.
Expand Down Expand Up @@ -65,7 +64,6 @@ elf = []
macho = []
pe = ["coff"]
wasm = ["wasmparser"]
xcoff = []

#=======================================
# By default, support all read features.
Expand All @@ -85,9 +83,15 @@ cargo-all = []
doc = [
"read_core", "write_std",
"std", "compression",
"archive", "coff", "elf", "macho", "pe", "wasm", "xcoff"
"archive", "coff", "elf", "macho", "pe", "wasm",
]

#=======================================
# Unstable features. Breaking changes in these features will not affect versioning.
unstable = []
xcoff = []
unstable-all = ["all", "unstable", "xcoff"]

#=======================================
# Internal feature, only used when building as part of libstd, not part of the
# stable interface of this crate.
Expand All @@ -96,4 +100,4 @@ rustc-dep-of-std = ['core', 'compiler_builtins', 'alloc', 'memchr/rustc-dep-of-s
[workspace]
members = ["crates/examples"]
default-members = [".", "crates/examples"]
#resolver = "2"
resolver = "2"
2 changes: 2 additions & 0 deletions crates/examples/Cargo.toml
Expand Up @@ -12,6 +12,8 @@ glob = "0.3"

[features]
read = ["object/read"]
wasm = ["object/wasm"]
xcoff = ["object/xcoff"]
default = ["read"]

[[bin]]
Expand Down
25 changes: 16 additions & 9 deletions crates/examples/tests/testfiles.rs
Expand Up @@ -6,14 +6,18 @@ use std::io::Write;
use std::path::PathBuf;
use std::{env, fs};

#[cfg(feature = "wasm")]
fn skip_wasm_test_if_unsupport(_: &PathBuf) -> bool {
true
}
const DISABLED_TEST_DIRS: &[&'static str] = &[
#[cfg(not(feature = "wasm"))]
"wasm",
#[cfg(not(feature = "xcoff"))]
"xcoff",
];

#[cfg(not(feature = "wasm"))]
fn skip_wasm_test_if_unsupport(path: &PathBuf) -> bool {
path.extension().and_then(OsStr::to_str) != Some("wasm")
fn test_dir_filter(path: &PathBuf) -> bool {
match path.file_name().and_then(OsStr::to_str) {
Some(dir) => !DISABLED_TEST_DIRS.contains(&dir),
None => true,
}
}

#[test]
Expand All @@ -22,12 +26,15 @@ fn testfiles() {
env::set_current_dir("../..").unwrap();

let mut fail = false;
for dir in glob::glob("testfiles/*").unwrap().filter_map(Result::ok) {
for dir in glob::glob("testfiles/*")
.unwrap()
.filter_map(Result::ok)
.filter(test_dir_filter)
{
let dir = dir.to_str().unwrap();
for path in glob::glob(&format!("{}/*", dir))
.unwrap()
.filter_map(Result::ok)
.filter(skip_wasm_test_if_unsupport)
{
let path = path.to_str().unwrap();
if glob::glob(&format!("crates/examples/{}.*", path))
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Expand Up @@ -73,6 +73,9 @@
#[cfg(feature = "cargo-all")]
compile_error!("'--all-features' is not supported; use '--features all' instead");

#[cfg(all(feature = "xcoff", not(feature = "unstable")))]
compile_error!("'xcoff` is an unstable feature; enable 'unstable' as well");

#[cfg(any(feature = "read_core", feature = "write_core"))]
#[allow(unused_imports)]
#[macro_use]
Expand Down

0 comments on commit 5105b4c

Please sign in to comment.