diff --git a/Makefile b/Makefile index 8a2d39a7..b27f0d20 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,8 @@ DUKTAPE_CMDLINE_SOURCES = \ extras/print-alert/duk_print_alert.c \ extras/console/duk_console.c \ extras/logging/duk_logging.c \ - extras/module-duktape/duk_module_duktape.c + extras/module-duktape/duk_module_duktape.c \ + extras/cbor/duk_cbor.c ifdef SYSTEMROOT # Windows DUKTAPE_CMDLINE_SOURCES += examples/debug-trans-socket/duk_trans_socket_windows.c else @@ -108,6 +109,7 @@ CCOPTS_SHARED += -DDUK_CMDLINE_PRINTALERT_SUPPORT CCOPTS_SHARED += -DDUK_CMDLINE_CONSOLE_SUPPORT CCOPTS_SHARED += -DDUK_CMDLINE_LOGGING_SUPPORT CCOPTS_SHARED += -DDUK_CMDLINE_MODULE_SUPPORT +CCOPTS_SHARED += -DDUK_CMDLINE_CBOR_SUPPORT ifdef SYSTEMROOT # Windows # Skip fancy (linenoise) else @@ -143,6 +145,7 @@ CCOPTS_SHARED += -I./extras/print-alert CCOPTS_SHARED += -I./extras/console CCOPTS_SHARED += -I./extras/logging CCOPTS_SHARED += -I./extras/module-duktape +CCOPTS_SHARED += -I./extras/cbor #CCOPTS_SHARED += -m32 # force 32-bit compilation on a 64-bit host #CCOPTS_SHARED += -mx32 # force X32 compilation on a 64-bit host #CCOPTS_SHARED += -fstack-usage # enable manually, then e.g. $ make clean duk; python util/pretty_stack_usage.py duktape.su @@ -164,9 +167,9 @@ CLANG_CCOPTS_NONDEBUG += -Wcomma GXXOPTS_SHARED = -pedantic -ansi -std=c++11 -fstrict-aliasing -Wall -Wextra -Wunused-result -Wunused-function GXXOPTS_SHARED += -DDUK_CMDLINE_PRINTALERT_SUPPORT GXXOPTS_NONDEBUG = $(GXXOPTS_SHARED) -Os -fomit-frame-pointer -GXXOPTS_NONDEBUG += -I./examples/alloc-logging -I./examples/alloc-torture -I./examples/alloc-hybrid -I./extras/print-alert -I./extras/console -I./extras/logging -I./extras/module-duktape +GXXOPTS_NONDEBUG += -I./examples/alloc-logging -I./examples/alloc-torture -I./examples/alloc-hybrid -I./extras/print-alert -I./extras/console -I./extras/logging -I./extras/module-duktape -I./extras/cbor GXXOPTS_DEBUG = $(GXXOPTS_SHARED) -O0 -g -ggdb -GXXOPTS_DEBUG += -I./examples/alloc-logging -I./examples/alloc-torture -I./examples/alloc-hybrid -I./extras/print-alert -I./extras/console -I./extras/logging -I./extras/module-duktape +GXXOPTS_DEBUG += -I./examples/alloc-logging -I./examples/alloc-torture -I./examples/alloc-hybrid -I./extras/print-alert -I./extras/console -I./extras/logging -I./extras/module-duktape -I./extras/cbor CCOPTS_DUKLOW = -m32 CCOPTS_DUKLOW += -flto -fno-asynchronous-unwind-tables -ffunction-sections -Wl,--gc-sections diff --git a/examples/cmdline/duk_cmdline.c b/examples/cmdline/duk_cmdline.c index b55ec660..06094d5b 100644 --- a/examples/cmdline/duk_cmdline.c +++ b/examples/cmdline/duk_cmdline.c @@ -12,6 +12,9 @@ * - To enable Duktape.Logger, define DUK_CMDLINE_LOGGING_SUPPORT * and add extras/logging/duk_logging.c to compilation. * + * - To enable CBOR, define DUK_CMDLINE_CBOR_SUPPORT and add + * extras/cbor/duk_cbor.c to compilation. + * * - To enable Duktape 1.x module loading support (require(), * Duktape.modSearch() etc), define DUK_CMDLINE_MODULE_SUPPORT and add * extras/module-duktape/duk_module_duktape.c to compilation. @@ -68,6 +71,9 @@ #if defined(DUK_CMDLINE_MODULE_SUPPORT) #include "duk_module_duktape.h" #endif +#if defined(DUK_CMDLINE_CBOR_SUPPORT) +#include "duk_cbor.h" +#endif #if defined(DUK_CMDLINE_FILEIO) #include #endif @@ -1164,6 +1170,11 @@ static duk_context *create_duktape_heap(int alloc_provider, int debugger, int lo duk_module_duktape_init(ctx); #endif + /* Register CBOR. */ +#if defined(DUK_CMDLINE_CBOR_SUPPORT) + duk_cbor_init(ctx, 0 /*flags*/); +#endif + /* Trivial readFile/writeFile bindings for testing. */ #if defined(DUK_CMDLINE_FILEIO) duk_push_c_function(ctx, fileio_read_file, 1 /*nargs*/);