英文:
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
有至少两种选择:
我建议使用第二种方法;如果我正确理解了你的问题,它可以满足你的需求。你指定一个要“导入”的包,它会返回一个 Package
结构,其中包含将被编译的 Go、C、ASM 文件集合。
英文:
There are at least a couple of options:
- Use
go build -n
to list the commands that would be executed by a build, and then parse the output. - 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论