将 gomake/gotest 用于具有外部依赖项的包

发布于 2024-12-03 08:09:26 字数 1179 浏览 0 评论 0原文

我有以下包 Makefile:

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 以指向 Google 代码存储库,如上所示,遵循 此建议

问题是:我可以 goinstall 该软件包,它会安装依赖项,但我不能再使用 gotest 或 gomake;我收到以下错误(使用 Go r59):

moraes@yukon:~/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

我首先尝试 goinstalling 依赖项 (goinstall gorilla.googlecode.com/hg/gorilla/context),它在 $GOROOT/pkg 中正确安装,但gotest/gomake 也会出现同样的错误。

我想我错过了一些非常基本的东西。我应该如何继续将 gomake/gotest 与上面的 Makefile 一起使用?这是否应该有效,或者我应该使用不同的进行开发?

I have the following package Makefile:

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

I changed TARG and DEPS today to point to the Google code repository as shown above, following this advice.

The problem is: I can goinstall the package and it will install the dependency, but I cannot use gotest or gomake anymore; I get the following error (using Go r59):

moraes@yukon:~/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

I tried goinstalling the dependency first (goinstall gorilla.googlecode.com/hg/gorilla/context), and it installs correctly in $GOROOT/pkg but the same error occurs with gotest/gomake.

I think I'm missing something pretty basic. How should I proceed to use gomake/gotest with the Makefile above? Is this supposed to work at all, or should I use a different one for development?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

变身佩奇 2024-12-10 08:09:26

goinstall 根本不使用 Makefile。相反,它会直接从 .go 文件解析依赖项。

要指定依赖项,请使用对依赖项的“规范化”引用注释导入行。例如。

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"

goinstall doesn't use the Makefile at all. Instead, it will parse dependencies directly from your .go files.

To specify dependencies, annotate your import lines with a "normalised" reference to the dependency. eg.

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

gomake doesn't automatically resolve dependencies though, so you'll have to manually install them.

Similarly, for installing cgo source with goinstall, you can specify CFLAGS and LDFLAGS in comment directives. eg.

/*
#cgo CFLAGS: -I/usr/local/include
#cgo LDFLAGS: -L/usr/local/lib -lzmq
#include <zmq.h>
*/
import "C"
半城柳色半声笛 2024-12-10 08:09:26

我认为 Makefile 正在尝试在当前目录中查找文件 gorilla.googlecode.com/hg/gorilla/context 。另外,为什么要在 make 文件中指定它而不是从源中导入它?

I think the Makefile is trying to find the file gorilla.googlecode.com/hg/gorilla/context in the current directory. Also, why would you want to specify it in a make file as opposed to importing it from within the Source?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文