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

[Minios-devel] [UNIKRAFT/PYTHON3 v5 12/14] 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 <costin.lupu@xxxxxxxxx>
Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>
---
 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 <Python.h>
+
+int main(int argc, char *argv[])
+{
+       return _Py_UnixMain(argc, argv);
+}
+
-- 
2.20.1


_______________________________________________
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®.