• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 const EXPECTED: &str = "\
2 cxxbridge $VERSION
3 David Tolnay <dtolnay@gmail.com>
4 https://github.com/dtolnay/cxx
5 
6 Usage:
7     cxxbridge <input>.rs              Emit .cc file for bridge to stdout
8     cxxbridge <input>.rs --header     Emit .h file for bridge to stdout
9     cxxbridge --header                Emit \"rust/cxx.h\" header to stdout
10 
11 Arguments:
12   [input]
13           Input Rust source file containing #[cxx::bridge].
14 
15 Options:
16       --cfg <name=\"value\" | name[=true] | name=false>
17           Compilation configuration matching what will be used to build
18           the Rust side of the bridge.
19 
20       --cxx-impl-annotations <annotation>
21           Optional annotation for implementations of C++ function wrappers
22           that may be exposed to Rust. You may for example need to provide
23           __declspec(dllexport) or __attribute__((visibility(\"default\")))
24           if Rust code from one shared object or executable depends on
25           these C++ functions in another.
26 
27       --header
28           Emit header with declarations only. Optional if using `-o` with
29           a path ending in `.h`.
30 
31       --help
32           Print help information.
33 
34   -i, --include <include>
35           Any additional headers to #include. The cxxbridge tool does not
36           parse or even require the given paths to exist; they simply go
37           into the generated C++ code as #include lines.
38 
39   -o, --output <output>
40           Path of file to write as output. Output goes to stdout if -o is
41           not specified.
42 
43       --version
44           Print version information.
45 ";
46 
47 #[test]
test_help()48 fn test_help() {
49     let mut app = super::app();
50     let mut out = Vec::new();
51     app.write_long_help(&mut out).unwrap();
52     let help = String::from_utf8(out).unwrap();
53     let version = option_env!("CARGO_PKG_VERSION").unwrap_or_default();
54     let expected = EXPECTED.replace("$VERSION", version);
55     assert_eq!(help, expected);
56 }
57 
58 #[test]
test_cli()59 fn test_cli() {
60     let app = super::app();
61     app.debug_assert();
62 }
63