From 0c2ac199065d36645c867aad8e385bc298e564a1 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 26 Nov 2015 01:07:06 +0900 Subject: [PATCH] Prepare extension in C --- .gitignore | 4 ++++ Rakefile | 9 +++++++-- ext/hamlit/extconf.rb | 3 +++ ext/hamlit/hamlit.c | 6 ++++++ hamlit.gemspec | 2 ++ lib/hamlit/attribute_builder.rb | 1 + 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 ext/hamlit/extconf.rb create mode 100644 ext/hamlit/hamlit.c diff --git a/.gitignore b/.gitignore index 2b16aae4..16c3c8ae 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ .sass-cache /hamlit1 .ruby-version +*.bundle +*.so +*.o +*.a diff --git a/Rakefile b/Rakefile index c8dac157..138c3fe3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ require 'bundler/gem_tasks' require 'rake/testtask' +require 'rake/extensiontask' Dir['benchmark/*.rake'].each { |b| import(b) } @@ -70,5 +71,9 @@ namespace :test do end end -task default: %w[hamlit:test] -task test: %w[test:all] +Rake::ExtensionTask.new(:hamlit) do |ext| + ext.lib_dir = 'lib/hamlit' +end + +task default: %w[compile hamlit:test] +task test: %w[compile test:all] diff --git a/ext/hamlit/extconf.rb b/ext/hamlit/extconf.rb new file mode 100644 index 00000000..f0c98814 --- /dev/null +++ b/ext/hamlit/extconf.rb @@ -0,0 +1,3 @@ +require 'mkmf' + +create_makefile('hamlit/hamlit') diff --git a/ext/hamlit/hamlit.c b/ext/hamlit/hamlit.c new file mode 100644 index 00000000..2ccc229c --- /dev/null +++ b/ext/hamlit/hamlit.c @@ -0,0 +1,6 @@ +#include + +void +Init_hamlit(void) +{ +} diff --git a/hamlit.gemspec b/hamlit.gemspec index 4f43c61c..1a24c0cc 100644 --- a/hamlit.gemspec +++ b/hamlit.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|hamlit1|sample)/}) } spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.extensions = ['ext/hamlit/extconf.rb'] spec.require_paths = ['lib'] spec.add_dependency 'escape_utils' @@ -31,6 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest-reporters', '~> 1.1' spec.add_development_dependency 'rails', '>= 4.0.0' spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'rake-compiler' spec.add_development_dependency 'redcarpet' spec.add_development_dependency 'sass' spec.add_development_dependency 'slim' diff --git a/lib/hamlit/attribute_builder.rb b/lib/hamlit/attribute_builder.rb index 6b2a9bb5..b60f7e07 100644 --- a/lib/hamlit/attribute_builder.rb +++ b/lib/hamlit/attribute_builder.rb @@ -1,3 +1,4 @@ +require 'hamlit/hamlit' require 'hamlit/object_ref' require 'temple/utils'