add lua build tag

maybe install golua error, and lua cannot be used
This commit is contained in:
siddontang 2014-09-04 16:39:23 +08:00
parent 8ad6eabd6a
commit b9ea592026
8 changed files with 41 additions and 4 deletions

View File

@ -16,4 +16,4 @@ go get github.com/BurntSushi/toml
go get github.com/siddontang/go-bson/bson go get github.com/siddontang/go-bson/bson
go get github.com/aarzilli/golua/lua go get github.com/siddontang/golua/lua

7
dev.sh
View File

@ -74,6 +74,13 @@ if [ -f $HYPERLEVELDB_DIR/include/hyperleveldb/c.h ]; then
GO_BUILD_TAGS="$GO_BUILD_TAGS hyperleveldb" GO_BUILD_TAGS="$GO_BUILD_TAGS hyperleveldb"
fi fi
#check lua
CHECK_LUA_FILE="$LEDISTOP/tools/check_lua.go"
go run $CHECK_LUA_FILE 2>/dev/null
if [ "$?" = 0 ]; then
GO_BUILD_TAGS="$GO_BUILD_TAGS lua"
fi
export CGO_CFLAGS export CGO_CFLAGS
export CGO_CXXFLAGS export CGO_CXXFLAGS
export CGO_LDFLAGS export CGO_LDFLAGS

View File

@ -1,10 +1,12 @@
// +build lua
package server package server
import ( import (
"crypto/sha1" "crypto/sha1"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/aarzilli/golua/lua" "github.com/siddontang/golua/lua"
"github.com/siddontang/ledisdb/ledis" "github.com/siddontang/ledisdb/ledis"
"strconv" "strconv"
"strings" "strings"

View File

@ -1,3 +1,5 @@
// +build lua
package server package server
import ( import (

View File

@ -1,9 +1,11 @@
// +build lua
package server package server
import ( import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/aarzilli/golua/lua" "github.com/siddontang/golua/lua"
"github.com/siddontang/ledisdb/ledis" "github.com/siddontang/ledisdb/ledis"
"io" "io"
"sync" "sync"
@ -159,6 +161,10 @@ func (app *App) openScript() {
l.OpenTable() l.OpenTable()
l.OpenPackage() l.OpenPackage()
l.OpenCJson()
l.OpenCMsgpack()
l.OpenStruct()
l.Register("error", luaErrorHandler) l.Register("error", luaErrorHandler)
s.l = l s.l = l

10
server/script_dummy.go Normal file
View File

@ -0,0 +1,10 @@
// +build !lua
package server
type script struct {
}
func (app *App) openScript() {}
func (app *App) closeScript() {}

View File

@ -1,8 +1,10 @@
// +build lua
package server package server
import ( import (
"fmt" "fmt"
"github.com/aarzilli/golua/lua" "github.com/siddontang/golua/lua"
"github.com/siddontang/ledisdb/config" "github.com/siddontang/ledisdb/config"
"testing" "testing"

8
tools/check_lua.go Normal file
View File

@ -0,0 +1,8 @@
package main
import "github.com/siddontang/golua/lua"
func main() {
L := lua.NewState()
L.Close()
}