-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
157 lines (126 loc) · 3.74 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# contents: Rakefile for the unicode library.
#
# Copyright © 2006 Nikolai Weibull <[email protected]>
require 'rake'
require 'rake/clean'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'rake/testtask'
require 'spec/rake/spectask'
PackageName = 'character-encodings'
PackageVersion = '0.4.1'
desc 'Default task'
task :default => [:extensions]
ExtensionDirectory = "ext/encoding/character"
extensions = [
'utf-8'
].map{ |extension| File.join(ExtensionDirectory, extension) }
Make = 'make'
Makefile = 'Makefile'
ExtConf = 'extconf.rb'
Depend = 'depend'
TAGS = 'TAGS'
CTags = 'ctags'
desc 'Build all C-based extensions'
task :extensions
extensions.each do |extension|
makefile = File.join(extension, Makefile)
so = File.join(extension, File.basename(extension).delete('-') + '.' + Config::CONFIG['DLEXT'])
tags = File.join(extension, TAGS)
task :extensions => [makefile, so, tags]
begin
sources = IO.read(makefile).grep(/^\s*SRCS/).first.sub(/^\s*SRCS\s*=\s*/, "").split(' ')
rescue
Dir.chdir(extension) do
sources = FileList['*.c'].to_a
end
end
file makefile => [ExtConf, Depend].map{ |tail| File.join(extension, tail) } do
Dir.chdir(extension) do
ruby ExtConf
File.open(Makefile, 'a') do |f|
f.puts <<EOF
TAGS:
@echo Running ‘ctags’ on source files…
@#{CTags} -f $@ -I UNUSED,HIDDEN,_ $(SRCS)
tags: TAGS
all: tags
.PHONY: tags
EOF
end
end
end
extension_sources = sources.map{ |source| File.join(extension, source) }
file so => extension_sources do
sh %{#{Make} -C #{extension}}
# TODO: Perhaps copying the ‘so’ to “lib” could save us some trouble with
# how libraries are loaded.
end
file tags => extension_sources do
sh %{#{Make} -C #{extension} tags}
end
end
desc 'Extract embedded documentation and build HTML documentation'
task :doc => [:rdoc]
task :rdoc => FileList['**/*.c', '**/*.rb']
desc 'Clean up by removing all generated files, e.g., documentation'
task :clean => [:clobber_rdoc]
Spec::Rake::SpecTask.new do |t|
t.warning = true
t.libs = ['lib', 'ext']
t.spec_files = FileList['specifications/*.rb']
end
Tests = [
['tests/foldcase.rb', 'tests/case.rb'],
['tests/normalize.rb']
]
Rake::TestTask.new do |t|
level = ENV['level'] ? Integer(ENV['level']) : 0
t.test_files = Tests[0..level].flatten
t.libs = ['lib', 'ext']
t.verbose = true
end
RDocDir = 'api'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = RDocDir
rdoc.title = 'Unicode'
rdoc.options = ['--charset UTF-8']
rdoc.rdoc_files.include('**/*.c')
rdoc.rdoc_files.include('**/*.rb')
end
PackageFiles = %w(README Rakefile) +
Dir.glob("{lib,specifications}/**/*") +
Dir.glob("ext/**/{*.{c,h,rb},depend}") +
Dir.glob("tests/*.rb")
spec =
Gem::Specification.new do |s|
s.name = PackageName
s.version = PackageVersion
s.platform = Gem::Platform::RUBY
s.has_rdoc = false
s.extra_rdoc_files = []
s.summary = 'A pluggable character-encoding library'
s.description = s.summary
s.author = 'Nikolai Weibull'
s.email = '[email protected]'
s.homepage = 'http://git.bitwi.se/?p=ruby-character-encodings.git;a=summary'
s.files = PackageFiles
s.require_path = "lib"
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
PackagesDirectory = 'packages'
Rake::GemPackageTask.new(spec) do |p|
p.package_dir = PackagesDirectory
p.need_tar_gz = true
p.gem_spec = spec
end
desc 'Install the gem for this project'
task :install => [:package] do
sh %{gem install #{PackagesDirectory}/#{PackageName}-#{PackageVersion}}
end
desc 'Uninstall the gem for this package'
task :uninstall => [] do
sh %{gem uninstall #{PackageName}}
end
CLEAN.include ["ext/**/{*.{o,so,#{Config::CONFIG['DLEXT']}},#{TAGS}}"]
CLOBBER.include ["ext/**/#{Makefile}"]