From nobody Sat Nov 15 16:07:44 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749819823; cv=none; d=zohomail.com; s=zohoarc; b=az3IrJxcD5VVwKEjdqAQeOqGlpTuzftDFbgd0GZwryouuV5EWT8kDzijxXt7Wmo0qwsCvQ3mLs+YwcdcldyIB43UzYM5GJg/NdiUq7Qp3BYt3vN/5uAZzlrW9E0oL0NxZClO6FcAyb5ZTnCw3plSvc9AtjuCOLZIoCY7JOOn7Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749819823; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m5umpPvvgjn/tpYWRO7zkHG7cUrCidjwdnI8p2wrau8=; b=jw9qN96ePXXBwbnm/VlX7Mm1anaFh9+drQapb+2uVOTiA1gv2/r2gO+cbOB8ncc253td2zvLUhQufRYtkKA3apLIeW6qenFOuGegHc7Y7VleJly64NJHmWMyKXSv41ldAGqcMIBgfDTi/7OZYHrZFglNYAyc96sXjz/7ckeW/Z8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174981982395482.1391449512547; Fri, 13 Jun 2025 06:03:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQ446-0000JO-3o; Fri, 13 Jun 2025 09:03:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ43i-00009c-7v for qemu-devel@nongnu.org; Fri, 13 Jun 2025 09:03:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ43f-0000Yb-NB for qemu-devel@nongnu.org; Fri, 13 Jun 2025 09:03:01 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-9CaGw-DMPG-ZWpjDnVzVkw-1; Fri, 13 Jun 2025 09:02:55 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a3696a0d3aso900611f8f.2 for ; Fri, 13 Jun 2025 06:02:55 -0700 (PDT) Received: from [192.168.122.1] ([151.49.64.79]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a568b087f8sm2338302f8f.53.2025.06.13.06.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 06:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749819779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m5umpPvvgjn/tpYWRO7zkHG7cUrCidjwdnI8p2wrau8=; b=MD842qGvjgYEUYeMzvHocZrumdzPQ2ZXPoIw6FMxNf6j/k1yQHtc/t3T6RInx7QNmJtEsP 0dWf7OaNpFKcloS8zbTzIdvgyG50+AqukVYMdUdOajtgXY0eA91vdEwcZx4rT3nzm5zCiN ziecl7XqdEzVPnG0dV3CwDOQo0H8hrg= X-MC-Unique: 9CaGw-DMPG-ZWpjDnVzVkw-1 X-Mimecast-MFC-AGG-ID: 9CaGw-DMPG-ZWpjDnVzVkw_1749819774 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749819774; x=1750424574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m5umpPvvgjn/tpYWRO7zkHG7cUrCidjwdnI8p2wrau8=; b=Jr0VFQpUQQjX0wT1vPLWdzYcVLSfdRc5bjznRdndoXXpprMMulaoP3v/o2XuyIkYs0 ZBwqGWYcUYu/wTEbkIsakttrJ1eEAYeqinvT/P13v+InITrEntHrZPM/T3xg9UF6bpxp 84KDP2pt+gN7ZGOpmxebLUqu81Auea2uDo0ZWvzI0XWdISeySsJ7zBsu2xjLJENzMlpi RJT/J/OtYyc2bG+xCaB4FEZTK5VZ4yO6mI3jQgf4gG9FNH+oeCITYmNB7UAhBWPKMW7V VxmtZny75f9Qs021OW0FI9t09bG4ZxNQzK9wVSq5xWfLMlfa/i+u8AvtbRgXGWvhXZdR 0UFg== X-Gm-Message-State: AOJu0YwdktZsTpdDjPD95NN/e0ZQ9xCEV2qJmtW1Dc0KuWtqZSGY18kc 0ksFNQDdWA3UhiQ7G+PoS3nKtDikM3u9d4PAQ2oA6zgJA8Ydts/kJcjReopSaDp0PBeqTd3+xBL AX75SgWT2wD1zXQRUXncnrIWifiO0NhLo2t6VAB6yBBSCRZ422JkoNOYs4rdhZmbnnJCvp5nh++ EGJ7nCHXB4FGROu238NQmrwTqzVNppHM1azGswuaWD X-Gm-Gg: ASbGncth3qB7o2bIR31XLdzc1LJHx0tko3mFrtE4WGEXwn7HeO+dbETl3zUaYzeSRkr 6fvpOA1+zaf5zKbBxBEF8B+Mz4Mq7z1m3O5+iB1/UuqixT2WNlm7CyFJfbAOXEfuC5YccOIcR5v AauSMTDbPt/TDHAWrSZaF2kJ6+kK0idmEyN78r+D5k4CQPtWWVXD19aTVzlMqRFTX1htGmVUfKa qU31VT4GKhtPFM++5TuIrYfKeYfvpl32SyL3mrEosgc466a1Oli4QSbSIVqa3VJD0zDCo/cjf9F NzXosfFyVtPpN0u2vB1YATHK X-Received: by 2002:a05:6000:2289:b0:3a5:2182:bce2 with SMTP id ffacd0b85a97d-3a568670d35mr3093299f8f.17.1749819773708; Fri, 13 Jun 2025 06:02:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7dPESzSJnMQK9ul1O+mcXOPsRqx6aLMWAt7BLIxvMa/wM99XZ8vHkYYbz9ON6yclE7voXKw== X-Received: by 2002:a05:6000:2289:b0:3a5:2182:bce2 with SMTP id ffacd0b85a97d-3a568670d35mr3093142f8f.17.1749819772004; Fri, 13 Jun 2025 06:02:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, tanishdesai37@gmail.com Subject: [PATCH 1/2] rust: prepare variable definitions for multiple bindgen invocations Date: Fri, 13 Jun 2025 15:02:48 +0200 Message-ID: <20250613130249.1225545-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613130249.1225545-1-pbonzini@redhat.com> References: <20250613130249.1225545-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749819826024116600 Content-Type: text/plain; charset="utf-8" When splitting the QEMU Rust bindings into multiple crates, the bindgen-generated structs also have to be split so that it's possible to add "impl" blocks (e.g. for Sync/Send or Default, or even for utility methods in cases such as VMStateFlags). Tweak various variable definitions in meson.build, to avoid naming conflicts once there will be multiple bindgen invocations. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- meson.build | 21 ++++++++++++--------- rust/meson.build | 2 +- rust/qemu-api/meson.build | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index ed60be2a2d0..d9838319dae 100644 --- a/meson.build +++ b/meson.build @@ -4200,10 +4200,11 @@ foreach target_base_arch, config_base_arch : config= _base_arch_mak endforeach =20 if have_rust + bindings_incdir =3D include_directories('.', 'include') # We would like to use --generate-cstr, but it is only available # starting with bindgen 0.66.0. The oldest supported versions # is 0.60.x (Debian 12 has 0.60.1) which introduces --allowlist-file. - bindgen_args =3D [ + bindgen_args_common =3D [ '--disable-header-comment', '--raw-line', '// @generated', '--ctypes-prefix', 'std::os::raw', @@ -4219,20 +4220,22 @@ if have_rust ] if not rustfmt.found() if bindgen.version().version_compare('<0.65.0') - bindgen_args +=3D ['--no-rustfmt-bindings'] + bindgen_args_common +=3D ['--no-rustfmt-bindings'] else - bindgen_args +=3D ['--formatter', 'none'] + bindgen_args_common +=3D ['--formatter', 'none'] endif endif if bindgen.version().version_compare('>=3D0.66.0') - bindgen_args +=3D ['--rust-target', '1.59'] + bindgen_args_common +=3D ['--rust-target', '1.59'] endif if bindgen.version().version_compare('<0.61.0') # default in 0.61+ - bindgen_args +=3D ['--size_t-is-usize'] + bindgen_args_common +=3D ['--size_t-is-usize'] else - bindgen_args +=3D ['--merge-extern-blocks'] + bindgen_args_common +=3D ['--merge-extern-blocks'] endif + + bindgen_args =3D [] c_enums =3D [ 'DeviceCategory', 'GpioPolarity', @@ -4264,13 +4267,13 @@ if have_rust # this case you must pass the path to `clang` and `libclang` to your bui= ld # command invocation using the environment variables CLANG_PATH and # LIBCLANG_PATH - bindings_rs =3D rust.bindgen( + _qemu_api_bindings_inc_rs =3D rust.bindgen( input: 'rust/wrapper.h', dependencies: common_ss.all_dependencies(), output: 'bindings.inc.rs', - include_directories: include_directories('.', 'include'), + include_directories: bindings_incdir, bindgen_version: ['>=3D0.60.0'], - args: bindgen_args, + args: bindgen_args_common + bindgen_args, ) subdir('rust') endif diff --git a/rust/meson.build b/rust/meson.build index 99ae7956cd0..e9f0879e296 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -33,5 +33,5 @@ if cargo.found() command: [config_host['MESON'], 'devenv', '--workdir', '@CURRENT_SOURCE_DIR@', cargo, 'fmt'], - depends: bindings_rs) + depends: _qemu_api_bindings_inc_rs) endif diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 33653b4a28e..64c04dfd74b 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -32,7 +32,7 @@ _qemu_api_rs =3D static_library( 'src/vmstate.rs', 'src/zeroable.rs', ], - {'.' : bindings_rs}, + {'.' : _qemu_api_bindings_inc_rs}, ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', --=20 2.49.0 From nobody Sat Nov 15 16:07:44 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749819859; cv=none; d=zohomail.com; s=zohoarc; b=T8ltQpL58qDOrBxgdAGIbN8dmljcd6eSAabPuSiSP2cX2/FtqHQFv4dF5KNHN+Ps2N2Ky9PwDYgcvw1z1hpXYTTlCmS7scXtteX5ViPPx97hgrNsJXHZeaLh1lyoVEPR+3CRflwVr4D8mc1Rf+wcQiSUEKraobjxt5h5PujUnUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749819859; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZA6ipBLWLrIC7AEh0eM3XoAiZ5TU/mlZesNKTaKlNBk=; b=Zhhd+VmgA/zCom0Tla9HdeC05AbeRHuhbj/Ebp4tXw20N7UTBe7ZMP44zG3VU+gb1M1dt2qyPKFZdliMNfK8bJoA6CsCZg8z5+T1ARCnqOYrMxYzgHtmu6jbTjPEsSidnH7r3fzhrfLk9PeSZ7PS8KfrtjD5BIpthNzL73YWPWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749819859063969.3490763261314; Fri, 13 Jun 2025 06:04:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQ44H-0000VY-Fe; Fri, 13 Jun 2025 09:03:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ43j-0000Ck-Tw for qemu-devel@nongnu.org; Fri, 13 Jun 2025 09:03:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ43h-0000Zj-Ss for qemu-devel@nongnu.org; Fri, 13 Jun 2025 09:03:03 -0400 Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-iy-AY0OQOMq5sETjARkz7A-1; Fri, 13 Jun 2025 09:02:58 -0400 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-553218c5adaso1042909e87.2 for ; Fri, 13 Jun 2025 06:02:58 -0700 (PDT) Received: from [192.168.122.1] ([151.49.64.79]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532e25e89fsm50539045e9.33.2025.06.13.06.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 06:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749819780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZA6ipBLWLrIC7AEh0eM3XoAiZ5TU/mlZesNKTaKlNBk=; b=bBrbh4u5jyBXcyzg5B4SaaLKla8vvUaPNt+N4lk476Hbkwjj2eomN3hngtqupHrQ0IrM+P lYnKKn+X8riNTvWfZK8tco7UvJ4WrDb+paRSQV7Rrc4iXNQW4XodC+oxKCeQSuHNH20aEG s9KSRs1GLaXYXG/ltwWokPrQxinigzc= X-MC-Unique: iy-AY0OQOMq5sETjARkz7A-1 X-Mimecast-MFC-AGG-ID: iy-AY0OQOMq5sETjARkz7A_1749819777 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749819776; x=1750424576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZA6ipBLWLrIC7AEh0eM3XoAiZ5TU/mlZesNKTaKlNBk=; b=RPqDvT34xp+7NF9Zle3qkD6T72W4C0UYheQ+Ktu/9zPKmkcR8DrSgwdcAQkIFGO7UG QP/wlymbcFXrVX3ZKnTG7NB5avw1pXU92OLVY0yLQGMh+nEtn0g2XFJh9vr6zooHCdrO 6n//MuCT3btQhHl0grQAbjOfM4hQTurlLw2huF6Ns3CLOACzdRe/2dW5TvGLU1fW7JZi GAy1C3q2M86L6d96aHYdHdIuPjzt0WPcxfWbxci2/GE4XgSugPkZ0i2fUV4BUcq8BCGZ J0Gf57zOXJfv2k6tCi2RJ9h9AACD4+tLWxZdMbYhIS/jmC0DbMrfqRzF+9zjhVftzpH+ ZGuw== X-Gm-Message-State: AOJu0Yzku0n5Nbg7WRgZtgoJFBYtJAg4ZWxTTSSWjFx0puwbUKxPAuGR FO5LJdhRTh3UIR3FC6JP9LfzTXVZfA/rm4tzBm7s4hVn91/G8z0qgwLJnsLVcixNg1xw9fay4Vh yxbJharu3XuU/qc7SEWYvV2mooD0C8ixls257z6QsgqCEU5nLs5c8MQyhON3fiY6CqLt93Gk2mR 0dJOYJtKjUMmXD8+sOy5ADs4GxHgv2MwtxQVZilole X-Gm-Gg: ASbGncthovkWzCiKHBF9lCorx85eKqVac3s2YCTurdTXbHgta1ZY74W2rPU2LjI4CEI /ulhuUZ7l0Qy5LGb7ssUhasy7bB0K531LXUB9DCh9/AtkJfxyv77elclTHHWnPDx8tALGCH7krw RBqthkE8lNLhOzv/ZJ0nCULW+SkQ04u9j/c0qA4Ok5GtiaMssIMIM0mNUXgrSunUJuwOqcM2kv/ gBgQhkoLr5ABxFrKI65f3Ieqcc6FMsdXsC9gxnD1ldQMG7q+WlkLXnQ7VR14jbt0aYFmlQcyA5y COb8TnsamfTaQloJ8JQD2DZO X-Received: by 2002:a05:6512:3b9e:b0:54f:c10b:7290 with SMTP id 2adb3069b0e04-553af990816mr679596e87.26.1749819775727; Fri, 13 Jun 2025 06:02:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpxJCiCgPC3g4pQu6RDNC9AT9wGHHLwPvV6P5CoOXSlnAU3g8YNDPvSc6gcFc/570e3/30jg== X-Received: by 2002:a05:6512:3b9e:b0:54f:c10b:7290 with SMTP id 2adb3069b0e04-553af990816mr679467e87.26.1749819774315; Fri, 13 Jun 2025 06:02:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, tanishdesai37@gmail.com Subject: [PATCH 2/2] rust: move rust.bindgen to qemu-api crate Date: Fri, 13 Jun 2025 15:02:49 +0200 Message-ID: <20250613130249.1225545-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613130249.1225545-1-pbonzini@redhat.com> References: <20250613130249.1225545-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749819860642116600 Content-Type: text/plain; charset="utf-8" Once qemu-api is split in multiple crates, each of which will have its own invocation of bindgen. There cannot be only one, because there are occasional "impl" blocks for the bindgen-generated structs (e.g. VMStateFlags or QOM classes) that have to reside in the same crate as the bindgen-generated code. For now, prepare for this new organization by invoking bindgen within the qemu-api crate's build definitions. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- meson.build | 41 ----------------------------------- rust/{ =3D> qemu-api}/wrapper.h | 0 rust/meson.build | 4 +++- rust/qemu-api/meson.build | 41 +++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 42 deletions(-) rename rust/{ =3D> qemu-api}/wrapper.h (100%) diff --git a/meson.build b/meson.build index d9838319dae..4676908dbb2 100644 --- a/meson.build +++ b/meson.build @@ -4234,47 +4234,6 @@ if have_rust else bindgen_args_common +=3D ['--merge-extern-blocks'] endif - - bindgen_args =3D [] - c_enums =3D [ - 'DeviceCategory', - 'GpioPolarity', - 'MachineInitPhase', - 'MemoryDeviceInfoKind', - 'MigrationPolicy', - 'MigrationPriority', - 'QEMUChrEvent', - 'QEMUClockType', - 'ResetType', - 'device_endian', - 'module_init_type', - ] - foreach enum : c_enums - bindgen_args +=3D ['--rustified-enum', enum] - endforeach - c_bitfields =3D [ - 'ClockEvent', - 'VMStateFlags', - ] - foreach enum : c_bitfields - bindgen_args +=3D ['--bitfield-enum', enum] - endforeach - - # TODO: Remove this comment when the clang/libclang mismatch issue is so= lved. - # - # Rust bindings generation with `bindgen` might fail in some cases where= the - # detected `libclang` does not match the expected `clang` version/target= . In - # this case you must pass the path to `clang` and `libclang` to your bui= ld - # command invocation using the environment variables CLANG_PATH and - # LIBCLANG_PATH - _qemu_api_bindings_inc_rs =3D rust.bindgen( - input: 'rust/wrapper.h', - dependencies: common_ss.all_dependencies(), - output: 'bindings.inc.rs', - include_directories: bindings_incdir, - bindgen_version: ['>=3D0.60.0'], - args: bindgen_args_common + bindgen_args, - ) subdir('rust') endif =20 diff --git a/rust/wrapper.h b/rust/qemu-api/wrapper.h similarity index 100% rename from rust/wrapper.h rename to rust/qemu-api/wrapper.h diff --git a/rust/meson.build b/rust/meson.build index e9f0879e296..331f11b7e72 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -20,6 +20,8 @@ proc_macro2_rs_native =3D dependency('proc-macro2-1-rs', = native: true) =20 qemuutil_rs =3D qemuutil.partial_dependency(link_args: true, links: true) =20 +genrs =3D [] + subdir('qemu-api-macros') subdir('bits') subdir('qemu-api') @@ -33,5 +35,5 @@ if cargo.found() command: [config_host['MESON'], 'devenv', '--workdir', '@CURRENT_SOURCE_DIR@', cargo, 'fmt'], - depends: _qemu_api_bindings_inc_rs) + depends: genrs) endif diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 64c04dfd74b..05d010e094f 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -7,6 +7,47 @@ if get_option('debug_mutex') _qemu_api_cfg +=3D ['--cfg', 'feature=3D"debug_cell"'] endif =20 +c_enums =3D [ + 'DeviceCategory', + 'GpioPolarity', + 'MachineInitPhase', + 'MemoryDeviceInfoKind', + 'MigrationPolicy', + 'MigrationPriority', + 'QEMUChrEvent', + 'QEMUClockType', + 'ResetType', + 'device_endian', + 'module_init_type', +] +_qemu_api_bindgen_args =3D [] +foreach enum : c_enums + _qemu_api_bindgen_args +=3D ['--rustified-enum', enum] +endforeach +c_bitfields =3D [ + 'ClockEvent', + 'VMStateFlags', +] +foreach enum : c_bitfields + _qemu_api_bindgen_args +=3D ['--bitfield-enum', enum] +endforeach + +# TODO: Remove this comment when the clang/libclang mismatch issue is solv= ed. +# +# Rust bindings generation with `bindgen` might fail in some cases where t= he +# detected `libclang` does not match the expected `clang` version/target. = In +# this case you must pass the path to `clang` and `libclang` to your build +# command invocation using the environment variables CLANG_PATH and +# LIBCLANG_PATH +_qemu_api_bindings_inc_rs =3D rust.bindgen( + input: 'wrapper.h', + dependencies: common_ss.all_dependencies(), + output: 'bindings.inc.rs', + include_directories: bindings_incdir, + bindgen_version: ['>=3D0.60.0'], + args: bindgen_args_common + _qemu_api_bindgen_args, + ) + _qemu_api_rs =3D static_library( 'qemu_api', structured_sources( --=20 2.49.0