From 79f17fa86352f3fc041081c783a63d51543eadf4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 24 Aug 2025 09:49:23 +0200 Subject: fix transient failure on rust/12 bindgen The test has a custom .h target that has the same name as the input in the test's source directory. Sometimes a compiler could build a target that intends to use the file in the source tree, but finds an incomplete output of the custom_target, causing the test to fail. To fix this, move the generated headers in a subdirectory of the build tree. Signed-off-by: Paolo Bonzini --- .../rust/12 bindgen/dependencies/internal_dep.h | 2 +- test cases/rust/12 bindgen/gen/gen_header.py | 19 +++++++++++++++++++ test cases/rust/12 bindgen/gen/meson.build | 13 +++++++++++++ test cases/rust/12 bindgen/meson.build | 15 +-------------- test cases/rust/12 bindgen/src/gen_header.py | 19 ------------------- 5 files changed, 34 insertions(+), 34 deletions(-) create mode 100644 test cases/rust/12 bindgen/gen/gen_header.py create mode 100644 test cases/rust/12 bindgen/gen/meson.build delete mode 100644 test cases/rust/12 bindgen/src/gen_header.py diff --git a/test cases/rust/12 bindgen/dependencies/internal_dep.h b/test cases/rust/12 bindgen/dependencies/internal_dep.h index b0629de78..f44e2787f 100644 --- a/test cases/rust/12 bindgen/dependencies/internal_dep.h +++ b/test cases/rust/12 bindgen/dependencies/internal_dep.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright © 2022 Intel Corporation -#include "gen.h" +#include "gen/gen.h" int64_t add64(const int64_t, const int64_t); diff --git a/test cases/rust/12 bindgen/gen/gen_header.py b/test cases/rust/12 bindgen/gen/gen_header.py new file mode 100644 index 000000000..07b699b1c --- /dev/null +++ b/test cases/rust/12 bindgen/gen/gen_header.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# SPDX-license-Identifier: Apache-2.0 +# Copyright © 2021-2023 Intel Corporation + +import argparse +import shutil + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument('input') + parser.add_argument('output') + args = parser.parse_args() + + shutil.copy2(args.input, args.output) + + +if __name__ == "__main__": + main() diff --git a/test cases/rust/12 bindgen/gen/meson.build b/test cases/rust/12 bindgen/gen/meson.build new file mode 100644 index 000000000..ff5fd84b9 --- /dev/null +++ b/test cases/rust/12 bindgen/gen/meson.build @@ -0,0 +1,13 @@ +gen_h = custom_target( + 'gen.h', + command : [find_program('gen_header.py'), '@INPUT@', '@OUTPUT@'], + output : 'gen.h', + input : meson.project_source_root() / 'src/header.h' +) + +gen2_h = custom_target( + 'other.h', + command : [find_program('gen_header.py'), '@INPUT@', '@OUTPUT@'], + output : 'other.h', + input : meson.project_source_root() / 'include/other.h' +) diff --git a/test cases/rust/12 bindgen/meson.build b/test cases/rust/12 bindgen/meson.build index 57e44a063..a0a52633d 100644 --- a/test cases/rust/12 bindgen/meson.build +++ b/test cases/rust/12 bindgen/meson.build @@ -66,20 +66,7 @@ rust_bin = executable( test('main', rust_bin) # Test a generated header -gen_h = custom_target( - 'gen.h', - command : [find_program('src/gen_header.py'), '@INPUT@', '@OUTPUT@'], - output : 'gen.h', - input : 'src/header.h' -) - -gen2_h = custom_target( - 'other.h', - command : [find_program('src/gen_header.py'), '@INPUT@', '@OUTPUT@'], - output : 'other.h', - input : 'include/other.h' -) - +subdir('gen') gen_rs = rust.bindgen( input : [gen_h, gen2_h], output : 'gen.rs', diff --git a/test cases/rust/12 bindgen/src/gen_header.py b/test cases/rust/12 bindgen/src/gen_header.py deleted file mode 100644 index 07b699b1c..000000000 --- a/test cases/rust/12 bindgen/src/gen_header.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-license-Identifier: Apache-2.0 -# Copyright © 2021-2023 Intel Corporation - -import argparse -import shutil - - -def main() -> None: - parser = argparse.ArgumentParser() - parser.add_argument('input') - parser.add_argument('output') - args = parser.parse_args() - - shutil.copy2(args.input, args.output) - - -if __name__ == "__main__": - main() -- cgit v1.2.3