From 2183aad753db9749d96ca2f5e005fdfae71a2c96 Mon Sep 17 00:00:00 2001 From: Costin Lupu Date: Wed, 16 Oct 2019 17:22:43 +0300 Subject: [PATCH] Provide main() function if configured to do so Sometimes all you want to run is the Python shell. In this case you can tick the option in menuconfig so that the library provides the main() function for you. Signed-off-by: Costin Lupu Reviewed-by: Felipe Huici --- Config.uk | 4 ++++ Makefile.uk | 1 + main.c | 8 ++++++++ 3 files changed, 13 insertions(+) create mode 100644 main.c diff --git a/Config.uk b/Config.uk index 530efbe..895c0c2 100644 --- a/Config.uk +++ b/Config.uk @@ -32,4 +32,8 @@ config LIBPYTHON3_TMPDIR string "Temp directory location" default "/tmp" +config LIBPYTHON3_MAIN_FUNCTION + bool "Provide main function" + default n + endif diff --git a/Makefile.uk b/Makefile.uk index f4c1c87..ed28f04 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -100,6 +100,7 @@ LIBPYTHON3_CXXINCLUDES-y += $(LIBPYTHON3_COMMON_INCLUDES-y) LIBPYTHON3_SRCS-y += $(LIBPYTHON3_BASE)/init.c|unikraft LIBPYTHON3_SRCS-y += $(LIBPYTHON3_BASE)/modules_config.c|unikraft LIBPYTHON3_SRCS-y += $(LIBPYTHON3_BASE)/stubs.c|unikraft +LIBPYTHON3_SRCS-$(CONFIG_LIBPYTHON3_MAIN_FUNCTION) += $(LIBPYTHON3_BASE)/main.c|unikraft ################################################################################ # Python core diff --git a/main.c b/main.c new file mode 100644 index 0000000..a79df2c --- /dev/null +++ b/main.c @@ -0,0 +1,8 @@ +#define Py_BUILD_CORE +#include + +int main(int argc, char *argv[]) +{ + return _Py_UnixMain(argc, argv); +} + -- 2.39.5