ritual 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ module Ritual
2
+ module Extension
3
+ class JRuby < Base
4
+ def define_task
5
+ task 'gem:build' => task_name
6
+ desc "Build the #{name} extension."
7
+ task task_name do
8
+ relative_install_path = relative_path(install_path)
9
+ relative_compiled_paths = compiled_paths.map { |p| relative_path(p) }
10
+ class_path = "#{Config::CONFIG['prefix']}/lib/jruby.jar"
11
+
12
+ sh 'javac', '-g', '-classpath', class_path, *source_paths
13
+ Dir.chdir path do
14
+ mkdir_p File.dirname(relative_install_path)
15
+ sh 'jar', 'cf', relative_install_path, *relative_compiled_paths
16
+ end
17
+ end
18
+ end
19
+
20
+ def source_paths
21
+ @source_paths ||= FileList["#{path}/**/*.java"]
22
+ end
23
+
24
+ protected
25
+
26
+ def compiled_path_for(source)
27
+ source.sub(/\.java\z/, '.class')
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ module Ritual
2
+ module Extension
3
+ class Standard < Base
4
+ def define_task
5
+ desc "Build the #{name} extension."
6
+ task task_name do
7
+ relative_build_path = relative_path(build_path)
8
+ relative_install_path = relative_path(install_path)
9
+ Dir.chdir path do
10
+ ruby 'extconf.rb'
11
+ sh(RUBY_PLATFORM =~ /win32/ ? 'nmake' : 'make')
12
+ mkdir_p File.dirname(relative_install_path)
13
+ sh "cp #{relative_build_path} #{relative_install_path}"
14
+ end
15
+ end
16
+ end
17
+
18
+ def source_paths
19
+ @sources ||= Dir["#{path}/**/*.{c,cxx,cpp,C}"]
20
+ end
21
+
22
+ protected
23
+
24
+ def compiled_path_for(source)
25
+ source.sub(/\.c(?:pp|xx)?\z/i, '.o')
26
+ end
27
+ end
28
+ end
29
+ end