]> xenbits.xensource.com Git - unikraft/libs/python3.git/commitdiff
Provide main() function if configured to do so
authorCostin Lupu <costin.lupu@cs.pub.ro>
Wed, 16 Oct 2019 14:22:43 +0000 (17:22 +0300)
committerCostin Lupu <costin.lupu@cs.pub.ro>
Thu, 17 Oct 2019 12:26:38 +0000 (15:26 +0300)
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 <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Config.uk
Makefile.uk
main.c [new file with mode: 0644]

index 530efbe59363942630e1fb1a88277b3ecb780c30..895c0c205d187c5bc540b9291ea4e51df19c9aa2 100644 (file)
--- 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
index f4c1c87913604d567ae219adfcc2630b94fbfc89..ed28f0418b01a0e7eb22e07cea935216170d1f34 100644 (file)
@@ -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 (file)
index 0000000..a79df2c
--- /dev/null
+++ b/main.c
@@ -0,0 +1,8 @@
+#define Py_BUILD_CORE
+#include <Python.h>
+
+int main(int argc, char *argv[])
+{
+       return _Py_UnixMain(argc, argv);
+}
+