From c604d2eb57e2c821811d30f59a71375b628fd5c2 Mon Sep 17 00:00:00 2001 From: Guillaume Raffin Date: Mon, 8 Jan 2024 17:05:01 +0100 Subject: [PATCH] Add a way to generate a list of symbols for dynamic linkage, resolves #907 --- src/bindgen/bindings.rs | 23 +++- src/main.rs | 16 ++- tests/expectations-symbols/abi_string.c.sym | 4 + tests/expectations-symbols/alias.c.sym | 3 + tests/expectations-symbols/annotation.c.sym | 3 + tests/expectations-symbols/array.c.sym | 3 + .../expectations-symbols/asserted_cast.c.sym | 3 + .../expectations-symbols/assoc_constant.c.sym | 3 + .../associated_in_body.c.sym | 3 + tests/expectations-symbols/bitfield.c.sym | 3 + tests/expectations-symbols/bitflags.c.sym | 3 + tests/expectations-symbols/body.c.sym | 3 + tests/expectations-symbols/box.c.sym | 5 + tests/expectations-symbols/cdecl.c.sym | 4 + tests/expectations-symbols/cell.c.sym | 3 + tests/expectations-symbols/cfg.c.sym | 5 + tests/expectations-symbols/cfg_2.c.sym | 3 + tests/expectations-symbols/char.c.sym | 3 + .../expectations-symbols/const_generics.c.sym | 3 + .../const_generics_arrayvec.c.sym | 3 + .../const_generics_bool.c.sym | 6 + .../const_generics_byte.c.sym | 5 + .../const_generics_char.c.sym | 3 + .../const_generics_constant.c.sym | 3 + .../const_generics_thru.c.sym | 4 + tests/expectations-symbols/constant.c.sym | 3 + .../constant_sort_name.c.sym | 4 + .../constant_sort_none.c.sym | 4 + .../expectations-symbols/custom_header.c.sym | 3 + .../decl_name_conflicting.c.sym | 3 + tests/expectations-symbols/dep_v2.c.sym | 3 + tests/expectations-symbols/deprecated.c.sym | 8 ++ tests/expectations-symbols/derive_eq.c.sym | 3 + .../expectations-symbols/derive_ostream.c.sym | 3 + .../destructor_and_copy_ctor.c.sym | 3 + tests/expectations-symbols/display_list.c.sym | 3 + .../doclength_short.c.sym | 4 + .../expectations-symbols/docstyle_auto.c.sym | 3 + tests/expectations-symbols/docstyle_c99.c.sym | 3 + .../expectations-symbols/docstyle_doxy.c.sym | 3 + .../expectations-symbols/documentation.c.sym | 3 + .../documentation_attr.c.sym | 3 + tests/expectations-symbols/enum.c.sym | 3 + .../enum_discriminant.c.sym | 3 + tests/expectations-symbols/enum_self.c.sym | 3 + tests/expectations-symbols/euclid.c.sym | 3 + .../exclude_generic_monomorph.c.sym | 3 + tests/expectations-symbols/expand.c.sym | 3 + .../expand_default_features.c.sym | 4 + tests/expectations-symbols/expand_dep.c.sym | 3 + .../expectations-symbols/expand_dep_v2.c.sym | 3 + .../expand_features.c.sym | 5 + .../expand_no_default_features.c.sym | 3 + tests/expectations-symbols/export_name.c.sym | 3 + tests/expectations-symbols/extern.c.sym | 4 + tests/expectations-symbols/extern_2.c.sym | 4 + .../external_workspace_child.c.sym | 3 + tests/expectations-symbols/fns.c.sym | 4 + .../forward_declaration.c.sym | 3 + .../expectations-symbols/function_args.c.sym | 5 + .../function_noreturn.c.sym | 4 + tests/expectations-symbols/function_ptr.c.sym | 3 + .../function_sort_name.c.sym | 6 + .../function_sort_none.c.sym | 6 + .../generic_pointer.c.sym | 3 + .../global_variable.c.sym | 4 + tests/expectations-symbols/ignore.c.sym | 3 + .../expectations-symbols/include_guard.c.sym | 3 + tests/expectations-symbols/inner_mod.c.sym | 3 + tests/expectations-symbols/item_types.c.sym | 3 + .../item_types_renamed.c.sym | 3 + tests/expectations-symbols/lifetime_arg.c.sym | 3 + tests/expectations-symbols/linestyle_cr.c.sym | 3 + .../expectations-symbols/linestyle_crlf.c.sym | 3 + tests/expectations-symbols/linestyle_lf.c.sym | 3 + tests/expectations-symbols/mangle.c.sym | 3 + tests/expectations-symbols/manuallydrop.c.sym | 4 + tests/expectations-symbols/maybeuninit.c.sym | 3 + tests/expectations-symbols/mod_2015.c.sym | 4 + tests/expectations-symbols/mod_2018.c.sym | 5 + tests/expectations-symbols/mod_attr.c.sym | 4 + tests/expectations-symbols/mod_path.c.sym | 3 + tests/expectations-symbols/monomorph_1.c.sym | 3 + tests/expectations-symbols/monomorph_2.c.sym | 4 + tests/expectations-symbols/monomorph_3.c.sym | 3 + tests/expectations-symbols/must_use.c.sym | 3 + .../namespace_constant.c.sym | 3 + .../namespaces_constant.c.sym | 3 + tests/expectations-symbols/no_includes.c.sym | 3 + .../expectations-symbols/non_pub_extern.c.sym | 6 + tests/expectations-symbols/nonnull.c.sym | 3 + .../nonnull_attribute.c.sym | 10 ++ tests/expectations-symbols/nonzero.c.sym | 3 + tests/expectations-symbols/opaque.c.sym | 3 + tests/expectations-symbols/pin.c.sym | 3 + tests/expectations-symbols/pragma_once.c.sym | 3 + tests/expectations-symbols/prefix.c.sym | 3 + .../prefixed_struct_literal.c.sym | 3 + .../prefixed_struct_literal_deep.c.sym | 3 + .../expectations-symbols/ptrs_as_arrays.c.sym | 7 ++ tests/expectations-symbols/raw_ident.c.sym | 4 + tests/expectations-symbols/raw_lines.c.sym | 3 + tests/expectations-symbols/rename.c.sym | 4 + tests/expectations-symbols/rename_case.c.sym | 7 ++ tests/expectations-symbols/rename_crate.c.sym | 5 + .../renaming_overrides_prefixing.c.sym | 3 + tests/expectations-symbols/reserved.c.sym | 3 + tests/expectations-symbols/sentinel.c.sym | 3 + .../simplify_option_ptr.c.sym | 3 + tests/expectations-symbols/size_types.c.sym | 3 + tests/expectations-symbols/static.c.sym | 6 + tests/expectations-symbols/std_lib.c.sym | 3 + tests/expectations-symbols/struct.c.sym | 3 + .../expectations-symbols/struct_literal.c.sym | 3 + .../struct_literal_order.c.sym | 3 + tests/expectations-symbols/struct_self.c.sym | 3 + tests/expectations-symbols/swift_name.c.sym | 21 ++++ tests/expectations-symbols/transform_op.c.sym | 3 + tests/expectations-symbols/transparent.c.sym | 3 + tests/expectations-symbols/typedef.c.sym | 3 + tests/expectations-symbols/union.c.sym | 3 + tests/expectations-symbols/union_self.c.sym | 3 + .../using_namespaces.c.sym | 3 + tests/expectations-symbols/va_list.c.sym | 4 + tests/expectations-symbols/workspace.c.sym | 3 + tests/expectations-symbols/zst.c.sym | 3 + tests/tests.rs | 108 ++++++++++++------ 127 files changed, 569 insertions(+), 36 deletions(-) create mode 100644 tests/expectations-symbols/abi_string.c.sym create mode 100644 tests/expectations-symbols/alias.c.sym create mode 100644 tests/expectations-symbols/annotation.c.sym create mode 100644 tests/expectations-symbols/array.c.sym create mode 100644 tests/expectations-symbols/asserted_cast.c.sym create mode 100644 tests/expectations-symbols/assoc_constant.c.sym create mode 100644 tests/expectations-symbols/associated_in_body.c.sym create mode 100644 tests/expectations-symbols/bitfield.c.sym create mode 100644 tests/expectations-symbols/bitflags.c.sym create mode 100644 tests/expectations-symbols/body.c.sym create mode 100644 tests/expectations-symbols/box.c.sym create mode 100644 tests/expectations-symbols/cdecl.c.sym create mode 100644 tests/expectations-symbols/cell.c.sym create mode 100644 tests/expectations-symbols/cfg.c.sym create mode 100644 tests/expectations-symbols/cfg_2.c.sym create mode 100644 tests/expectations-symbols/char.c.sym create mode 100644 tests/expectations-symbols/const_generics.c.sym create mode 100644 tests/expectations-symbols/const_generics_arrayvec.c.sym create mode 100644 tests/expectations-symbols/const_generics_bool.c.sym create mode 100644 tests/expectations-symbols/const_generics_byte.c.sym create mode 100644 tests/expectations-symbols/const_generics_char.c.sym create mode 100644 tests/expectations-symbols/const_generics_constant.c.sym create mode 100644 tests/expectations-symbols/const_generics_thru.c.sym create mode 100644 tests/expectations-symbols/constant.c.sym create mode 100644 tests/expectations-symbols/constant_sort_name.c.sym create mode 100644 tests/expectations-symbols/constant_sort_none.c.sym create mode 100644 tests/expectations-symbols/custom_header.c.sym create mode 100644 tests/expectations-symbols/decl_name_conflicting.c.sym create mode 100644 tests/expectations-symbols/dep_v2.c.sym create mode 100644 tests/expectations-symbols/deprecated.c.sym create mode 100644 tests/expectations-symbols/derive_eq.c.sym create mode 100644 tests/expectations-symbols/derive_ostream.c.sym create mode 100644 tests/expectations-symbols/destructor_and_copy_ctor.c.sym create mode 100644 tests/expectations-symbols/display_list.c.sym create mode 100644 tests/expectations-symbols/doclength_short.c.sym create mode 100644 tests/expectations-symbols/docstyle_auto.c.sym create mode 100644 tests/expectations-symbols/docstyle_c99.c.sym create mode 100644 tests/expectations-symbols/docstyle_doxy.c.sym create mode 100644 tests/expectations-symbols/documentation.c.sym create mode 100644 tests/expectations-symbols/documentation_attr.c.sym create mode 100644 tests/expectations-symbols/enum.c.sym create mode 100644 tests/expectations-symbols/enum_discriminant.c.sym create mode 100644 tests/expectations-symbols/enum_self.c.sym create mode 100644 tests/expectations-symbols/euclid.c.sym create mode 100644 tests/expectations-symbols/exclude_generic_monomorph.c.sym create mode 100644 tests/expectations-symbols/expand.c.sym create mode 100644 tests/expectations-symbols/expand_default_features.c.sym create mode 100644 tests/expectations-symbols/expand_dep.c.sym create mode 100644 tests/expectations-symbols/expand_dep_v2.c.sym create mode 100644 tests/expectations-symbols/expand_features.c.sym create mode 100644 tests/expectations-symbols/expand_no_default_features.c.sym create mode 100644 tests/expectations-symbols/export_name.c.sym create mode 100644 tests/expectations-symbols/extern.c.sym create mode 100644 tests/expectations-symbols/extern_2.c.sym create mode 100644 tests/expectations-symbols/external_workspace_child.c.sym create mode 100644 tests/expectations-symbols/fns.c.sym create mode 100644 tests/expectations-symbols/forward_declaration.c.sym create mode 100644 tests/expectations-symbols/function_args.c.sym create mode 100644 tests/expectations-symbols/function_noreturn.c.sym create mode 100644 tests/expectations-symbols/function_ptr.c.sym create mode 100644 tests/expectations-symbols/function_sort_name.c.sym create mode 100644 tests/expectations-symbols/function_sort_none.c.sym create mode 100644 tests/expectations-symbols/generic_pointer.c.sym create mode 100644 tests/expectations-symbols/global_variable.c.sym create mode 100644 tests/expectations-symbols/ignore.c.sym create mode 100644 tests/expectations-symbols/include_guard.c.sym create mode 100644 tests/expectations-symbols/inner_mod.c.sym create mode 100644 tests/expectations-symbols/item_types.c.sym create mode 100644 tests/expectations-symbols/item_types_renamed.c.sym create mode 100644 tests/expectations-symbols/lifetime_arg.c.sym create mode 100644 tests/expectations-symbols/linestyle_cr.c.sym create mode 100644 tests/expectations-symbols/linestyle_crlf.c.sym create mode 100644 tests/expectations-symbols/linestyle_lf.c.sym create mode 100644 tests/expectations-symbols/mangle.c.sym create mode 100644 tests/expectations-symbols/manuallydrop.c.sym create mode 100644 tests/expectations-symbols/maybeuninit.c.sym create mode 100644 tests/expectations-symbols/mod_2015.c.sym create mode 100644 tests/expectations-symbols/mod_2018.c.sym create mode 100644 tests/expectations-symbols/mod_attr.c.sym create mode 100644 tests/expectations-symbols/mod_path.c.sym create mode 100644 tests/expectations-symbols/monomorph_1.c.sym create mode 100644 tests/expectations-symbols/monomorph_2.c.sym create mode 100644 tests/expectations-symbols/monomorph_3.c.sym create mode 100644 tests/expectations-symbols/must_use.c.sym create mode 100644 tests/expectations-symbols/namespace_constant.c.sym create mode 100644 tests/expectations-symbols/namespaces_constant.c.sym create mode 100644 tests/expectations-symbols/no_includes.c.sym create mode 100644 tests/expectations-symbols/non_pub_extern.c.sym create mode 100644 tests/expectations-symbols/nonnull.c.sym create mode 100644 tests/expectations-symbols/nonnull_attribute.c.sym create mode 100644 tests/expectations-symbols/nonzero.c.sym create mode 100644 tests/expectations-symbols/opaque.c.sym create mode 100644 tests/expectations-symbols/pin.c.sym create mode 100644 tests/expectations-symbols/pragma_once.c.sym create mode 100644 tests/expectations-symbols/prefix.c.sym create mode 100644 tests/expectations-symbols/prefixed_struct_literal.c.sym create mode 100644 tests/expectations-symbols/prefixed_struct_literal_deep.c.sym create mode 100644 tests/expectations-symbols/ptrs_as_arrays.c.sym create mode 100644 tests/expectations-symbols/raw_ident.c.sym create mode 100644 tests/expectations-symbols/raw_lines.c.sym create mode 100644 tests/expectations-symbols/rename.c.sym create mode 100644 tests/expectations-symbols/rename_case.c.sym create mode 100644 tests/expectations-symbols/rename_crate.c.sym create mode 100644 tests/expectations-symbols/renaming_overrides_prefixing.c.sym create mode 100644 tests/expectations-symbols/reserved.c.sym create mode 100644 tests/expectations-symbols/sentinel.c.sym create mode 100644 tests/expectations-symbols/simplify_option_ptr.c.sym create mode 100644 tests/expectations-symbols/size_types.c.sym create mode 100644 tests/expectations-symbols/static.c.sym create mode 100644 tests/expectations-symbols/std_lib.c.sym create mode 100644 tests/expectations-symbols/struct.c.sym create mode 100644 tests/expectations-symbols/struct_literal.c.sym create mode 100644 tests/expectations-symbols/struct_literal_order.c.sym create mode 100644 tests/expectations-symbols/struct_self.c.sym create mode 100644 tests/expectations-symbols/swift_name.c.sym create mode 100644 tests/expectations-symbols/transform_op.c.sym create mode 100644 tests/expectations-symbols/transparent.c.sym create mode 100644 tests/expectations-symbols/typedef.c.sym create mode 100644 tests/expectations-symbols/union.c.sym create mode 100644 tests/expectations-symbols/union_self.c.sym create mode 100644 tests/expectations-symbols/using_namespaces.c.sym create mode 100644 tests/expectations-symbols/va_list.c.sym create mode 100644 tests/expectations-symbols/workspace.c.sym create mode 100644 tests/expectations-symbols/zst.c.sym diff --git a/src/bindgen/bindings.rs b/src/bindgen/bindings.rs index 029cfc66b..7ef85baba 100644 --- a/src/bindgen/bindings.rs +++ b/src/bindgen/bindings.rs @@ -7,7 +7,7 @@ use std::cell::RefCell; use std::collections::HashMap; use std::fs; use std::fs::File; -use std::io::{Read, Write}; +use std::io::{BufWriter, Read, Write}; use std::path; use std::rc::Rc; @@ -129,6 +129,27 @@ impl Bindings { fields } + /// Lists the exported symbols that can be dynamically linked, i.e. globals and functions. + pub fn dynamic_symbols_names(&self) -> impl Iterator { + use crate::bindgen::ir::Item; + + let function_names = self.functions.iter().map(|f| f.path().name()); + let global_names = self.globals.iter().map(|g| g.export_name()); + function_names.chain(global_names) + } + + pub fn generate_symfile>(&self, symfile_path: P) { + if let Some(dir) = symfile_path.as_ref().parent() { + std::fs::create_dir_all(dir).unwrap(); + } + let mut writer = BufWriter::new(File::create(symfile_path).unwrap()); + write!(&mut writer, "{{\n").expect("writing symbol file header failed"); + for symbol in self.dynamic_symbols_names() { + write!(&mut writer, "{};\n", symbol).expect("writing symbol failed"); + } + write!(&mut writer, "}};").expect("writing symbol file footer failed"); + } + pub fn generate_depfile>(&self, header_path: P, depfile_path: P) { if let Some(dir) = depfile_path.as_ref().parent() { if !dir.exists() { diff --git a/src/main.rs b/src/main.rs index a6a1852c2..f8d9c437a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -298,6 +298,17 @@ fn main() { This option is ignored if `--out` is missing." ) ) + .arg( + Arg::new("symfile") + .value_name("PATH") + .long("symfile") + .num_args(1) + .required(false) + .help("Generate a list of symbols at the given Path. This list can be \ + given to a linker in order to compile an application that exposes \ + dynamic symbols. Useful when creating a plugin system with a C interface." + ) + ) .get_matches(); if matches.get_flag("verify") && !matches.contains_id("out") { @@ -343,7 +354,10 @@ fn main() { std::process::exit(2); } if let Some(depfile) = matches.get_one("depfile") { - bindings.generate_depfile(file, depfile) + bindings.generate_depfile(file, depfile); + } + if let Some(symfile) = matches.get_one::("symfile") { + bindings.generate_symfile(symfile); } } _ => { diff --git a/tests/expectations-symbols/abi_string.c.sym b/tests/expectations-symbols/abi_string.c.sym new file mode 100644 index 000000000..19e73069e --- /dev/null +++ b/tests/expectations-symbols/abi_string.c.sym @@ -0,0 +1,4 @@ +{ +c; +c_unwind; +}; diff --git a/tests/expectations-symbols/alias.c.sym b/tests/expectations-symbols/alias.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/alias.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/annotation.c.sym b/tests/expectations-symbols/annotation.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/annotation.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/array.c.sym b/tests/expectations-symbols/array.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/array.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/asserted_cast.c.sym b/tests/expectations-symbols/asserted_cast.c.sym new file mode 100644 index 000000000..57c772c4a --- /dev/null +++ b/tests/expectations-symbols/asserted_cast.c.sym @@ -0,0 +1,3 @@ +{ +foo; +}; diff --git a/tests/expectations-symbols/assoc_constant.c.sym b/tests/expectations-symbols/assoc_constant.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/assoc_constant.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/associated_in_body.c.sym b/tests/expectations-symbols/associated_in_body.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/associated_in_body.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/bitfield.c.sym b/tests/expectations-symbols/bitfield.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/bitfield.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/bitflags.c.sym b/tests/expectations-symbols/bitflags.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/bitflags.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/body.c.sym b/tests/expectations-symbols/body.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/body.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/box.c.sym b/tests/expectations-symbols/box.c.sym new file mode 100644 index 000000000..79a114122 --- /dev/null +++ b/tests/expectations-symbols/box.c.sym @@ -0,0 +1,5 @@ +{ +root; +drop_box; +drop_box_opt; +}; diff --git a/tests/expectations-symbols/cdecl.c.sym b/tests/expectations-symbols/cdecl.c.sym new file mode 100644 index 000000000..b3f50ef4a --- /dev/null +++ b/tests/expectations-symbols/cdecl.c.sym @@ -0,0 +1,4 @@ +{ +O; +root; +}; diff --git a/tests/expectations-symbols/cell.c.sym b/tests/expectations-symbols/cell.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/cell.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/cfg.c.sym b/tests/expectations-symbols/cfg.c.sym new file mode 100644 index 000000000..732af1661 --- /dev/null +++ b/tests/expectations-symbols/cfg.c.sym @@ -0,0 +1,5 @@ +{ +root; +root; +cond; +}; diff --git a/tests/expectations-symbols/cfg_2.c.sym b/tests/expectations-symbols/cfg_2.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/cfg_2.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/char.c.sym b/tests/expectations-symbols/char.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/char.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/const_generics.c.sym b/tests/expectations-symbols/const_generics.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/const_generics.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/const_generics_arrayvec.c.sym b/tests/expectations-symbols/const_generics_arrayvec.c.sym new file mode 100644 index 000000000..f6b2cd601 --- /dev/null +++ b/tests/expectations-symbols/const_generics_arrayvec.c.sym @@ -0,0 +1,3 @@ +{ +push; +}; diff --git a/tests/expectations-symbols/const_generics_bool.c.sym b/tests/expectations-symbols/const_generics_bool.c.sym new file mode 100644 index 000000000..1bed6d7ae --- /dev/null +++ b/tests/expectations-symbols/const_generics_bool.c.sym @@ -0,0 +1,6 @@ +{ +new_set; +set_for_each; +new_map; +map_for_each; +}; diff --git a/tests/expectations-symbols/const_generics_byte.c.sym b/tests/expectations-symbols/const_generics_byte.c.sym new file mode 100644 index 000000000..6a1843f1f --- /dev/null +++ b/tests/expectations-symbols/const_generics_byte.c.sym @@ -0,0 +1,5 @@ +{ +init_parens_parser; +destroy_parens_parser; +init_braces_parser; +}; diff --git a/tests/expectations-symbols/const_generics_char.c.sym b/tests/expectations-symbols/const_generics_char.c.sym new file mode 100644 index 000000000..5888deefd --- /dev/null +++ b/tests/expectations-symbols/const_generics_char.c.sym @@ -0,0 +1,3 @@ +{ +until_nul; +}; diff --git a/tests/expectations-symbols/const_generics_constant.c.sym b/tests/expectations-symbols/const_generics_constant.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/const_generics_constant.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/const_generics_thru.c.sym b/tests/expectations-symbols/const_generics_thru.c.sym new file mode 100644 index 000000000..59344f322 --- /dev/null +++ b/tests/expectations-symbols/const_generics_thru.c.sym @@ -0,0 +1,4 @@ +{ +one; +two; +}; diff --git a/tests/expectations-symbols/constant.c.sym b/tests/expectations-symbols/constant.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/constant.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/constant_sort_name.c.sym b/tests/expectations-symbols/constant_sort_name.c.sym new file mode 100644 index 000000000..3f7f900f8 --- /dev/null +++ b/tests/expectations-symbols/constant_sort_name.c.sym @@ -0,0 +1,4 @@ +{ +C; +D; +}; diff --git a/tests/expectations-symbols/constant_sort_none.c.sym b/tests/expectations-symbols/constant_sort_none.c.sym new file mode 100644 index 000000000..85430bed2 --- /dev/null +++ b/tests/expectations-symbols/constant_sort_none.c.sym @@ -0,0 +1,4 @@ +{ +D; +C; +}; diff --git a/tests/expectations-symbols/custom_header.c.sym b/tests/expectations-symbols/custom_header.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/custom_header.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/decl_name_conflicting.c.sym b/tests/expectations-symbols/decl_name_conflicting.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/decl_name_conflicting.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/dep_v2.c.sym b/tests/expectations-symbols/dep_v2.c.sym new file mode 100644 index 000000000..1f4414931 --- /dev/null +++ b/tests/expectations-symbols/dep_v2.c.sym @@ -0,0 +1,3 @@ +{ +get_x; +}; diff --git a/tests/expectations-symbols/deprecated.c.sym b/tests/expectations-symbols/deprecated.c.sym new file mode 100644 index 000000000..159198dd4 --- /dev/null +++ b/tests/expectations-symbols/deprecated.c.sym @@ -0,0 +1,8 @@ +{ +deprecated_without_note; +deprecated_without_bracket; +deprecated_with_note; +deprecated_with_note_and_since; +deprecated_with_note_which_requires_to_be_escaped; +dummy; +}; diff --git a/tests/expectations-symbols/derive_eq.c.sym b/tests/expectations-symbols/derive_eq.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/derive_eq.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/derive_ostream.c.sym b/tests/expectations-symbols/derive_ostream.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/derive_ostream.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/destructor_and_copy_ctor.c.sym b/tests/expectations-symbols/destructor_and_copy_ctor.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/destructor_and_copy_ctor.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/display_list.c.sym b/tests/expectations-symbols/display_list.c.sym new file mode 100644 index 000000000..c39f6f8b3 --- /dev/null +++ b/tests/expectations-symbols/display_list.c.sym @@ -0,0 +1,3 @@ +{ +push_item; +}; diff --git a/tests/expectations-symbols/doclength_short.c.sym b/tests/expectations-symbols/doclength_short.c.sym new file mode 100644 index 000000000..ea28bf2be --- /dev/null +++ b/tests/expectations-symbols/doclength_short.c.sym @@ -0,0 +1,4 @@ +{ +root; +trunk; +}; diff --git a/tests/expectations-symbols/docstyle_auto.c.sym b/tests/expectations-symbols/docstyle_auto.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/docstyle_auto.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/docstyle_c99.c.sym b/tests/expectations-symbols/docstyle_c99.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/docstyle_c99.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/docstyle_doxy.c.sym b/tests/expectations-symbols/docstyle_doxy.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/docstyle_doxy.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/documentation.c.sym b/tests/expectations-symbols/documentation.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/documentation.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/documentation_attr.c.sym b/tests/expectations-symbols/documentation_attr.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/documentation_attr.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/enum.c.sym b/tests/expectations-symbols/enum.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/enum.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/enum_discriminant.c.sym b/tests/expectations-symbols/enum_discriminant.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/enum_discriminant.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/enum_self.c.sym b/tests/expectations-symbols/enum_self.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/enum_self.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/euclid.c.sym b/tests/expectations-symbols/euclid.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/euclid.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/exclude_generic_monomorph.c.sym b/tests/expectations-symbols/exclude_generic_monomorph.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/exclude_generic_monomorph.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/expand.c.sym b/tests/expectations-symbols/expand.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/expand.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/expand_default_features.c.sym b/tests/expectations-symbols/expand_default_features.c.sym new file mode 100644 index 000000000..67cb8bbe7 --- /dev/null +++ b/tests/expectations-symbols/expand_default_features.c.sym @@ -0,0 +1,4 @@ +{ +extra_debug_fn; +root; +}; diff --git a/tests/expectations-symbols/expand_dep.c.sym b/tests/expectations-symbols/expand_dep.c.sym new file mode 100644 index 000000000..1f4414931 --- /dev/null +++ b/tests/expectations-symbols/expand_dep.c.sym @@ -0,0 +1,3 @@ +{ +get_x; +}; diff --git a/tests/expectations-symbols/expand_dep_v2.c.sym b/tests/expectations-symbols/expand_dep_v2.c.sym new file mode 100644 index 000000000..1f4414931 --- /dev/null +++ b/tests/expectations-symbols/expand_dep_v2.c.sym @@ -0,0 +1,3 @@ +{ +get_x; +}; diff --git a/tests/expectations-symbols/expand_features.c.sym b/tests/expectations-symbols/expand_features.c.sym new file mode 100644 index 000000000..70a323c35 --- /dev/null +++ b/tests/expectations-symbols/expand_features.c.sym @@ -0,0 +1,5 @@ +{ +extra_debug_fn; +cbindgen; +root; +}; diff --git a/tests/expectations-symbols/expand_no_default_features.c.sym b/tests/expectations-symbols/expand_no_default_features.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/expand_no_default_features.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/export_name.c.sym b/tests/expectations-symbols/export_name.c.sym new file mode 100644 index 000000000..3698cd3d3 --- /dev/null +++ b/tests/expectations-symbols/export_name.c.sym @@ -0,0 +1,3 @@ +{ +do_the_thing_with_export_name; +}; diff --git a/tests/expectations-symbols/extern.c.sym b/tests/expectations-symbols/extern.c.sym new file mode 100644 index 000000000..eb1bbe714 --- /dev/null +++ b/tests/expectations-symbols/extern.c.sym @@ -0,0 +1,4 @@ +{ +foo; +bar; +}; diff --git a/tests/expectations-symbols/extern_2.c.sym b/tests/expectations-symbols/extern_2.c.sym new file mode 100644 index 000000000..8638cd5a5 --- /dev/null +++ b/tests/expectations-symbols/extern_2.c.sym @@ -0,0 +1,4 @@ +{ +first; +second; +}; diff --git a/tests/expectations-symbols/external_workspace_child.c.sym b/tests/expectations-symbols/external_workspace_child.c.sym new file mode 100644 index 000000000..0cb41d3fe --- /dev/null +++ b/tests/expectations-symbols/external_workspace_child.c.sym @@ -0,0 +1,3 @@ +{ +consume_ext; +}; diff --git a/tests/expectations-symbols/fns.c.sym b/tests/expectations-symbols/fns.c.sym new file mode 100644 index 000000000..f299d02d3 --- /dev/null +++ b/tests/expectations-symbols/fns.c.sym @@ -0,0 +1,4 @@ +{ +root; +no_return; +}; diff --git a/tests/expectations-symbols/forward_declaration.c.sym b/tests/expectations-symbols/forward_declaration.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/forward_declaration.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/function_args.c.sym b/tests/expectations-symbols/function_args.c.sym new file mode 100644 index 000000000..361aca4ad --- /dev/null +++ b/tests/expectations-symbols/function_args.c.sym @@ -0,0 +1,5 @@ +{ +unnamed; +pointer_test; +print_from_rust; +}; diff --git a/tests/expectations-symbols/function_noreturn.c.sym b/tests/expectations-symbols/function_noreturn.c.sym new file mode 100644 index 000000000..c38fe7d9e --- /dev/null +++ b/tests/expectations-symbols/function_noreturn.c.sym @@ -0,0 +1,4 @@ +{ +loop_forever; +normal_return; +}; diff --git a/tests/expectations-symbols/function_ptr.c.sym b/tests/expectations-symbols/function_ptr.c.sym new file mode 100644 index 000000000..25aa6ab49 --- /dev/null +++ b/tests/expectations-symbols/function_ptr.c.sym @@ -0,0 +1,3 @@ +{ +my_function; +}; diff --git a/tests/expectations-symbols/function_sort_name.c.sym b/tests/expectations-symbols/function_sort_name.c.sym new file mode 100644 index 000000000..b4badb861 --- /dev/null +++ b/tests/expectations-symbols/function_sort_name.c.sym @@ -0,0 +1,6 @@ +{ +A; +B; +C; +D; +}; diff --git a/tests/expectations-symbols/function_sort_none.c.sym b/tests/expectations-symbols/function_sort_none.c.sym new file mode 100644 index 000000000..38ad212b2 --- /dev/null +++ b/tests/expectations-symbols/function_sort_none.c.sym @@ -0,0 +1,6 @@ +{ +C; +B; +D; +A; +}; diff --git a/tests/expectations-symbols/generic_pointer.c.sym b/tests/expectations-symbols/generic_pointer.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/generic_pointer.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/global_variable.c.sym b/tests/expectations-symbols/global_variable.c.sym new file mode 100644 index 000000000..b64e8969c --- /dev/null +++ b/tests/expectations-symbols/global_variable.c.sym @@ -0,0 +1,4 @@ +{ +MUT_GLOBAL_ARRAY; +CONST_GLOBAL_ARRAY; +}; diff --git a/tests/expectations-symbols/ignore.c.sym b/tests/expectations-symbols/ignore.c.sym new file mode 100644 index 000000000..dff03068a --- /dev/null +++ b/tests/expectations-symbols/ignore.c.sym @@ -0,0 +1,3 @@ +{ +no_ignore_root; +}; diff --git a/tests/expectations-symbols/include_guard.c.sym b/tests/expectations-symbols/include_guard.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/include_guard.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/inner_mod.c.sym b/tests/expectations-symbols/inner_mod.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/inner_mod.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/item_types.c.sym b/tests/expectations-symbols/item_types.c.sym new file mode 100644 index 000000000..f6fcdc99f --- /dev/null +++ b/tests/expectations-symbols/item_types.c.sym @@ -0,0 +1,3 @@ +{ +; +}; diff --git a/tests/expectations-symbols/item_types_renamed.c.sym b/tests/expectations-symbols/item_types_renamed.c.sym new file mode 100644 index 000000000..f6fcdc99f --- /dev/null +++ b/tests/expectations-symbols/item_types_renamed.c.sym @@ -0,0 +1,3 @@ +{ +; +}; diff --git a/tests/expectations-symbols/lifetime_arg.c.sym b/tests/expectations-symbols/lifetime_arg.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/lifetime_arg.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/linestyle_cr.c.sym b/tests/expectations-symbols/linestyle_cr.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/linestyle_cr.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/linestyle_crlf.c.sym b/tests/expectations-symbols/linestyle_crlf.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/linestyle_crlf.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/linestyle_lf.c.sym b/tests/expectations-symbols/linestyle_lf.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/linestyle_lf.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/mangle.c.sym b/tests/expectations-symbols/mangle.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/mangle.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/manuallydrop.c.sym b/tests/expectations-symbols/manuallydrop.c.sym new file mode 100644 index 000000000..2d62f6ada --- /dev/null +++ b/tests/expectations-symbols/manuallydrop.c.sym @@ -0,0 +1,4 @@ +{ +root; +take; +}; diff --git a/tests/expectations-symbols/maybeuninit.c.sym b/tests/expectations-symbols/maybeuninit.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/maybeuninit.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/mod_2015.c.sym b/tests/expectations-symbols/mod_2015.c.sym new file mode 100644 index 000000000..bbc2e6756 --- /dev/null +++ b/tests/expectations-symbols/mod_2015.c.sym @@ -0,0 +1,4 @@ +{ +export_me; +from_really_nested_mod; +}; diff --git a/tests/expectations-symbols/mod_2018.c.sym b/tests/expectations-symbols/mod_2018.c.sym new file mode 100644 index 000000000..814cea8ee --- /dev/null +++ b/tests/expectations-symbols/mod_2018.c.sym @@ -0,0 +1,5 @@ +{ +export_me; +export_me_2; +from_really_nested_mod; +}; diff --git a/tests/expectations-symbols/mod_attr.c.sym b/tests/expectations-symbols/mod_attr.c.sym new file mode 100644 index 000000000..eb1bbe714 --- /dev/null +++ b/tests/expectations-symbols/mod_attr.c.sym @@ -0,0 +1,4 @@ +{ +foo; +bar; +}; diff --git a/tests/expectations-symbols/mod_path.c.sym b/tests/expectations-symbols/mod_path.c.sym new file mode 100644 index 000000000..441241ba2 --- /dev/null +++ b/tests/expectations-symbols/mod_path.c.sym @@ -0,0 +1,3 @@ +{ +export_me; +}; diff --git a/tests/expectations-symbols/monomorph_1.c.sym b/tests/expectations-symbols/monomorph_1.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/monomorph_1.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/monomorph_2.c.sym b/tests/expectations-symbols/monomorph_2.c.sym new file mode 100644 index 000000000..eb1bbe714 --- /dev/null +++ b/tests/expectations-symbols/monomorph_2.c.sym @@ -0,0 +1,4 @@ +{ +foo; +bar; +}; diff --git a/tests/expectations-symbols/monomorph_3.c.sym b/tests/expectations-symbols/monomorph_3.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/monomorph_3.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/must_use.c.sym b/tests/expectations-symbols/must_use.c.sym new file mode 100644 index 000000000..2b1a7af14 --- /dev/null +++ b/tests/expectations-symbols/must_use.c.sym @@ -0,0 +1,3 @@ +{ +maybe_consume; +}; diff --git a/tests/expectations-symbols/namespace_constant.c.sym b/tests/expectations-symbols/namespace_constant.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/namespace_constant.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/namespaces_constant.c.sym b/tests/expectations-symbols/namespaces_constant.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/namespaces_constant.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/no_includes.c.sym b/tests/expectations-symbols/no_includes.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/no_includes.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/non_pub_extern.c.sym b/tests/expectations-symbols/non_pub_extern.c.sym new file mode 100644 index 000000000..ce9b8673b --- /dev/null +++ b/tests/expectations-symbols/non_pub_extern.c.sym @@ -0,0 +1,6 @@ +{ +first; +renamed; +FIRST; +RENAMED; +}; diff --git a/tests/expectations-symbols/nonnull.c.sym b/tests/expectations-symbols/nonnull.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/nonnull.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/nonnull_attribute.c.sym b/tests/expectations-symbols/nonnull_attribute.c.sym new file mode 100644 index 000000000..78a53d315 --- /dev/null +++ b/tests/expectations-symbols/nonnull_attribute.c.sym @@ -0,0 +1,10 @@ +{ +value_arg; +mutltiple_args; +ref_arg; +mut_ref_arg; +optional_ref_arg; +optional_mut_ref_arg; +nullable_const_ptr; +nullable_mut_ptr; +}; diff --git a/tests/expectations-symbols/nonzero.c.sym b/tests/expectations-symbols/nonzero.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/nonzero.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/opaque.c.sym b/tests/expectations-symbols/opaque.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/opaque.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/pin.c.sym b/tests/expectations-symbols/pin.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/pin.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/pragma_once.c.sym b/tests/expectations-symbols/pragma_once.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/pragma_once.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/prefix.c.sym b/tests/expectations-symbols/prefix.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/prefix.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/prefixed_struct_literal.c.sym b/tests/expectations-symbols/prefixed_struct_literal.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/prefixed_struct_literal.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/prefixed_struct_literal_deep.c.sym b/tests/expectations-symbols/prefixed_struct_literal_deep.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/prefixed_struct_literal_deep.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/ptrs_as_arrays.c.sym b/tests/expectations-symbols/ptrs_as_arrays.c.sym new file mode 100644 index 000000000..de7efd434 --- /dev/null +++ b/tests/expectations-symbols/ptrs_as_arrays.c.sym @@ -0,0 +1,7 @@ +{ +ptr_as_array; +ptr_as_array1; +ptr_as_array2; +ptr_as_array_wrong_syntax; +ptr_as_array_unnamed; +}; diff --git a/tests/expectations-symbols/raw_ident.c.sym b/tests/expectations-symbols/raw_ident.c.sym new file mode 100644 index 000000000..ea76f34b7 --- /dev/null +++ b/tests/expectations-symbols/raw_ident.c.sym @@ -0,0 +1,4 @@ +{ +fn; +STATIC; +}; diff --git a/tests/expectations-symbols/raw_lines.c.sym b/tests/expectations-symbols/raw_lines.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/raw_lines.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/rename.c.sym b/tests/expectations-symbols/rename.c.sym new file mode 100644 index 000000000..8a247ae6f --- /dev/null +++ b/tests/expectations-symbols/rename.c.sym @@ -0,0 +1,4 @@ +{ +root; +G; +}; diff --git a/tests/expectations-symbols/rename_case.c.sym b/tests/expectations-symbols/rename_case.c.sym new file mode 100644 index 000000000..1bacd14c0 --- /dev/null +++ b/tests/expectations-symbols/rename_case.c.sym @@ -0,0 +1,7 @@ +{ +test_camel_case; +test_pascal_case; +test_snake_case; +test_screaming_snake_case; +test_gecko_case; +}; diff --git a/tests/expectations-symbols/rename_crate.c.sym b/tests/expectations-symbols/rename_crate.c.sym new file mode 100644 index 000000000..256a2894a --- /dev/null +++ b/tests/expectations-symbols/rename_crate.c.sym @@ -0,0 +1,5 @@ +{ +root; +renamed_func; +no_extern_func; +}; diff --git a/tests/expectations-symbols/renaming_overrides_prefixing.c.sym b/tests/expectations-symbols/renaming_overrides_prefixing.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/renaming_overrides_prefixing.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/reserved.c.sym b/tests/expectations-symbols/reserved.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/reserved.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/sentinel.c.sym b/tests/expectations-symbols/sentinel.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/sentinel.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/simplify_option_ptr.c.sym b/tests/expectations-symbols/simplify_option_ptr.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/simplify_option_ptr.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/size_types.c.sym b/tests/expectations-symbols/size_types.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/size_types.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/static.c.sym b/tests/expectations-symbols/static.c.sym new file mode 100644 index 000000000..53daac495 --- /dev/null +++ b/tests/expectations-symbols/static.c.sym @@ -0,0 +1,6 @@ +{ +root; +NUMBER; +FOO; +BAR; +}; diff --git a/tests/expectations-symbols/std_lib.c.sym b/tests/expectations-symbols/std_lib.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/std_lib.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/struct.c.sym b/tests/expectations-symbols/struct.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/struct.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/struct_literal.c.sym b/tests/expectations-symbols/struct_literal.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/struct_literal.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/struct_literal_order.c.sym b/tests/expectations-symbols/struct_literal_order.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/struct_literal_order.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/struct_self.c.sym b/tests/expectations-symbols/struct_self.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/struct_self.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/swift_name.c.sym b/tests/expectations-symbols/swift_name.c.sym new file mode 100644 index 000000000..5110fbbf8 --- /dev/null +++ b/tests/expectations-symbols/swift_name.c.sym @@ -0,0 +1,21 @@ +{ +rust_print_hello_world; +SelfTypeTestStruct_should_exist_ref; +SelfTypeTestStruct_should_exist_ref_mut; +SelfTypeTestStruct_should_not_exist_box; +SelfTypeTestStruct_should_not_exist_return_box; +SelfTypeTestStruct_should_exist_annotated_self; +SelfTypeTestStruct_should_exist_annotated_mut_self; +SelfTypeTestStruct_should_exist_annotated_by_name; +SelfTypeTestStruct_should_exist_annotated_mut_by_name; +SelfTypeTestStruct_should_exist_unannotated; +SelfTypeTestStruct_should_exist_mut_unannotated; +free_function_should_exist_ref; +free_function_should_exist_ref_mut; +unnamed_argument; +free_function_should_not_exist_box; +free_function_should_exist_annotated_by_name; +free_function_should_exist_annotated_mut_by_name; +PointerToOpaque_create; +PointerToOpaque_sayHello; +}; diff --git a/tests/expectations-symbols/transform_op.c.sym b/tests/expectations-symbols/transform_op.c.sym new file mode 100644 index 000000000..57c772c4a --- /dev/null +++ b/tests/expectations-symbols/transform_op.c.sym @@ -0,0 +1,3 @@ +{ +foo; +}; diff --git a/tests/expectations-symbols/transparent.c.sym b/tests/expectations-symbols/transparent.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/transparent.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/typedef.c.sym b/tests/expectations-symbols/typedef.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/typedef.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/union.c.sym b/tests/expectations-symbols/union.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/union.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/union_self.c.sym b/tests/expectations-symbols/union_self.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/union_self.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/using_namespaces.c.sym b/tests/expectations-symbols/using_namespaces.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/using_namespaces.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/expectations-symbols/va_list.c.sym b/tests/expectations-symbols/va_list.c.sym new file mode 100644 index 000000000..715658c35 --- /dev/null +++ b/tests/expectations-symbols/va_list.c.sym @@ -0,0 +1,4 @@ +{ +va_list_test; +va_list_test2; +}; diff --git a/tests/expectations-symbols/workspace.c.sym b/tests/expectations-symbols/workspace.c.sym new file mode 100644 index 000000000..0cb41d3fe --- /dev/null +++ b/tests/expectations-symbols/workspace.c.sym @@ -0,0 +1,3 @@ +{ +consume_ext; +}; diff --git a/tests/expectations-symbols/zst.c.sym b/tests/expectations-symbols/zst.c.sym new file mode 100644 index 000000000..8c89234f5 --- /dev/null +++ b/tests/expectations-symbols/zst.c.sym @@ -0,0 +1,3 @@ +{ +root; +}; diff --git a/tests/tests.rs b/tests/tests.rs index eebabefbe..56fce8b39 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,6 +1,7 @@ extern crate cbindgen; use cbindgen::*; +use tempfile::NamedTempFile; use std::collections::HashSet; use std::fs::File; use std::io::Read; @@ -21,6 +22,12 @@ fn style_str(style: Style) -> &'static str { } } +struct CBindgenOutput { + bindings_content: Vec, + depfile_content: Option, + symfile_content: Option, +} + fn run_cbindgen( path: &Path, output: Option<&Path>, @@ -29,20 +36,30 @@ fn run_cbindgen( style: Option