Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package cargo-c for openSUSE:Factory checked in at 2024-06-06 12:30:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cargo-c (Old) and /work/SRC/openSUSE:Factory/.cargo-c.new.24587 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cargo-c" Thu Jun 6 12:30:21 2024 rev:17 rq:1178628 version:0.9.32~git0.56dfe34 Changes: -------- --- /work/SRC/openSUSE:Factory/cargo-c/cargo-c.changes 2023-10-20 23:15:55.928692147 +0200 +++ /work/SRC/openSUSE:Factory/.cargo-c.new.24587/cargo-c.changes 2024-06-06 12:30:23.095584481 +0200 @@ -1,0 +2,15 @@ +Tue Jun 04 19:59:22 UTC 2024 - david.mul...@suse.com + +- Update to version 0.9.32~git0.56dfe34: + * Prepare for release + * Bump cargo version + * Use clone_from/clone_into + * Do not install the versioned links and lib on Android + * docs: add rustls-ffi to README users list + * Bump the msrv again + * Bump msrv + * Bump cargo version + * Match the beaviour of meson regarding relative paths in the install directories + * Bump cargo version + +------------------------------------------------------------------- Old: ---- cargo-c-0.9.27~git0.54774e0.tar.xz New: ---- cargo-c-0.9.32~git0.56dfe34.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cargo-c.spec ++++++ --- /var/tmp/diff_new_pack.ZWcQCr/_old 2024-06-06 12:30:25.979689815 +0200 +++ /var/tmp/diff_new_pack.ZWcQCr/_new 2024-06-06 12:30:25.979689815 +0200 @@ -1,7 +1,7 @@ # # spec file for package cargo-c # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # Copyright (c) 2019 Andreas Schneider <a...@cryptomilk.org>. # # All modifications and additions to the file contributed by third parties @@ -20,7 +20,7 @@ %global rustflags -Clink-arg=-Wl,-z,relro,-z,now -C debuginfo=2 Name: cargo-c -Version: 0.9.27~git0.54774e0 +Version: 0.9.32~git0.56dfe34 Release: 0 Summary: Helper to build and install c-like libraries from Rust License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.ZWcQCr/_old 2024-06-06 12:30:26.363703841 +0200 +++ /var/tmp/diff_new_pack.ZWcQCr/_new 2024-06-06 12:30:26.403705302 +0200 @@ -3,7 +3,7 @@ <param name="url">https://github.com/lu-zero/cargo-c.git</param> <param name="versionformat">@PARENT_TAG@~git@TAG_OFFSET@.%h</param> <param name="scm">git</param> - <param name="revision">v0.9.27</param> + <param name="revision">v0.9.32</param> <param name="match-tag">*</param> <param name="versionrewrite-pattern">v(\d+\.\d+\.\d+)</param> <param name="versionrewrite-replacement">\1</param> ++++++ cargo-c-0.9.27~git0.54774e0.tar.xz -> cargo-c-0.9.32~git0.56dfe34.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/Cargo.toml new/cargo-c-0.9.32~git0.56dfe34/Cargo.toml --- old/cargo-c-0.9.27~git0.54774e0/Cargo.toml 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/Cargo.toml 2024-05-04 09:41:19.000000000 +0200 @@ -1,6 +1,6 @@ [package] name = "cargo-c" -version = "0.9.27+cargo-0.74.0" +version = "0.9.32+cargo-0.79.0" authors = ["Luca Barbato <lu_z...@gentoo.org>"] description = "Helper program to build and install c-like libraries" license = "MIT" @@ -9,7 +9,7 @@ repository = "https://github.com/lu-zero/cargo-c" categories = ["command-line-utilities", "development-tools::cargo-plugins"] keywords = ["cargo", "cdylib"] -rust-version = "1.70" +rust-version = "1.76" [[bin]] name = "cargo-capi" @@ -28,25 +28,25 @@ path = "src/bin/ctest.rs" [dependencies] -cargo = "0.74.0" +cargo = "0.79.0" cargo-util = "0.2" semver = "1.0.3" log = "0.4" clap = { version="4.0.29", features=["color", "derive", "cargo"] } regex = "1.5.6" cbindgen = { version="0.26.0", default-features=false } -toml = "0.7" +toml = "0.8" serde = "1.0.123" serde_derive = "1.0" serde_json = "1.0.62" anyhow = "1.0" cc = "1.0" glob = "0.3" -itertools = "0.11" +itertools = "0.12" # workaround cargo [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.48" +version = "0.52" features = [ "Win32_Foundation", "Win32_Storage_FileSystem", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/README.md new/cargo-c-0.9.32~git0.56dfe34/README.md --- old/cargo-c-0.9.27~git0.54774e0/README.md 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/README.md 2024-05-04 09:41:19.000000000 +0200 @@ -135,6 +135,10 @@ install_subdir = "gstreamer-1.0" # Used to disable versioning links when installing the dynamic library versioning = false +# Instead of using semver, select a fixed number of version components for your SONAME version suffix: +# Setting this to 1 with a version of 0.0.0 allows a suffix of `.so.0` +# Setting this to 3 always includes the full version in the SONAME (indicate any update is ABI breaking) +#version_suffix_components = 2 # Add `-Cpanic=abort` to the RUSTFLAGS automatically, it may be useful in case # something might panic in the crates used by the library. rustflags = "-Cpanic=abort" @@ -181,6 +185,7 @@ - [libdovi](https://github.com/quietvoid/dovi_tool/tree/main/dolby_vision#libdovi-c-api) - [libimagequant](https://github.com/ImageOptim/libimagequant#building-with-cargo-c) - [rav1e](https://github.com/xiph/rav1e) +- [rustls-ffi](https://github.com/rustls/rustls-ffi) - [sled](https://github.com/spacejam/sled/tree/master/bindings/sled-native) - [pathfinder](https://github.com/servo/pathfinder#c) - [udbserver](https://github.com/bet4it/udbserver) @@ -209,6 +214,28 @@ [](https://repology.org/project/cargo-c/versions) +## Troubleshooting + +### Shared libraries are not built on musl systems + +When running on a musl-based system (e.g. Alpine Linux), it could be that using the `cdylib` library type results in the following error (as reported [here](https://github.com/lu-zero/cargo-c/issues/180)): + +> Error: CliError { error: Some(cannot produce cdylib for <package> as the target x86_64-unknown-linux-musl does not support these crate types), exit_code: 101 } + +This suggests that Rust was not built with `crt-static=false` and it typically happens if Rust has been installed through rustup. + +Shared libraries can be enabled manually in this case, by editing the file `.cargo/config` like so: + +```toml +# .cargo/config + +[target.x86_64-unknown-linux-musl] +rustflags = [ + "-C", "target-feature=-crt-static", +] +``` + +However, it is preferred to install Rust through the system package manager instead of rustup (e.g. with `apk add rust`), because the provided package should already handle this (see e.g. [here](https://git.alpinelinux.org/aports/tree/main/rust/APKBUILD?h=3.19-stable#n232)). ## Acknowledgements diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/bin/capi.rs new/cargo-c-0.9.32~git0.56dfe34/src/bin/capi.rs --- old/cargo-c-0.9.27~git0.54774e0/src/bin/capi.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/bin/capi.rs 2024-05-04 09:41:19.000000000 +0200 @@ -5,13 +5,12 @@ use cargo::util::command_prelude::flag; use cargo::util::command_prelude::ArgMatchesExt; -use cargo::CliResult; -use cargo::Config; +use cargo::{CliResult, GlobalContext}; use clap::*; fn main() -> CliResult { - let mut config = Config::default()?; + let mut config = GlobalContext::default()?; let cli_build = subcommand_build("build", "Build the crate C-API"); let cli_install = subcommand_install("install", "Install the crate C-API"); @@ -60,7 +59,7 @@ return Ok(()); } - config_configure(&mut config, subcommand_args)?; + global_context_configure(&mut config, subcommand_args)?; let mut ws = subcommand_args.workspace(&config)?; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/bin/cbuild.rs new/cargo-c-0.9.32~git0.56dfe34/src/bin/cbuild.rs --- old/cargo-c-0.9.27~git0.54774e0/src/bin/cbuild.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/bin/cbuild.rs 2024-05-04 09:41:19.000000000 +0200 @@ -1,6 +1,6 @@ use cargo::util::command_prelude::ArgMatchesExt; use cargo::CliResult; -use cargo::Config; +use cargo::GlobalContext; use cargo_c::build::*; use cargo_c::cli::run_cargo_fallback; @@ -8,7 +8,7 @@ use cargo_c::config::*; fn main() -> CliResult { - let mut config = Config::default()?; + let mut config = GlobalContext::default()?; let subcommand = subcommand_build("cbuild", "Build the crate C-API"); let mut app = clap::command!() @@ -35,7 +35,7 @@ return Ok(()); } - config_configure(&mut config, subcommand_args)?; + global_context_configure(&mut config, subcommand_args)?; let mut ws = subcommand_args.workspace(&config)?; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/bin/cinstall.rs new/cargo-c-0.9.32~git0.56dfe34/src/bin/cinstall.rs --- old/cargo-c-0.9.27~git0.54774e0/src/bin/cinstall.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/bin/cinstall.rs 2024-05-04 09:41:19.000000000 +0200 @@ -1,15 +1,15 @@ use cargo::util::command_prelude::ArgMatchesExt; use cargo::CliResult; -use cargo::Config; +use cargo::GlobalContext; use cargo_c::build::cbuild; use cargo_c::cli::run_cargo_fallback; use cargo_c::cli::subcommand_install; -use cargo_c::config::config_configure; +use cargo_c::config::global_context_configure; use cargo_c::install::cinstall; fn main() -> CliResult { - let mut config = Config::default()?; + let mut config = GlobalContext::default()?; let subcommand = subcommand_install("cinstall", "Install the crate C-API"); let mut app = clap::command!() @@ -36,7 +36,7 @@ return Ok(()); } - config_configure(&mut config, subcommand_args)?; + global_context_configure(&mut config, subcommand_args)?; let mut ws = subcommand_args.workspace(&config)?; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/bin/ctest.rs new/cargo-c-0.9.32~git0.56dfe34/src/bin/ctest.rs --- old/cargo-c-0.9.27~git0.54774e0/src/bin/ctest.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/bin/ctest.rs 2024-05-04 09:41:19.000000000 +0200 @@ -1,6 +1,4 @@ use cargo::util::command_prelude::*; -use cargo::CliResult; -use cargo::Config; use cargo_c::build::*; use cargo_c::cli::run_cargo_fallback; @@ -8,7 +6,7 @@ use cargo_c::config::*; fn main() -> CliResult { - let mut config = Config::default()?; + let mut config = GlobalContext::default()?; let subcommand = subcommand_test("ctest"); @@ -36,7 +34,7 @@ return Ok(()); } - config_configure(&mut config, subcommand_args)?; + global_context_configure(&mut config, subcommand_args)?; let mut ws = subcommand_args.workspace(&config)?; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/build.rs new/cargo-c-0.9.32~git0.56dfe34/src/build.rs --- old/cargo-c-0.9.27~git0.54774e0/src/build.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/build.rs 2024-05-04 09:41:19.000000000 +0200 @@ -4,16 +4,15 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; -use cargo::core::compiler::unit_graph::UnitDep; -use cargo::core::compiler::unit_graph::UnitGraph; -use cargo::core::compiler::Unit; -use cargo::core::{compiler::Executor, profiles::Profiles}; -use cargo::core::{TargetKind, Workspace}; +use cargo::core::compiler::{unit_graph::UnitDep, unit_graph::UnitGraph, Executor, Unit}; +use cargo::core::profiles::Profiles; +use cargo::core::{FeatureValue, Package, PackageId, Target, TargetKind, Workspace}; use cargo::ops::{self, CompileFilter, CompileOptions, FilterRule, LibRule}; use cargo::util::command_prelude::{ArgMatches, ArgMatchesExt, CompileMode, ProfileChecking}; use cargo::util::interning::InternedString; -use cargo::{CliResult, Config}; +use cargo::{CliResult, GlobalContext}; +use anyhow::Context as _; use cargo_util::paths::{copy, create, create_dir_all, open, read, read_bytes, write}; use semver::Version; @@ -30,7 +29,7 @@ root_output: &Path, root_path: &Path, ) -> anyhow::Result<()> { - ws.config() + ws.gctx() .shell() .status("Building", "header file using cbindgen")?; let mut header_name = PathBuf::from(name); @@ -65,7 +64,7 @@ build_targets: &BuildTargets, root_output: &Path, ) -> anyhow::Result<()> { - let mut shell = ws.config().shell(); + let mut shell = ws.gctx().shell(); shell.status("Populating", "uninstalled header directory")?; let path = &format!("PKG_CONFIG_PATH=\"{}\"", root_output.display()); shell.verbose(move |s| s.note(path))?; @@ -91,7 +90,7 @@ root_output: &Path, pc: &PkgConfig, ) -> anyhow::Result<()> { - ws.config().shell().status("Building", "pkg-config files")?; + ws.gctx().shell().status("Building", "pkg-config files")?; build_pc_file(filename, root_output, pc)?; let pc_uninstalled = pc.uninstalled(root_output); build_pc_file( @@ -141,7 +140,7 @@ let env = &target.env; if os == "windows" && env == "msvc" { - ws.config() + ws.gctx() .shell() .status("Building", ".def file using dumpbin")?; @@ -214,7 +213,7 @@ if os == "windows" { let arch = &target.arch; if env == "gnu" { - ws.config() + ws.gctx() .shell() .status("Building", "implib using dlltool")?; @@ -243,7 +242,7 @@ Err(anyhow::anyhow!("Command failed {:?}", dlltool_command)) } } else { - ws.config().shell().status("Building", "implib using lib")?; + ws.gctx().shell().status("Building", "implib using lib")?; let target_str = format!("{}-pc-windows-msvc", &target.arch); let mut lib = match cc::windows_registry::find(&target_str, "lib.exe") { Some(command) => command, @@ -401,15 +400,42 @@ } #[derive(Debug)] +pub enum VersionSuffix { + Major, + MajorMinor, + MajorMinorPatch, +} + +#[derive(Debug)] pub struct LibraryCApiConfig { pub name: String, pub version: Version, pub install_subdir: Option<String>, pub versioning: bool, + pub version_suffix_components: Option<VersionSuffix>, pub import_library: bool, pub rustflags: Vec<String>, } +impl LibraryCApiConfig { + pub fn sover(&self) -> String { + let major = self.version.major; + let minor = self.version.minor; + let patch = self.version.patch; + + match self.version_suffix_components { + None => match (major, minor, patch) { + (0, 0, patch) => format!("0.0.{patch}"), + (0, minor, _) => format!("0.{minor}"), + (major, _, _) => format!("{major}"), + }, + Some(VersionSuffix::Major) => format!("{major}"), + Some(VersionSuffix::MajorMinor) => format!("{major}.{minor}"), + Some(VersionSuffix::MajorMinorPatch) => format!("{major}.{minor}.{patch}"), + } + } +} + #[derive(Debug, Default)] pub struct InstallCApiConfig { pub include: Vec<InstallTarget>, @@ -484,7 +510,10 @@ } } -fn load_manifest_capi_config(pkg: &Package) -> anyhow::Result<CApiConfig> { +fn load_manifest_capi_config( + pkg: &Package, + rustc_target: &target::Target, +) -> anyhow::Result<CApiConfig> { let name = &pkg .manifest() .targets() @@ -619,6 +648,7 @@ let mut version = pkg.version().clone(); let mut install_subdir = None; let mut versioning = true; + let mut version_suffix_components = None; let mut import_library = true; let mut rustflags = Vec::new(); @@ -636,6 +666,19 @@ .get("versioning") .and_then(|v| v.as_bool()) .unwrap_or(true); + + if let Some(value) = library.get("version_suffix_components") { + let value = value.as_integer().with_context(|| { + format!("Value for `version_suffix_components` is not an integer: {value:?}") + })?; + version_suffix_components = Some(match value { + 1 => VersionSuffix::Major, + 2 => VersionSuffix::MajorMinor, + 3 => VersionSuffix::MajorMinorPatch, + _ => anyhow::bail!("Out of range value for version suffix components: {value}"), + }); + } + import_library = library .get("import_library") .and_then(|v| v.as_bool()) @@ -650,11 +693,16 @@ } } + if rustc_target.os == "android" { + versioning = false; + } + let library = LibraryCApiConfig { name: lib_name, version, install_subdir, versioning, + version_suffix_components, import_library, rustflags, }; @@ -754,14 +802,14 @@ fn compile_options( ws: &Workspace, - config: &Config, + gctx: &GlobalContext, args: &ArgMatches, profile: InternedString, compile_mode: CompileMode, ) -> anyhow::Result<CompileOptions> { use cargo::core::compiler::CompileKind; let mut compile_opts = - args.compile_options(config, compile_mode, Some(ws), ProfileChecking::Custom)?; + args.compile_options(gctx, compile_mode, Some(ws), ProfileChecking::Custom)?; compile_opts.build_config.requested_profile = profile; @@ -779,12 +827,12 @@ compile_opts.build_config.unit_graph = false; - let rustc = config.load_global_rustc(Some(ws))?; + let rustc = gctx.load_global_rustc(Some(ws))?; // Always set the target, requested_kinds is a vec of a single element. if compile_opts.build_config.requested_kinds[0].is_host() { compile_opts.build_config.requested_kinds = - CompileKind::from_requested_targets(config, &[rustc.host.to_string()])? + CompileKind::from_requested_targets(gctx, &[rustc.host.to_string()])? } Ok(compile_opts) @@ -796,7 +844,6 @@ link_line: Mutex<HashMap<PackageId, String>>, } -use cargo::core::*; use cargo::CargoResult; use cargo_util::ProcessBuilder; @@ -846,7 +893,6 @@ use cargo::core::compiler::{unit_graph, UnitInterner}; use cargo::ops::create_bcx; -use cargo::util::profile; fn set_deps_args( dep: &UnitDep, @@ -880,7 +926,7 @@ for unit in bcx.roots.iter() { let pkg = &unit.pkg; - let capi_config = load_manifest_capi_config(pkg)?; + let capi_config = load_manifest_capi_config(pkg, rustc_target)?; let name = &capi_config.library.name; let install_paths = InstallPaths::new(name, args, &capi_config); let pkg_rustflags = &capi_config.library.rustflags; @@ -912,11 +958,10 @@ } if options.build_config.unit_graph { - unit_graph::emit_serialized_unit_graph(&bcx.roots, &bcx.unit_graph, ws.config())?; + unit_graph::emit_serialized_unit_graph(&bcx.roots, &bcx.unit_graph, ws.gctx())?; return Ok(HashMap::new()); } - let _p = profile::start("compiling"); - let cx = cargo::core::compiler::Context::new(&bcx)?; + let cx = cargo::core::compiler::BuildRunner::new(&bcx)?; let r = cx.compile(exec)?; @@ -967,7 +1012,7 @@ let id = pkg.package_id(); let version = pkg.version().clone(); let root_path = pkg.root().to_path_buf(); - let capi_config = load_manifest_capi_config(pkg)?; + let capi_config = load_manifest_capi_config(pkg, rustc_target)?; patch_target(pkg, libkinds, &capi_config)?; @@ -992,12 +1037,12 @@ pub fn cbuild( ws: &mut Workspace, - config: &Config, + config: &GlobalContext, args: &ArgMatches, default_profile: &str, ) -> anyhow::Result<(Vec<CPackage>, CompileOptions)> { let rustc = config.load_global_rustc(Some(ws))?; - let targets = args.targets(); + let targets = args.targets()?; let target = match targets.len() { 0 => rustc.host.to_string(), 1 => targets[0].to_string(), @@ -1193,7 +1238,7 @@ pub fn ctest( ws: &Workspace, - config: &Config, + config: &GlobalContext, args: &ArgMatches, packages: &[CPackage], mut compile_opts: CompileOptions, @@ -1246,3 +1291,66 @@ ops::run_tests(ws, &ops, &test_args) } + +#[cfg(test)] +mod tests { + use super::*; + use semver::Version; + + fn make_test_library_config(version: &str) -> LibraryCApiConfig { + LibraryCApiConfig { + name: "example".to_string(), + version: Version::parse(version).unwrap(), + install_subdir: None, + versioning: true, + version_suffix_components: None, + import_library: true, + rustflags: vec![], + } + } + + #[test] + pub fn test_semver_zero_zero_zero() { + let library = make_test_library_config("0.0.0"); + let sover = library.sover(); + assert_eq!(sover, "0.0.0"); + } + + #[test] + pub fn test_semver_zero_one_zero() { + let library = make_test_library_config("0.1.0"); + let sover = library.sover(); + assert_eq!(sover, "0.1"); + } + + #[test] + pub fn test_semver_one_zero_zero() { + let library = make_test_library_config("1.0.0"); + let sover = library.sover(); + assert_eq!(sover, "1"); + } + + #[test] + pub fn text_one_fixed_zero_zero_zero() { + let mut library = make_test_library_config("0.0.0"); + library.version_suffix_components = Some(VersionSuffix::Major); + let sover = library.sover(); + assert_eq!(sover, "0"); + } + + #[test] + pub fn text_two_fixed_one_zero_zero() { + let mut library = make_test_library_config("1.0.0"); + library.version_suffix_components = Some(VersionSuffix::MajorMinor); + let sover = library.sover(); + assert_eq!(sover, "1.0"); + } + + #[test] + pub fn text_three_fixed_one_zero_zero() { + let mut library = make_test_library_config("1.0.0"); + library.version_suffix_components = Some(VersionSuffix::MajorMinorPatch); + let sover = library.sover(); + assert_eq!(sover, "1.0.0"); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/build_targets.rs new/cargo-c-0.9.32~git0.56dfe34/src/build_targets.rs --- old/cargo-c-0.9.27~git0.54774e0/src/build_targets.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/build_targets.rs 2024-05-04 09:41:19.000000000 +0200 @@ -89,7 +89,7 @@ let shared_lib = targetdir.join(format!("lib{lib_name}.so")); (shared_lib, static_lib, None, None) } - ("macos", _) | ("ios", _) => { + ("macos", _) | ("ios", _) | ("tvos", _) => { let static_lib = targetdir.join(format!("lib{lib_name}.a")); let shared_lib = targetdir.join(format!("lib{lib_name}.dylib")); (shared_lib, static_lib, None, None) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/cli.rs new/cargo-c-0.9.32~git0.56dfe34/src/cli.rs --- old/cargo-c-0.9.27~git0.54774e0/src/cli.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/cli.rs 2024-05-04 09:41:19.000000000 +0200 @@ -16,27 +16,32 @@ /// 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")] @@ -62,7 +67,7 @@ .action(ArgAction::Count) .global(true), ) - .arg_quiet() + .arg_silent_suggestion() .arg( opt("color", "Coloring: auto, always, never") .value_name("WHEN") @@ -80,7 +85,7 @@ .action(ArgAction::Append) .global(true), ) - .arg_jobs() + .arg_parallel() .arg_targets_all( "Build only this package's library", "Build only the specified binary", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/config.rs new/cargo-c-0.9.32~git0.56dfe34/src/config.rs --- old/cargo-c-0.9.27~git0.54774e0/src/config.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/config.rs 2024-05-04 09:41:19.000000000 +0200 @@ -1,7 +1,7 @@ use std::env; use cargo::util::command_prelude::{ArgMatches, ArgMatchesExt}; -use cargo::{CliResult, Config}; +use cargo::{CliResult, GlobalContext}; // Take the original cargo instance and save it as a separate env var if not already set. fn setup_env() { @@ -12,14 +12,14 @@ } } -pub fn config_configure(config: &mut Config, args: &ArgMatches) -> CliResult { - let arg_target_dir = &args.value_of_path("target-dir", config); +pub fn global_context_configure(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { + let arg_target_dir = &args.value_of_path("target-dir", gctx); let config_args: Vec<_> = args .get_many::<String>("config") .unwrap_or_default() .map(|s| s.to_owned()) .collect(); - config.configure( + gctx.configure( args.verbose(), args.flag("quiet"), args.get_one::<String>("color").map(String::as_str), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/install.rs new/cargo-c-0.9.32~git0.56dfe34/src/install.rs --- old/cargo-c-0.9.27~git0.54774e0/src/install.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/install.rs 2024-05-04 09:41:19.000000000 +0200 @@ -3,11 +3,9 @@ use cargo::core::Workspace; use cargo_util::paths::{copy, create_dir_all}; -use semver::Version; use crate::build::*; use crate::build_targets::BuildTargets; -use crate::VersionExt; fn append_to_destdir(destdir: Option<&Path>, path: &Path) -> PathBuf { if let Some(destdir) = destdir { @@ -93,7 +91,7 @@ | ("haiku", _) | ("illumos", _) | ("emscripten", _) => LibType::So, - ("macos", _) | ("ios", _) => LibType::Dylib, + ("macos", _) | ("ios", _) | ("tvos", _) => LibType::Dylib, ("windows", _) => LibType::Windows, _ => unimplemented!("The target {}-{} is not supported yet", os, env), } @@ -107,8 +105,10 @@ } impl UnixLibNames { - pub(crate) fn new(lib_type: LibType, lib_name: &str, lib_version: &Version) -> Option<Self> { - let main_version = lib_version.main_version(); + pub(crate) fn new(lib_type: LibType, library: &LibraryCApiConfig) -> Option<Self> { + let lib_name = &library.name; + let lib_version = &library.version; + let main_version = library.sover(); match lib_type { LibType::So => { @@ -198,9 +198,7 @@ create_dir_all(&install_path_lib)?; create_dir_all(&install_path_pc)?; - ws.config() - .shell() - .status("Installing", "pkg-config file")?; + ws.gctx().shell().status("Installing", "pkg-config file")?; copy( &build_targets.pc, @@ -208,7 +206,7 @@ )?; if capi_config.header.enabled { - ws.config().shell().status("Installing", "header file")?; + ws.gctx().shell().status("Installing", "header file")?; for (from, to) in build_targets.extra.include.iter() { let to = install_path_include.join(to); create_dir_all(to.parent().unwrap())?; @@ -217,7 +215,7 @@ } if !build_targets.extra.data.is_empty() { - ws.config().shell().status("Installing", "data file")?; + ws.gctx().shell().status("Installing", "data file")?; for (from, to) in build_targets.extra.data.iter() { let to = install_path_data.join(to); create_dir_all(to.parent().unwrap())?; @@ -226,7 +224,7 @@ } if let Some(ref static_lib) = build_targets.static_lib { - ws.config().shell().status("Installing", "static library")?; + ws.gctx().shell().status("Installing", "static library")?; copy( static_lib, install_path_lib.join(static_lib.file_name().unwrap()), @@ -234,14 +232,12 @@ } if let Some(ref shared_lib) = build_targets.shared_lib { - ws.config().shell().status("Installing", "shared library")?; + ws.gctx().shell().status("Installing", "shared library")?; - let lib_name = &capi_config.library.name; let lib_type = LibType::from_build_targets(build_targets); match lib_type { LibType::So | LibType::Dylib => { - let lib = UnixLibNames::new(lib_type, lib_name, &capi_config.library.version) - .unwrap(); + let lib = UnixLibNames::new(lib_type, &capi_config.library).unwrap(); lib.install(capi_config, shared_lib, &install_path_lib)?; } LibType::Windows => { @@ -291,32 +287,20 @@ .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 { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/lib.rs new/cargo-c-0.9.32~git0.56dfe34/src/lib.rs --- old/cargo-c-0.9.27~git0.54774e0/src/lib.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/lib.rs 2024-05-04 09:41:19.000000000 +0200 @@ -5,18 +5,3 @@ pub mod install; pub mod pkg_config_gen; pub mod target; - -trait VersionExt { - /// build the main version string - fn main_version(&self) -> String; -} - -impl VersionExt for semver::Version { - fn main_version(&self) -> String { - match (self.major, self.minor, self.patch) { - (0, 0, patch) => format!("0.0.{patch}"), - (0, minor, _) => format!("0.{minor}"), - (major, _, _) => format!("{major}"), - } - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/pkg_config_gen.rs new/cargo-c-0.9.32~git0.56dfe34/src/pkg_config_gen.rs --- old/cargo-c-0.9.27~git0.54774e0/src/pkg_config_gen.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/pkg_config_gen.rs 2024-05-04 09:41:19.000000000 +0200 @@ -129,7 +129,7 @@ ) -> Self { let mut pc = PkgConfig::new(name, capi_config); - pc.prefix = install_paths.prefix.clone(); + pc.prefix.clone_from(&install_paths.prefix); // TODO: support exec_prefix if args.contains_id("includedir") { if let Ok(suffix) = install_paths.includedir.strip_prefix(&pc.prefix) { @@ -137,7 +137,7 @@ includedir.push(suffix); pc.includedir = includedir; } else { - pc.includedir = install_paths.includedir.clone(); + pc.includedir.clone_from(&install_paths.includedir); } } if args.contains_id("libdir") { @@ -146,7 +146,7 @@ libdir.push(suffix); pc.libdir = libdir; } else { - pc.libdir = install_paths.libdir.clone(); + pc.libdir.clone_from(&install_paths.libdir); } } pc @@ -164,7 +164,7 @@ } pub fn set_description<S: AsRef<str>>(&mut self, descr: S) -> &mut Self { - self.description = descr.as_ref().to_owned(); + descr.as_ref().clone_into(&mut self.description); self } @@ -298,6 +298,7 @@ version: Version::parse("0.1.0").unwrap(), install_subdir: None, versioning: true, + version_suffix_components: None, import_library: true, rustflags: Vec::default(), }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cargo-c-0.9.27~git0.54774e0/src/target.rs new/cargo-c-0.9.32~git0.56dfe34/src/target.rs --- old/cargo-c-0.9.27~git0.54774e0/src/target.rs 2023-10-12 00:51:34.000000000 +0200 +++ new/cargo-c-0.9.32~git0.56dfe34/src/target.rs 2024-05-04 09:41:19.000000000 +0200 @@ -3,7 +3,6 @@ use anyhow::*; use crate::build::CApiConfig; -use crate::VersionExt; /// Split a target string to its components /// @@ -70,7 +69,7 @@ let os = &self.os; let env = &self.env; - let sover = version.main_version(); + let sover = capi_config.library.sover(); if os == "android" { lines.push(format!("-Wl,-soname,lib{lib_name}.so")); @@ -86,7 +85,7 @@ } else { format!("-Wl,-soname,lib{lib_name}.so") }); - } else if os == "macos" || os == "ios" { + } else if os == "macos" || os == "ios" || os == "tvos" { let line = if capi_config.library.versioning { format!("-Wl,-install_name,{1}/lib{0}.{5}.dylib,-current_version,{2}.{3}.{4},-compatibility_version,{5}", lib_name, libdir.display(), major, minor, patch, sover) ++++++ vendor.tar.xz ++++++ /work/SRC/openSUSE:Factory/cargo-c/vendor.tar.xz /work/SRC/openSUSE:Factory/.cargo-c.new.24587/vendor.tar.xz differ: char 8, line 1