Skip to content

Commit d4cbe39

Browse files
committed
Match the beaviour of meson regarding relative paths in the install directories
Fixes #366
1 parent 647c5a8 commit d4cbe39

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

src/cli.rs

+19-14
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,32 @@ struct Common {
1616
/// Path to directory where target should be copied to
1717
#[clap(long = "destdir")]
1818
destdir: Option<PathBuf>,
19-
/// Directory path used to construct default values of
20-
/// includedir, libdir, bindir, pkgconfigdir
21-
#[clap(long = "prefix")]
22-
prefix: Option<PathBuf>,
19+
/// Directory path used to construct the values of
20+
/// `bindir`, `datarootdir`, `includedir`, `libdir`
21+
///
22+
/// If they are absolute the prefix is ignored.
23+
#[clap(long = "prefix", default_value = "/usr/local")]
24+
prefix: PathBuf,
2325
/// Path to directory for installing generated library files
24-
#[clap(long = "libdir")]
25-
libdir: Option<PathBuf>,
26+
#[clap(long = "libdir", default_value = "lib")]
27+
libdir: PathBuf,
2628
/// Path to directory for installing generated headers files
27-
#[clap(long = "includedir")]
28-
includedir: Option<PathBuf>,
29+
#[clap(long = "includedir", default_value = "include")]
30+
includedir: PathBuf,
2931
/// Path to directory for installing generated executable files
30-
#[clap(long = "bindir")]
31-
bindir: Option<PathBuf>,
32+
#[clap(long = "bindir", default_value = "bin")]
33+
bindir: PathBuf,
3234
/// Path to directory for installing generated pkg-config .pc files
35+
///
36+
/// [default: {libdir}/pkgconfig]
3337
#[clap(long = "pkgconfigdir")]
3438
pkgconfigdir: Option<PathBuf>,
35-
/// Path to directory for installing read-only data (defaults to {prefix}/share)
36-
#[clap(long = "datarootdir")]
37-
datarootdir: Option<PathBuf>,
39+
/// Path to directory for installing read-only data
40+
#[clap(long = "datarootdir", default_value = "share")]
41+
datarootdir: PathBuf,
3842
/// Path to directory for installing read-only application-specific data
39-
/// (defaults to {datarootdir})
43+
///
44+
/// [default: {datarootdir}]
4045
#[clap(long = "datadir")]
4146
datadir: Option<PathBuf>,
4247
#[clap(long = "dlltool")]

src/install.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -289,32 +289,20 @@ impl InstallPaths {
289289
.get_one::<PathBuf>("prefix")
290290
.map(PathBuf::from)
291291
.unwrap_or_else(|| "/usr/local".into());
292-
let libdir = args
293-
.get_one::<PathBuf>("libdir")
294-
.map(PathBuf::from)
295-
.unwrap_or_else(|| prefix.join("lib"));
296-
let includedir = args
297-
.get_one::<PathBuf>("includedir")
298-
.map(PathBuf::from)
299-
.unwrap_or_else(|| prefix.join("include"));
300-
let datarootdir = args
301-
.get_one::<PathBuf>("datarootdir")
302-
.map(PathBuf::from)
303-
.unwrap_or_else(|| prefix.join("share"));
292+
let libdir = prefix.join(args.get_one::<PathBuf>("libdir").unwrap());
293+
let includedir = prefix.join(args.get_one::<PathBuf>("includedir").unwrap());
294+
let datarootdir = prefix.join(args.get_one::<PathBuf>("datarootdir").unwrap());
304295
let datadir = args
305296
.get_one::<PathBuf>("datadir")
306-
.map(PathBuf::from)
297+
.map(|d| prefix.join(d))
307298
.unwrap_or_else(|| datarootdir.clone());
308299

309300
let subdir_name = PathBuf::from(&capi_config.header.subdirectory);
310301

311-
let bindir = args
312-
.get_one::<PathBuf>("bindir")
313-
.map(PathBuf::from)
314-
.unwrap_or_else(|| prefix.join("bin"));
302+
let bindir = prefix.join(args.get_one::<PathBuf>("bindir").unwrap());
315303
let pkgconfigdir = args
316304
.get_one::<PathBuf>("pkgconfigdir")
317-
.map(PathBuf::from)
305+
.map(|d| prefix.join(d))
318306
.unwrap_or_else(|| libdir.join("pkgconfig"));
319307

320308
InstallPaths {

0 commit comments

Comments
 (0)