# C ext to ruby : hom to manage dirs?

**URL:** <https://www.ruby-forum.com/t/c-ext-to-ruby-hom-to-manage-dirs/69039>\
**Category:** Ruby\
**Created:** [September 18, 2006, 10:47am UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-hom-to-manage-dirs/69039 "2006-09-18T10:47:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 18, 2006, 10:47am UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-hom-to-manage-dirs/69039/1 "2006-09-18T10:47:17Z")

</div>

i’m writting c ext to ruby specifically for the Mac OS X platform.

i’ve seen in the ruby files that, for example, RubyCocoa is under a  
folder /path/to/osx

i think it’s a good idae then i wonder on how to have my ext reflect  
that.

is it sufficient to organize my ext dir like that :

ext/  
osx/  
[all the files for this ext]

???

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 18, 2006, 11:21am UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-hom-to-manage-dirs/69039/2 "2006-09-18T11:21:21Z")

</div>

On Sep 18, 2006, at 1:46 AM, Une bévue wrote:

> i’m writting c ext to ruby specifically for the Mac OS X platform.

If it is specifically and only for one platform, don’t bother making  
the directory structure (or code structure) more complicated. If it  
is mostly platform agnostic separate that out and have the platform  
specific stuff either split out if it is big, or if not, separated  
with ifdefs (I say that only because even with platform specific  
files, a good portion of those files will be duplicate anyways (think  
includes, declarations, definition skeletons–everything but the meat)).

In other words, do the simplest thing that works, right now, for what  
you actually need… If you need to extend for a second platform  
someday, deal with it then.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 18, 2006, 1:25pm UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-hom-to-manage-dirs/69039/3 "2006-09-18T13:25:34Z")

</div>

Ryan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If it is specifically and only for one platform, don’t bother making  
> the directory structure (or code structure) more complicated.

true, it is only for mac os x.  
then i’ll leave it as it is, thanxs !

> If it  
> is mostly platform agnostic separate that out and have the platform  
> specific stuff either split out if it is big, or if not, separated  
> with ifdefs (I say that only because even with platform specific  
> files, a good portion of those files will be duplicate anyways (think  
> includes, declarations, definition skeletons–everything but the meat)).
> 
> In other words, do the simplest thing that works, right now, for what  
> you actually need… If you need to extend for a second platform  
> someday, deal with it then.

that’s working actually, in fact, in my “extconf.rb” i do have a test :

case RUBY\_PLATFORM  
when /._darwin._/ # are you over running Mac OS X 10.+ ?  
  
else  
puts “This Ruby extension needs MacOS X 10.+”  
end

to alert the user wanting inadvertedly to compile over a box not running  
Mac OS X.
