rake-builder 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/Rakefile +8 -5
  2. data/examples/05_tests/Rakefile +3 -3
  3. data/examples/05_tests/include/units.h +2 -2
  4. data/lib/compiler.rb +25 -30
  5. data/lib/rake/builder.rb +135 -136
  6. data/lib/rake/builder/installer.rb +37 -0
  7. data/lib/rake/{local_config.rb → builder/local_config.rb} +13 -14
  8. data/lib/rake/builder/logger/formatter.rb +7 -1
  9. data/lib/rake/builder/presenters/makefile/builder_presenter.rb +66 -33
  10. data/lib/rake/builder/presenters/makefile_am/builder_presenter.rb +4 -4
  11. data/lib/rake/builder/qt_builder.rb +3 -8
  12. data/lib/rake/builder/task_definers/builder_task_definer.rb +1 -4
  13. data/lib/rake/builder/version.rb +1 -1
  14. data/lib/rake/{microsecond.rb → microsecond_task.rb} +22 -27
  15. data/lib/rake/once_task.rb +2 -7
  16. data/lib/rake/path.rb +1 -6
  17. data/spec/gather_rspec_coverage.rb +2 -0
  18. data/spec/spec_helper.rb +13 -98
  19. data/spec/unit/compiler_spec.rb +129 -0
  20. data/spec/unit/rake/builder/autoconf/version_spec.rb +62 -5
  21. data/spec/unit/rake/builder/configure_ac_spec.rb +53 -0
  22. data/spec/unit/rake/builder/install_spec.rb +101 -0
  23. data/spec/unit/rake/builder/local_config_spec.rb +53 -0
  24. data/spec/unit/rake/builder/logger/formatter_spec.rb +20 -0
  25. data/spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb +163 -0
  26. data/spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb +4 -2
  27. data/spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb +6 -0
  28. data/spec/unit/rake/builder_spec.rb +391 -16
  29. data/spec/unit/rake/microsecond_task_spec.rb +63 -0
  30. metadata +39 -55
  31. data/examples/01_hello_world_cpp/vendor/bundle/gems/coderay-1.0.8/Rakefile +0 -35
  32. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/Rakefile +0 -412
  33. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/fbuffer/fbuffer.h +0 -185
  34. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.c +0 -1427
  35. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.h +0 -149
  36. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.c +0 -2204
  37. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.h +0 -77
  38. data/examples/01_hello_world_cpp/vendor/bundle/gems/method_source-0.8.1/Rakefile +0 -79
  39. data/examples/01_hello_world_cpp/vendor/bundle/gems/pry-0.9.11.3/Rakefile +0 -136
  40. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/Rakefile +0 -374
  41. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/a.c +0 -6
  42. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/b.c +0 -6
  43. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/main.c +0 -11
  44. data/examples/01_hello_world_cpp/vendor/bundle/gems/slop-3.4.3/Rakefile +0 -29
  45. data/lib/rake/file_task_alias.rb +0 -24
  46. data/spec/c_project/main.c +0 -12
  47. data/spec/c_project/main.h +0 -6
  48. data/spec/c_project_spec.rb +0 -41
  49. data/spec/cpp_project/main.cpp +0 -12
  50. data/spec/cpp_project/main.h +0 -8
  51. data/spec/cpp_project_spec.rb +0 -203
  52. data/spec/generated_files_spec.rb +0 -65
  53. data/spec/libraries_spec.rb +0 -35
  54. data/spec/local_config_spec.rb +0 -95
  55. data/spec/logger_spec.rb +0 -25
  56. data/spec/microsecond_task_spec.rb +0 -32
  57. data/spec/objective_c_project/main.h +0 -1
  58. data/spec/objective_c_project/main.m +0 -18
  59. data/spec/objective_c_project_spec.rb +0 -72
  60. data/spec/paths_spec.rb +0 -19
  61. data/spec/project_spec.rb +0 -20
  62. data/spec/target_spec.rb +0 -48
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rake::Microsecond::DirectoryTask do
4
+ let(:path) { '/a/path' }
5
+ let(:task) do
6
+ task = Rake::Microsecond::DirectoryTask.define_task(path)
7
+ task.stub(:mkdir_p => nil)
8
+ task
9
+ end
10
+
11
+ before do
12
+ Rake::Task.clear
13
+ end
14
+
15
+ context '#needed?' do
16
+ let(:base_time) { Time.now }
17
+ let(:task1) { Rake::Microsecond::DirectoryTask.define_task('/path1') }
18
+ let(:task2) { Rake::Microsecond::DirectoryTask.define_task('/path2') }
19
+ let(:needed_task) { Rake::Task.define_task('needed') }
20
+ let(:unneeded_task) { Rake::Task.define_task('unneeded') }
21
+
22
+ context 'when the directory exists' do
23
+ before do
24
+ File.stub(:directory? => true)
25
+ File.stub_chain(:stat, :mtime).and_return(33)
26
+ end
27
+
28
+ it 'true if a prerequisite FileTask is more recent' do
29
+ task1.timestamp = base_time - 10
30
+ task2.timestamp = base_time - 1
31
+ task1.enhance([task2])
32
+
33
+ expect(task1).to be_needed
34
+ end
35
+
36
+ it 'true if a prerequisite non-FileTask is needed?' do
37
+ task.enhance([needed_task])
38
+
39
+ expect(task).to be_needed
40
+ end
41
+
42
+ it 'false otherwise' do
43
+ task.enhance([unneeded_task])
44
+ unneeded_task.stub(:needed? => false)
45
+
46
+ expect(task).to_not be_needed
47
+ end
48
+ end
49
+ end
50
+
51
+ context '#execute' do
52
+ let(:stub_time) { stub('Time') }
53
+
54
+ it 'memorizes the directory creation time including fractional seconds' do
55
+ Time.stub(:now => stub_time)
56
+
57
+ task.execute
58
+
59
+ expect(task.timestamp).to eq(stub_time)
60
+ end
61
+ end
62
+ end
63
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-20 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.3.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: simplecov
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: pry-plus
64
80
  requirement: !ruby/object:Gem::Requirement
@@ -88,25 +104,22 @@ files:
88
104
  - README.md
89
105
  - lib/compiler.rb
90
106
  - lib/rake/once_task.rb
91
- - lib/rake/microsecond.rb
92
- - lib/rake/file_task_alias.rb
107
+ - lib/rake/microsecond_task.rb
93
108
  - lib/rake/builder/logger/formatter.rb
94
109
  - lib/rake/builder/task_definers/builder_collection_task_definer.rb
95
110
  - lib/rake/builder/task_definers/builder_task_definer.rb
96
111
  - lib/rake/builder/qt_builder.rb
97
112
  - lib/rake/builder/error.rb
113
+ - lib/rake/builder/local_config.rb
98
114
  - lib/rake/builder/version.rb
99
115
  - lib/rake/builder/autoconf/version.rb
116
+ - lib/rake/builder/installer.rb
100
117
  - lib/rake/builder/presenters/makefile_am/builder_presenter.rb
101
118
  - lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb
102
119
  - lib/rake/builder/presenters/makefile/builder_presenter.rb
103
120
  - lib/rake/builder/configure_ac.rb
104
- - lib/rake/local_config.rb
105
121
  - lib/rake/path.rb
106
122
  - lib/rake/builder.rb
107
- - examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/fbuffer/fbuffer.h
108
- - examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.h
109
- - examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.h
110
123
  - examples/05_tests/include/main.h
111
124
  - examples/05_tests/include/units.h
112
125
  - examples/03_search_paths/vendor/bundle/gems/json-1.7.6/ext/json/ext/fbuffer/fbuffer.h
@@ -440,11 +453,6 @@ files:
440
453
  - examples/04_zlib/vendor/bundle/gems/binding_of_caller-0.6.8/ext/binding_of_caller/ruby_headers/193/debug.h
441
454
  - examples/04_zlib/vendor/bundle/gems/binding_of_caller-0.6.8/ext/binding_of_caller/ruby_headers/193/internal.h
442
455
  - examples/04_zlib/include/main.h
443
- - examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/main.c
444
- - examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/a.c
445
- - examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/b.c
446
- - examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.c
447
- - examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.c
448
456
  - examples/07_multiple_targets/main.c
449
457
  - examples/03_search_paths/vendor/bundle/gems/rake-10.0.3/doc/example/main.c
450
458
  - examples/03_search_paths/vendor/bundle/gems/rake-10.0.3/doc/example/a.c
@@ -475,12 +483,6 @@ files:
475
483
  - examples/03_search_paths/src/main.cpp
476
484
  - examples/06_hello_world_objective_c/main.m
477
485
  - examples/README.rdoc
478
- - examples/01_hello_world_cpp/vendor/bundle/gems/pry-0.9.11.3/Rakefile
479
- - examples/01_hello_world_cpp/vendor/bundle/gems/coderay-1.0.8/Rakefile
480
- - examples/01_hello_world_cpp/vendor/bundle/gems/method_source-0.8.1/Rakefile
481
- - examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/Rakefile
482
- - examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/Rakefile
483
- - examples/01_hello_world_cpp/vendor/bundle/gems/slop-3.4.3/Rakefile
484
486
  - examples/01_hello_world_cpp/Rakefile
485
487
  - examples/05_tests/Rakefile
486
488
  - examples/06_hello_world_objective_c/Rakefile
@@ -511,29 +513,20 @@ files:
511
513
  - examples/04_zlib/Rakefile
512
514
  - examples/02_hello_world_c/Rakefile
513
515
  - spec/spec_helper.rb
514
- - spec/cpp_project/main.h
515
- - spec/cpp_project/main.cpp
516
- - spec/generated_files_spec.rb
516
+ - spec/unit/compiler_spec.rb
517
517
  - spec/unit/rake/builder_spec.rb
518
+ - spec/unit/rake/microsecond_task_spec.rb
519
+ - spec/unit/rake/builder/logger/formatter_spec.rb
518
520
  - spec/unit/rake/builder/task_definers/builder_collection_task_definer_spec.rb
519
521
  - spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb
522
+ - spec/unit/rake/builder/configure_ac_spec.rb
523
+ - spec/unit/rake/builder/install_spec.rb
520
524
  - spec/unit/rake/builder/autoconf/version_spec.rb
525
+ - spec/unit/rake/builder/local_config_spec.rb
521
526
  - spec/unit/rake/builder/presenters/makefile_am/builder_collection_presenter_spec.rb
522
527
  - spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb
523
- - spec/c_project/main.c
524
- - spec/c_project/main.h
525
- - spec/c_project_spec.rb
526
- - spec/objective_c_project/main.h
527
- - spec/objective_c_project/main.m
528
- - spec/target_spec.rb
529
- - spec/microsecond_task_spec.rb
530
- - spec/cpp_project_spec.rb
531
- - spec/project_spec.rb
532
- - spec/logger_spec.rb
533
- - spec/objective_c_project_spec.rb
534
- - spec/paths_spec.rb
535
- - spec/local_config_spec.rb
536
- - spec/libraries_spec.rb
528
+ - spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb
529
+ - spec/gather_rspec_coverage.rb
537
530
  homepage: http://github.com/joeyates/rake-builder
538
531
  licenses: []
539
532
  post_install_message:
@@ -548,7 +541,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
548
541
  version: '0'
549
542
  segments:
550
543
  - 0
551
- hash: 2504554925241815953
544
+ hash: -1718297716615207943
552
545
  required_rubygems_version: !ruby/object:Gem::Requirement
553
546
  none: false
554
547
  requirements:
@@ -557,7 +550,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
557
550
  version: '0'
558
551
  segments:
559
552
  - 0
560
- hash: 2504554925241815953
553
+ hash: -1718297716615207943
561
554
  requirements: []
562
555
  rubyforge_project: nowarning
563
556
  rubygems_version: 1.8.23
@@ -566,27 +559,18 @@ specification_version: 3
566
559
  summary: Rake for C/C++ Projects
567
560
  test_files:
568
561
  - spec/spec_helper.rb
569
- - spec/cpp_project/main.h
570
- - spec/cpp_project/main.cpp
571
- - spec/generated_files_spec.rb
562
+ - spec/unit/compiler_spec.rb
572
563
  - spec/unit/rake/builder_spec.rb
564
+ - spec/unit/rake/microsecond_task_spec.rb
565
+ - spec/unit/rake/builder/logger/formatter_spec.rb
573
566
  - spec/unit/rake/builder/task_definers/builder_collection_task_definer_spec.rb
574
567
  - spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb
568
+ - spec/unit/rake/builder/configure_ac_spec.rb
569
+ - spec/unit/rake/builder/install_spec.rb
575
570
  - spec/unit/rake/builder/autoconf/version_spec.rb
571
+ - spec/unit/rake/builder/local_config_spec.rb
576
572
  - spec/unit/rake/builder/presenters/makefile_am/builder_collection_presenter_spec.rb
577
573
  - spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb
578
- - spec/c_project/main.c
579
- - spec/c_project/main.h
580
- - spec/c_project_spec.rb
581
- - spec/objective_c_project/main.h
582
- - spec/objective_c_project/main.m
583
- - spec/target_spec.rb
584
- - spec/microsecond_task_spec.rb
585
- - spec/cpp_project_spec.rb
586
- - spec/project_spec.rb
587
- - spec/logger_spec.rb
588
- - spec/objective_c_project_spec.rb
589
- - spec/paths_spec.rb
590
- - spec/local_config_spec.rb
591
- - spec/libraries_spec.rb
574
+ - spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb
575
+ - spec/gather_rspec_coverage.rb
592
576
  has_rdoc:
@@ -1,35 +0,0 @@
1
- $:.unshift File.dirname(__FILE__) unless $:.include? '.'
2
-
3
- ROOT = '.'
4
- LIB_ROOT = File.join ROOT, 'lib'
5
-
6
- task :default => :test
7
-
8
- if File.directory? 'rake_tasks'
9
-
10
- # load rake tasks from subfolder
11
- for task_file in Dir['rake_tasks/*.rake'].sort
12
- load task_file
13
- end
14
-
15
- else
16
-
17
- # fallback tasks when rake_tasks folder is not present (eg. in the distribution package)
18
- desc 'Run CodeRay tests (basic)'
19
- task :test do
20
- ruby './test/functional/suite.rb'
21
- ruby './test/functional/for_redcloth.rb'
22
- end
23
-
24
- gem 'rdoc' if defined? gem
25
- require 'rdoc/task'
26
- desc 'Generate documentation for CodeRay'
27
- Rake::RDocTask.new :doc do |rd|
28
- rd.title = 'CodeRay Documentation'
29
- rd.main = 'README_INDEX.rdoc'
30
- rd.rdoc_files.add Dir['lib']
31
- rd.rdoc_files.add rd.main
32
- rd.rdoc_dir = 'doc'
33
- end
34
-
35
- end
@@ -1,412 +0,0 @@
1
- begin
2
- require 'rubygems/package_task'
3
- rescue LoadError
4
- end
5
-
6
- require 'rbconfig'
7
- include\
8
- begin
9
- RbConfig
10
- rescue NameError
11
- Config
12
- end
13
-
14
- require 'rake/clean'
15
- CLOBBER.include 'doc', 'Gemfile.lock'
16
- CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp',
17
- FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'],
18
- FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class,dSYM}"],
19
- FileList['java/src/**/*.class']
20
-
21
- require 'rake/testtask'
22
- class UndocumentedTestTask < Rake::TestTask
23
- def desc(*) end
24
- end
25
-
26
- def skip_sdoc(src)
27
- src.gsub(/^.*sdoc.*/) { |s| s + ' if RUBY_VERSION > "1.8.6"' }
28
- end
29
-
30
- MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
31
- BUNDLE = ENV['BUNDLE'] || %w[bundle].find { |c| system(c, '-v') }
32
- PKG_NAME = 'json'
33
- PKG_TITLE = 'JSON Implementation for Ruby'
34
- PKG_VERSION = File.read('VERSION').chomp
35
- PKG_FILES = FileList[`git ls-files`.split(/\n/)]
36
-
37
- EXT_ROOT_DIR = 'ext/json/ext'
38
- EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
39
- EXT_PARSER_DL = "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}"
40
- RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
41
- EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
42
- EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
43
- EXT_GENERATOR_DL = "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}"
44
- EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
45
-
46
- JAVA_DIR = "java/src/json/ext"
47
- JAVA_RAGEL_PATH = "#{JAVA_DIR}/Parser.rl"
48
- JAVA_PARSER_SRC = "#{JAVA_DIR}/Parser.java"
49
- JAVA_SOURCES = FileList["#{JAVA_DIR}/*.java"]
50
- JAVA_CLASSES = []
51
- JRUBY_PARSER_JAR = File.expand_path("lib/json/ext/parser.jar")
52
- JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")
53
-
54
- RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
55
- RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
56
-
57
- desc "Installing library (pure)"
58
- task :install_pure => :version do
59
- ruby 'install.rb'
60
- end
61
-
62
- task :install_ext_really do
63
- sitearchdir = CONFIG["sitearchdir"]
64
- cd 'ext' do
65
- for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"]
66
- d = File.join(sitearchdir, file)
67
- mkdir_p File.dirname(d)
68
- install(file, d)
69
- end
70
- warn " *** Installed EXT ruby library."
71
- end
72
- end
73
-
74
- desc "Installing library (extension)"
75
- task :install_ext => [ :compile, :install_pure, :install_ext_really ]
76
-
77
- desc "Installing library (extension)"
78
- task :install => :install_ext
79
-
80
- if defined?(Gem) and defined?(Gem::PackageTask)
81
- spec_pure = Gem::Specification.new do |s|
82
- s.name = 'json_pure'
83
- s.version = PKG_VERSION
84
- s.summary = PKG_TITLE
85
- s.description = "This is a JSON implementation in pure Ruby."
86
-
87
- s.files = PKG_FILES
88
-
89
- s.require_path = 'lib'
90
- s.add_development_dependency 'permutation'
91
- s.add_development_dependency 'sdoc', '~> 0.3.16'
92
- s.add_development_dependency 'rake', '~>0.9.2'
93
-
94
- s.extra_rdoc_files << 'README.rdoc'
95
- s.rdoc_options <<
96
- '--title' << 'JSON implemention for ruby' << '--main' << 'README.rdoc'
97
- s.test_files.concat Dir['./tests/test_*.rb']
98
-
99
- s.author = "Florian Frank"
100
- s.email = "flori@ping.de"
101
- s.homepage = "http://flori.github.com/#{PKG_NAME}"
102
- s.rubyforge_project = "json"
103
- end
104
-
105
- desc 'Creates a json_pure.gemspec file'
106
- task :gemspec_pure => :version do
107
- File.open('json_pure.gemspec', 'w') do |gemspec|
108
- gemspec.write skip_sdoc(spec_pure.to_ruby)
109
- end
110
- end
111
-
112
- Gem::PackageTask.new(spec_pure) do |pkg|
113
- pkg.need_tar = true
114
- pkg.package_files = PKG_FILES
115
- end
116
-
117
- spec_ext = Gem::Specification.new do |s|
118
- s.name = 'json'
119
- s.version = PKG_VERSION
120
- s.summary = PKG_TITLE
121
- s.description = "This is a JSON implementation as a Ruby extension in C."
122
-
123
- s.files = PKG_FILES
124
-
125
- s.extensions = FileList['ext/**/extconf.rb']
126
-
127
- s.require_path = 'lib'
128
- s.add_development_dependency 'permutation'
129
- s.add_development_dependency 'sdoc', '~> 0.3.16'
130
-
131
- s.extra_rdoc_files << 'README.rdoc'
132
- s.rdoc_options <<
133
- '--title' << 'JSON implemention for Ruby' << '--main' << 'README.rdoc'
134
- s.test_files.concat Dir['./tests/test_*.rb']
135
-
136
- s.author = "Florian Frank"
137
- s.email = "flori@ping.de"
138
- s.homepage = "http://flori.github.com/#{PKG_NAME}"
139
- s.rubyforge_project = "json"
140
- end
141
-
142
- desc 'Creates a json.gemspec file'
143
- task :gemspec_ext => :version do
144
- File.open('json.gemspec', 'w') do |gemspec|
145
- gemspec.write skip_sdoc(spec_ext.to_ruby)
146
- end
147
- end
148
-
149
- Gem::PackageTask.new(spec_ext) do |pkg|
150
- pkg.need_tar = true
151
- pkg.package_files = PKG_FILES
152
- end
153
-
154
-
155
- desc 'Create all gemspec files'
156
- task :gemspec => [ :gemspec_pure, :gemspec_ext ]
157
- end
158
-
159
- desc m = "Writing version information for #{PKG_VERSION}"
160
- task :version do
161
- puts m
162
- File.open(File.join('lib', 'json', 'version.rb'), 'w') do |v|
163
- v.puts <<EOT
164
- module JSON
165
- # JSON version
166
- VERSION = '#{PKG_VERSION}'
167
- VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
168
- VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
169
- VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
170
- VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
171
- end
172
- EOT
173
- end
174
- end
175
-
176
- desc "Testing library (pure ruby)"
177
- task :test_pure => [ :clean, :do_test_pure ]
178
-
179
- UndocumentedTestTask.new do |t|
180
- t.name = 'do_test_pure'
181
- t.libs << 'lib'
182
- t.test_files = FileList['tests/test_*.rb']
183
- t.verbose = true
184
- t.options = '-v'
185
- end
186
-
187
- desc "Testing library (pure ruby and extension)"
188
- task :test do
189
- sh "env JSON=pure #{BUNDLE} exec rake test_pure" or exit 1
190
- sh "env JSON=ext #{BUNDLE} exec rake test_ext" or exit 1
191
- end
192
-
193
- namespace :gems do
194
- desc 'Install all development gems'
195
- task :install do
196
- sh "#{BUNDLE}"
197
- end
198
- end
199
-
200
- if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
201
- if ENV.key?('JAVA_HOME')
202
- warn " *** JAVA_HOME was set to #{ENV['JAVA_HOME'].inspect}"
203
- elsif File.directory?(local_java = '/usr/local/java/jdk') ||
204
- File.directory?(local_java = '/usr/lib/jvm/java-6-openjdk')
205
- then
206
- ENV['JAVA_HOME'] = local_java
207
- end
208
- if ENV['JAVA_HOME']
209
- warn " *** JAVA_HOME is set to #{ENV['JAVA_HOME'].inspect}"
210
- ENV['PATH'] = ENV['PATH'].split(/:/).unshift(java_path = "#{ENV['JAVA_HOME']}/bin") * ':'
211
- warn " *** java binaries are assumed to be in #{java_path.inspect}"
212
- else
213
- warn " *** JAVA_HOME was not set or could not be guessed!"
214
- exit 1
215
- end
216
-
217
- file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do
218
- cd JAVA_DIR do
219
- if RAGEL_CODEGEN == 'ragel'
220
- sh "ragel Parser.rl -J -o Parser.java"
221
- else
222
- sh "ragel -x Parser.rl | #{RAGEL_CODEGEN} -J"
223
- end
224
- end
225
- end
226
-
227
- desc "Generate parser for java with ragel"
228
- task :ragel => JAVA_PARSER_SRC
229
-
230
- desc "Delete the ragel generated Java source"
231
- task :ragel_clean do
232
- rm_rf JAVA_PARSER_SRC
233
- end
234
-
235
- JRUBY_JAR = File.join(CONFIG["libdir"], "jruby.jar")
236
- if File.exist?(JRUBY_JAR)
237
- JAVA_SOURCES.each do |src|
238
- classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
239
- obj = src.sub(/\.java\Z/, '.class')
240
- file obj => src do
241
- sh 'javac', '-classpath', classpath, '-source', '1.5', '-target', '1.5', src
242
- end
243
- JAVA_CLASSES << obj
244
- end
245
- else
246
- warn "WARNING: Cannot find jruby in path => Cannot build jruby extension!"
247
- end
248
-
249
- desc "Compiling jruby extension"
250
- task :compile => JAVA_CLASSES
251
-
252
- desc "Package the jruby gem"
253
- task :jruby_gem => :create_jar do
254
- sh 'gem build json-java.gemspec'
255
- mkdir_p 'pkg'
256
- mv "json-#{PKG_VERSION}-java.gem", 'pkg'
257
- end
258
-
259
- desc "Testing library (jruby)"
260
- task :test_ext => [ :create_jar, :do_test_ext ]
261
-
262
- UndocumentedTestTask.new do |t|
263
- t.name = 'do_test_ext'
264
- t.libs << 'lib'
265
- t.test_files = FileList['tests/test_*.rb']
266
- t.verbose = true
267
- t.options = '-v'
268
- end
269
-
270
- file JRUBY_PARSER_JAR => :compile do
271
- cd 'java/src' do
272
- parser_classes = FileList[
273
- "json/ext/ByteListTranscoder*.class",
274
- "json/ext/OptionsReader*.class",
275
- "json/ext/Parser*.class",
276
- "json/ext/RuntimeInfo*.class",
277
- "json/ext/StringDecoder*.class",
278
- "json/ext/Utils*.class"
279
- ]
280
- sh 'jar', 'cf', File.basename(JRUBY_PARSER_JAR), *parser_classes
281
- mv File.basename(JRUBY_PARSER_JAR), File.dirname(JRUBY_PARSER_JAR)
282
- end
283
- end
284
-
285
- desc "Create parser jar"
286
- task :create_parser_jar => JRUBY_PARSER_JAR
287
-
288
- file JRUBY_GENERATOR_JAR => :compile do
289
- cd 'java/src' do
290
- generator_classes = FileList[
291
- "json/ext/ByteListTranscoder*.class",
292
- "json/ext/OptionsReader*.class",
293
- "json/ext/Generator*.class",
294
- "json/ext/RuntimeInfo*.class",
295
- "json/ext/StringEncoder*.class",
296
- "json/ext/Utils*.class"
297
- ]
298
- sh 'jar', 'cf', File.basename(JRUBY_GENERATOR_JAR), *generator_classes
299
- mv File.basename(JRUBY_GENERATOR_JAR), File.dirname(JRUBY_GENERATOR_JAR)
300
- end
301
- end
302
-
303
- desc "Create generator jar"
304
- task :create_generator_jar => JRUBY_GENERATOR_JAR
305
-
306
- desc "Create parser and generator jars"
307
- task :create_jar => [ :create_parser_jar, :create_generator_jar ]
308
-
309
- desc "Build all gems and archives for a new release of the jruby extension."
310
- task :build => [ :clean, :version, :jruby_gem ]
311
-
312
- task :release => :build
313
- else
314
- desc "Compiling extension"
315
- task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
316
-
317
- file EXT_PARSER_DL => EXT_PARSER_SRC do
318
- cd EXT_PARSER_DIR do
319
- ruby 'extconf.rb'
320
- sh MAKE
321
- end
322
- cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
323
- end
324
-
325
- file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
326
- cd EXT_GENERATOR_DIR do
327
- ruby 'extconf.rb'
328
- sh MAKE
329
- end
330
- cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
331
- end
332
-
333
- desc "Testing library (extension)"
334
- task :test_ext => [ :compile, :do_test_ext ]
335
-
336
- UndocumentedTestTask.new do |t|
337
- t.name = 'do_test_ext'
338
- t.libs << 'ext' << 'lib'
339
- t.test_files = FileList['tests/test_*.rb']
340
- t.verbose = true
341
- t.options = '-v'
342
- end
343
-
344
- desc "Create RDOC documentation"
345
- task :doc => [ :version, EXT_PARSER_SRC ] do
346
- sh "sdoc -o doc -t '#{PKG_TITLE}' -m README.rdoc README.rdoc lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
347
- end
348
-
349
- desc "Generate parser with ragel"
350
- task :ragel => EXT_PARSER_SRC
351
-
352
- desc "Delete the ragel generated C source"
353
- task :ragel_clean do
354
- rm_rf EXT_PARSER_SRC
355
- end
356
-
357
- desc "Update the tags file"
358
- task :tags do
359
- system 'ctags', *Dir['**/*.{rb,c,h,java}']
360
- end
361
-
362
- file EXT_PARSER_SRC => RAGEL_PATH do
363
- cd EXT_PARSER_DIR do
364
- if RAGEL_CODEGEN == 'ragel'
365
- sh "ragel parser.rl -G2 -o parser.c"
366
- else
367
- sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2"
368
- end
369
- src = File.read("parser.c").gsub(/[ \t]+$/, '')
370
- File.open("parser.c", "w") {|f| f.print src}
371
- end
372
- end
373
-
374
- desc "Generate diagrams of ragel parser (ps)"
375
- task :ragel_dot_ps do
376
- root = 'diagrams'
377
- specs = []
378
- File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
379
- for s in specs
380
- if RAGEL_DOTGEN == 'ragel'
381
- sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tps -o#{root}/#{s}.ps"
382
- else
383
- sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tps -o#{root}/#{s}.ps"
384
- end
385
- end
386
- end
387
-
388
- desc "Generate diagrams of ragel parser (png)"
389
- task :ragel_dot_png do
390
- root = 'diagrams'
391
- specs = []
392
- File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
393
- for s in specs
394
- if RAGEL_DOTGEN == 'ragel'
395
- sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tpng -o#{root}/#{s}.png"
396
- else
397
- sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tpng -o#{root}/#{s}.png"
398
- end
399
- end
400
- end
401
-
402
- desc "Generate diagrams of ragel parser"
403
- task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
404
-
405
- desc "Build all gems and archives for a new release of json and json_pure."
406
- task :build => [ :clean, :gemspec, :package ]
407
-
408
- task :release => :build
409
- end
410
-
411
- desc "Compile in the the source directory"
412
- task :default => [ :clean, :gemspec, :test ]