[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT/RUBY PATCH 15/16] Provide main() function if configured to do so



Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@xxxxxxxxx>

On Sun, Dec 8, 2019 at 11:56 AM Costin Lupu <costin.lupu@xxxxxxxxx> wrote:
>
> 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>
> ---
>  Config.uk           |  6 ++++++
>  Makefile.uk         |  1 +
>  ruby_main_example.c | 13 +++++++++++++
>  3 files changed, 20 insertions(+)
>  create mode 100644 ruby_main_example.c
>
> diff --git a/Config.uk b/Config.uk
> index 8f6d689..907b399 100644
> --- a/Config.uk
> +++ b/Config.uk
> @@ -22,6 +22,12 @@ config LIBRUBY_MINI
>         bool "Mini configuration"
>         default n
>
> +config LIBRUBY_MAIN_FUNCTION
> +       bool "Provide main function"
> +       select LIBVFSCORE_AUTOMOUNT_ROOTFS
> +       select LIBVFSCORE_ROOTFS_9PFS
> +       default n
> +
>  config LIBRUBY_EXT
>         bool "Enable extensions"
>         depends on !LIBRUBY_MINI
> diff --git a/Makefile.uk b/Makefile.uk
> index 74d8378..c120ac1 100644
> --- a/Makefile.uk
> +++ b/Makefile.uk
> @@ -92,6 +92,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

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.