diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2022-12-11 00:09:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-11 00:09:27 +0200 |
commit | dbb33aaf92a581e87c1451933fe148eea6808ecc (patch) | |
tree | ee36ba59da94c02c30f92e18bb8bf59a5595a668 /test cases | |
parent | c8766468a30b997e637b21301fe9254c0c252bd2 (diff) | |
parent | d49e6bc0384a4a01754f13edb793cb1d6ce0b836 (diff) | |
download | meson-dbb33aaf92a581e87c1451933fe148eea6808ecc.zip meson-dbb33aaf92a581e87c1451933fe148eea6808ecc.tar.gz meson-dbb33aaf92a581e87c1451933fe148eea6808ecc.tar.bz2 |
Merge pull request #11024 from dcbaker/submit/bindgen-dependencies
Add a `dependencies` keyword argument to bindgen
Diffstat (limited to 'test cases')
6 files changed, 80 insertions, 1 deletions
diff --git a/test cases/rust/12 bindgen/dependencies/clib2.c b/test cases/rust/12 bindgen/dependencies/clib2.c new file mode 100644 index 0000000..63d3e0a --- /dev/null +++ b/test cases/rust/12 bindgen/dependencies/clib2.c @@ -0,0 +1,5 @@ +#include "internal_dep.h" + +int64_t add64(const int64_t first, const int64_t second) { + return first + second; +} diff --git a/test cases/rust/12 bindgen/dependencies/external_dep.h b/test cases/rust/12 bindgen/dependencies/external_dep.h new file mode 100644 index 0000000..284661b --- /dev/null +++ b/test cases/rust/12 bindgen/dependencies/external_dep.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifer: Apache-2.0 */ +/* Copyright © 2022 Intel Corporation */ + +#include <zlib.h> + +struct External { + z_stream * stream; +}; diff --git a/test cases/rust/12 bindgen/dependencies/internal_dep.h b/test cases/rust/12 bindgen/dependencies/internal_dep.h new file mode 100644 index 0000000..b0629de --- /dev/null +++ b/test cases/rust/12 bindgen/dependencies/internal_dep.h @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright © 2022 Intel Corporation + +#include "gen.h" + +int64_t add64(const int64_t, const int64_t); diff --git a/test cases/rust/12 bindgen/dependencies/internal_main.rs b/test cases/rust/12 bindgen/dependencies/internal_main.rs new file mode 100644 index 0000000..4890b43 --- /dev/null +++ b/test cases/rust/12 bindgen/dependencies/internal_main.rs @@ -0,0 +1,16 @@ +// SPDX-license-identifer: Apache-2.0 +// Copyright © 2021 Intel Corporation + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +include!("internal_dep.rs"); + +use std::convert::TryInto; + +fn main() { + unsafe { + std::process::exit(add64(0, 0).try_into().unwrap_or(5)); + }; +} diff --git a/test cases/rust/12 bindgen/dependencies/meson.build b/test cases/rust/12 bindgen/dependencies/meson.build new file mode 100644 index 0000000..37e5a42 --- /dev/null +++ b/test cases/rust/12 bindgen/dependencies/meson.build @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright © 2022 Intel Corporation + +dep_zlib = dependency('zlib', required : false, disabler : true) + +external_dep_rs = rust.bindgen( + input : 'external_dep.h', + output : 'external_dep.rs', + dependencies : dep_zlib +) + +external_dep = static_library( + 'external_dep', + [external_dep_rs], + dependencies : dep_zlib.partial_dependency(links : true), +) + +rust.test('external dep', external_dep) + +int_dep = declare_dependency( + sources : [gen_h, gen2_h], + include_directories : include_directories('..'), +) + +internal_dep_rs = rust.bindgen( + input : 'internal_dep.h', + output : 'internal_dep.rs', + dependencies : int_dep, +) + +c_lib2 = static_library( + 'clib2', + 'clib2.c', + dependencies : int_dep, +) + +rust_bin_int_dep = executable( + 'rust_bin_int_dep', + structured_sources(['internal_main.rs', internal_dep_rs]), + link_with : [c_lib, c_lib2], +) + +test('generated header dependency', rust_bin_int_dep) diff --git a/test cases/rust/12 bindgen/meson.build b/test cases/rust/12 bindgen/meson.build index b88aca2..c05cc06 100644 --- a/test cases/rust/12 bindgen/meson.build +++ b/test cases/rust/12 bindgen/meson.build @@ -1,5 +1,5 @@ # SPDX-license-identifer: Apache-2.0 -# Copyright © 2021 Intel Corporation +# Copyright © 2021-2022 Intel Corporation project('rustmod bindgen', ['c', 'rust'], meson_version : '>= 0.63') @@ -80,3 +80,4 @@ rust_bin2 = executable( test('generated header', rust_bin2) subdir('sub') +subdir('dependencies') |