From 0ec10ed693c1dc880988eba22a3f99a7c3a90ce0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 30 Jan 2025 20:55:57 +0000 Subject: [PATCH] Add include_dirs to all libraries One can link directly to `rust_library` as well. The current logic is brittle: not all crates explicitly list crate-types, especially because not all crate types are available on all platforms: e.g. specifying a crate-type staticlib or cdylib makes it *impossible* to compile a crate to Wasm. On the other hand, crate consumers are free to specify whatever crate type they'd like via cargo, so not explicitly listing crate-types is a decent choice for crates. So the current logic leaves out crates like `icu_capi`, which have headers but don't have a `staticlib` crate-type. Test: m cargo_embargo + crate_tool regenerate icu_capi Change-Id: Iaf62f6abdcc5cd84090f37b1ddc200c9d64e8500 --- tools/cargo_embargo/src/cargo.rs | 5 ----- tools/cargo_embargo/src/main.rs | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/cargo_embargo/src/cargo.rs b/tools/cargo_embargo/src/cargo.rs index 723459a6c9c..fcd29839006 100644 --- a/tools/cargo_embargo/src/cargo.rs +++ b/tools/cargo_embargo/src/cargo.rs @@ -64,11 +64,6 @@ impl CrateType { pub fn is_test(self) -> bool { matches!(self, Self::Test | Self::TestNoHarness) } - - /// Returns whether the crate type is a kind of C ABI library. - pub fn is_c_library(self) -> bool { - matches!(self, Self::CDyLib | Self::StaticLib) - } } /// Info extracted from `CargoOut` for a crate. diff --git a/tools/cargo_embargo/src/main.rs b/tools/cargo_embargo/src/main.rs index 10085cd64a3..e24b18870d7 100644 --- a/tools/cargo_embargo/src/main.rs +++ b/tools/cargo_embargo/src/main.rs @@ -1114,7 +1114,7 @@ fn crate_to_bp_modules( if !crate_type.is_test() && package_cfg.host_supported && package_cfg.host_first_multilib { m.props.set("compile_multilib", "first"); } - if crate_type.is_c_library() { + if crate_type.is_library() { m.props.set_if_nonempty("include_dirs", package_cfg.exported_c_header_dir.clone()); }