From 4b565172d1f0f8962599219076b3246c63b1adf1 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 18 Oct 2018 20:17:05 +0200 Subject: [PATCH] iotjs: Add modules path option Change-Id: I1cc40989e45527c40d96838f12652610f7abbf85 Forwarded: https://github.com/Samsung/TizenRT/pull/2360 Signed-off-by: Philippe Coval --- apps/examples/iotjs_startup/Kconfig | 6 ++++++ apps/examples/iotjs_startup/iotjs_startup_main.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/apps/examples/iotjs_startup/Kconfig b/apps/examples/iotjs_startup/Kconfig index a684f9c707..9a9272f047 100644 --- a/apps/examples/iotjs_startup/Kconfig +++ b/apps/examples/iotjs_startup/Kconfig @@ -27,6 +27,12 @@ config EXAMPLES_IOTJS_STARTUP_JS_FILE ---help--- This is the name of the javascript loaded by IoT.js runtime +config EXAMPLES_IOTJS_EXTRA_MODULE_PATH + string "Directories used for external modules lookup" + default "/rom/example/iotjs_modules" + ---help--- + This is the name of the javascript loaded by IoT.js runtime + config EXAMPLES_IOTJS_STARTUP_WIFI bool "Connect WiFi" select WIFI_MANAGER diff --git a/apps/examples/iotjs_startup/iotjs_startup_main.c b/apps/examples/iotjs_startup/iotjs_startup_main.c index dc0a4e4a53..cca739193f 100644 --- a/apps/examples/iotjs_startup/iotjs_startup_main.c +++ b/apps/examples/iotjs_startup/iotjs_startup_main.c @@ -26,6 +26,10 @@ #define CONFIG_EXAMPLES_IOTJS_STARTUP_JS_FILE "/rom/example/index.js" #endif +#ifndef CONFIG_EXAMPLES_IOTJS_EXTRA_MODULE_PATH +#define CONFIG_EXAMPLES_IOTJS_EXTRA_MODULE_PATH "/rom/example/iotjs_modules" +#endif + #ifndef CONFIG_EXAMPLES_IOTJS_STARTUP_WIFI_SSID #define CONFIG_EXAMPLES_IOTJS_STARTUP_WIFI_SSID "public" #endif @@ -112,6 +116,7 @@ int main(int argc, FAR char *argv[]) int iotjs_startup_main(int argc, char *argv[]) #endif { + setenv("IOTJS_EXTRA_MODULE_PATH", CONFIG_EXAMPLES_IOTJS_EXTRA_MODULE_PATH, 1); chdir(dirname(CONFIG_EXAMPLES_IOTJS_STARTUP_JS_FILE)); char *targv[] = { "iotjs", CONFIG_EXAMPLES_IOTJS_STARTUP_JS_FILE }; int targc = 2;