[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT/RUBY PATCH v3 5/6] 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 | 2 ++ ruby_main_example.c | 15 +++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 ruby_main_example.c diff --git a/Config.uk b/Config.uk index e47eee3..e163687 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 9abef23..946afef 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -96,6 +96,8 @@ 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 +LIBRUBY_RUBY_MAIN_EXAMPLE_FLAGS-y = -DLIBRUBY_VERSION_LONG=\"$(LIBRUBY_VERSION_LONG)\" 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..33bf033 --- /dev/null +++ b/ruby_main_example.c @@ -0,0 +1,15 @@ +#include <stdlib.h> + +extern int ruby_main(int argc, char *argv[]); + +int main(int argc, char *argv[]) +{ + setenv("GEM_HOME", "/lib/ruby/gems/"LIBRUBY_VERSION_LONG, 0); + setenv("GEM_PATH", "/lib/ruby/gems/"LIBRUBY_VERSION_LONG, 0); + setenv("RUBYGEMS_GEMDEPS", "/lib/ruby/"LIBRUBY_VERSION_LONG"/Gemfile", 0); + setenv("RUBYLIB", "/lib/ruby/"LIBRUBY_VERSION_LONG":" + "/lib/ruby/"LIBRUBY_VERSION_LONG"/x86_64-linux:" + "/lib/ruby/"LIBRUBY_VERSION_LONG"/.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 |