Skip to content

Commit

Permalink
Match the beaviour of meson regarding relative paths in the install d…
Browse files Browse the repository at this point in the history
…irectories

Fixes #366
  • Loading branch information
lu-zero committed Feb 29, 2024
1 parent 647c5a8 commit e9f27c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
33 changes: 19 additions & 14 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,32 @@ struct Common {
/// Path to directory where target should be copied to
#[clap(long = "destdir")]
destdir: Option<PathBuf>,
/// Directory path used to construct default values of
/// includedir, libdir, bindir, pkgconfigdir
#[clap(long = "prefix")]
prefix: Option<PathBuf>,
/// Directory path used to construct the values of
/// `bindir`, `datarootdir`, `includedir`, `libdir`
///
/// If they are absolute the prefix is ignored.
#[clap(long = "prefix", default_value = "/usr/local")]
prefix: PathBuf,
/// Path to directory for installing generated library files
#[clap(long = "libdir")]
libdir: Option<PathBuf>,
#[clap(long = "libdir", default_value = "lib")]
libdir: PathBuf,
/// Path to directory for installing generated headers files
#[clap(long = "includedir")]
includedir: Option<PathBuf>,
#[clap(long = "includedir", default_value = "include")]
includedir: PathBuf,
/// Path to directory for installing generated executable files
#[clap(long = "bindir")]
bindir: Option<PathBuf>,
#[clap(long = "bindir", default_value = "bin")]
bindir: PathBuf,
/// Path to directory for installing generated pkg-config .pc files
///
/// [default: {libdir}/pkgconfig]
#[clap(long = "pkgconfigdir")]
pkgconfigdir: Option<PathBuf>,
/// Path to directory for installing read-only data (defaults to {prefix}/share)
#[clap(long = "datarootdir")]
datarootdir: Option<PathBuf>,
/// Path to directory for installing read-only data
#[clap(long = "datarootdir", default_value = "share")]
datarootdir: PathBuf,
/// Path to directory for installing read-only application-specific data
/// (defaults to {datarootdir})
///
/// [default: {datarootdir}]
#[clap(long = "datadir")]
datadir: Option<PathBuf>,
#[clap(long = "dlltool")]
Expand Down
24 changes: 6 additions & 18 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,32 +289,20 @@ impl InstallPaths {
.get_one::<PathBuf>("prefix")
.map(PathBuf::from)
.unwrap_or_else(|| "/usr/local".into());
let libdir = args
.get_one::<PathBuf>("libdir")
.map(PathBuf::from)
.unwrap_or_else(|| prefix.join("lib"));
let includedir = args
.get_one::<PathBuf>("includedir")
.map(PathBuf::from)
.unwrap_or_else(|| prefix.join("include"));
let datarootdir = args
.get_one::<PathBuf>("datarootdir")
.map(PathBuf::from)
.unwrap_or_else(|| prefix.join("share"));
let libdir = prefix.join(args.get_one::<PathBuf>("libdir").unwrap());
let includedir = prefix.join(args.get_one::<PathBuf>("includedir").unwrap());
let datarootdir = prefix.join(args.get_one::<PathBuf>("datarootdir").unwrap());
let datadir = args
.get_one::<PathBuf>("datadir")
.map(PathBuf::from)
.map(|d| prefix.join(d))
.unwrap_or_else(|| datarootdir.clone());

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

let bindir = args
.get_one::<PathBuf>("bindir")
.map(PathBuf::from)
.unwrap_or_else(|| prefix.join("bin"));
let bindir = prefix.join(args.get_one::<PathBuf>("bindir").unwrap());
let pkgconfigdir = args
.get_one::<PathBuf>("pkgconfigdir")
.map(PathBuf::from)
.map(|d| prefix.join(d))
.unwrap_or_else(|| libdir.join("pkgconfig"));

InstallPaths {
Expand Down

0 comments on commit e9f27c0

Please sign in to comment.