multiple ruby extension modules under one directory - ruby

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.

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.

Related

How to include only specific directories in rdoc?

I'm using rdoc to generate API documentation for my Ruby program, but it's pulling in lots of files I don't care to include in the documentation. I see that there is an option to exclude files by pattern, but it would really be better for me to simply provide an explicit list of files and directories to include.
Is there an option to do this, or am I out of luck?

How to find out list of kernel files compiled by a kernel? [duplicate]

I'm working on different Android projects and need to setup project in Source Insight for different kernel source tree.
There are many unused files in kernel, I want to find a method to pick out all .c,.h,.S files that are compiled in kernel. I was nearly crazy when I pick the source files manually.
I'd wrote a script that can pick up the files corresponding to the .o files, but there are some .o files are compiled by multiple .c files, which make it more complicated.
Is there an easier way to know what files are handled in the compiling process?
Any information would be greatly appreciated.
It's my first question in stackoverflow, I love here so much.
Thanks.
I always need to search the kernel source without looking at powerpc, ia86, sparc, alpha, infiniband, etc. Assuming you can compile the kernel, several ways of doing this:
1) $K/scripts/basic/fixdep.c is called from Makefile.build to create a .cmd file for each source which contains information about the compile options, compile source/target and dependency list. Modify this to write a separate file with just the source file or source/dependencies.
2) Hack $K/scripts/Makefile.build to log the currently compiled file. See the cmd_as_o_S and rule_cc_o_c areas.
Option #1 is the best but requires a little coding. Option #2 is easiest but a true hack, and doesn't pick up the dependencies.

How to add file to all targets in Xcode when you have many targets?

I have a project with over 50 targets and growing and it is becoming cumbersome to add files to all targets because it takes a long time to select each target.
I am aware of multiple methods to add a file to multiple targets but they all involve checking a box for each target. (for those looking for that: How to add .plist file to all targets in XCode?)
What I'm looking for is an alternative method or script that can be used to add a file or set of files to all targets in the project without selecting them one by one. Anyone know of a trick?
Here is a link to GitHub repo. In the example project I have three targets, added file only in first target. When you run ruby ./addfile.rb from project's directory, the script will add img.jpg resource into two other targets (projex2, projex3). You need to install xcodeproj ruby gem before running the script. You should run sudo gem install xcodeproj in terminal.
What I'm looking for is an alternative method or script that can be used to add a file or set of files to all targets in the project without selecting them one by one. Anyone know of a trick?
If you're often adding the same source to all your targets, then one way to avoid that would be to create a framework the contains all the files your various targets have in common, and then have each of those targets link in the framework. That way, you only add common files to the one framework, and all the targets get access to them via the framework.

How to get a whole list of compiled files of Linux kernel?

I'm working on different Android projects and need to setup project in Source Insight for different kernel source tree.
There are many unused files in kernel, I want to find a method to pick out all .c,.h,.S files that are compiled in kernel. I was nearly crazy when I pick the source files manually.
I'd wrote a script that can pick up the files corresponding to the .o files, but there are some .o files are compiled by multiple .c files, which make it more complicated.
Is there an easier way to know what files are handled in the compiling process?
Any information would be greatly appreciated.
It's my first question in stackoverflow, I love here so much.
Thanks.
I always need to search the kernel source without looking at powerpc, ia86, sparc, alpha, infiniband, etc. Assuming you can compile the kernel, several ways of doing this:
1) $K/scripts/basic/fixdep.c is called from Makefile.build to create a .cmd file for each source which contains information about the compile options, compile source/target and dependency list. Modify this to write a separate file with just the source file or source/dependencies.
2) Hack $K/scripts/Makefile.build to log the currently compiled file. See the cmd_as_o_S and rule_cc_o_c areas.
Option #1 is the best but requires a little coding. Option #2 is easiest but a true hack, and doesn't pick up the dependencies.

Common structure of gem

As we all know, the common structure of rubygem assumes presence of lib directory. I noticed, that generally in this directory are two items: gem_name.rb and gem_name/ directory. The gem_name/ directory hold main sources of project. It is heart of application. So, the question is about gem_name.rb file. What does it stand for?
The reason it's structured like that is if you had files other than gem_name.rb in the lib/ directory (say another_file_name.rb), you'd be liable to cause problems if there was a gem with the name another_file_name and someone did require another_file_name - it'd load your file, rather than the other gem's file.
If your code is small enough it can all fit into gem_name.rb, then put it there, otherwise put it into gem_name/other_file_name.rb.
Typically that just requires everything from the gem_name/ directory that's needed. It's used to keep all the requires in a central location and separate from the actual code

Resources