From: Hiroyuki_Katsura <hiroyuki.katsura.0513(a)gmail.com>
---
Makefile.am | 4 ++++
configure.ac | 3 +++
generator/Makefile.am | 3 +++
generator/bindtests.ml | 3 +++
generator/bindtests.mli | 1 +
generator/main.ml | 5 +++++
generator/rust.ml | 34 ++++++++++++++++++++++++++++++++++
generator/rust.mli | 19 +++++++++++++++++++
m4/guestfs-rust.m4 | 30 ++++++++++++++++++++++++++++++
rust/Cargo.toml | 6 ++++++
rust/Makefile.am | 29 +++++++++++++++++++++++++++++
rust/src/.gitkeep | 0
rust/tests/.gitkeep | 0
13 files changed, 137 insertions(+)
create mode 100644 generator/rust.ml
create mode 100644 generator/rust.mli
create mode 100644 m4/guestfs-rust.m4
create mode 100644 rust/Cargo.toml
create mode 100644 rust/Makefile.am
create mode 100644 rust/src/.gitkeep
create mode 100644 rust/tests/.gitkeep
diff --git a/Makefile.am b/Makefile.am
index b5f33f62b..69142cf41 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -151,6 +151,10 @@ endif
if HAVE_GOLANG
SUBDIRS += golang golang/examples
endif
+if HAVE_RUST
+SUBDIRS += rust
+endif
+
# Unconditional because nothing is built yet.
SUBDIRS += csharp
diff --git a/configure.ac b/configure.ac
index 6b701bef2..f9bdbe54b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,8 @@ HEADING([Checking for Go])
m4_include([m4/guestfs-golang.m4])
HEADING([Checking for GObject Introspection])
m4_include([m4/guestfs-gobject.m4])
+HEADING([Checking for Rust])
+m4_include([m4/guestfs-rust.m4])
HEADING([Checking for Vala])
VAPIGEN_CHECK
@@ -315,6 +317,7 @@ AC_CONFIG_FILES([Makefile
ruby/Rakefile
ruby/examples/Makefile
ruby/ext/guestfs/extconf.rb
+ rust/Makefile
sparsify/Makefile
sysprep/Makefile
test-data/Makefile
diff --git a/generator/Makefile.am b/generator/Makefile.am
index 07872d49c..676c08ce5 100644
--- a/generator/Makefile.am
+++ b/generator/Makefile.am
@@ -105,6 +105,8 @@ sources = \
p2v_config.mli \
ruby.ml \
ruby.mli \
+ rust.ml \
+ rust.mli \
structs.ml \
structs.mli \
tests_c_api.ml \
@@ -163,6 +165,7 @@ objects = \
lua.cmo \
GObject.cmo \
golang.cmo \
+ rust.cmo \
bindtests.cmo \
errnostring.cmo \
customize.cmo \
diff --git a/generator/bindtests.ml b/generator/bindtests.ml
index 58d7897b3..8a5682d5e 100644
--- a/generator/bindtests.ml
+++ b/generator/bindtests.ml
@@ -983,6 +983,9 @@ and generate_php_bindtests () =
dump "bindtests"
+and generate_rust_bindtests () =
+ generate_header CStyle GPLv2plus
+
(* Language-independent bindings tests - we do it this way to
* ensure there is parity in testing bindings across all languages.
*)
diff --git a/generator/bindtests.mli b/generator/bindtests.mli
index 6f469b3a1..0e18a4c44 100644
--- a/generator/bindtests.mli
+++ b/generator/bindtests.mli
@@ -28,3 +28,4 @@ val generate_perl_bindtests : unit -> unit
val generate_php_bindtests : unit -> unit
val generate_python_bindtests : unit -> unit
val generate_ruby_bindtests : unit -> unit
+val generate_rust_bindtests : unit -> unit
diff --git a/generator/main.ml b/generator/main.ml
index 7974550c5..5de89138c 100644
--- a/generator/main.ml
+++ b/generator/main.ml
@@ -372,6 +372,11 @@ Run it from the top source directory using the command
output_to "p2v/virt-p2v-kernel-config.pod"
P2v_config.generate_p2v_kernel_config_pod;
+ output_to "rust/src/lib.rs"
+ Rust.generate_rust;
+ output_to "rust/tests/bind_test.rs"
+ Bindtests.generate_rust_bindtests;
+
(* Generate the list of files generated -- last. *)
printf "generated %d lines of code\n" (get_lines_generated ());
let files = List.sort compare (get_files_generated ()) in
diff --git a/generator/rust.ml b/generator/rust.ml
new file mode 100644
index 000000000..40ca8d198
--- /dev/null
+++ b/generator/rust.ml
@@ -0,0 +1,34 @@
+(* libguestfs
+ * Copyright (C) 2019 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*)
+
+(* Please read generator/README first. *)
+
+open Std_utils
+open Types
+open Utils
+open Pr
+open Docstrings
+open Optgroups
+open Actions
+open Structs
+open C
+open Events
+
+let generate_rust () =
+ generate_header CStyle LGPLv2plus
+
diff --git a/generator/rust.mli b/generator/rust.mli
new file mode 100644
index 000000000..4fef55d4e
--- /dev/null
+++ b/generator/rust.mli
@@ -0,0 +1,19 @@
+(* libguestfs
+ * Copyright (C) 2009-2019 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*)
+
+val generate_rust: unit -> unit
\ No newline at end of file
diff --git a/m4/guestfs-rust.m4 b/m4/guestfs-rust.m4
new file mode 100644
index 000000000..f46ce960b
--- /dev/null
+++ b/m4/guestfs-rust.m4
@@ -0,0 +1,30 @@
+# libguestfs
+# Copyright (C) 2009-2019 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+dnl Rust
+AC_ARG_ENABLE([rust],
+ AS_HELP_STRING([--disable-rust], [disable Rust language bindings]),
+ [],
+ [enable_rust=yes])
+AS_IF([test "x$enable_rust" != "xno"],[
+ AC_CHECK_PROG([RUSTC],[rustc],[rustc],[no])
+ AC_CHECK_PROG([CARGO],[cargo],[cargo],[no])
+],[
+ RUSTC=no
+ CARGO=no
+ ])
+AM_CONDITIONAL([HAVE_RUST],[test "x$RUSTC" != "xno" && test
"x$CARGO" != "xno"])
\ No newline at end of file
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
new file mode 100644
index 000000000..e730ee830
--- /dev/null
+++ b/rust/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "rust"
+version = "0.1.0"
+edition = "2018"
+
+[dependencies]
diff --git a/rust/Makefile.am b/rust/Makefile.am
new file mode 100644
index 000000000..e8bf27894
--- /dev/null
+++ b/rust/Makefile.am
@@ -0,0 +1,29 @@
+# libguestfs golang bindings
+# Copyright (C) 2019 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include $(top_srcdir)/subdir-rules.mk
+
+generator_built = \
+ src/lib.rs
+
+EXTRA_DIST = \
+ $(generator_built)
+
+if HAVE_RUST
+
+endif
+
diff --git a/rust/src/.gitkeep b/rust/src/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/rust/tests/.gitkeep b/rust/tests/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--
2.20.1 (Apple Git-117)