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

Add support for c libraries. #15

Closed
technorama opened this issue Jul 22, 2015 · 7 comments
Closed

Add support for c libraries. #15

technorama opened this issue Jul 22, 2015 · 7 comments
Milestone

Comments

@technorama
Copy link

One possible way to add c library support:

  1. A build command (or list of commands) in shard.yml
  2. State tracking and output capture of commands for debugging (similar to rubygems).
  3. Additional library path injection to the crystal build process. shards.yml could contain additional c library paths. Minor modification of crystal may be necessary to read the list of additional library paths.
@ysbaddaden
Copy link
Contributor

Could you detail your problem and use case before jumping to potential solutions? I'd like to understand what's actually needed beforehand.

It may involve a bunch of problems, like checking for the presence of a library, downloading, compiling, making the lib available to Crystal when linking, etc.

@technorama
Copy link
Author

Use case #1:

I want to use an existing library but need a few C functions added. As far as I know the only way to use them is by compiling a library and linking it using the crystal provided c bindings.

Use case #2 (similar to above):

I have a small library in my git repository that must be compiled before crystal build is run. Crystal c bindings are used to access the library.

@kostya
Copy link

kostya commented Jul 23, 2015

what if always call make shard when install new shard, and if user create that task in Makefile, it would be executed (compile some static c libs or something)

@ysbaddaden
Copy link
Contributor

Thanks for the use cases. We could have some hook commands to be run when an action is performed. For example:

scripts:
  postinstall: "cd ext && make"

The most obvious is postinstall but there could be others, like pre/post upgrade.

@ysbaddaden ysbaddaden modified the milestone: v0.4.0 Aug 2, 2015
ysbaddaden added a commit that referenced this issue Aug 16, 2015
Dependencies may now have a post install script hook that will be
run whenever the dependency is installed or updated:

    - scripts:
      - postinstall: "cd ext && make"

refs #15
@ysbaddaden
Copy link
Contributor

@technorama I just implemented the postinstall script in #19, tell me if it fits your needs.

@ysbaddaden
Copy link
Contributor

Closing since #19 got merged.

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

No branches or pull requests

5 participants
@ysbaddaden @technorama @kostya @straight-shoota and others