Skip to content
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

mrbgems #479

Merged
merged 106 commits into from Dec 7, 2012
Merged

mrbgems #479

merged 106 commits into from Dec 7, 2012

Conversation

@bovi
Copy link
Member

bovi commented Sep 23, 2012

mrbgems is a library manager to integrate C and Ruby extensions in an easy and standardised way into mruby.

This is a follow up to #470

After talking shortly to matz on the RubyKaigi in Sapporo I have worked over the last week to bring this implementation up to an usable state. The current implementation can integrate extensions build in C or Ruby.

Documentation

I have written a documentation for mrbgems (located under doc/mrbgems) and prepared two example Gems (one pure Ruby extension and one pure C extension).

Test

Test of gems

A Gem can have tests which will be automatically integrated by the build process into mrbtest.

Test of mrbgems

I have tested C and Ruby Extension on:

Mac OS X (10.8.2)
Darwin 12.2.0 Darwin Kernel Version 12.2.0; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

Ubuntu 64bit
Linux 3.2.0-23-generic Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

Overhead

There is no overhead anymore in case mrbgems isn't used!!!
I have check the overhead of the implementation. In case no Gem exists the impact to the size of the mruby binary is:

before:

550452 (538K) mirb
534828 (522K) mrbc
550224 (537K) mruby

after:

These binaries were compiled on Mac OS X (10.8.2) with "-g -O3". The overhead is only 336 bytes.

@mattn
Copy link
Contributor

mattn commented Dec 7, 2012

Thank you!

@beoran
Copy link

beoran commented Dec 7, 2012

OK, now I can start my work to port this to the CMake build system also. Might take me a while though...

@masuidrive
Copy link
Contributor

masuidrive commented Dec 8, 2012

Hi @bovi, I have some questions.

I'm porting my "mruby-cfunc" library. it refer from mruby-cocoa, so mruby-cfunc has exported header files.
https://github.com/mobiruby/mruby-cfunc
Could you add all mrbgems exported header directory to CFLAGS in mrbgems?

And, What's order of calling each gems init method?
Is it same as GEMS.active lines?

Last one, GEMS.active path is absolute now, Could you change to relative from mrbgems/ when the path is relative?

@bovi
Copy link
Member Author

bovi commented Dec 8, 2012

Hi @masuidrive,

  • gem init method will be called in the order of the GEMS.active line
  • about the exported header files, do you mean you want to get inside of your CFLAS something like "-I..path/to/every/gems/include"?
  • I will have a look at how to make the path relative in case it isn't absolute. but I would prefer to make it relative from mrbgems/g. That is the directory I consider to be the default directory for GEMs delivered by mruby directly.

Is this ok for you?

@masuidrive
Copy link
Contributor

masuidrive commented Dec 8, 2012

Hi @bovi , thank you for replying.

  • I understood GEMs init order.
  • So it is. I want add all include directory of GEMs to CFLAGS.
  • I understood.

Could you add all-headers-include-feture? I hope,to support it.

@bovi
Copy link
Member Author

bovi commented Dec 8, 2012

Hi @masuidrive,

I implemented:

  • relative/absolute path support in GEMS.active
  • include path integration into make calls
  • remove dependency of ENABLE_GEMS and only use DISABLE_GEMS as all the other flags

I couldn't test it on windows. there is one dependency which might work different under WIN32. I implemented a check but due to the lack of windows I couldn't test this edge case. I hope someone has a system to test it and report if it fails or not.

@sogabe
Copy link
Contributor

sogabe commented Dec 10, 2012

Thank you so much! In our case, it is good that mrbgems have a ability to link 'simple_http' to 'socket'. I think it is not necessary to have a central repository. mrubygems.org and gem command for mruby (not yet) can achieve our requirements :)

@schmurfy
Copy link
Contributor

schmurfy commented Dec 10, 2012

A simple "list" repository like homebrew for mac os x would be nice to keep track of the available gems, even a wiki page would be enough if kept up to date.
Since mruby is more targeted at embedded or light devices I really wonder if a gem command would be of any use considering you have to recompile everything anyway, mruby is quite different from MRI.

I was curious if anyone was working on a socket gem ? I am really looking forward to try connecting mruby to the external world !

@Qard
Copy link

Qard commented Dec 10, 2012

There's an interface for libuv, which has all sorts of I/O stuff--networked
and otherwise.
On 10 Dec 2012 01:17, "Julien Ammous" notifications@github.com wrote:

A simple "list" repository like homebrew for mac os x would be nice to
keep track of the available gems, even a wiki page would be enough if kept
up to date.
Since mruby is more targeted at embedded or light devices I really wonder
if a gem command would be of any use considering you have to recompile
everything anyway, mruby is quite different from MRI.

I was curious if anyone was working on a socket gem ? I am really looking
forward to try connecting mruby to the external world !


Reply to this email directly or view it on GitHubhttps://github.com//pull/479#issuecomment-11186255.

@schmurfy
Copy link
Contributor

schmurfy commented Dec 10, 2012

Thanks for the mruby-uv pointer but the code is not yet gemified I think, anyway I was thinking more about a low level socket extension.

@mattn
Copy link
Contributor

mattn commented Dec 10, 2012

I'm author of mruby-uv.

Currently, we can't specify LDFLAGS for external library for mrbgems yet.

@Qard
Copy link

Qard commented Dec 10, 2012

There's a fork that adds a bunch of that stuff; https://github.com/iij/mruby

You could use that, or try to rip out the parts you want and gemify them.
On 10 Dec 2012 01:31, "Julien Ammous" notifications@github.com wrote:

Thanks for the mruby-uv pointer but the code is not yet gemified I think,
anyway I was thinking more about a low level socket extension.


Reply to this email directly or view it on GitHubhttps://github.com//pull/479#issuecomment-11186628.

@masuidrive
Copy link
Contributor

masuidrive commented Dec 10, 2012

I'm working for LDFLAGS for mrbgems
plz wait a minute.

@mattn
Copy link
Contributor

mattn commented Dec 10, 2012

@masuidrive probably, you are saying we can, but we need to specify for make command ? i've done already to build mruby-uv with my LDFLAGS from command-line. i'm thinking that mrbgems should be easy to build for all gem uesrs.

@masuidrive
Copy link
Contributor

masuidrive commented Dec 10, 2012

It mean "You can set CFLAGS/LDFLAGS each GEM in gem's Makefile"

If you want to link with libuv, I can write "MRUBY_LDFLAGS = -luv" in gem's Makefile.

@mattn
Copy link
Contributor

mattn commented Dec 10, 2012

Is it better ot use MRUBY_LDFLAGS+=-luv. It breaks mruby's behavior probably ?
BTW, I hope to do make test on my gem working directory.

@ghost
Copy link

ghost commented Dec 10, 2012

I'll try to convert some extension modules in our repository https://github.com/iij/mruby to mrbgems.
Thanks for great job, @bovi.

@bovi
Copy link
Member Author

bovi commented Dec 10, 2012

@mattn what is your desire for make test? At the moment all your tests are automatically integrated into the normal mruby build process as long as your put them into a test directory of your GEM. Calling make test directly inside of your GEM project doesn't work with the current design due to the reason that it first needs to integrate your library into the mrbtest binary. Or did I misunderstood you in some way?

@tsahara-iij I'm looking forward to the IIJ extensions :)

@mattn
Copy link
Contributor

mattn commented Dec 10, 2012

@bovi I'm doing all of things on the gem's working directory. I hope to run make test on the working directory. But not MUST, it's BETTER.

@bovi
Copy link
Member Author

bovi commented Dec 10, 2012

@mattn ah ok I think I understand. You want to build mruby together with GEMs outside of the mruby source directory? I think this should be much cleaner and I don't see why we shouldn't be able to cleanup all Makefiles to make this work. Or did I misunderstand?

@mattn
Copy link
Contributor

mattn commented Dec 10, 2012

You want to build mruby together with GEMs outside of the mruby source directory?

Yep! :)

why we shouldn't be able to cleanup all Makefiles to make this work.

Currently, we should open two terminals to build all.

@mattn
Copy link
Contributor

mattn commented Dec 11, 2012

@bovi @masuidrive What I want to say is that we need to specify CFLAGS/LDFLAGS for bin/mruby not for each mrbgems on windows. Task of bin/mruby should include flags which is same flags which is used for mrbgems.

@mattn
Copy link
Contributor

mattn commented Dec 11, 2012

And one more thing, on windows, order of -l flags must be resolvable. This mean, if libA.a uses functions in libB.a, we must specify the arguments as -lB -lA not -lA -lB.

@kristoph
Copy link

kristoph commented Dec 31, 2012

@bovi You mentioned in an earlier comment that the GEM.active file can be located anywhere. How do I specify it's location when building mruby as a whole? Also, I understand GEM.active needs the full path of the GEM which is a little impractical when working on a team with multiple developers, any suggestions on how to address that? Thanks.

@schmurfy
Copy link
Contributor

schmurfy commented Dec 31, 2012

just found the https://github.com/matsumoto-r/build_my_mruby repository and it confirmed what I first thought: I had no idea how many "gems" were already available out there !
Maybe a wiki page would be appropriate to keep track of them and avoid rebuilding the wheel, while I think the infrastructure rubygems have for MRI is a complete overkill in this case a way to keep track the gems would still be great.

@bovi
Copy link
Member Author

bovi commented Dec 31, 2012

@kristoph it is possible to use an relative path from mrbgems/g it is possible to define the GEMS.active location inside of the Makefile. But @masuidrive is currently rewriting the
build process and by doing that some things will be relocated. So stay tuned. Most things woll become quite easy by next year.

@schmurfy I'm currently working on an application which contains a list of all Gems and which also provides a way to add your own one to it.

@schmurfy
Copy link
Contributor

schmurfy commented Dec 31, 2012

@bovi great !

@schmurfy
Copy link
Contributor

schmurfy commented Dec 31, 2012

@bovi just had a look at mgem, I was wondering how you plan to distribute it, it might make sense to distribute it as a rubygems (a real one ;) )

@bovi
Copy link
Member Author

bovi commented Dec 31, 2012

@schmurfy the idea is to make a GEM indeed out of it ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

You can’t perform that action at this time.