qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Mads Ynddal" <mads@ynddal.dk>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Gustavo Romero" <gustavo.romero@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	rowan.hart@intel.com,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [RFC PATCH v5 1/8] build-sys: Add rust feature option
Date: Mon, 22 Jul 2024 14:43:31 +0300	[thread overview]
Message-ID: <cdba13875d38feb836468a73509d24a88c8332ca.1721648163.git.manos.pitsidianakis@linaro.org> (raw)
In-Reply-To: <rust-pl011-rfc-v5.git.manos.pitsidianakis@linaro.org>

Add rust feature in meson.build, configure, to prepare for adding Rust
code in the followup commits.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
---
 MAINTAINERS                   |  5 +++++
 configure                     | 12 ++++++++++++
 meson.build                   | 17 ++++++++++++++++-
 Kconfig                       |  1 +
 Kconfig.host                  |  3 +++
 meson_options.txt             |  5 +++++
 rust/Kconfig                  |  0
 scripts/meson-buildoptions.sh |  3 +++
 8 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 rust/Kconfig

diff --git a/MAINTAINERS b/MAINTAINERS
index 7d9811458c..d427f13b79 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4228,6 +4228,11 @@ F: docs/sphinx/
 F: docs/_templates/
 F: docs/devel/docs.rst
 
+Rust build system integration
+M: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
+S: Maintained
+F: rust/Kconfig
+
 Miscellaneous
 -------------
 Performance Tools and Tests
diff --git a/configure b/configure
index 019fcbd0ef..8476968b96 100755
--- a/configure
+++ b/configure
@@ -173,6 +173,7 @@ fi
 
 # default parameters
 container_engine="auto"
+have_rust="no"
 cpu=""
 cross_compile="no"
 cross_prefix=""
@@ -757,6 +758,15 @@ for opt do
   ;;
   --gdb=*) gdb_bin="$optarg"
   ;;
+  --enable-rust)
+    have_rust="yes" ;
+    meson_option_add -Dhave_rust=true
+  ;;
+  --disable-rust)
+    have_rust="no" ;
+    meson_option_add -Dhave_rust=false
+    meson_option_add -Ddisable_rust=true
+  ;;
   # everything else has the same name in configure and meson
   --*) meson_option_parse "$opt" "$optarg"
   ;;
@@ -874,6 +884,8 @@ Advanced options (experts only):
                            start the emulator (only use if you are including
                            desired devices in configs/devices/)
   --with-devices-ARCH=NAME override default configs/devices
+  --enable-rust            enable compilation of Rust code
+  --disable-rust           disable compilation of Rust code
   --enable-debug           enable common debug build options
   --cpu=CPU                Build for host CPU [$cpu]
   --disable-containers     don't use containers for cross-building
diff --git a/meson.build b/meson.build
index a1e51277b0..a3f346ab3c 100644
--- a/meson.build
+++ b/meson.build
@@ -70,6 +70,14 @@ if host_os == 'darwin' and \
   all_languages += ['objc']
   objc = meson.get_compiler('objc')
 endif
+if get_option('have_rust') and meson.version().version_compare('<1.0.0')
+  error('Rust support requires Meson version >=1.0.0')
+endif
+have_rust = false
+if not get_option('disable_rust') and add_languages('rust', required: get_option('have_rust'), native: false)
+  rustc = meson.get_compiler('rust')
+  have_rust = true
+endif
 
 dtrace = not_found
 stap = not_found
@@ -2119,6 +2127,7 @@ endif
 
 config_host_data = configuration_data()
 
+config_host_data.set('CONFIG_HAVE_RUST', have_rust)
 audio_drivers_selected = []
 if have_system
   audio_drivers_available = {
@@ -3038,7 +3047,8 @@ host_kconfig = \
   (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
   (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \
   (vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : []) + \
-  (hv_balloon ? ['CONFIG_HV_BALLOON_POSSIBLE=y'] : [])
+  (hv_balloon ? ['CONFIG_HV_BALLOON_POSSIBLE=y'] : []) + \
+  (have_rust ? ['CONFIG_HAVE_RUST=y'] : [])
 
 ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
 
@@ -4242,6 +4252,11 @@ if 'objc' in all_languages
 else
   summary_info += {'Objective-C compiler': false}
 endif
+summary_info += {'Rust support':      have_rust}
+if have_rust
+  summary_info += {'rustc version':      rustc.version()}
+  summary_info += {'rustc':      ' '.join(rustc.cmd_array())}
+endif
 option_cflags = (get_option('debug') ? ['-g'] : [])
 if get_option('optimization') != 'plain'
   option_cflags += ['-O' + get_option('optimization')]
diff --git a/Kconfig b/Kconfig
index fb6a24a2de..63ca7f46df 100644
--- a/Kconfig
+++ b/Kconfig
@@ -4,3 +4,4 @@ source accel/Kconfig
 source target/Kconfig
 source hw/Kconfig
 source semihosting/Kconfig
+source rust/Kconfig
diff --git a/Kconfig.host b/Kconfig.host
index 17f405004b..4ade7899d6 100644
--- a/Kconfig.host
+++ b/Kconfig.host
@@ -52,3 +52,6 @@ config VFIO_USER_SERVER_ALLOWED
 
 config HV_BALLOON_POSSIBLE
     bool
+
+config HAVE_RUST
+    bool
diff --git a/meson_options.txt b/meson_options.txt
index 0269fa0f16..9eef45f85b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -371,3 +371,8 @@ option('hexagon_idef_parser', type : 'boolean', value : true,
 
 option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'], value: '1',
        description: 'tweak required x86_64 architecture version beyond compiler default')
+
+option('have_rust', type: 'boolean', value: false,
+       description: 'Have Rust support')
+option('disable_rust', type: 'boolean', value: false,
+       description: 'Disable Rust support')
diff --git a/rust/Kconfig b/rust/Kconfig
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index c97079a38c..bb5854115a 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -170,6 +170,7 @@ meson_options_help() {
   printf "%s\n" '  rbd             Ceph block device driver'
   printf "%s\n" '  rdma            Enable RDMA-based migration'
   printf "%s\n" '  replication     replication support'
+  printf "%s\n" '  rust            Rust support'
   printf "%s\n" '  rutabaga-gfx    rutabaga_gfx support'
   printf "%s\n" '  sdl             SDL user interface'
   printf "%s\n" '  sdl-image       SDL Image support for icons'
@@ -556,6 +557,8 @@ _meson_option_parse() {
     --enable-whpx) printf "%s" -Dwhpx=enabled ;;
     --disable-whpx) printf "%s" -Dwhpx=disabled ;;
     --x86-version=*) quote_sh "-Dx86_version=$2" ;;
+    --enable-with-rust) printf "%s" -Dhave_rust=true ;;
+    --disable-with-rust) printf "%s" -Dhave_rust=false ;;
     --enable-xen) printf "%s" -Dxen=enabled ;;
     --disable-xen) printf "%s" -Dxen=disabled ;;
     --enable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=enabled ;;
-- 
γαῖα πυρί μιχθήτω



  reply	other threads:[~2024-07-22 11:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-22 11:43 [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011 Manos Pitsidianakis
2024-07-22 11:43 ` Manos Pitsidianakis [this message]
2024-07-23  6:37   ` [RFC PATCH v5 1/8] build-sys: Add rust feature option Zhao Liu
2024-07-23 10:13     ` Manos Pitsidianakis
2024-07-22 11:43 ` [RFC PATCH v5 2/8] build deps: update lcitool to include rust bits Manos Pitsidianakis
2024-07-23  8:31   ` Richard Henderson
2024-07-23 10:11     ` Manos Pitsidianakis
2024-07-22 11:43 ` [RFC PATCH v5 3/8] CI: Add build-system-rust-debian job Manos Pitsidianakis
2024-07-23  8:32   ` Richard Henderson
2024-07-23  8:39   ` Daniel P. Berrangé
2024-07-23 10:06     ` Manos Pitsidianakis
2024-07-23 10:11       ` Daniel P. Berrangé
2024-07-23 10:24         ` Manos Pitsidianakis
2024-07-22 11:43 ` [RFC PATCH v5 4/8] rust: add bindgen step as a meson dependency Manos Pitsidianakis
2024-07-22 11:43 ` [RFC PATCH v5 5/8] .gitattributes: add Rust diff and merge attributes Manos Pitsidianakis
2024-07-23  8:38   ` Zhao Liu
2024-07-22 11:43 ` [RFC PATCH v5 6/8] rust: add crate to expose bindings and interfaces Manos Pitsidianakis
2024-07-22 11:43 ` [RFC PATCH v5 7/8] rust: add PL011 device model Manos Pitsidianakis
2024-07-22 11:43 ` [RFC PATCH v5 8/8] rust/pl011: vendor dependencies Manos Pitsidianakis
2024-07-23  8:37   ` Zhao Liu
2024-07-23 10:19     ` Manos Pitsidianakis
2024-07-23 15:07 ` [RFC PATCH v5 0/8] Add Rust support, implement ARM PL011 Paolo Bonzini
2024-07-24  9:14   ` Manos Pitsidianakis
2024-07-24 10:34     ` Paolo Bonzini
2024-07-25  5:47       ` Manos Pitsidianakis
2024-07-25  9:50         ` Paolo Bonzini
2024-07-25 10:02           ` Manos Pitsidianakis
2024-07-25 11:19             ` Paolo Bonzini
2024-07-25 14:48               ` Manos Pitsidianakis
2024-07-25 15:15                 ` Paolo Bonzini
2024-07-26  7:12                   ` Manos Pitsidianakis
2024-07-26  8:19                     ` Paolo Bonzini
2024-07-26  9:26                       ` Manos Pitsidianakis
2024-07-31  9:41                         ` Manos Pitsidianakis
2024-07-31 10:35                           ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cdba13875d38feb836468a73509d24a88c8332ca.1721648163.git.manos.pitsidianakis@linaro.org \
    --to=manos.pitsidianakis@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=gustavo.romero@linaro.org \
    --cc=mads@ynddal.dk \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rowan.hart@intel.com \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).