Skip to content

Improve Ruby extension Compilation#13

Merged
marcoroth merged 3 commits intomainfrom
ruby-extension-compile
Feb 9, 2025
Merged

Improve Ruby extension Compilation#13
marcoroth merged 3 commits intomainfrom
ruby-extension-compile

Conversation

@karreiro
Copy link
Contributor

@karreiro karreiro commented Oct 7, 2024

What does this PR do?

This PR focuses on getting the project build passing and on incorporating the compile/clean tasks into the Rakefile. This should help us integrate everything a bit more smoothly into the publishing workflow.

Question

The way we currently build the native extension involves two phases—one with the Makefile in the root and another generated by ext/erbx/extconf.rb. While this setup works, it adds an extra point of failure for users compiling the gem from source.

What do you think about adjusting the directory structure to have a single compilation process based on ext/erbx/extconf.rb? We could move from this:

.
├── Gemfile
├── ext
│   └── erbx
│       ├── extconf.rb
│       ├── extension.c
│       ├── extension.h
│       ├── test
│       │   ├── lexer_test.rb
│       │   └── test_helper.rb
│       └── test.rb
├── src
│   ├── array.c
│   ├── ast.c
│   ├── buffer.c
│   ├── erbx.c
│   ├── include
│   │   ├── array.h
│   │   ├── ...
│   │   └── version.h

To something like this:

.
├── Gemfile
├── ext
│   └── erbx
│       ├── erbx.c
│       ├── erbx.h
│       ├── extconf.rb
│       └── src
│           ├── array.c
│           ├── ast.c
│           ├── ...
│           └── buffer.c
├── lib
│   ├── erbx
│   │   ├── erbx.bundle
│   │   └── version.rb
│   └── erbx.rb

I think this change could simplify things and make the build process a bit safer. I do like the current style of the repository, but having just one Makefile, based on ext/erbx/extconf.rb seems like a more straightforward convention to follow.

@karreiro karreiro requested a review from marcoroth October 7, 2024 23:00
@karreiro karreiro changed the title Ruby extension compile Ruby extension compilation Oct 7, 2024
Base automatically changed from ruby-extension to main February 9, 2025 00:01
@marcoroth marcoroth force-pushed the ruby-extension-compile branch from d4ef574 to 0c3d54b Compare February 9, 2025 14:17
@marcoroth marcoroth changed the title Ruby extension compilation Improve Ruby extension Compilation Feb 9, 2025
Copy link
Owner

@marcoroth marcoroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @karreiro, thanks so much for this improvement!

After cherry-picking some of your commits from here into #3 I merged that PR. Now I rebased this PR off of main which is why there are only 3 commits left now.

But either way, I think they improve the way the project gets compiled!

As per your question, I opened #14 to keep that valid question around.

Ideally we could simply the process with the suggestions you made, but the reason why I personally wanted to keep it separate was because this projects is primarily meant to be a C-Project.

For now, the Ruby gem is just a convenience for testing and ease-of-use. Which is why I feel like it doesn't make sense to let the Ruby extension itself dictate the folder structure of the whole project at this point.

That said, I'm new to writing C, and Ruby C-extensions for that matter. So maybe there is a reason why we'd want to do that.

I think for now in this PR it makes sense to keep it that way. But please let me know if you have any concerns with this approach. I'm more than happy to adapt it at a later point.

@marcoroth marcoroth merged commit 0241320 into main Feb 9, 2025
3 checks passed
@marcoroth marcoroth deleted the ruby-extension-compile branch February 9, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants