Move extension to a subdirectory

This commit is contained in:
Sami Samhuri 2022-01-16 21:45:41 -08:00
parent 8f6e90d0a6
commit 0795eb3f91
No known key found for this signature in database
GPG key ID: 4B4195422742FC16
6 changed files with 18 additions and 13 deletions

7
.gitignore vendored
View file

@ -7,6 +7,7 @@
/site/
/spec/reports/
/tmp/
ext/Makefile
ext/*.o
ext/*.bundle
ext/**/Makefile
ext/**/*.o
ext/**/*.bundle
*.gem

View file

@ -1,12 +1,18 @@
require 'bundler/gem_tasks'
require 'English'
require 'open3'
require 'rake/testtask'
require 'rubocop/rake_task'
task :compile do
puts 'Compiling C extension'
`cd ext && make clean`
`cd ext && ruby extconf.rb`
`cd ext && make`
# ignore clean failure because the Makefile may not exist yet
cmd = 'cd ext/wordexp_ext && (make clean || true) && ruby extconf.rb && make'
out, status = Open3.capture2e(cmd)
unless status.success?
warn out
raise 'Failed to compile native extension'
end
puts 'Done'
end

View file

@ -1,3 +0,0 @@
require 'mkmf'
create_makefile 'wordexp_ext'

View file

@ -0,0 +1,3 @@
require 'mkmf'
create_makefile 'wordexp_ext/wordexp_ext'

View file

@ -11,12 +11,10 @@
*
*/
#include <ruby.h>
#include <string.h>
#include <wordexp.h>
#include "ruby.h"
#include "ruby/encoding.h"
static VALUE ext_wordexp(VALUE self, VALUE rstring) {
Check_Type(rstring, T_STRING);
char *string = RSTRING_PTR(rstring);

View file

@ -1,4 +1,4 @@
require 'wordexp_ext'
require 'wordexp_ext/wordexp_ext'
module Wordexp
autoload :CLI, 'wordexp/cli'