rbplusplus 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/rdoctask'
3
3
  require 'rake/contrib/sshpublisher'
4
4
 
5
5
  PROJECT_NAME = "rb++"
6
- RBPLUSPLUS_VERSION = "0.1"
6
+ RBPLUSPLUS_VERSION = "0.1.1"
7
7
 
8
8
  task :default => :test
9
9
 
@@ -57,7 +57,8 @@ Rb++ combines the powerful query interface of rbgccxml and the Rice library to
57
57
  make Ruby wrapping extensions easier to write than ever.
58
58
  END
59
59
 
60
- s.add_dependency "rbgccxml", "=0.1"
60
+ s.add_dependency "rbgccxml", "0.1.1"
61
+ s.add_dependency "rice", "1.0.1"
61
62
 
62
63
  patterns = [
63
64
  'TODO',
@@ -54,6 +54,12 @@ module RbPlusPlus
54
54
  # List of libraries to link
55
55
  attr_accessor :libraries
56
56
 
57
+ # List of extra CXXFLAGS that might need to be added to compile lines
58
+ attr_accessor :cxxflags
59
+
60
+ # List of extra LDFLAGS that might need to be added to compile lines
61
+ attr_accessor :ldflags
62
+
57
63
  # Create a new Ruby extension with a given name. This name will be
58
64
  # the module built into the extension.
59
65
  # This constructor can be standalone or take a block.
@@ -64,6 +70,8 @@ module RbPlusPlus
64
70
  @includes = []
65
71
  @lib_paths = []
66
72
  @libraries = []
73
+ @cxxflags = []
74
+ @ldflags = []
67
75
 
68
76
  if block
69
77
  build_working_dir(&block)
@@ -83,6 +91,8 @@ module RbPlusPlus
83
91
  # * <tt>:include_paths</tt> - An array or string of full paths to be added as -I flags
84
92
  # * <tt>:library_paths</tt> - An array or string of full paths to be added as -L flags
85
93
  # * <tt>:libraries</tt> - An array or string of full paths to be added as -l flags
94
+ # * <tt>:cxxflags</tt> - An array or string of flags to be added to command line for parsing / compiling
95
+ # * <tt>:ldflags</tt> - An array or string of flags to be added to command line for linking
86
96
  def sources(dirs, options = {})
87
97
  parser_options = {}
88
98
 
@@ -99,6 +109,15 @@ module RbPlusPlus
99
109
  @libraries << libs
100
110
  end
101
111
 
112
+ if (flags = options.delete(:cxxflags))
113
+ @cxxflags << flags
114
+ parser_options[:cxxflags] = @cxxflags
115
+ end
116
+
117
+ if (flags = options.delete(:ldflags))
118
+ @ldflags << flags
119
+ end
120
+
102
121
  @parser = RbGCCXML.parse(dirs, parser_options)
103
122
  end
104
123
 
@@ -151,6 +170,8 @@ module RbPlusPlus
151
170
  extconf.includes = @includes
152
171
  extconf.library_paths = @lib_paths
153
172
  extconf.libraries = @libraries
173
+ extconf.cxxflags = @cxxflags
174
+ extconf.ldflags = @ldflags
154
175
  extconf.write
155
176
  end
156
177
 
@@ -15,19 +15,28 @@ module RbPlusPlus
15
15
  # List of -l directives
16
16
  attr_accessor :libraries
17
17
 
18
+ # Extra CXXFLAGS
19
+ attr_accessor :cxxflags
20
+
21
+ # Extra LDFLAGS
22
+ attr_accessor :ldflags
23
+
18
24
  def write
19
25
  extconf = File.join(working_dir, "extconf.rb")
20
26
 
21
27
  @includes ||= []
22
28
 
23
29
  inc_str = @includes.flatten.uniq.map {|i| "-I#{i}"}.join(" ")
30
+ inc_str += " " + @cxxflags.flatten.join(" ")
24
31
  lib_path_str = @library_paths.flatten.uniq.map {|i| "-L#{i}"}.join(" ")
25
32
  lib_str = @libraries.flatten.uniq.map {|i| "-l#{i}"}.join(" ")
33
+ lib_str += " " + @ldflags.flatten.join(" ")
26
34
 
27
35
  File.open(extconf, "w+") do |file|
28
36
  file.puts "require \"rubygems\""
29
37
  file.puts "require \"mkmf-rice\""
30
- file.puts %Q($CPPFLAGS = $CPPFLAGS + " -I#{working_dir} #{inc_str} #{lib_path_str} #{lib_str}")
38
+ file.puts %Q($CPPFLAGS = $CPPFLAGS + " -I#{working_dir} #{inc_str}")
39
+ file.puts %Q($LDFLAGS = $LDFLAGS + " #{lib_path_str} #{lib_str}")
31
40
  file.puts "create_makefile(\"#{builder.name}\")"
32
41
  end
33
42
  end
data/lib/rbplusplus.rb CHANGED
@@ -5,6 +5,7 @@ gem 'rbgccxml'
5
5
  require 'rbgccxml'
6
6
 
7
7
  require 'inflector'
8
+ require 'fileutils'
8
9
  require 'rbplusplus/rbplusplus'
9
10
 
10
11
  module RbPlusPlus
@@ -82,4 +82,48 @@ context "Compiler settings" do
82
82
  contents.should.match(%r(-lwonko))
83
83
  contents.should.match(%r(-lprankit))
84
84
  end
85
+
86
+ specify "can add extra cxxflags for gccxml and compiling" do
87
+ e = Extension.new "flags_test"
88
+ e.working_dir = full_dir("generated")
89
+ e.sources full_dir("headers/empty.h"),
90
+ :cxxflags => "-I/i/love/scotch -D__AND_DEFINE_THAT"
91
+ e.build
92
+ e.write
93
+
94
+ ext_file = full_dir("generated/extconf.rb")
95
+
96
+ contents = File.read(ext_file)
97
+
98
+ contents.should.match(%r(-I/i/love/scotch))
99
+ contents.should.match(%r(-D__AND_DEFINE_THAT))
100
+ end
101
+
102
+ specify "can add extra ldflags for gccxml and compiling" do
103
+ e = Extension.new "flags_test"
104
+ e.working_dir = full_dir("generated")
105
+ e.sources full_dir("headers/empty.h"),
106
+ :ldflags => "-R/wootage/to/you -lthisandthat -nothing_here"
107
+ e.build
108
+ e.write
109
+
110
+ ext_file = full_dir("generated/extconf.rb")
111
+
112
+ contents = File.read(ext_file)
113
+
114
+ contents.should.match(%r(-R/wootage/to/you))
115
+ contents.should.match(%r(-lthisandthat))
116
+ contents.should.match(%r(-nothing_here))
117
+ end
118
+
119
+ specify "should pass cxxflags to rbgccxml" do
120
+ should.not.raise do
121
+ e = Extension.new "parsing_test"
122
+ e.working_dir = full_dir("generated")
123
+ e.sources full_dir("headers/requires_define.h"),
124
+ :cxxflags => "-DMUST_BE_DEFINED"
125
+ e.build
126
+ e.write
127
+ end
128
+ end
85
129
  end
@@ -0,0 +1,5 @@
1
+ require "rubygems"
2
+ require "mkmf-rice"
3
+ $CPPFLAGS = $CPPFLAGS + " -I/home/roelofs/projects/rbplusplus/test/generated "
4
+ $LDFLAGS = $LDFLAGS + " "
5
+ create_makefile("adder")
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Test file that's for ensuring that extra CXXFLAGS are
3
+ * properly sent to GCCXML for when the preprocessor is
4
+ * looking for other defines
5
+ */
6
+
7
+ #ifndef MUST_BE_DEFINED
8
+ #error "You're not defining the key that must be defined!"
9
+ #endif
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbplusplus
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Roelofs
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-04 00:00:00 -04:00
12
+ date: 2008-05-12 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,16 @@ dependencies:
19
19
  requirements:
20
20
  - - "="
21
21
  - !ruby/object:Gem::Version
22
- version: "0.1"
22
+ version: 0.1.1
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: rice
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - "="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.0.1
23
32
  version:
24
33
  description: Rb++ combines the powerful query interface of rbgccxml and the Rice library to make Ruby wrapping extensions easier to write than ever.
25
34
  email: jameskilton@gmail.com
@@ -76,6 +85,7 @@ summary: Ruby library to generate Rice wrapper code
76
85
  test_files:
77
86
  - test/classes_test.rb
78
87
  - test/extension_test.rb
88
+ - test/generated/extconf.rb
79
89
  - test/compiling_test.rb
80
90
  - test/modules_test.rb
81
91
  - test/functions_test.rb
@@ -84,6 +94,7 @@ test_files:
84
94
  - test/headers/Subtracter.hpp
85
95
  - test/headers/functions.h
86
96
  - test/headers/empty.h
97
+ - test/headers/requires_define.h
87
98
  - test/headers/nested_classes.h
88
99
  - test/headers/with_includes.h
89
100
  - test/headers/include