29 Commits

Author SHA1 Message Date
Jonathan Schwender
25132a3690 Add --depfile option
Add an option to output a depfile for outside build-systems to learn
the source file dependencies of the bindings.
This can be used by 3rd party build system integrations to only rerun
bindgen when necessary.

Testing is done via CMake integration tests, since CMake
is a 3rd party buildsystem which supports depfiles.
2023-05-29 18:56:53 +02:00
Jonathan Schwender
cb42a00ab6 Improve cbindgen detection in tests
Since our MSRV is now Rust 1.54, we can rely on cargo setting `CARGO_BIN_EXE_cbindgen`
to the cbindgen path in integration tests.
This is more reliable than guessing the path, since cargo knows where it placed the bin.
2023-05-29 18:56:53 +02:00
Jonathan Schwender
fb1fdc8aed Fix clippy warning (1.40 -> 1.54)
The clippy.toml suppresses warnings added in newer rust versions,
so fixing the documented MSRV also shows new warnings.
2023-03-08 16:59:28 +01:00
Sean McArthur
0e3f9bd9cb Add documentation_style to with short and full options 2021-11-02 11:13:49 +01:00
Emilio Cobos Álvarez
57add9c860 Fix some clippy lints. 2021-06-21 13:25:53 +02:00
Vadim Petrochenkov
1c1d4754ce tests: Remove Cython-specific configs 2020-11-25 17:30:30 +01:00
Vadim Petrochenkov
51405d1277 Support generation of Cython bindings 2020-11-17 15:27:34 +01:00
Vadim Petrochenkov
3a7e24d2d7 test suite: Do not generate identical expectation files 2020-10-20 22:59:14 +02:00
Vadim Petrochenkov
d09fe6b753 test suite: Use suffixes instead of directories for test variants 2020-10-19 20:33:29 +02:00
Emilio Cobos Álvarez
5d1217c7c0
tests: Instead of adding skip_cpp as a feature, make the tests work with C++ 2020-09-29 13:36:46 +02:00
Ivan Enderlin
4304907d01
test: Support a new .skip_cpp test suffix.
Following the example of `.skip_warning_as_error`, this patch
introduces a `.skip_cpp` suffix to skip the generation of `.cpp`
files.

This patch also simplifies the code. Ideally, we would create and
implement a new trait offering an API like `is_cpp_skipped`,
`is_warning_as_error_skipped`, and `normalize` (to remove all
suffixes), but it's a little bit overkill for our needs right now.
2020-09-29 13:36:46 +02:00
Emilio Cobos Álvarez
6ba31b49f4 tests: Fix errors when testing with clang.
Fixes #554
2020-07-31 12:07:20 +02:00
Igor Sadchenko
6fce1ccc4b Review fixes. Add parameter skip_warning_as_error to skip threat a warning as an error 2020-04-14 19:03:55 +02:00
Igor Sadchenko
4baadb049d Review fixes 2020-04-14 19:03:55 +02:00
Igor Sadchenko
275b36fb09 Added pragma once option. Issue #510 2020-04-14 19:03:55 +02:00
Emilio Cobos Álvarez
a519f1bda4 Actually use the temp dir for temporary compiled objects.
If the cbindgen_output is an absolute path, then join() will just return it.

Really fixes #499.
2020-04-04 23:46:42 +02:00
Emilio Cobos Álvarez
39bae60ad7 Generate test object files in a temporary directory instead of in-tree
Closes #499

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2020-04-04 17:54:52 +02:00
AlaskanEmily
dfa6e5f982 Check for CFLAGS and CXXFLAGS when running tests
This is needed when running tests with clang/clang++, as some of the tests have
errors that clang reports which gcc does not such as unused static const
variables.
2020-02-25 01:24:27 +01:00
Emilio Cobos Álvarez
12248c2fef tests: Add a simple testing-helpers headers that tests can include.
This allows to assert easily as described in the previous commit.
2020-01-26 02:35:39 +01:00
Emilio Cobos Álvarez
bd831ded19 tests: Provide style definition to the C / C++ tests.
This will be useful to add static assertion to some tests like #463 wants to do.

For example, in the case of the test for #463, the test would need something
like:

    trailer = """
    #include <assert.h>

    #if defined(CBINDGEN_STYLE_TAG) && !defined(__cplusplus)
    static_assert(sizeof(struct P) == 4, "unexpected size for P");
    #else
    static_assert(sizeof(P) == 4, "unexpected size for P");
    #endif
    """

As more of these tests are added it may be worth just adding a helper header
like this to avoid some duplication:

    #include <assert.h>
    #if defined(CBINDGEN_STYLE_TAG) && !defined(__cplusplus)
    #define CBINDGEN_STRUCT(name) struct name
    #else
    #define CBINDGEN_STRUCT(name) name
    #endif

And so on, so the previous configuration would become just:

    trailer = """
    #include "testing-helpers.h" // Or whatever
    static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P");
    """

That may or may not be overkill to do as part of #463.
2020-01-26 02:35:39 +01:00
John VanEnk
70188bb3b2 Enable most warnings, and make them errors.
This adds `-Wall` and `-Werror` to the C and C++ compiler flags. It
also adds `-Wno-attributes` to disable warnings about unrecognized
attributes. This is needed because the `swift_name` test relies on
`__attribute__((swift_name(some_name)))` attribute.
2020-01-24 11:22:39 +01:00
John VanEnk
fb348d91e8 Change std=c++11 to std=c++17 to support inline variables.
The inline variables feature is used by the associated_in_body test.
2020-01-24 11:22:39 +01:00
Wodann
af95d87c05 Improve verbosity of cpp_compat test cases 2019-06-01 10:59:43 +09:00
Wodann
bbeff3e3aa Add option to generate C headers with C++ compatibility
By default C++ compatibility is disabled.
2019-06-01 10:57:50 +09:00
Wodann
767fce25d1 Add support for selection of a custom C++ compiler 2019-06-01 10:56:09 +09:00
Wodann
7970564887 Add stderr output of cbindgen to a tests error log upon failure 2019-06-01 10:56:09 +09:00
Emilio Cobos Álvarez
357f34460d Do a better job at detecting the final binary location.
Still not great, I guess we should convert the tests to run the library version
of cbindgen, but this trivially-fixes #342.
2019-05-23 16:40:06 +02:00
Alexis Beingessner
ee2af57499 require c++11 to run the test suite
fixes #330
2019-05-10 17:58:52 -04:00
Emilio Cobos Álvarez
2bb3e9ba66 Use cargo test instead of test.py.
This makes cargo test test all the stuff in tests/rust, and thus makes tests.py
unnecessary.

Co-authored-by: Axel Nennker <axel.nennker@telekom.de>
2019-04-20 00:30:58 +02:00