Skip to content

Commit

Permalink
Move examples to a separate crate (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Aug 8, 2023
1 parent 1c3d19b commit cfac938
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ jobs:
- name: Run dwarfdump (macos)
if: matrix.os == 'macOS-latest'
run: |
cargo run --example dwarfdump -- \
cargo run --bin dwarfdump -- \
$(find ./target/debug -type f | grep DWARF | grep gimli | head -n 1) \
> /dev/null
- name: Run dwarfdump (linux)
if: matrix.os == 'ubuntu-latest'
run: |
cargo run --example dwarfdump -- \
cargo run --bin dwarfdump -- \
$(find ./target/debug -type f -perm -100 | grep gimli | head -n 1) \
> /dev/null
Expand Down
28 changes: 4 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition = "2018"
include = [
"/CHANGELOG.md",
"/Cargo.toml",
"/examples",
"/LICENSE-APACHE",
"/LICENSE-MIT",
"/README.md",
Expand All @@ -31,15 +30,7 @@ alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-all
compiler_builtins = { version = "0.1.2", optional = true }

[dev-dependencies]
crossbeam = "0.8"
getopts = "0.2"
memmap2 = "0.6.1"
num_cpus = "1"
object = { version = "0.30.0", features = ["wasm"] }
rayon = "1.0"
regex = "1"
test-assembler = "0.1.3"
typed-arena = "2"

[features]
read-core = []
Expand All @@ -61,18 +52,7 @@ debug = true
codegen-units = 1
split-debuginfo = "packed"

[[example]]
name = "simple"
required-features = ["read"]

[[example]]
name = "simple_line"
required-features = ["read"]

[[example]]
name = "dwarfdump"
required-features = ["read", "std"]

[[example]]
name = "dwarf-validate"
required-features = ["read", "std"]
[workspace]
members = ["crates/examples"]
default-members = [".", "crates/examples"]
resolver = "2"
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

* Unsure which object file parser to use? Try the cross-platform
[`object`](https://github.com/gimli-rs/object) crate. See the
[`examples/`](./examples) directory for usage with `gimli`.
[`gimli-examples`](./crates/examples/src/bin) crate for usage with `gimli`.

## Install

Expand All @@ -41,11 +41,11 @@ The minimum supported Rust version is 1.42.0.

* Example programs:

* [A simple `.debug_info` parser](./examples/simple.rs)
* [A simple `.debug_info` parser](./crates/examples/src/bin/simple.rs)

* [A simple `.debug_line` parser](./examples/simple_line.rs)
* [A simple `.debug_line` parser](./crates/examples/src/bin/simple_line.rs)

* [A `dwarfdump` clone](./examples/dwarfdump.rs)
* [A `dwarfdump` clone](./crates/examples/src/bin/dwarfdump.rs)

* [An `addr2line` clone](https://github.com/gimli-rs/addr2line)

Expand All @@ -56,7 +56,7 @@ The minimum supported Rust version is 1.42.0.
compilers used to create each compilation unit within a shared library or
executable (via `DW_AT_producer`).

* [`dwarf-validate`](./examples/dwarf-validate.rs), a program to validate the
* [`dwarf-validate`](./crates/examples/src/bin/dwarf-validate.rs), a program to validate the
integrity of some DWARF and its references between sections and compilation
units.

Expand Down
37 changes: 37 additions & 0 deletions crates/examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "gimli-examples"
version = "0.0.0"
edition = "2018"

[dependencies]
gimli = { path = "../..", default-features = false }
crossbeam = "0.8"
fallible-iterator = { version = "0.2.0", default-features = false }
getopts = "0.2"
memmap2 = "0.6.1"
num_cpus = "1"
object = { version = "0.30.0", features = ["wasm"] }
rayon = "1.0"
regex = "1"
typed-arena = "2"

[features]
read = ["gimli/read"]
std = ["gimli/std"]
default = ["read", "std"]

[[bin]]
name = "simple"
required-features = ["read"]

[[bin]]
name = "simple_line"
required-features = ["read"]

[[bin]]
name = "dwarfdump"
required-features = ["read", "std"]

[[bin]]
name = "dwarf-validate"
required-features = ["read", "std"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
//!
//! Full example programs:
//!
//! * [A simple parser](https://github.com/gimli-rs/gimli/blob/master/examples/simple.rs)
//! * [A simple parser](https://github.com/gimli-rs/gimli/blob/master/crates/examples/src/bin/simple.rs)
//!
//! * [A `dwarfdump`
//! clone](https://github.com/gimli-rs/gimli/blob/master/examples/dwarfdump.rs)
//! clone](https://github.com/gimli-rs/gimli/blob/master/crates/examples/src/bin/dwarfdump.rs)
//!
//! * [An `addr2line` clone](https://github.com/gimli-rs/addr2line)
//!
Expand All @@ -55,7 +55,7 @@
//! compilers used to create each compilation unit within a shared library or
//! executable (via `DW_AT_producer`)
//!
//! * [`dwarf-validate`](https://github.com/gimli-rs/gimli/blob/master/examples/dwarf-validate.rs),
//! * [`dwarf-validate`](https://github.com/gimli-rs/gimli/blob/master/crates/examples/src/bin/dwarf-validate.rs),
//! a program to validate the integrity of some DWARF and its references
//! between sections and compilation units.
//!
Expand Down

0 comments on commit cfac938

Please sign in to comment.