ruby-debug-base 0.10.4-java → 0.10.5.rc1-java

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,174 +1,296 @@
1
- require 'rake'
1
+ #!/usr/bin/env rake
2
+ # -*- Ruby -*-
2
3
  require 'rubygems'
3
- require 'rake/clean'
4
- require 'rake/gempackagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rdoc/task'
5
6
  require 'rake/testtask'
6
- require 'rake/rdoctask'
7
+ require 'rake/extensiontask'
8
+ require 'rake/javaextensiontask'
7
9
 
8
- GEM_NAME='ruby-debug-base'
9
- GEM_VERSION='0.10.4'
10
+ $:.push File.expand_path("../lib", __FILE__)
11
+ require "ruby-debug-base/version"
10
12
 
11
- RUBY_DEBUG_JAR='ext/ruby_debug.jar'
13
+ SO_NAME = "ruby_debug.so"
14
+ ROOT_DIR = File.dirname(__FILE__)
12
15
 
13
- CLEAN.include('ext')
14
- CLEAN.include('lib/ruby_debug.jar')
15
-
16
- DIST_FILES = FileList[
16
+ # ------- Default Package ----------
17
+ COMMON_FILES = FileList[
17
18
  'AUTHORS',
19
+ 'CHANGES',
20
+ 'LICENSE',
21
+ 'README',
22
+ 'Rakefile',
23
+ ]
24
+
25
+ CLI_TEST_FILE_LIST = FileList['test/cli/commands/unit/*.rb',
26
+ 'test/cli/commands/*_test.rb',
27
+ 'test/cli/**/*_test.rb',
28
+ 'test/test-*.rb']
29
+ CLI_FILES = COMMON_FILES + FileList[
30
+ "cli/**/*",
18
31
  'ChangeLog',
19
- 'lib/linecache.rb',
20
- 'lib/linecache-ruby.rb',
32
+ 'bin/*',
33
+ 'doc/rdebug.1',
34
+ 'test/rdebug-save.1',
35
+ 'test/**/data/*.cmd',
36
+ 'test/**/data/*.right',
37
+ 'test/**/example/*.rb',
38
+ 'test/config.yaml',
39
+ 'test/**/*.rb',
40
+ 'rdbg.rb',
41
+ CLI_TEST_FILE_LIST
42
+ ]
43
+
44
+ BASE_TEST_FILE_LIST = FileList['test/base/*.rb']
45
+
46
+ BASE_FILES = COMMON_FILES + FileList[
47
+ 'ext/breakpoint.c',
48
+ 'ext/extconf.rb',
49
+ 'ext/ruby_debug.c',
50
+ 'ext/ruby_debug.h',
51
+ 'ext/win32/*',
21
52
  'lib/ruby-debug-base.rb',
22
- 'lib/ruby_debug.jar',
23
- 'lib/tracelines.rb',
24
- 'MIT-LICENSE',
25
- 'Rakefile',
26
- 'README'
53
+ 'lib/ruby-debug-base/version.rb',
54
+ BASE_TEST_FILE_LIST,
27
55
  ]
28
56
 
29
- BASE_TEST_FILE_LIST = %w(
30
- test/base/base.rb
31
- test/base/binding.rb
32
- test/base/catchpoint.rb)
57
+ ext = File.join(ROOT_DIR, 'ext')
33
58
 
34
- task :default => :package
59
+ desc "Test everything."
60
+ Rake::TestTask.new(:test) do |t|
61
+ t.libs += %W(#{ROOT_DIR}/lib #{ROOT_DIR}/cli)
62
+ t.libs << ext if File.exist?(ext)
63
+ t.test_files = CLI_TEST_FILE_LIST
64
+ t.options = '--verbose' if $VERBOSE
65
+ t.ruby_opts << "--debug" if defined?(JRUBY_VERSION)
66
+ end
35
67
 
36
- CLI_TEST_FILE_LIST = 'test/test-*.rb'
68
+ task :test => :test_base if File.exist?(ext)
37
69
 
38
70
  desc "Test ruby-debug-base."
39
- task :test_base => :lib do
40
- Rake::TestTask.new(:test_base) do |t|
41
- t.libs << './ext'
42
- t.libs << './lib'
43
- t.test_files = FileList[BASE_TEST_FILE_LIST]
44
- t.verbose = true
45
- end
71
+ Rake::TestTask.new(:test_base) do |t|
72
+ t.libs += ['./ext', './lib']
73
+ t.test_files = FileList[BASE_TEST_FILE_LIST]
74
+ t.options = '--verbose' if $VERBOSE
75
+ t.ruby_opts << "--debug" if defined?(JRUBY_VERSION)
46
76
  end
47
77
 
48
- desc "Test everything."
49
- task :test => :test_base do
50
- Rake::TestTask.new(:test) do |t|
51
- t.libs << './ext'
52
- t.libs << './lib'
53
- t.libs << './cli'
54
- t.pattern = CLI_TEST_FILE_LIST
55
- t.verbose = true
56
- end
78
+ if defined?(JRUBY_VERSION)
79
+ task :test_base => 'jruby:compile:java'
80
+ else
81
+ task :test_base => :compile
82
+ end
83
+
84
+ desc "Test everything - same as test."
85
+ task :check => :test
86
+
87
+ desc "Create a GNU-style ChangeLog via svn2cl"
88
+ task :ChangeLog do
89
+ system('git log --pretty --numstat --summary | git2cl > ChangeLog')
90
+ system('git log --pretty --numstat --summary ext | git2cl > ext/ChangeLog')
91
+ system('git log --pretty --numstat --summary lib | git2cl > lib/ChangeLog')
57
92
  end
58
93
 
59
- desc "Helps to setup the project to be able to run tests"
60
- task :prepare_tests do
61
- # needed to run CLI test. Unable to use svn:externals yet:
62
- # http://subversion.tigris.org/issues/show_bug.cgi?id=937
94
+ # Base GEM Specification
95
+ base_spec = Gem::Specification.new do |spec|
96
+ spec.name = "ruby-debug-base"
63
97
 
64
- # rdbg.rb
65
- sh "svn cat svn://rubyforge.org/var/svn/ruby-debug/tags/ruby-debug-#{GEM_VERSION}/rdbg.rb > rdbg.rb" unless File.exists?('rdbg.rb')
66
-
67
- # runner.sh
68
- runner = 'runner.sh'
69
- sh "svn cat svn://rubyforge.org/var/svn/ruby-debug/tags/ruby-debug-#{GEM_VERSION}/runner.sh > #{runner}" unless File.exists?(runner)
70
- text = File.read('runner.sh')
71
- File.open(runner, 'w') {|f| f.write(text.gsub(/-ruby/ , '-jruby --debug'))}
72
- File.chmod(0755, runner)
73
-
74
- File.open('test/config.private.yaml', 'w') do |f|
75
- f.write <<EOF
76
- # either should be on the $PATH or use full path
77
- ruby: jruby
78
-
79
- # possibility to specify interpreter parameters
80
- ruby_params: --debug
98
+ spec.homepage = "http://rubyforge.org/projects/ruby-debug/"
99
+ spec.summary = "Fast Ruby debugger - core component"
100
+ spec.description = <<-EOF
101
+ ruby-debug is a fast implementation of the standard Ruby debugger debug.rb.
102
+ It is implemented by utilizing a new Ruby C API hook. The core component
103
+ provides support that front-ends can build on. It provides breakpoint
104
+ handling, bindings for stack frames among other things.
81
105
  EOF
82
- end
83
106
 
84
- # - prepare default customized test/config.private.yaml suitable for JRuby
85
- # - tweak test suite to be able to pass for jruby-debug-base which does not
86
- # support e.g. TraceLineNumbers yet.
87
- sh "patch -p0 < patch-#{GEM_VERSION}.diff"
107
+ spec.version = Debugger::VERSION
108
+
109
+ spec.author = "Kent Sibilev"
110
+ spec.email = "ksibilev@yahoo.com"
111
+ spec.platform = Gem::Platform::RUBY
112
+ spec.require_path = "lib"
113
+ spec.extensions = ["ext/extconf.rb"]
114
+ spec.files = BASE_FILES.to_a
115
+
116
+ spec.required_ruby_version = '>= 1.8.2'
117
+ spec.date = Time.now
118
+ spec.rubyforge_project = 'ruby-debug'
119
+ spec.add_dependency('linecache', '>= 0.3')
120
+ spec.add_development_dependency('rake-compiler')
121
+
122
+ spec.test_files = FileList[BASE_TEST_FILE_LIST]
123
+
124
+ # rdoc
125
+ spec.has_rdoc = true
126
+ spec.extra_rdoc_files = ['README', 'ext/ruby_debug.c']
88
127
  end
89
128
 
90
- desc "Create the core ruby-debug shared library extension"
91
- task :lib do
92
- compile_java
93
- make_jar
129
+ cli_spec = Gem::Specification.new do |spec|
130
+ spec.name = "ruby-debug"
131
+
132
+ spec.homepage = "http://rubyforge.org/projects/ruby-debug/"
133
+ spec.summary = "Command line interface (CLI) for ruby-debug-base"
134
+ spec.description = <<-EOF
135
+ A generic command line interface for ruby-debug.
136
+ EOF
137
+
138
+ spec.version = Debugger::VERSION
139
+
140
+ spec.author = "Kent Sibilev"
141
+ spec.email = "ksibilev@yahoo.com"
142
+ spec.platform = Gem::Platform::RUBY
143
+ spec.require_path = "cli"
144
+ spec.bindir = "bin"
145
+ spec.executables = ["rdebug"]
146
+ spec.files = CLI_FILES.to_a
147
+
148
+ spec.required_ruby_version = '>= 1.8.2'
149
+ spec.date = Time.now
150
+ spec.rubyforge_project = 'ruby-debug'
151
+ spec.add_dependency('columnize', '>= 0.1')
152
+ spec.add_dependency('ruby-debug-base', "~> #{Debugger::VERSION}.0")
153
+
154
+ # FIXME: work out operational logistics for this
155
+ # spec.test_files = FileList[CLI_TEST_FILE_LIST]
156
+
157
+ # rdoc
158
+ spec.has_rdoc = true
159
+ spec.extra_rdoc_files = ['README']
94
160
  end
95
161
 
96
- file RUBY_DEBUG_JAR => :lib
162
+ # Rake task to build the default package
163
+ Gem::PackageTask.new(base_spec) do |pkg|
164
+ pkg.need_tar = true
165
+ end
166
+ Gem::PackageTask.new(cli_spec) do |pkg|
167
+ pkg.need_tar = true
168
+ end
97
169
 
98
- spec = Gem::Specification.new do |s|
99
- s.platform = "java"
100
- s.summary = "Java implementation of Fast Ruby Debugger"
101
- s.name = GEM_NAME
102
- s.version = GEM_VERSION
103
- s.require_path = 'lib'
104
- s.files = DIST_FILES
105
- s.description = <<-EOF
106
- Java extension to make fast ruby debugger run on JRuby.
107
- It is the same what ruby-debug-base is for native Ruby.
108
- EOF
109
- s.author = 'debug-commons team'
110
- s.homepage = 'http://rubyforge.org/projects/debug-commons/'
111
- s.has_rdoc = true
112
- s.rubyforge_project = 'debug-commons'
170
+ Rake::ExtensionTask.new('ruby_debug', base_spec) do |t|
171
+ t.ext_dir = "ext"
113
172
  end
114
173
 
115
- gem_name = "#{GEM_NAME}-#{GEM_VERSION}-#{spec.platform}.gem"
174
+ task :default => :test
175
+
176
+ # Windows specification
177
+ win_spec = base_spec.clone
178
+ win_spec.extensions = []
179
+ ## win_spec.platform = Gem::Platform::WIN32 # deprecated
180
+ win_spec.platform = 'mswin32'
181
+ win_spec.files += ["lib/#{SO_NAME}"]
116
182
 
117
- desc "Build the gem file #{gem_name}"
118
- task :gem => :lib do
119
- gem_task = Rake::GemPackageTask.new(spec)
183
+ desc "Create Windows Gem"
184
+ task :win32_gem do
185
+ # Copy the win32 extension the top level directory
120
186
  current_dir = File.expand_path(File.dirname(__FILE__))
121
- source = File.join(current_dir, RUBY_DEBUG_JAR)
122
- target = File.join(current_dir, "lib", "ruby_debug.jar")
187
+ source = File.join(current_dir, "ext", "win32", SO_NAME)
188
+ target = File.join(current_dir, "lib", SO_NAME)
123
189
  cp(source, target)
124
- # Create the gem, then move it to pkg.
125
- Gem::Builder.new(spec).build
126
- gem_file = "#{spec.name}-#{spec.version}-#{spec.platform}.gem"
127
- mv(gem_task.gem_file, "pkg/#{gem_task.gem_file}")
128
- # Delete the temporary target
129
- rm target
130
- end
131
190
 
132
- desc 'Build all the packages'
133
- task :package => :gem
191
+ # Create the gem, then move it to pkg.
192
+ Gem::Builder.new(win_spec).build
193
+ gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
194
+ mv(gem_file, "pkg/#{gem_file}")
134
195
 
135
- Rake::RDocTask.new do |t|
136
- t.main = 'README'
137
- t.rdoc_files.include 'README'
196
+ # Remove win extension from top level directory.
197
+ rm(target)
138
198
  end
139
199
 
200
+ desc "Publish ruby-debug to RubyForge."
201
+ task :publish do
202
+ require 'rake/contrib/sshpublisher'
203
+
204
+ # Get ruby-debug path.
205
+ ruby_debug_path = File.expand_path(File.dirname(__FILE__))
140
206
 
141
- desc "Create a GNU-style ChangeLog via svn2cl"
142
- task :ChangeLog do
143
- system("svn2cl --authors=svn2cl_usermap svn://rubyforge.org/var/svn/debug-commons/jruby-debug/trunk")
207
+ Rake::SshDirPublisher.new("kent@rubyforge.org",
208
+ "/var/www/gforge-projects/ruby-debug", ruby_debug_path)
144
209
  end
145
210
 
146
- # Builds classpath containing needed JRuby's jars (like jruby.jar).
147
- def jruby_classpath
148
- begin
149
- require 'java'
150
- classpath = java.lang.System.getProperty('java.class.path')
151
- rescue LoadError
211
+ desc "Remove built files"
212
+ task :clean do
213
+ cd "ext" do
214
+ if File.exists?("Makefile")
215
+ sh "make clean"
216
+ rm "Makefile"
217
+ end
218
+ derived_files = Dir.glob(".o") + Dir.glob("*.so")
219
+ rm derived_files unless derived_files.empty?
152
220
  end
221
+ rm 'lib/ruby_debug.jar' if File.exists?("lib/ruby_debug.jar")
222
+ end
153
223
 
154
- unless classpath
155
- classpath = FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
156
- end
224
+ # --------- RDoc Documentation ------
225
+ desc "Generate rdoc documentation"
226
+ RDoc::Task.new("rdoc") do |rdoc|
227
+ rdoc.rdoc_dir = 'doc/rdoc'
228
+ rdoc.title = "ruby-debug"
229
+ # Show source inline with line numbers
230
+ rdoc.options << "--inline-source" << "--line-numbers"
231
+ # Make the readme file the start page for the generated html
232
+ rdoc.options << '--main' << 'README'
233
+ rdoc.rdoc_files.include('bin/**/*',
234
+ 'cli/ruby-debug/commands/*.rb',
235
+ 'cli/ruby-debug/*.rb',
236
+ 'lib/**/*.rb',
237
+ 'ext/**/ruby_debug.c',
238
+ 'README',
239
+ 'LICENSE')
240
+ end
157
241
 
158
- classpath ? "-cp #{classpath}" : ""
242
+ desc "Publish the release files to RubyForge."
243
+ task :rubyforge_upload do
244
+ `rubyforge login`
245
+ release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} '#{PKG_NAME}-#{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.gem"
246
+ puts release_command
247
+ system(release_command)
159
248
  end
160
249
 
161
- # Compiles Java classes into the pkg/classes directory.
162
- def compile_java
163
- mkdir_p "pkg/classes"
164
- sh "javac -Xlint -Xlint:-serial -g -target 1.5 -source 1.5 -d pkg/classes #{jruby_classpath} #{FileList['src/**/*.java'].join(' ')}"
250
+ PKG_NAME = 'ruby-debug'
251
+ desc "Publish the release files to RubyForge."
252
+ task :rubyforge_upload do
253
+ `rubyforge login`
254
+ for pkg_name in ['ruby-debug', 'ruby-debug-base'] do
255
+ pkg_file_name = "#{pkg_name}-#{pkg_version}"
256
+ release_command = "rubyforge add_release ruby-debug #{pkg_name} '#{pkg_file_name}' pkg/#{pkg_file_name}.gem"
257
+ puts release_command
258
+ system(release_command)
259
+ end
165
260
  end
166
261
 
167
- def make_jar
168
- require 'fileutils'
169
- ext = File.join(File.dirname(__FILE__), 'ext')
170
- FileUtils.mkdir_p(ext)
171
- separator = File::ALT_SEPARATOR || File::SEPARATOR
172
- sh "jar cf #{RUBY_DEBUG_JAR} -C pkg#{separator}classes ."
262
+ def install_gem(spec, *opts)
263
+ args = ['gem', 'install', "pkg/#{spec.name}-#{spec.version}.gem"] + opts
264
+ args.unshift 'sudo' unless 0 == Process.uid || ENV['rvm_path']
265
+ system(*args)
173
266
  end
174
267
 
268
+ desc 'Install locally'
269
+ task :install => :package do
270
+ Dir.chdir(File::dirname(__FILE__)) do
271
+ # ri and rdoc take lots of time
272
+ install_gem(base_spec, '--no-ri', '--no-rdoc')
273
+ install_gem(cli_spec, '--no-ri', '--no-rdoc')
274
+ end
275
+ end
276
+
277
+ task :install_full => :package do
278
+ Dir.chdir(File::dirname(__FILE__)) do
279
+ install_gem(base_spec)
280
+ install_gem(cli_spec)
281
+ end
282
+ end
283
+
284
+ namespace :jruby do
285
+ jruby_spec = base_spec.clone
286
+ jruby_spec.platform = "java"
287
+ jruby_spec.files = jruby_spec.files.reject {|f| f =~ /^ext/ }
288
+ jruby_spec.files += ['lib/ruby_debug.jar']
289
+ jruby_spec.extensions = []
290
+
291
+ Gem::PackageTask.new(jruby_spec) {}
292
+
293
+ Rake::JavaExtensionTask.new('ruby_debug') do |t|
294
+ t.ext_dir = "src"
295
+ end
296
+ end
data/ext/extconf.rb ADDED
@@ -0,0 +1,23 @@
1
+ require "mkmf"
2
+
3
+ if RUBY_VERSION >= "1.9"
4
+ STDERR.print("Ruby version #{RUBY_VERSION} is too new\n")
5
+ exit(1)
6
+ elsif RUBY_VERSION >= "1.8"
7
+ if RUBY_RELEASE_DATE < "2005-03-22"
8
+ STDERR.print("Ruby release date #{RUBY_RELEASE_DATE} is too old\n")
9
+ exit(1)
10
+ end
11
+ else
12
+ STDERR.print("Ruby version is not compatible for this version.\n")
13
+ exit(1)
14
+ end
15
+
16
+ # Allow use customization of compile options. For example, the
17
+ # following lines could be put in config_options to to turn off
18
+ # optimization:
19
+ # $CFLAGS='-fPIC -fno-strict-aliasing -g3 -ggdb -O2 -fPIC'
20
+ config_file = File.join(File.dirname(__FILE__), 'config_options.rb')
21
+ load config_file if File.exist?(config_file)
22
+
23
+ create_makefile("ruby_debug")