root/Rakefile

Revision faedb82a6fa9090b3d7a904ca413c09d8ad98621, 2.7 kB (checked in by Robin Luckey <robin@ohloh.net>, 1 month ago)

[FIX] Gem fixes: Add lib/license to the gem, also fix ticket #229.

There's still some trouble with RDoc in the gem install.

  • Property mode set to 100644
Line 
1 require 'rake'
2 require 'rake/clean'
3 require 'rake/gempackagetask'
4 require 'rake/rdoctask'
5 require 'rake/testtask'
6 require 'rbconfig'
7 include Config
8
9 NAME = 'ohcount'
10 VERS = '2.0.0'
11
12 EXT_DIR  = "ext/ohcount_native"
13 EXT_DL   = "#{EXT_DIR}/ohcount_native.#{CONFIG['DLEXT']}"
14 ARCH_DIR = "lib/#{::Config::CONFIG['arch']}"
15 ARCH_DL  = "#{ARCH_DIR}/ohcount_native.#{CONFIG['DLEXT']}"
16
17 CLEAN.include FileList["#{EXT_DIR}/*.{so,bundle,#{CONFIG['DLEXT']}}"],
18               FileList["#{EXT_DIR}/*.o"],
19               FileList["#{EXT_DIR}/Makefile"],
20               (FileList["#{EXT_DIR}/*_parser.h"] - FileList["#{EXT_DIR}/ragel_parser.h"])
21
22 RDOC_OPTS = ['--quiet', '--title', 'Ohcount Reference', '--main', 'README', '--inline-source']
23
24 PKG_FILES = %w(README COPYING Rakefile lib/ohcount.rb) +
25   Dir.glob("ext/ohcount_native/*.{h,c,rb}") +
26   Dir.glob("lib/**/*.rb") +
27   Dir.glob("test/*") +
28   Dir.glob("test/**/*") +
29   Dir.glob("bin/*")
30
31 SPEC =
32   Gem::Specification.new do |s|
33     s.name = NAME
34     s.version = VERS
35     s.platform = Gem::Platform::RUBY
36     s.has_rdoc = true
37     s.rdoc_options = RDOC_OPTS
38     s.summary = "The Ohloh source code line counter"
39     s.description = s.summary
40     s.author = "Ohloh Corporation"
41     s.email = "info@ohloh.net"
42     s.homepage = "http://labs.ohloh.net/ohcount"
43     s.files = PKG_FILES
44     s.require_paths <<  'lib'
45     s.extensions << 'ext/ohcount_native/extconf.rb'
46     s.bindir = 'bin'
47     s.executables = ['ohcount']
48   end
49
50 Rake::GemPackageTask.new(SPEC) do |p|
51   p.need_tar = true
52   p.gem_spec = SPEC
53 end
54
55 task :install => :package do
56   `sudo gem install pkg/#{NAME}-#{VERS}`
57 end
58
59 file ARCH_DL => EXT_DL do
60   mkdir_p ARCH_DIR
61   cp EXT_DL, ARCH_DIR
62 end
63
64 file EXT_DL => FileList["#{EXT_DIR}/Makefile", "#{EXT_DIR}/*.{c,h,rb}"] do
65   cd EXT_DIR do
66     cd 'ragel_parsers' do
67       require 'construct_embedded'
68       rls = FileList['*.rl']
69       rls.exclude('common.rl')
70       rls.each do |rl|
71         h = rl.scan(/^(.+)\.rl$/).flatten.first + '_parser.h'
72         if has_embedded?(rl)
73           construct_language(rl)
74           sh "ragel #{rl + '.tmp'} -o ../#{h}"
75           File.delete(rl + '.tmp')
76         else
77           sh "ragel #{rl} -o ../#{h}"
78         end
79       end
80     end
81     sh 'make'
82   end
83 end
84
85 file "#{EXT_DIR}/Makefile" => "#{EXT_DIR}/extconf.rb" do
86   cd EXT_DIR do
87     if ENV['DEBUG']
88       ruby 'extconf.rb', 'debug'
89     else
90       ruby 'extconf.rb'
91     end
92   end
93 end
94
95 Rake::RDocTask.new do |rdoc|
96   rdoc.rdoc_dir = 'doc'
97   rdoc.options += RDOC_OPTS
98   rdoc.rdoc_files.add ['README' ,'COPYING', 'lib/**/*.rb', 'ext/**/*.rb', 'ext/**/*.c', 'test/test_helper.rb', 'test/unit/detector_test.rb']
99 end
100
101 Rake::TestTask.new :ohcount_unit_tests => ARCH_DL do |t|
102   # puts File.dirname(__FILE__) + '/test/unit/*_test.rb'
103   t.test_files = FileList[File.dirname(__FILE__) + '/test/unit/*_test.rb']
104   # t.verbose = true
105 end
106
107 task :default => :ohcount_unit_tests
Note: See TracBrowser for help on using the browser.