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/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"
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_CXXFLAGS
export CGO_LDFLAGS

View File

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

View File

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

View File

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