|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT/RUBY PATCH 7/8] Provide main() function if configured to do so
We provide a configurable main() function for running Ruby out-of-the-box and
also for showing an example of such a function to be used by custom
applications. It also sets the necessary Ruby environment variables.
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@xxxxxxxxx>
---
Config.uk | 10 ++++++++++
Makefile.uk | 1 +
ruby_main_example.c | 13 +++++++++++++
3 files changed, 24 insertions(+)
create mode 100644 ruby_main_example.c
diff --git a/Config.uk b/Config.uk
index 48b9669..2125918 100644
--- a/Config.uk
+++ b/Config.uk
@@ -22,6 +22,16 @@ config LIBRUBY_MINI
bool "Mini configuration"
default n
+config LIBRUBY_MAIN_FUNCTION
+ bool "Provide main function"
+ imply LIBUKLIBPARAM
+ imply LIBVFSCORE_AUTOMOUNT_ROOTFS
+ imply LIBVFSCORE_ROOTFS_9PFS
+ imply LIBDEVFS_AUTOMOUNT
+ imply LIBDEVFS_DEV_NULL
+ imply LIBUK9P
+ default n
+
config LIBRUBY_EXT
bool "Enable extensions"
depends on !LIBRUBY_MINI
diff --git a/Makefile.uk b/Makefile.uk
index c832518..8333894 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -96,6 +96,7 @@ LIBRUBY_CFLAGS-y += -std=gnu99 -D_FORTIFY_SOURCE=2 \
-DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN
LIBRUBY_SRCS-y += $(LIBRUBY_BASE)/thread.c|unikraft
+LIBRUBY_SRCS-$(CONFIG_LIBRUBY_MAIN_FUNCTION) +=
$(LIBRUBY_BASE)/ruby_main_example.c|unikraft
ifeq ($(CONFIG_LIBRUBY_MINI),y)
LIBRUBY_SRCS-y += $(LIBRUBY_SRC)/dmydln.c
diff --git a/ruby_main_example.c b/ruby_main_example.c
new file mode 100644
index 0000000..8d711fb
--- /dev/null
+++ b/ruby_main_example.c
@@ -0,0 +1,13 @@
+#include <stdlib.h>
+
+extern int ruby_main(int argc, char *argv[]);
+
+int main(int argc, char *argv[])
+{
+ setenv("GEM_HOME", "/lib/ruby/gems/2.6.0", 0);
+ setenv("GEM_PATH", "/lib/ruby/gems/2.6.0", 0);
+ setenv("RUBYGEMS_GEMDEPS", "/lib/ruby/2.6.0/Gemfile", 0);
+ setenv("RUBYLIB",
"/lib/ruby/2.6.0/:/lib/ruby/2.6.0/x86_64-linux:/lib/ruby/2.6.0/.ext", 0);
+
+ return ruby_main(argc, argv);
+}
--
2.20.1
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |