Skip to content

Commit 88df556

Browse files
committed
dev: Use compile-time macro env!
1 parent e447448 commit 88df556

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

dev/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ edition.workspace = true
88
rust-version.workspace = true
99

1010
[dependencies]
11-
plib = { path = "../plib" }
1211
clap.workspace = true
1312
gettext-rs.workspace = true
1413
object = { version = "0.35", features = ["read", "build", "elf"]}
1514
chrono.workspace = true
1615
ar = "0.9"
1716

17+
[dev-dependencies]
18+
plib = { path = "../plib" }
19+
1820
[lints]
1921
workspace = true
2022

dev/nm.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use object::{
1818

1919
use clap::{Parser, ValueEnum};
2020
use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
21-
use plib::PROJECT_NAME;
2221
use std::collections::HashMap;
2322
use std::fs;
2423

@@ -143,12 +142,11 @@ fn show_object_file(args: &Args) -> Result<(), Box<dyn std::error::Error>> {
143142
}
144143

145144
fn main() -> Result<(), Box<dyn std::error::Error>> {
146-
// parse command line arguments
147-
let args = Args::parse();
148-
149145
setlocale(LocaleCategory::LcAll, "");
150-
textdomain(PROJECT_NAME)?;
151-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
146+
textdomain(env!("PROJECT_NAME"))?;
147+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
148+
149+
let args = Args::parse();
152150

153151
show_object_file(&args)?;
154152

dev/strings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use std::ffi::OsString;
1212
use clap::{Parser, ValueEnum};
1313
use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
1414
use object::{Object, ObjectSection};
15-
use plib::PROJECT_NAME;
1615

1716
#[derive(Clone, Copy, ValueEnum)]
1817
enum OffsetFormat {
@@ -188,10 +187,11 @@ where
188187

189188
fn main() -> StringsResult {
190189
setlocale(LocaleCategory::LcAll, "");
191-
textdomain(PROJECT_NAME)?;
192-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
190+
textdomain(env!("PROJECT_NAME"))?;
191+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
193192

194193
let args = Args::parse();
194+
195195
match CharacterSet::from_env() {
196196
CharacterSet::Utf8 => {
197197
for file in args.input_files {

dev/strip.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77
// SPDX-License-Identifier: MIT
88
//
99

10-
use std::{
11-
ffi::{OsStr, OsString},
12-
io::Read,
13-
};
14-
1510
use clap::Parser;
1611
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
1712
use object::{
1813
archive,
1914
build::elf::{Builder, Section, SectionData},
2015
elf,
2116
};
22-
use plib::PROJECT_NAME;
17+
use std::{
18+
ffi::{OsStr, OsString},
19+
io::Read,
20+
};
2321

2422
#[derive(Parser)]
2523
#[command(version, about = gettext("strip - remove unnecessary information from strippable files"))]
@@ -145,10 +143,11 @@ fn strip_file(file: &OsStr) {
145143

146144
fn main() -> Result<(), Box<dyn std::error::Error>> {
147145
setlocale(LocaleCategory::LcAll, "");
148-
textdomain(PROJECT_NAME)?;
149-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
146+
textdomain(env!("PROJECT_NAME"))?;
147+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
150148

151149
let args = Args::parse();
150+
152151
for file in args.input_files {
153152
strip_file(&file);
154153
}

dev/tests/dev-tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use object::{Object, ObjectSection, ObjectSymbol};
2-
use plib::{run_test, run_test_with_checker, TestPlan};
2+
use plib::testing::{run_test, run_test_with_checker, TestPlan};
33
use std::fs;
44

55
fn ar_compare_test(

0 commit comments

Comments
 (0)