RubyInline 3.6.7 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,19 @@
1
+ === 3.7.0 / 2008-06-09
2
+
3
+ * 1 major enhancements:
4
+
5
+ * Removed inline_package in favor of hoe's packaging.
6
+
7
+ * 2 minor enhancements:
8
+
9
+ * Switched from warn/exit to abort to fix buffering for error messages.
10
+ * Improved some error messages.
11
+
12
+ * 2 bug fixes:
13
+
14
+ * Fixes for rubinius.
15
+ * Fixes for 1.9.
16
+
1
17
  === 3.6.7 / 2008-03-20
2
18
 
3
19
  * 3 minor enhancements:
@@ -2,7 +2,6 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
- bin/inline_package
6
5
  demo/fastmath.rb
7
6
  demo/hello.rb
8
7
  example.rb
data/README.txt CHANGED
@@ -7,14 +7,29 @@
7
7
 
8
8
  == DESCRIPTION:
9
9
 
10
- Ruby Inline is an analog to Perl's Inline::C. Out of the box, it
11
- allows you to embed C/++ external module code in your ruby script
12
- directly. By writing simple builder classes, you can teach how to cope
13
- with new languages (fortran, perl, whatever). The code is compiled and
14
- run on the fly when needed.
10
+ Inline allows you to write foreign code within your ruby code. It
11
+ automatically determines if the code in question has changed and
12
+ builds it only when necessary. The extensions are then automatically
13
+ loaded into the class/module that defines it.
15
14
 
16
- Using the package_inline tool Inline allows you to package up your
17
- inlined object code for distribution to systems without a compiler.
15
+ You can even write extra builders that will allow you to write inlined
16
+ code in any language. Use Inline::C as a template and look at
17
+ Module#inline for the required API.
18
+
19
+ == PACKAGING:
20
+
21
+ To package your binaries into a gem, use hoe's INLINE and
22
+ FORCE_PLATFORM env vars.
23
+
24
+ Example:
25
+
26
+ rake package INLINE=1
27
+
28
+ or:
29
+
30
+ rake package INLINE=1 FORCE_PLATFORM=mswin32
31
+
32
+ See hoe for more details.
18
33
 
19
34
  == FEATURES/PROBLEMS:
20
35
 
@@ -26,7 +41,6 @@ inlined object code for distribution to systems without a compiler.
26
41
  + Only recompiles if the inlined code has changed.
27
42
  + Pretends to be secure.
28
43
  + Only requires standard ruby libraries, nothing extra to download.
29
- + Can generate a basic Rakefile and package up built extensions for distribution.
30
44
 
31
45
  == SYNOPSYS:
32
46
 
@@ -62,13 +76,6 @@ inlined object code for distribution to systems without a compiler.
62
76
  t = MyTest.new()
63
77
  t.hello(3)
64
78
 
65
- == SYNOPSYS (packaging):
66
-
67
- rm -rf ~/.ruby_inline
68
- make test
69
- inline_package packagename 1.0.0
70
- ls lib/inline
71
-
72
79
  == (PSEUDO)BENCHMARKS:
73
80
 
74
81
  > make bench
@@ -100,7 +107,6 @@ inlined object code for distribution to systems without a compiler.
100
107
  + POSIX compliant system (ie pretty much any UNIX, or Cygwin on MS platforms).
101
108
  + A C/C++ compiler (the same one that compiled your ruby interpreter).
102
109
  + test::unit for running tests ( http://testunit.talbott.ws/ ).
103
- + rubygems & rake if you'd like - these are used by inline_package.
104
110
 
105
111
  == INSTALL:
106
112
 
data/Rakefile CHANGED
@@ -13,6 +13,8 @@ Hoe.new("RubyInline", Inline::VERSION) do |inline|
13
13
  "A POSIX environment and a compiler for your language."
14
14
  end
15
15
 
16
+ task :test => :clean
17
+
16
18
  desc "run all examples"
17
19
  task :examples do
18
20
  %w(example.rb example2.rb
data/example.rb CHANGED
File without changes
File without changes
@@ -4,7 +4,7 @@
4
4
  # Ruby Inline is a framework for writing ruby extensions in foreign
5
5
  # languages.
6
6
  #
7
- # = SYNOPSIS
7
+ # == SYNOPSIS
8
8
  #
9
9
  # require 'inline'
10
10
  # class MyClass
@@ -20,24 +20,37 @@
20
20
  # end
21
21
  # end
22
22
  #
23
- # = DESCRIPTION
23
+ # == DESCRIPTION
24
24
  #
25
25
  # Inline allows you to write foreign code within your ruby code. It
26
26
  # automatically determines if the code in question has changed and
27
27
  # builds it only when necessary. The extensions are then automatically
28
28
  # loaded into the class/module that defines it.
29
29
  #
30
- # Using the package_inline tool Inline now allows you to package up
31
- # your inlined object code for distribution to systems without a
32
- # compiler (read: windows)!
33
- #
34
30
  # You can even write extra builders that will allow you to write
35
31
  # inlined code in any language. Use Inline::C as a template and look
36
32
  # at Module#inline for the required API.
33
+ #
34
+ # == PACKAGING
35
+ #
36
+ # To package your binaries into a gem, use hoe's INLINE and
37
+ # FORCE_PLATFORM env vars.
38
+ #
39
+ # Example:
40
+ #
41
+ # rake package INLINE=1
42
+ #
43
+ # or:
44
+ #
45
+ # rake package INLINE=1 FORCE_PLATFORM=mswin32
46
+ #
47
+ # See hoe for more details.
48
+ #
37
49
 
38
50
  require "rbconfig"
39
51
  require "digest/md5"
40
52
  require 'fileutils'
53
+ require 'rubygems'
41
54
 
42
55
  $TESTING = false unless defined? $TESTING
43
56
 
@@ -50,12 +63,20 @@ class CompilationError < RuntimeError; end
50
63
  # the current namespace.
51
64
 
52
65
  module Inline
53
- VERSION = '3.6.7'
66
+ VERSION = '3.7.0'
54
67
 
55
68
  WINDOZE = /win(32|64)/ =~ RUBY_PLATFORM
69
+ RUBINIUS = defined? RUBY_ENGINE
56
70
  DEV_NULL = (WINDOZE ? 'nul' : '/dev/null')
57
- RAKE = (WINDOZE ? 'rake.bat' : 'rake')
58
71
  GEM = (WINDOZE ? 'gem.bat' : 'gem')
72
+ RAKE = if WINDOZE then
73
+ 'rake.bat'
74
+ elsif RUBINIUS then
75
+ File.join(Gem.bindir, 'rake')
76
+ else
77
+ "#{Gem.ruby} -S rake"
78
+ end
79
+
59
80
 
60
81
  warn "RubyInline v #{VERSION}" if $DEBUG
61
82
 
@@ -69,8 +90,7 @@ module Inline
69
90
  env = ENV['HOMEDRIVE'] + ENV['HOMEPATH'] if env.nil? and WINDOZE
70
91
 
71
92
  if env.nil? then
72
- warn "Define INLINEDIR or HOME in your environment and try again"
73
- exit 1
93
+ abort "Define INLINEDIR or HOME in your environment and try again"
74
94
  end
75
95
 
76
96
  unless defined? @@rootdir and env == @@rootdir and test ?d, @@rootdir then
@@ -348,8 +368,9 @@ module Inline
348
368
  io.puts " VALUE c = rb_cObject;"
349
369
 
350
370
  # TODO: use rb_class2path
371
+ # io.puts " VALUE c = rb_path2class(#{@mod.name.inspect});"
351
372
  io.puts @mod.name.split("::").map { |n|
352
- " c = rb_const_get_at(c,rb_intern(\"#{n}\"));"
373
+ " c = rb_const_get(c,rb_intern(\"#{n}\"));"
353
374
  }.join("\n")
354
375
 
355
376
  @sig.keys.sort.each do |name|
@@ -387,7 +408,7 @@ module Inline
387
408
  if recompile then
388
409
 
389
410
  hdrdir = %w(srcdir archdir rubyhdrdir).map { |name|
390
- dir = Config::CONFIG[name]
411
+ Config::CONFIG[name]
391
412
  }.find { |dir|
392
413
  dir and File.exist? File.join(dir, "/ruby.h")
393
414
  } or abort "ERROR: Can't find header dir for ruby. Exiting..."
@@ -425,7 +446,7 @@ module Inline
425
446
  if $? != 0 then
426
447
  bad_src_name = src_name + ".bad"
427
448
  File.rename src_name, bad_src_name
428
- raise CompilationError, "error executing #{cmd}: #{$?}\nRenamed #{src_name} to #{bad_src_name}"
449
+ raise CompilationError, "error executing #{cmd.inspect}: #{$?}\nRenamed #{src_name} to #{bad_src_name}"
429
450
  end
430
451
 
431
452
  # NOTE: manifest embedding is only required when using VC8 ruby
@@ -590,82 +611,6 @@ module Inline
590
611
  end
591
612
 
592
613
  end # class Inline::C
593
- class Packager
594
- attr_accessor :name, :version, :summary, :libs_copied, :inline_dir
595
-
596
- def initialize(name, version, summary = '')
597
- @name = name
598
- @version = version
599
- @summary = summary
600
- @libs_copied = false
601
- @ext = Config::CONFIG['DLEXT']
602
-
603
- # TODO (maybe) put libs in platform dir
604
- @inline_dir = File.join "lib", "inline"
605
- end
606
-
607
- def package
608
- copy_libs
609
- generate_rakefile
610
- build_gem
611
- end
612
-
613
- def copy_libs
614
- unless @libs_copied then
615
- FileUtils.mkdir_p @inline_dir
616
- built_libs = Dir.glob File.join(Inline.directory, "*.#{@ext}")
617
- FileUtils.cp built_libs, @inline_dir
618
- @libs_copied = true
619
- end
620
- end
621
-
622
- def generate_rakefile
623
- if File.exists? 'Rakefile' then
624
- unless $TESTING then
625
- STDERR.puts "Hrm, you already have a Rakefile, so I didn't touch it."
626
- STDERR.puts "You might have to add the following files to your gemspec's files list:"
627
- STDERR.puts "\t#{gem_libs.join "\n\t"}"
628
- end
629
- return
630
- end
631
-
632
- rakefile = eval RAKEFILE_TEMPLATE
633
-
634
- STDERR.puts "==> Generating Rakefile" unless $TESTING
635
- File.open 'Rakefile', 'w' do |fp|
636
- fp.puts rakefile
637
- end
638
- end
639
-
640
- def build_gem
641
- STDERR.puts "==> Running rake" unless $TESTING or $DEBUG
642
-
643
- cmd = "#{RAKE} package"
644
- cmd += "> #{DEV_NULL} 2> #{DEV_NULL}" if $TESTING unless $DEBUG
645
-
646
- if system cmd then
647
- unless $TESTING then
648
- STDERR.puts
649
- STDERR.puts "Ok, you now have a gem in ./pkg, enjoy!"
650
- end
651
- else
652
- STDERR.puts "Calling rake to build the gem failed." unless $TESTING
653
- end
654
- end
655
-
656
- def gem_libs
657
- unless defined? @gem_libs then
658
- @gem_libs = Dir.glob File.join(@inline_dir, "*.#{@ext}")
659
- files = Dir.glob(File.join('lib', '*')).select { |f| test ?f, f }
660
-
661
- @gem_libs.push(*files)
662
- @gem_libs.sort!
663
- end
664
- @gem_libs
665
- end
666
-
667
- RAKEFILE_TEMPLATE = '%[require "rake"\nrequire "rake/gempackagetask"\n\nsummary = #{summary.inspect}\n\nif summary.empty? then\n STDERR.puts "*************************************"\n STDERR.puts "*** Summary not filled in, SHAME! ***"\n STDERR.puts "*************************************"\nend\n\nspec = Gem::Specification.new do |s|\n s.name = #{name.inspect}\n s.version = #{version.inspect}\n s.summary = summary\n\n s.has_rdoc = false\n s.files = #{gem_libs.inspect}\n s.add_dependency "RubyInline", ">= 3.3.0"\n s.require_path = "lib"\nend\n\ndesc "Builds a gem with #{name} in it"\nRake::GemPackageTask.new spec do |pkg|\n pkg.need_zip = false\n pkg.need_tar = false\nend\n]'
668
- end # class Packager
669
614
  end # module Inline
670
615
 
671
616
  class Module
@@ -1,6 +1,6 @@
1
1
  $TESTING = true
2
2
 
3
- $0 = __FILE__ if $0 == "-e" # for autotest style execution
3
+ $0 = __FILE__ if $0 =~ /-e|\(eval\)/
4
4
 
5
5
  require 'inline'
6
6
  require 'tempfile'
@@ -10,18 +10,7 @@ require 'fileutils' unless defined?(::FileUtils)
10
10
 
11
11
  File.umask(0)
12
12
 
13
- module Foo
14
- class Bar
15
- inline do |builder|
16
- builder.c <<-EOC
17
- int arity6(int u, int v, int w, int x, int y, char * z) { return x + y + strlen(z); }
18
- EOC
19
- end
20
- end
21
- end
22
-
23
13
  class InlineTestCase < Test::Unit::TestCase
24
-
25
14
  def setup
26
15
  super
27
16
  @rootdir = File.join(Dir.tmpdir, "test_inline.#{$$}")
@@ -40,7 +29,6 @@ class InlineTestCase < Test::Unit::TestCase
40
29
  def test_stupid
41
30
  #shuts test unit up
42
31
  end
43
-
44
32
  end
45
33
 
46
34
  class TestDir < InlineTestCase
@@ -54,9 +42,7 @@ class TestDir < InlineTestCase
54
42
  @count += 1
55
43
  Dir.mkdir path, perms unless perms.nil?
56
44
  if should_pass then
57
- assert_nothing_raised do
58
- Dir.assert_secure path
59
- end
45
+ Dir.assert_secure path
60
46
  else
61
47
  assert_raises(SecurityError) do
62
48
  Dir.assert_secure path
@@ -377,7 +363,7 @@ return INT2FIX(42)}"
377
363
  return q+x+y+z;
378
364
  }"
379
365
 
380
- assert_raise(ArgumentError) do
366
+ assert_raises ArgumentError do
381
367
  @builder.generate src, true
382
368
  end
383
369
  end
@@ -591,6 +577,12 @@ puts(s); return rb_str_new2(s)}"
591
577
  end # class TestC
592
578
  end # class TestInline
593
579
 
580
+ module Foo
581
+ class Bar
582
+ # inline stuff will go here...
583
+ end
584
+ end
585
+
594
586
  $test_module_code = <<-EOR
595
587
  module Foo
596
588
  class Bar
@@ -627,7 +619,6 @@ end
627
619
  EOR
628
620
 
629
621
  class TestModule < InlineTestCase
630
-
631
622
  def test_nested
632
623
  Object.class_eval $test_module_code
633
624
  fb = Foo::Bar.new
@@ -638,33 +629,36 @@ class TestModule < InlineTestCase
638
629
  tempfile.write($test_module_code2)
639
630
  tempfile.flush
640
631
  tempfile.rewind
641
-
632
+
642
633
  FileUtils.cp tempfile.path, "#{tempfile.path}.rb"
643
-
634
+
644
635
  require "#{tempfile.path}.rb"
645
636
  assert_equal(12, fb.twelve_instance)
646
637
  assert_equal(12, Foo::Bar.twelve_class)
647
-
638
+
648
639
  FileUtils.rm "#{tempfile.path}.rb"
649
640
  end
650
641
 
651
642
  def test_argument_check_good
643
+ util_arity_check
652
644
  fb = Foo::Bar.new
653
645
  assert_equal 13, fb.arity6(1, 2, 3, 4, 5, "blah")
654
646
  end
655
647
 
656
648
  def test_argument_check_fewer
649
+ util_arity_check
657
650
  fb = Foo::Bar.new
658
651
 
659
- assert_raise(ArgumentError) do
660
- assert_equal 13, fb.arity6(1, 2, 3)
652
+ assert_raises ArgumentError do
653
+ fb.arity6(1, 2, 3)
661
654
  end
662
655
  end
663
656
 
664
657
  def test_argument_check_more
658
+ util_arity_check
665
659
  fb = Foo::Bar.new
666
- assert_raise ArgumentError do
667
- assert_equal 13, fb.arity6(1, 2, 3, 4, 5, "blah", :extra)
660
+ assert_raises ArgumentError do
661
+ fb.arity6(1, 2, 3, 4, 5, "blah", :extra)
668
662
  end
669
663
  end
670
664
 
@@ -681,113 +675,14 @@ class TestModule < InlineTestCase
681
675
  "Library file should have been created")
682
676
  end
683
677
 
684
- end
685
-
686
- class TestInlinePackager < InlineTestCase
678
+ def util_arity_check
679
+ methods = Foo::Bar.public_instance_methods.map { |s| s.to_s }
687
680
 
688
- def setup
689
- super
690
-
691
- @name = "Packager Test"
692
- @version = "1.0.0"
693
- @summary = "This is a Packager test gem"
694
- @packager = Inline::Packager.new @name, @version, @summary
695
-
696
- @package_dir = @rootdir + "_package"
697
- Dir.mkdir @package_dir, 0700 unless test ?d, @package_dir
698
- @orig_dir = Dir.pwd
699
- Dir.chdir @package_dir
700
-
701
- @ext = Config::CONFIG['DLEXT']
702
- end
703
-
704
- def teardown
705
- super
706
- Dir.chdir @orig_dir
707
- FileUtils.rm_rf @package_dir unless $DEBUG
708
- end
709
-
710
- def util_generate_rakefile
711
- summary = @summary
712
- name = @name
713
- version = @version
714
- gem_libs = []
715
-
716
- eval Inline::Packager::RAKEFILE_TEMPLATE
717
- end
718
-
719
- def test_initialize
720
- assert_equal "lib/inline", @packager.inline_dir
721
- assert_equal false, @packager.libs_copied
722
- end
723
-
724
- def test_package
725
- assert_nothing_raised do
726
- @packager.package
727
- end
728
- end
729
-
730
- def test_copy_libs
731
- assert_equal false, @packager.libs_copied
732
-
733
- built_lib = "Inline_Test.#{@ext}"
734
- dir = "#{@rootdir}/.ruby_inline"
735
-
736
- Dir.mkdir dir, 0700 unless test ?d, dir
737
- Dir.chdir dir do
738
- FileUtils.touch built_lib
739
- end
740
-
741
- @packager.copy_libs
742
-
743
- assert_equal true, File.directory?("#{@package_dir}/lib/inline")
744
- assert_equal true, File.exists?("#{@package_dir}/lib/inline/#{built_lib}")
745
-
746
- assert_equal true, @packager.libs_copied
747
- end
748
-
749
- def test_generate_rakefile_has_rakefile
750
- FileUtils.rm 'Rakefile' if test ?f, 'Rakefile' and $DEBUG
751
- FileUtils.touch 'Rakefile'
752
-
753
- @packager.generate_rakefile
754
-
755
- assert_equal "", File.read('Rakefile')
756
- end
757
-
758
- def test_generate_rakefile_no_rakefile
759
- FileUtils.rm 'Rakefile' if test ?f, 'Rakefile' and $DEBUG
760
- FileUtils.rm_r 'lib' if test ?d, 'lib' and $DEBUG
761
-
762
- @packager.generate_rakefile
763
-
764
- assert_equal util_generate_rakefile, File.read('Rakefile')
765
- end
766
-
767
- def test_build_gem
768
- # test_copy_libs
769
- pwd = Dir.pwd
770
-
771
- File.open 'Rakefile', 'w' do |fp|
772
- src = util_generate_rakefile
773
- fp.puts src
681
+ unless methods.include? "arity6" then
682
+ Foo::Bar.inline do |builder|
683
+ builder.include "<string.h>"
684
+ builder.c "int arity6(int u, int v, int w, int x, int y, char * z) { return x + y + strlen(z); }"
685
+ end
774
686
  end
775
-
776
- @packager.build_gem
777
-
778
- package_name = "pkg/#{@name}-#{@version}.gem"
779
- assert File.exists?(package_name), "File #{package_name} must exist"
780
- assert system("#{Inline::GEM} check #{package_name}"), "gem check must pass"
781
- end
782
-
783
- def test_gem_libs
784
- system "rm lib/inline/*" if $DEBUG # hacky
785
- @packager.libs_copied = true
786
- expected = ["lib/blah.rb", "lib/inline/Inline_Test.#{@ext}"]
787
-
788
- FileUtils.mkdir_p "lib/inline"
789
- FileUtils.touch(expected)
790
-
791
- assert_equal expected, @packager.gem_libs
792
687
  end
793
688
  end
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RubyInline
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.7
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-20 00:00:00 -07:00
12
+ date: 2008-06-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,13 +19,13 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.5.1
22
+ version: 1.5.3
23
23
  version:
24
- description: Ruby Inline is an analog to Perl's Inline::C. Out of the box, it allows you to embed C/++ external module code in your ruby script directly. By writing simple builder classes, you can teach how to cope with new languages (fortran, perl, whatever). The code is compiled and run on the fly when needed. Using the package_inline tool Inline allows you to package up your inlined object code for distribution to systems without a compiler.
24
+ description: Inline allows you to write foreign code within your ruby code. It automatically determines if the code in question has changed and builds it only when necessary. The extensions are then automatically loaded into the class/module that defines it. You can even write extra builders that will allow you to write inlined code in any language. Use Inline::C as a template and look at Module#inline for the required API.
25
25
  email:
26
26
  - ryand-ruby@zenspider.com
27
- executables:
28
- - inline_package
27
+ executables: []
28
+
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
@@ -37,7 +37,6 @@ files:
37
37
  - Manifest.txt
38
38
  - README.txt
39
39
  - Rakefile
40
- - bin/inline_package
41
40
  - demo/fastmath.rb
42
41
  - demo/hello.rb
43
42
  - example.rb
@@ -69,9 +68,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
68
  requirements:
70
69
  - A POSIX environment and a compiler for your language.
71
70
  rubyforge_project: rubyinline
72
- rubygems_version: 1.0.1
71
+ rubygems_version: 1.1.1
73
72
  signing_key:
74
73
  specification_version: 2
75
- summary: Ruby Inline is an analog to Perl's Inline::C
74
+ summary: Inline allows you to write foreign code within your ruby code
76
75
  test_files:
77
76
  - test/test_inline.rb
@@ -1,15 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- require 'inline'
4
-
5
- name = ARGV.shift
6
- version = ARGV.shift
7
- summary = ARGV.shift || ""
8
-
9
- if version.nil? then # TODO better usage
10
- STDERR.puts "Usage: #{$0} NAME VERSION [SUMMARY]"
11
- exit 1
12
- end
13
-
14
- packager = Inline::Packager.new name, version, summary
15
- packager.package