2011-09-06 102 views
1

我有以下包裝的Makefile包:使用gomake/gotest與外部依賴性

include ${GOROOT}/src/Make.inc 

TARG=gorilla.googlecode.com/hg/gorilla/mux 

GOFILES=\ 
     doc.go\ 
     mux.go\ 

DEPS=\ 
     gorilla.googlecode.com/hg/gorilla/context 

include ${GOROOT}/src/Make.pkg 

我改變TARG和DEPS今天指向谷歌代碼庫,如上圖所示,下面this advice

問題是:我可以安裝軟件包,它會安裝依賴項,但我不能再使用gotest或gomake;我得到以下錯誤(使用轉到R59):

[email protected]:~/dev/repos/gorilla/gorilla/mux$ gotest 
rm -f _test/gorilla.googlecode.com/hg/gorilla/mux.a 
make -C gorilla.googlecode.com/hg/gorilla/context install 
make: *** gorilla.googlecode.com/hg/gorilla/context: No such file or directory. Stop. 
make: *** [gorilla.googlecode.com/hg/gorilla/context.make] Error 2 
gotest: "/home/moraes/dev/repos/go/go.r59/bin/gomake testpackage GOTESTFILES=mux_test.go" failed: exit status 2 

我第一次嘗試(goinstall gorilla.googlecode.com/hg/gorilla/context)goinstalling的依賴,並在$ GOROOT /正確安裝PKG但gotest/gomake發生同樣的錯誤。

我想我錯過了一些非常基本的東西。我應該如何繼續在上面的Makefile中使用gomake/gotest?這是否應該工作,或者我應該使用不同的發展?

+0

你如何運行測試?我剛剛嘗試過,測試仍然不起作用(有問題)... –

+0

在運行測試之前,我當前將Makefile改爲使用大猩猩軟件包的相對路徑,例如「../ context」。 – moraes

回答

0

我認爲Makefile正試圖在當前目錄中找到gorilla.googlecode.com/hg/gorilla/context文件。另外,你爲什麼要在make文件中指定它,而不是從源文件中導入它?

1

goinstall根本不使用Makefile。相反,它會直接從.go文件中解析依賴關係。

要指定依賴項,annotate your import lines具有對「依賴項」的「規範化」引用。例如。

import (
    gorilla_context "gorilla.googlecode.com/hg/gorilla/context" 
... 

gomake不會自動解決依賴關係,所以你必須手動安裝它們。

同樣,對於使用goinstall安裝cgo源代碼,您可以在註釋指令中指定CFLAGS和LDFLAGS。例如。

/* 
#cgo CFLAGS: -I/usr/local/include 
#cgo LDFLAGS: -L/usr/local/lib -lzmq 
#include <zmq.h> 
*/ 
import "C"