New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use "make install" instead of manually copying extension binary #191
Conversation
Until now rake-compiler uses "make" to build the extension binary, but doesn't use "make install" to copy it into the lib directory. This has the downside, that only the extension binary is copied, but no additional files. In particular files registered per mkmf's $INSTALLFILES mechanism are not respected. Using "make install" fixes this.
File.open(siteconf_path, "w") do |siteconf| | ||
siteconf.puts "require 'rbconfig'" | ||
siteconf.puts "require 'mkmf'" | ||
siteconf.puts "dest_path = mkintpath(#{File.expand_path(lib_path).dump})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same mechanism as used in rubygems. However we're using an absolute dest_path
here, which has to be passed through mkintpath
to properly work on Windows. In contrast rubygems uses a relative path and subsequently copies the files from a temporary directory to the destination extension directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also tested on MacOS with ruby/ruby#4310 and confirmed that it does copy the *.bundle.dSYM
file to lib
task "copy:#{@name}:#{platf}:#{ruby_ver}" => [lib_binary_dir_path, tmp_binary_path, "#{tmp_path}/Makefile"] do | ||
# install in lib for native platform only | ||
unless for_platform | ||
sh "#{make} install", chdir: tmp_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use sh make, install, chdir: tmp_path
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how I did it first, but then I noticed, that it doesn't work if one sets the MAKE
environment variable to something like MAKE=make -j8 V=1
. In this case a make binary with spaces in the name is tried to be executed instead of being interpret as command line options. In contrast build tools like autoconf or cmake accept options to make as part of the MAKE
environment variable. I therefore think it's best how it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
I understand.
siteconf.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path" | ||
siteconf.puts "RbConfig::CONFIG['#{dir}'] = dest_path" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is highly problematic, could you find a way which does not mutate RbConfig, as that can break many things?
See #202
Until now rake-compiler uses
make
to build the extension binary, but doesn't usemake install
to copy it into thelib
directory. This has the downside, that only the extension binary is copied, but no additional files. In particular files registered per mkmf's$INSTALLFILES
mechanism are not respected. Usingmake install
fixes this and possibly also #189.With this PR, the call to
make install
is not invoked for cross ruby tasks but only for native compile. This changes the cross build, so that cross compiled extension binaries are no longer copied into the nativelib
directory. IMHO that makes sense in any case, since the cross compiled extension binaries belong into the platform gems only and are superfluous in the nativelib
directory.As another extension to this PR, it might be useful to run the cross packaging tasks through
make install
as well. However the cross build and packaging is way more complex and at least in case of the pg gem, it is not helpful, since the$INSTALLFILES
are not necessary for cross builds.Fixes #190