一个目录下有多个ruby扩展模块
离散 ruby 扩展模块的源代码是否可以位于同一目录中,由同一个 extconf.rb 脚本控制?
背景:我有一个包含两个扩展模块的项目,foo.so和bar.so,它们当前位于它们自己的子目录中,如下所示:
myproject/ext/foo/extconf.rb
myproject/ext/foo/foo.c
myproject/ext/foo/foo.h
myproject/ext/bar/extconf.rb
myproject/ext/bar/bar.c
myproject/ext/bar/bar.h
我希望所有< code>.c 和 .h
源代码仅驻留在 ext/
下,受单个 extconf.rb
文件的控制,但是我不知道如何让 mkmf
一起玩。
Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb
script?
Background: I've a project with two extension modules, foo.so and bar.so which currently live in their own subdirectories like so:
myproject/ext/foo/extconf.rb
myproject/ext/foo/foo.c
myproject/ext/foo/foo.h
myproject/ext/bar/extconf.rb
myproject/ext/bar/bar.c
myproject/ext/bar/bar.h
I'd prefer that all .c
and .h
sources simply reside under ext/
under the control of a single extconf.rb
file, but I don't know how to get mkmf
play along.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 mkmf,您将需要使用单独的目录;它不适用于将多个扩展放在同一目录中。
您可以使用 mkmf 替代方案之一(例如 mkrf)将扩展放在同一目录中;我不知道这是否有效。我曾经想做同样的事情,但最终发现,随着我的库的增长,为我的扩展提供多个目录对于保持项目的组织性变得非常理想。
With mkmf, you will need to use separate directories; it's not designed for putting multiple extensions in the same directory.
You may be able to use one of the mkmf alternatives (e.g. mkrf) to put the extensions in the same directory; I don't know whether or not this will work. I once wanted to do the same thing, but eventually discovered that as my library grew, having multiple directories for my extensions became desirable for keeping the project organized.