哪些文件被编译了?

huangapple go评论86阅读模式
英文:

Which files are compiled?

问题

当你有几个特定于系统的文件时,如何知道哪些文件将被编译和链接?

英文:

How to know which files are going to be compiled and linked when you have several files which are specific to a system?

答案1

得分: 2

有至少两种选择:

  1. 使用 go build -n 命令列出构建过程中将执行的命令,然后解析输出结果。
  2. 使用 go/build 包。具体来说,查看 Import 函数。

我建议使用第二种方法;如果我正确理解了你的问题,它可以满足你的需求。你指定一个要“导入”的包,它会返回一个 Package 结构,其中包含将被编译的 Go、C、ASM 文件集合。

英文:

There are at least a couple of options:

  1. Use go build -n to list the commands that would be executed by a build, and then parse the output.
  2. Use the go/build package. Specifically, look at the Import function.

I suggest the second method; if I understand your question correctly it does what you need. You specify a package to "import", and it returns a Package structure which contains, among other things, the set of Go, C, ASM files that will be compiled.

huangapple
  • 本文由 发表于 2012年5月29日 05:30:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/10790605.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定