高度模块化的便携式开源项目构建系统

发布于 2024-08-12 03:36:23 字数 1539 浏览 7 评论 0原文

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

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

发布评论

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

评论(2

清风夜微凉 2024-08-19 03:36:23

您可以很好地与自动工具同时构建东西。您只需要避免对要并行构建的内容进行递归 make 即可。基本思想是有一个 Makefile.am 像:

bin_PROGRAMS =
noinst_LDLIBRARIES =
SUBDIRS = sub1 sub2 .
include here1/Makefile-files
include here2/Makefile-files

here1/Makefile-files 像:

bin_PROGRAMS += here1
noinst_LDLIBRARIES += libhere1.la
here1_SOURCES = here1/src1.c here1/src2.c here1/src3.c
libhere1_la_SOURCES = here1/lib1.c here1/lib2.c

然后子目录中的东西 sub1/sub2/ 将与当前目录及其之前的目录分开构建(即使各个构建可能会使用相同的技巧并行执行某些操作!),然后当前目录将开始在当前目录的 Makefile.amhere[12]/Makefile-files 并行。

例如 libgphoto2 使用该机制 在构建了一些先决条件后,并行构建 50 多个相机驱动程序。这显着加快了总构建时间。

好的,configure 脚本本身不会因此而加速,但至少这仍然会进行交叉编译(与某些替代构建系统不同)。 (您将可移植列为您的要求之一,这通常意味着交叉编译。)

You can very well build stuff concurrently with autotools. You just need to avoid doing recursive make for the stuff you want to build in parallel. The basic idea is to have a Makefile.am like:

bin_PROGRAMS =
noinst_LDLIBRARIES =
SUBDIRS = sub1 sub2 .
include here1/Makefile-files
include here2/Makefile-files

and here1/Makefile-files like:

bin_PROGRAMS += here1
noinst_LDLIBRARIES += libhere1.la
here1_SOURCES = here1/src1.c here1/src2.c here1/src3.c
libhere1_la_SOURCES = here1/lib1.c here1/lib2.c

Then the stuff in the subdirectories sub1/ and sub2/ will be built separately from the current directory and before it (even though the respective builds might do stuff in parallel with the same trick!), and then the current directory will start building the stuff in the current dir's Makefile.am and here[12]/Makefile-files in parallel.

E.g. libgphoto2 use that mechanism to build 50+ camera drivers in parallel after a few prerequesites have been built. This significantly speeds up the total build time.

OK, the configure script itself will not be sped up by this, but at least this will still do cross-compiling (unlike some of the alternative build systems). (You are listing portable as one of your requirements, and that often implies cross-compilation.)

断桥再见 2024-08-19 03:36:23

还可以考虑将 CMAKE 用于高度模块化的项目。

Consider also using CMAKE for highly modular projects.

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