Skip to content

Commit

Permalink
add standalone demo
Browse files Browse the repository at this point in the history
  • Loading branch information
pangweiwei committed Sep 27, 2017
1 parent 8a3619c commit 61c5b61
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 9 deletions.
12 changes: 11 additions & 1 deletion standalone/gmake/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ endif
ifeq ($(config),debug_any_cpu)
slua_standalone_config = debug_any_cpu
slua_standalone_tests_config = debug_any_cpu
slua_standalone_demo_config = debug_any_cpu
endif
ifeq ($(config),release_any_cpu)
slua_standalone_config = release_any_cpu
slua_standalone_tests_config = release_any_cpu
slua_standalone_demo_config = release_any_cpu
endif

PROJECTS := slua-standalone slua-standalone-tests
PROJECTS := slua-standalone slua-standalone-tests slua-standalone-demo

.PHONY: all clean help $(PROJECTS)

Expand All @@ -35,9 +37,16 @@ ifneq (,$(slua_standalone_tests_config))
@${MAKE} --no-print-directory -C . -f slua-standalone-tests.make config=$(slua_standalone_tests_config)
endif

slua-standalone-demo: slua-standalone
ifneq (,$(slua_standalone_demo_config))
@echo "==== Building slua-standalone-demo ($(slua_standalone_demo_config)) ===="
@${MAKE} --no-print-directory -C . -f slua-standalone-demo.make config=$(slua_standalone_demo_config)
endif

clean:
@${MAKE} --no-print-directory -C . -f slua-standalone.make clean
@${MAKE} --no-print-directory -C . -f slua-standalone-tests.make clean
@${MAKE} --no-print-directory -C . -f slua-standalone-demo.make clean

help:
@echo "Usage: make [config=name] [target]"
Expand All @@ -51,5 +60,6 @@ help:
@echo " clean"
@echo " slua-standalone"
@echo " slua-standalone-tests"
@echo " slua-standalone-demo"
@echo ""
@echo "For more information, see http://industriousone.com/premake/quick-start"
113 changes: 113 additions & 0 deletions standalone/gmake/slua-standalone-demo.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# GNU Make project makefile autogenerated by Premake

ifndef config
config=debug_any_cpu
endif

ifndef verbose
SILENT = @
endif

.PHONY: clean prebuild prelink

ifeq ($(config),debug_any_cpu)
CSC = mcs
RESGEN = resgen
TARGETDIR = ../bin
TARGET = $(TARGETDIR)/slua-standalone-demo.exe
OBJDIR = obj/Any\ CPU/Debug/slua-standalone-demo
FLAGS = /unsafe /debug /noconfig /d:_DEBUG /d:DEBUG /d:TRACE
DEPENDS = ../bin/slua-standalone.dll
REFERENCES = /r:../bin/slua-standalone.dll
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
endif

ifeq ($(config),release_any_cpu)
CSC = mcs
RESGEN = resgen
TARGETDIR = ../bin
TARGET = $(TARGETDIR)/slua-standalone-demo.exe
OBJDIR = obj/Any\ CPU/Release/slua-standalone-demo
FLAGS = /unsafe /optimize /noconfig
DEPENDS = ../bin/slua-standalone.dll
REFERENCES = /r:../bin/slua-standalone.dll
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
endif

FLAGS += /t:exe
REFERENCES += /r:System /r:../packages/NUnit.2.6.4/lib/nunit.framework.dll

SOURCES += \
../slua-standalone-tests/Demo.cs \
../slua-standalone-tests/TestArray.cs \
../slua-standalone-tests/TestClass.cs \
../slua-standalone-tests/TestDLL.cs \
../slua-standalone-tests/TestEnum.cs \
../slua-standalone-tests/TestProperty.cs \
../slua-standalone-tests/TestSLua.cs \
../slua-standalone-tests/TestStruct.cs \

EMBEDFILES += \

RESPONSE += $(OBJDIR)/slua-standalone-demo.rsp
SHELLTYPE := msdos
ifeq (,$(ComSpec)$(COMSPEC))
SHELLTYPE := posix
endif
ifeq (/bin,$(findstring /bin,$(SHELL)))
SHELLTYPE := posix
endif

all: $(TARGETDIR) $(OBJDIR) prebuild $(EMBEDFILES) $(COPYFILES) prelink $(TARGET)

$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS) $(RESPONSE)
$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) @$(RESPONSE) $(patsubst %,/resource:%,$(EMBEDFILES))
$(POSTBUILDCMDS)

$(TARGETDIR):
@echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif

$(RESPONSE): slua-standalone-demo.make
@echo Generating response file
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(RESPONSE)
else
$(SILENT) if exist $(RESPONSE) del $(OBJDIR)\slua-standalone-demo.rsp
endif
@echo ../slua-standalone-tests/Demo.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestArray.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestClass.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestDLL.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestEnum.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestProperty.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestSLua.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestStruct.cs >> $(RESPONSE)

$(OBJDIR):
@echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif

prebuild:
$(PREBUILDCMDS)

prelink:
$(PRELINKCMDS)
6 changes: 4 additions & 2 deletions standalone/gmake/slua-standalone-tests.make
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ifeq ($(config),debug_any_cpu)
TARGETDIR = ../bin
TARGET = $(TARGETDIR)/slua-standalone-tests.dll
OBJDIR = obj/Any\ CPU/Debug/slua-standalone-tests
FLAGS = /debug /noconfig /d:_DEBUG /d:DEBUG /d:TRACE
FLAGS = /unsafe /debug /noconfig /d:_DEBUG /d:DEBUG /d:TRACE
DEPENDS = ../bin/slua-standalone.dll
REFERENCES = /r:../bin/slua-standalone.dll
define PREBUILDCMDS
Expand All @@ -33,7 +33,7 @@ ifeq ($(config),release_any_cpu)
TARGETDIR = ../bin
TARGET = $(TARGETDIR)/slua-standalone-tests.dll
OBJDIR = obj/Any\ CPU/Release/slua-standalone-tests
FLAGS = /optimize /noconfig
FLAGS = /unsafe /optimize /noconfig
DEPENDS = ../bin/slua-standalone.dll
REFERENCES = /r:../bin/slua-standalone.dll
define PREBUILDCMDS
Expand All @@ -48,6 +48,7 @@ FLAGS += /t:library
REFERENCES += /r:System /r:../packages/NUnit.2.6.4/lib/nunit.framework.dll

SOURCES += \
../slua-standalone-tests/Demo.cs \
../slua-standalone-tests/TestArray.cs \
../slua-standalone-tests/TestClass.cs \
../slua-standalone-tests/TestDLL.cs \
Expand Down Expand Up @@ -88,6 +89,7 @@ ifeq (posix,$(SHELLTYPE))
else
$(SILENT) if exist $(RESPONSE) del $(OBJDIR)\slua-standalone-tests.rsp
endif
@echo ../slua-standalone-tests/Demo.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestArray.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestClass.cs >> $(RESPONSE)
@echo ../slua-standalone-tests/TestDLL.cs >> $(RESPONSE)
Expand Down
8 changes: 4 additions & 4 deletions standalone/gmake/slua-standalone.make
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ifeq ($(config),debug_any_cpu)
TARGETDIR = ../bin
TARGET = $(TARGETDIR)/slua-standalone.dll
OBJDIR = obj/Any\ CPU/Debug/slua-standalone
FLAGS = /debug /noconfig /d:_DEBUG /d:DEBUG /d:TRACE /d:SLUA_STANDALONE /d:UNITY_STANDALONE_WIN /d:UNITY_STANDALONE
FLAGS = /unsafe /debug /noconfig /d:_DEBUG /d:DEBUG /d:TRACE /d:SLUA_STANDALONE /d:UNITY_STANDALONE_WIN /d:UNITY_STANDALONE
DEPENDS =
REFERENCES =
define PREBUILDCMDS
Expand All @@ -33,7 +33,7 @@ ifeq ($(config),release_any_cpu)
TARGETDIR = ../bin
TARGET = $(TARGETDIR)/slua-standalone.dll
OBJDIR = obj/Any\ CPU/Release/slua-standalone
FLAGS = /optimize /noconfig /d:SLUA_STANDALONE /d:UNITY_STANDALONE_WIN /d:UNITY_STANDALONE
FLAGS = /unsafe /optimize /noconfig /d:SLUA_STANDALONE /d:UNITY_STANDALONE_WIN /d:UNITY_STANDALONE
DEPENDS =
REFERENCES =
define PREBUILDCMDS
Expand All @@ -44,7 +44,7 @@ ifeq ($(config),release_any_cpu)
endef
endif

FLAGS += /t:library /unsafe
FLAGS += /t:library
REFERENCES += /r:System /r:System.Core

SOURCES += \
Expand All @@ -71,7 +71,7 @@ SOURCES += \
../../Assets/Plugins/Slua_Managed/SLuaSetting.cs \
../../Assets/Plugins/Slua_Managed/Timer.cs \
../../Assets/Plugins/Slua_Managed/WeakDictionary.cs \
/Users/siney/slua/build/BytesHelper.cs \
../../build/BytesHelper.cs \

EMBEDFILES += \

Expand Down
28 changes: 26 additions & 2 deletions standalone/premake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ solution "slua-standalone"
--filter "platforms:x32"
--architecture "x32"
configuration "Debug"
flags { "Symbols" }
symbols "on"
clr "unsafe"
defines { "_DEBUG", "DEBUG", "TRACE" }
configuration "Release"
flags { "Optimize" }
optimize "on"
clr "unsafe"
configuration "vs*"
defines { "" }

Expand Down Expand Up @@ -69,3 +71,25 @@ links
"System",
"./packages/NUnit.2.6.4/lib/nunit.framework.dll",
}

project "slua-standalone-demo"
language "C#"
kind "ConsoleApp"
framework "3.5"
targetdir "./bin"

files
{
"./slua-standalone-tests/**.cs",
}

defines
{
}

links
{
"slua-standalone",
"System",
"./packages/NUnit.2.6.4/lib/nunit.framework.dll",
}
28 changes: 28 additions & 0 deletions standalone/slua-standalone-tests/Demo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using SLua;


public class Demo
{
private LuaSvr luaSvr;

static public void Main() {
Demo demo = new Demo();
demo.Init();
}

public void Init()
{
luaSvr = new LuaSvr();
luaSvr.init(null,onComplete);
}
void onComplete() {
Console.WriteLine("complete");
string txt=@"
local a=1
local b=2
print('result',a+b)
";
LuaSvr.mainState.doString(txt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
compatible with the code `DLLImport("slua")`
-->
<dllmap dll="slua" target="slua.so"/>
<dllmap dll="slua" target="../Assets/Plugins/slua.bundle/Contents/MacOS/slua" os="osx"/>
</configuration>

0 comments on commit 61c5b61

Please sign in to comment.