-
Notifications
You must be signed in to change notification settings - Fork 229
/
doc.rb
42 lines (33 loc) · 945 Bytes
/
doc.rb
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
require 'fileutils'
include FileUtils
begin
incflags = File.read('ext/Makefile')[/INCFLAGS\s*=\s*(.*)$/,1]
rescue Errno::ENOENT
$stderr.puts("No makefile found; run `rake ext/Makefile' first.")
end
pp_srcdir = 'ext'
rm_rf(tmpdir = '.doc-tmp')
mkdir(tmpdir)
begin
if ARGV.include?('--cpp')
begin
if `cpp --version` =~ /\(GCC\)/
# gnu cpp
$stderr.puts "Running GNU cpp over source"
Dir['ext/*.c'].each do |fn|
system("cpp -DRDOC_NEVER_DEFINED -C #{incflags} -o " +
"#{File.join(tmpdir, File.basename(fn))} #{fn}")
end
pp_srcdir = tmpdir
else
$stderr.puts "Not running cpp (non-GNU)"
end
rescue
# no cpp
$stderr.puts "No cpp found"
end
end
system("rdoc --title='Curb - libcurl bindings for ruby' --main=README #{pp_srcdir}/*.c README LICENSE lib/curb.rb")
ensure
rm_rf(tmpdir)
end