nmatrix
nmatrix copied to clipboard
rake compile doesn't rebuild if only .h files modified
If I modify one of the .h files in ext/nmatrix/math and run rake compile, nothing happens. I need to touch ext/nmatrix/math.cpp to get it to work. I have no idea how rake works, so I don't know if this is an easy fix or not.
I think this is actually a combination of the behavior of make
with the fact that we don't list the makefile targets as depending on header files. (You can see what the generated Makefile looks like if you run rake compile
and then poke around in tmp/x86_64-linux/nmatrix/2.1.1
(substituting your architecture and ruby version number as needed).
I'm not sure whether this is a necessary consequence of ruby's mkmf library for generating makefiles, or whether it's something we could change via configuration. If you want to investigate, the changes would need to happen in ext/nmatrix/extconf.rb
. We also don't want to just compile the headers in as if they were normal C++ source files, so there'd need to be some way to depend on the headers without actually compiling them in (except via the includes in the other source files).
Typically to compile I just run rake clean && rake compile
, which is slower if you only need to recompile some things, but will definitely work.
It'd be great to see this problem solved. It's been an issue for a while, though never listed in the tracker (AFAIK).
@cjfuller is correct. I've never found an easy solution, but I may not have looked very hard.
This still doesn't work for me. The Makefile targets still don't depend on the header files. Did this fix work for anyone else?
Hmm. Apparently I actually asked about this exact thing on StackOverflow. Not sure why I never got around to implementing it:
http://stackoverflow.com/questions/18685355/extconf-rb-how-do-i-generate-makefile-targets-dependent-upon-header-file-change
It's a pain because you need to maintain a list of all the header files a particular C file depends on... you don't need to do it by hand, gcc can generate the dependcy file for you... but then you need to make a script to make gcc do it for you... and then you would want it to automatically regenerate the dependencies anytime anything changed... sigh
It'd be lovely if mkmf supported CMake. On Wed, Jun 3, 2015 at 8:43 PM wlevine [email protected] wrote:
It's a pain because you need to maintain a list of all the header files a particular C file depends on... you don't need to do it by hand, gcc can generate the dependcy file for you... but then you need to make a script to make gcc do it for you... and then you would want it to automatically regenerate the dependencies anytime anything changed... sigh
— Reply to this email directly or view it on GitHub https://github.com/SciRuby/nmatrix/issues/329#issuecomment-108658776.