]> xenbits.xensource.com Git - unikraft/libs/duktape.git/commitdiff
Provide main(), jump into interactive mode. RELEASE-0.4 RELEASE-0.5
authorFelipe Huici <felipe.huici@neclab.eu>
Wed, 12 Feb 2020 13:54:22 +0000 (14:54 +0100)
committerSimon Kuenzer <simon.kuenzer@neclab.eu>
Thu, 13 Feb 2020 09:37:41 +0000 (10:37 +0100)
Add the ability for the duktape library to provide a main() so that
the application doesn't have to (selectable from the menu). In
addition, duktape now goes straight into interactive mode; previosuly
it was assuming that the --append parameter was a file name to be
read and executed, which was broken. At some point we should add
initrd support to this port.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.keunzer@neclab.eu>
Config.uk
Makefile.uk
glue.c [new file with mode: 0644]
patches/0001-jump-into-interactive-mode.patch [new file with mode: 0644]
patches/0001-rename-main-function.patch [deleted file]

index 6a3c59c329a3337843efae7b0e985bc2e3dda433..b9e2274e7f0a18e6aee2cde84ad843323c1b21b3 100644 (file)
--- a/Config.uk
+++ b/Config.uk
@@ -1,4 +1,10 @@
-config DUKTAPE
+menuconfig DUKTAPE
           bool "Duktape - an embeddable Javascript engine"
           default n
            select LIBNEWLIBC
+
+if DUKTAPE
+config DUKTAPE_MAIN_FUNCTION
+       bool "Provide main function"
+       default y
+endif
index 45dffcc5ae69b99beace4c558c681bc16f1f7cdd..bcb3defeb51034a50cdbeb2623b80178129ec4d5 100644 (file)
@@ -60,9 +60,17 @@ DUKTAPE_GENERATED=$(DUKTAPE_EXTRACTED)/duktape-src
 CINCLUDES-$(CONFIG_DUKTAPE) += -I$(DUKTAPE_EXTRACTED)/duktape-src
 CXXINCLUDES-$(CONFIG_DUKTAPE) += -I$(DUKTAPE_EXTRACTED)/duktape-src
 
+################################################################################
+# Library flags
+################################################################################
+DUKTAPE_CFLAGS-y += -Wno-unused-function
+DUKTAPE_CXXFLAGS-y += -Wno-unused-function
+
 ################################################################################
 # Sources
 ################################################################################
+DUKTAPE_DUK_CMDLINE_FLAGS-y += -Dmain=duktape_main
+DUKTAPE_SRCS-$(CONFIG_DUKTAPE_MAIN_FUNCTION) += $(DUKTAPE_BASE)/glue.c
 DUKTAPE_SRCS-y += $(DUKTAPE_GENERATED)/duktape.c
 DUKTAPE_SRCS-y += $(DUKTAPE_EXTRACTED)/examples/cmdline/duk_cmdline.c
 
diff --git a/glue.c b/glue.c
new file mode 100644 (file)
index 0000000..7cee52d
--- /dev/null
+++ b/glue.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+/* Import user configuration: */
+#include <uk/config.h>
+
+extern int duktape_main(int argc, char *argv[]);
+
+int main(int argc, char *argv[])
+{
+  return duktape_main(argc, argv);
+}
diff --git a/patches/0001-jump-into-interactive-mode.patch b/patches/0001-jump-into-interactive-mode.patch
new file mode 100644 (file)
index 0000000..7ba2f01
--- /dev/null
@@ -0,0 +1,28 @@
+--- a/examples/cmdline/duk_cmdline.c   2020-02-12 14:43:19.599772761 +0100
++++ b/examples/cmdline/duk_cmdline.c   2020-02-12 14:41:23.393106690 +0100
+@@ -1265,7 +1265,7 @@
+       int retval = 0;
+       int have_files = 0;
+       int have_eval = 0;
+-      int interactive = 0;
++      int interactive = 1;
+       int memlimit_high = 1;
+       int alloc_provider = ALLOC_DEFAULT;
+       int lowmem_log = 0;
+@@ -1456,6 +1456,7 @@
+                       continue;
+               }
++              /*
+               if (verbose) {
+                       fprintf(stderr, "*** Executing file: %s\n", arg);
+                       fflush(stderr);
+@@ -1465,7 +1466,7 @@
+                       retval = 1;
+                       goto cleanup;
+               }
+-
++              */
+               if (recreate_heap) {
+                       if (verbose) {
+                               fprintf(stderr, "*** Recreating heap...\n");
diff --git a/patches/0001-rename-main-function.patch b/patches/0001-rename-main-function.patch
deleted file mode 100644 (file)
index 8c4a8cc..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/examples/cmdline/duk_cmdline.c   2019-09-09 08:23:15.891284704 +0200
-+++ b/examples/cmdline/duk_cmdline.c   2019-09-09 08:22:57.783472251 +0200
-@@ -1260,7 +1260,7 @@
-  *  Main
-  */
--int main(int argc, char *argv[]) {
-+int duktape_main(int argc, char *argv[]) {
-       duk_context *ctx = NULL;
-       int retval = 0;
-       int have_files = 0;