Skip to content

Commit

Permalink
Use a working bootstrap node for testing.
Browse files Browse the repository at this point in the history
nurupo's node is down.

Also, remove the clang stuff for now. It's not working on travis.
  • Loading branch information
iphydf committed Mar 8, 2020
1 parent 3c9c577 commit a5603bd
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 95 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ before_install:

install:
# Add libclang's lib directory to search path for Go.
- export CGO_LDFLAGS="-L`llvm-config-3.4 --libdir`"
- export CGO_LDFLAGS="-L`llvm-config-3.8 --libdir`"
# Install toxcore.
- git clone https://github.com/TokTok/c-toxcore
- cd c-toxcore
Expand All @@ -38,7 +38,7 @@ install:
- sudo ldconfig > /dev/null
# Install Go packages.
- go get github.com/bitly/go-simplejson
- go get github.com/go-clang/v3.4/clang
# - go get -u github.com/go-clang/v3.8/clang
- go get github.com/kitech/godsts/maps/hashbidimap
- go get github.com/kitech/godsts/maps/hashmap
- go get github.com/kitech/godsts/sets/hashset
Expand All @@ -49,5 +49,6 @@ install:
- go get github.com/xrash/smetrics

script:
- go run tools/generrmsg.go > const_auto.go && git diff --exit-code
# - go run tools/generrmsg.go > const_auto.go && git diff --exit-code
- rm tools/generrmsg.go
- $GOPATH/bin/goveralls -service=travis-ci
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ go_library(

go_test(
name = "go_default_test",
size = "small",
srcs = [
"group_intern_test.go",
"tox_test.go",
],
args = ["-test.parallel 50"],
data = ["tox_test.go"],
embed = [":go_default_library"],
importpath = "github.com/TokTok/go-toxcore-c",
)
26 changes: 13 additions & 13 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package tox
#include <string.h>
#include <tox/tox.h>
void callbackConferenceInviteWrapperForC(Tox*, uint32_t, TOX_CONFERENCE_TYPE, uint8_t *, size_t, void *);
void callbackConferenceMessageWrapperForC(Tox *, uint32_t, uint32_t, TOX_MESSAGE_TYPE, int8_t *, size_t, void *);
void callbackConferenceInviteWrapperForC(Tox*, uint32_t, Tox_Conference_Type, uint8_t *, size_t, void *);
void callbackConferenceMessageWrapperForC(Tox *, uint32_t, uint32_t, Tox_Message_Type, int8_t *, size_t, void *);
// void callbackConferenceActionWrapperForC(Tox*, uint32_t, uint32_t, uint8_t*, size_t, void*);
void callbackConferenceTitleWrapperForC(Tox*, uint32_t, uint32_t, uint8_t*, size_t, void*);
Expand Down Expand Up @@ -40,7 +40,7 @@ type cb_conference_peer_list_changed_ftype func(this *Tox, groupNumber uint32, u
// tox_callback_conference_***

//export callbackConferenceInviteWrapperForC
func callbackConferenceInviteWrapperForC(m *C.Tox, a0 C.uint32_t, a1 C.TOX_CONFERENCE_TYPE, a2 *C.uint8_t, a3 C.size_t, a4 unsafe.Pointer) {
func callbackConferenceInviteWrapperForC(m *C.Tox, a0 C.uint32_t, a1 C.Tox_Conference_Type, a2 *C.uint8_t, a3 C.size_t, a4 unsafe.Pointer) {
var this = cbUserDatas.get(m)
for cbfni, ud := range this.cb_conference_invites {
cbfn := *(*cb_conference_invite_ftype)(cbfni)
Expand All @@ -64,7 +64,7 @@ func (this *Tox) CallbackConferenceInviteAdd(cbfn cb_conference_invite_ftype, us
}

//export callbackConferenceMessageWrapperForC
func callbackConferenceMessageWrapperForC(m *C.Tox, a0 C.uint32_t, a1 C.uint32_t, mtype C.TOX_MESSAGE_TYPE, a2 *C.int8_t, a3 C.size_t, a4 unsafe.Pointer) {
func callbackConferenceMessageWrapperForC(m *C.Tox, a0 C.uint32_t, a1 C.uint32_t, mtype C.Tox_Message_Type, a2 *C.int8_t, a3 C.size_t, a4 unsafe.Pointer) {
var this = cbUserDatas.get(m)
if int(mtype) == MESSAGE_TYPE_NORMAL {
for cbfni, ud := range this.cb_conference_messages {
Expand Down Expand Up @@ -187,7 +187,7 @@ func (this *Tox) ConferenceNew() (uint32, error) {
this.lock()
defer this.unlock()

var cerr C.TOX_ERR_CONFERENCE_NEW
var cerr C.Tox_Err_Conference_New
r := C.tox_conference_new(this.toxcore, &cerr)
if r == C.UINT32_MAX {
return uint32(r), toxerrf("add group chat failed: %d", cerr)
Expand All @@ -203,7 +203,7 @@ func (this *Tox) ConferenceDelete(groupNumber uint32) (int, error) {
this.lock()

var _gn = C.uint32_t(groupNumber)
var cerr C.TOX_ERR_CONFERENCE_DELETE
var cerr C.Tox_Err_Conference_Delete
r := C.tox_conference_delete(this.toxcore, _gn, &cerr)
if bool(r) == false {
this.unlock()
Expand All @@ -226,7 +226,7 @@ func (this *Tox) ConferencePeerGetName(groupNumber uint32, peerNumber uint32) (s
var _pn = C.uint32_t(peerNumber)
var _name [MAX_NAME_LENGTH]byte

var cerr C.TOX_ERR_CONFERENCE_PEER_QUERY
var cerr C.Tox_Err_Conference_Peer_Query
r := C.tox_conference_peer_get_name(this.toxcore, _gn, _pn, (*C.uint8_t)(&_name[0]), &cerr)
if r == false {
return "", toxerrf("get peer name failed: %d", cerr)
Expand All @@ -240,7 +240,7 @@ func (this *Tox) ConferencePeerGetPublicKey(groupNumber uint32, peerNumber uint3
var _pn = C.uint32_t(peerNumber)
var _pubkey [PUBLIC_KEY_SIZE]byte

var cerr C.TOX_ERR_CONFERENCE_PEER_QUERY
var cerr C.Tox_Err_Conference_Peer_Query
r := C.tox_conference_peer_get_public_key(this.toxcore, _gn, _pn, (*C.uint8_t)(&_pubkey[0]), &cerr)
if r == false {
return "", toxerrf("get pubkey failed: %d", cerr)
Expand All @@ -265,7 +265,7 @@ func (this *Tox) ConferenceInvite(friendNumber uint32, groupNumber uint32) (int,
return -1, toxerrf("friend not exists: %d", friendNumber)
}

var cerr C.TOX_ERR_CONFERENCE_INVITE
var cerr C.Tox_Err_Conference_Invite
r := C.tox_conference_invite(this.toxcore, _fn, _gn, &cerr)
if r == false {
return 0, toxerrf("conference invite failed: %d", cerr)
Expand All @@ -291,7 +291,7 @@ func (this *Tox) ConferenceJoin(friendNumber uint32, cookie string) (uint32, err
var _fn = C.uint32_t(friendNumber)
var _length = C.size_t(datlen)

var cerr C.TOX_ERR_CONFERENCE_JOIN
var cerr C.Tox_Err_Conference_Join
r := C.tox_conference_join(this.toxcore, _fn, (*C.uint8_t)(&data[0]), _length, &cerr)
if r == C.UINT32_MAX {
defer this.unlock()
Expand Down Expand Up @@ -321,8 +321,8 @@ func (this *Tox) ConferenceSendMessage(groupNumber uint32, mtype int, message st
return 0, toxerrf("Invalid message type: %d", mtype)
}

var cerr C.TOX_ERR_CONFERENCE_SEND_MESSAGE
r := C.tox_conference_send_message(this.toxcore, _gn, (C.TOX_MESSAGE_TYPE)(mtype), (*C.uint8_t)(&_message[0]), _length, &cerr)
var cerr C.Tox_Err_Conference_Send_Message
r := C.tox_conference_send_message(this.toxcore, _gn, (C.Tox_Message_Type)(mtype), (*C.uint8_t)(&_message[0]), _length, &cerr)
if r == false {
return 0, toxerrf("group send message failed: %d", cerr)
}
Expand All @@ -337,7 +337,7 @@ func (this *Tox) ConferenceSetTitle(groupNumber uint32, title string) (int, erro
var _title = []byte(title)
var _length = C.size_t(len(title))

var cerr C.TOX_ERR_CONFERENCE_TITLE
var cerr C.Tox_Err_Conference_Title
r := C.tox_conference_set_title(this.toxcore, _gn, (*C.uint8_t)(&_title[0]), _length, &cerr)
if r == false {
if len(title) > MAX_NAME_LENGTH {
Expand Down
8 changes: 4 additions & 4 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package tox
#include <string.h>
#include <tox/tox.h>
extern void toxCallbackLog(Tox*, TOX_LOG_LEVEL, char*, uint32_t, char*, char*);
extern void toxCallbackLog(Tox*, Tox_Log_Level, char*, uint32_t, char*, char*);
*/
import "C"
Expand Down Expand Up @@ -74,11 +74,11 @@ func (this *ToxOptions) toCToxOptions() *C.struct_Tox_Options {

if this.Savedata_data != nil {
C.tox_options_set_savedata_data(toxopts, (*C.uint8_t)(&this.Savedata_data[0]), C.size_t(len(this.Savedata_data)))
C.tox_options_set_savedata_type(toxopts, C.TOX_SAVEDATA_TYPE(this.Savedata_type))
C.tox_options_set_savedata_type(toxopts, C.Tox_Savedata_Type(this.Savedata_type))
}
C.tox_options_set_tcp_port(toxopts, (C.uint16_t)(this.Tcp_port))

C.tox_options_set_proxy_type(toxopts, C.TOX_PROXY_TYPE(this.Proxy_type))
C.tox_options_set_proxy_type(toxopts, C.Tox_Proxy_Type(this.Proxy_type))
C.tox_options_set_proxy_port(toxopts, C.uint16_t(this.Proxy_port))
if len(this.Proxy_host) > 0 {
C.tox_options_set_proxy_host(toxopts, C.CString(this.Proxy_host))
Expand All @@ -95,7 +95,7 @@ func (this *ToxOptions) toCToxOptions() *C.struct_Tox_Options {
}

//export toxCallbackLog
func toxCallbackLog(ctox *C.Tox, level C.TOX_LOG_LEVEL, file *C.char, line C.uint32_t, fname *C.char, msg *C.char) {
func toxCallbackLog(ctox *C.Tox, level C.Tox_Log_Level, file *C.char, line C.uint32_t, fname *C.char, msg *C.char) {
t := cbUserDatas.get(ctox)
if t != nil && t.opts != nil && t.opts.LogCallback != nil {
t.opts.LogCallback(t, int(level), C.GoString(file), uint32(line), C.GoString(fname), C.GoString(msg))
Expand Down
4 changes: 2 additions & 2 deletions tools/generrmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os/exec"
"strings"

"github.com/go-clang/v3.4/clang"
"github.com/go-clang/v3.8/clang"
)

func main() {
Expand All @@ -23,7 +23,7 @@ func main() {
_ = tuArgs

// auto find clang include dir
clincdir := "/usr/lib/clang/3.4/include"
clincdir := "/usr/lib/clang/3.8/include"
clexe, err := exec.LookPath("clang")
if err != nil {
log.Println(err)
Expand Down
Loading

0 comments on commit a5603bd

Please sign in to comment.