2011-09-06 103 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"