diff options
Diffstat (limited to 'Examples/lua/embed')
-rw-r--r-- | Examples/lua/embed/Makefile | 6 | ||||
-rw-r--r-- | Examples/lua/embed/embed.c | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile index 57979c061..5e3a91893 100644 --- a/Examples/lua/embed/Makefile +++ b/Examples/lua/embed/Makefile @@ -9,12 +9,12 @@ LIBS = -lm # this is a little different to normal as we have our own special interpreter # which we want to static link check: build - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f $(TARGET) diff --git a/Examples/lua/embed/embed.c b/Examples/lua/embed/embed.c index 507567489..1f10cc8e8 100644 --- a/Examples/lua/embed/embed.c +++ b/Examples/lua/embed/embed.c @@ -13,6 +13,7 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <lua.h> #include <lauxlib.h> @@ -62,9 +63,13 @@ int main(int argc,char* argv[]) { luaopen_example(L); printf("[C] all looks ok\n"); printf("\n"); - printf("[C] let's load the file 'runme.lua'\n"); + if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) { + printf("[C] ERROR: no lua file given on command line\n"); + exit(3); + } + printf("[C] let's load the file '%s'\n", argv[1]); printf("[C] any lua code in this file will be executed\n"); - if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) { + if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) { printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1)); exit(3); } |