mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject incubator-mynewt-larva git commit: Move shell command registration for lua to happen inside lua egg, instead of in the project.
Date Thu, 28 Jan 2016 18:00:29 GMT
Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master f36c61287 -> d8852809d


Move shell command registration for lua to happen inside lua egg,
instead of in the project.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/d8852809
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/d8852809
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/d8852809

Branch: refs/heads/master
Commit: d8852809dde736ffd1792d85edb1187f30cfefd5
Parents: f36c612
Author: Marko Kiiskila <marko@runtime.io>
Authored: Thu Jan 28 10:00:03 2016 -0800
Committer: Marko Kiiskila <marko@runtime.io>
Committed: Thu Jan 28 10:00:03 2016 -0800

----------------------------------------------------------------------
 libs/elua/elua_base/egg.yml                  |  4 +++-
 libs/elua/elua_base/include/elua_base/elua.h |  2 ++
 libs/elua/elua_base/src/lmynewt.c            | 25 +++++++++++++++++++++++
 project/luatest/src/main.c                   | 12 +----------
 4 files changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d8852809/libs/elua/elua_base/egg.yml
----------------------------------------------------------------------
diff --git a/libs/elua/elua_base/egg.yml b/libs/elua/elua_base/egg.yml
index 79b17b2..edb97fc 100644
--- a/libs/elua/elua_base/egg.yml
+++ b/libs/elua/elua_base/egg.yml
@@ -5,4 +5,6 @@ egg.req_caps:
     - console
 egg.deps:
     - fs/fs
-
+egg.deps.SHELL:
+    - libs/shell
+egg.cflags.SHELL: -DSHELL_PRESENT

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d8852809/libs/elua/elua_base/include/elua_base/elua.h
----------------------------------------------------------------------
diff --git a/libs/elua/elua_base/include/elua_base/elua.h b/libs/elua/elua_base/include/elua_base/elua.h
index 2578fd5..4f8b5eb 100644
--- a/libs/elua/elua_base/include/elua_base/elua.h
+++ b/libs/elua/elua_base/include/elua_base/elua.h
@@ -19,4 +19,6 @@
 
 int lua_main( int argc, char **argv );
 
+int lua_init(void);
+
 #endif /* __ELUA_BASE_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d8852809/libs/elua/elua_base/src/lmynewt.c
----------------------------------------------------------------------
diff --git a/libs/elua/elua_base/src/lmynewt.c b/libs/elua/elua_base/src/lmynewt.c
index ac66c44..0c768ef 100644
--- a/libs/elua/elua_base/src/lmynewt.c
+++ b/libs/elua/elua_base/src/lmynewt.c
@@ -13,4 +13,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <shell/shell.h>
+#include <elua_base/elua.h>
 
+#ifdef MYNEWT
+
+#ifdef SHELL_PRESENT
+static struct shell_cmd lua_shell_cmd;
+
+static int
+lua_cmd(int argc, char **argv)
+{
+    lua_main(argc, argv);
+    return 0;
+}
+#endif
+
+int
+lua_init(void)
+{
+#ifdef SHELL_PRESENT
+    return shell_cmd_register(&lua_shell_cmd, "lua", lua_cmd);
+#else
+    return 0;
+#endif
+}
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d8852809/project/luatest/src/main.c
----------------------------------------------------------------------
diff --git a/project/luatest/src/main.c b/project/luatest/src/main.c
index 5fefbc9..5c41ba9 100755
--- a/project/luatest/src/main.c
+++ b/project/luatest/src/main.c
@@ -35,18 +35,10 @@ int init_tasks(void);
 #define SHELL_TASK_PRIO      (8)
 #define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
 static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
-static struct shell_cmd lua_shell_cmd;
 
 /* NFFS */
 #define NFFS_AREA_MAX		16
 
-static int
-lua_cmd(int argc, char **argv)
-{
-    lua_main(argc, argv);
-    return 0;
-}
-
 static void
 create_script_file(void)
 {
@@ -95,9 +87,6 @@ main(int argc, char **argv)
     shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE);
     console_init(shell_console_rx_cb);
 
-    rc = shell_cmd_register(&lua_shell_cmd, "lua", lua_cmd);
-    assert(rc == 0);
-
     nffs_init();
 
     cnt = NFFS_AREA_MAX;
@@ -109,6 +98,7 @@ main(int argc, char **argv)
         assert(rc == 0);
     }
 
+    lua_init();
     create_script_file();
 
     /* Start the OS */


Mime
View raw message