Skip to content

Commit a0228ab

Browse files
committed
make: Use compile-time macro env!
1 parent e86e3fb commit a0228ab

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

make/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ license = "MIT"
77
repository = "https://github.com/rustcoreutils/posixutils-rs.git"
88

99
[dependencies]
10-
plib = { path = "../plib" }
1110
clap.workspace = true
1211
libc.workspace = true
1312
gettext-rs.workspace = true
1413
const_format = "0.2"
1514
rowan = "0.15"
1615

16+
[dev-dependencies]
17+
plib = { path = "../plib" }
18+
1719
[[bin]]
1820
name = "make"
1921
path = "src/main.rs"

make/src/main.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,24 @@
77
// SPDX-License-Identifier: MIT
88
//
99

10+
use core::str::FromStr;
11+
use std::collections::{BTreeMap, BTreeSet};
12+
use std::ffi::OsString;
13+
use std::io::Read;
14+
use std::path::{Path, PathBuf};
15+
use std::sync::atomic::Ordering::Relaxed;
16+
use std::{env, fs, io, process};
17+
1018
use clap::Parser;
1119
use const_format::formatcp;
12-
use core::str::FromStr;
13-
use gettextrs::{bind_textdomain_codeset, gettext, textdomain};
14-
use plib::PROJECT_NAME;
20+
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
21+
1522
use posixutils_make::{
1623
config::Config,
1724
error_code::ErrorCode::{self, *},
1825
parser::{preprocessor::ENV_MACROS, Makefile},
1926
Make,
2027
};
21-
use std::sync::atomic::Ordering::Relaxed;
22-
use std::{
23-
collections::{BTreeMap, BTreeSet},
24-
env,
25-
ffi::OsString,
26-
fs,
27-
io::{self, Read},
28-
path::{Path, PathBuf},
29-
process,
30-
};
3128

3229
const MAKEFILE_NAME: [&str; 2] = ["makefile", "Makefile"];
3330
const MAKEFILE_PATH: [&str; 2] = [
@@ -111,8 +108,9 @@ struct Args {
111108
}
112109

113110
fn main() -> Result<(), Box<dyn std::error::Error>> {
114-
textdomain(PROJECT_NAME)?;
115-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
111+
setlocale(LocaleCategory::LcAll, "");
112+
textdomain(env!("PROJECT_NAME"))?;
113+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
116114

117115
let Args {
118116
directory,

make/tests/integration.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use std::fs::{remove_file, File};
1212
use std::io::Write;
1313
use std::process::{Child, Command, Stdio};
1414

15-
use plib::{run_test, run_test_base, TestPlan};
15+
use plib::testing::{run_test, run_test_base, TestPlan};
16+
1617
use posixutils_make::error_code::ErrorCode;
1718

1819
pub fn run_test_not_comparing_error_message(plan: TestPlan) {

0 commit comments

Comments
 (0)