非C项目的跨平台自动构建
实际上,我需要在 Windows / Linux 平台下为不同的语言构建二进制文件 - Java、Pascal (Delphi/FPC)、C++、C# 等。
这怎么能做到呢?我现在正在将 CMake 用于 C 项目,如下所示:
cmake --build .
并提供了 CMakeLists.txt
。
Actually, I need to build binaries for different languages - Java, Pascal (Delphi/FPC), C++, C#, etc under Windows / Linux platforms.
How this could be done? I am using CMake for C projects for now like this:
cmake --build .
with CMakeLists.txt
providen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个
*make
系统对于 Java 项目来说都是没有用的,因为make
基本上假设“一个文件输入,一个文件输出”之一(例如.c
到.o
)或“N 个文件输入,一个文件输出”(例如*.o
到.a
、. dll、
.exe
)。使用这些“原语”执行构建。但 Java 编译器本质上要求“完整的源代码树输入,完整的类树输出”。
这两种范式并不匹配,试图这样做迟早会带来比其价值更多的小问题。去过那里,做过那件事。
您能做的最好的事情就是从顶级 Makefile 中调用 Ant 或 Maven(或其他)。
编辑:不要忘记另外两件事:
使用
make
编译 Java 内容是一门黑暗、神秘的艺术。您不会发现很多人同时了解 Java 和 make,并且能够利用这种组合来解决问题。 Ant/Maven 和 Java 是标准组合。使用这种组合找到帮助或建议完全没有问题。Java 中的许多框架都需要特殊的编译步骤。几乎在所有情况下,都有可用的 Ant 和 Maven 插件。使用 make 您将不得不每次重新发明轮子。
Every
*make
system is not usefull for Java project becausemake
basically assumes one of "One file in, one file out" (e.g..c
to.o
) or "N files in, one file out" (e.g.*.o
to one of.a
,.dll
,.exe
). With these "primitives" a build is performed.But the Java compiler requires inherently "complete sourcetree in, comlete class-tree out".
Those two paradigmata don't match and trying to do will introduce more little nasty problems than its worth sooner or later. Been there, done that.
The best you can do is to call Ant or Maven (or whatever) from within a toplevel Makefile.
Edit: Not to forget two more things:
Compiling Java stuff with
make
is a dark, arcane art. You will not find many people who know both Java and make and who can solve problems with that combination. Ant/Maven and Java is a standard combination. There is simply no problem finding help or advises with that combination.Many frameworks in Java require special compilation steps. In almost all cases there are plugins for Ant and Maven available. Using make you will have to reinvent the wheel every time again.
Free Pascal 提供了自己的构建系统。参见例如
http://www.stack.nl/~marcov/buildfaq.pdf
默认的 makefile(基于大多数生成的 gmake makefile)已经具有交叉能力。
我不认识任何人使用 cmake 和 Free Pascal,而且我已经出现在他们的邮件列表上十多年了。
Free Pascal provides its own build systems. See e.g.
http://www.stack.nl/~marcov/buildfaq.pdf
the default makefiles (based on mostly generated gmake makefiles) are already cross- capable.
I don't know anybody who uses cmake with Free Pascal, and I've been on their maillists for over a decade.