-
Notifications
You must be signed in to change notification settings - Fork 16
/
Rakefile
132 lines (107 loc) · 3.45 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
require 'rubygems'
require 'rubygems/package_task'
require 'rake/clean'
require_relative "lib/sdl2/version"
C_M4_FILES = Dir.glob("*.c.m4")
C_FROM_M4_FILES = C_M4_FILES.map{|path| path.gsub(/\.c\.m4\Z/, ".c") }
C_FILES = Dir.glob("*.c") | C_FROM_M4_FILES
RB_FILES = Dir.glob("lib/**/*.rb")
O_FILES = Rake::FileList[*C_FILES].pathmap('%n.o')
POT_SOURCES = RB_FILES + ["main.c"] + (C_FILES - ["main.c"])
YARD_DOC_FILES = ["README.md", "COPYING.txt"] + POT_SOURCES
YARD_SOURCES = "-m markdown --main README.md --files COPYING.txt #{POT_SOURCES.join(" ")}"
YARD_CHECKSUM_FILE = ".yardoc/checksums"
WATCH_TARGETS = (C_FILES - C_FROM_M4_FILES) + C_M4_FILES + ["README.md"]
CLEAN.include(O_FILES)
CLOBBER.include(*C_FROM_M4_FILES)
locale = ENV["YARD_LOCALE"]
def extconf_options
return ENV["RUBYSDL2_EXTCONF_OPTS"] if ENV["RUBYSDL2_EXTCONF_OPTS"]
return ENV["EXTCONF_OPTS"] if ENV["EXTCONF_OPTS"]
begin
return File.readlines("extconf-options.txt").map(&:chomp).join(" ")
rescue Errno::ENOENT
return ""
end
end
def gem_spec
Gem::Specification.new do |spec|
spec.name = "ruby-sdl2"
spec.version = SDL2::VERSION
spec.summary = "The simple ruby extension library for SDL 2.x"
spec.description = <<-EOS
Ruby/SDL2 is an extension library to use SDL 2.x
(Simple DirectMedia Layer). SDL 2.x is quite refined
from SDL 1.x and API is changed.
This library enables you to control audio, keyboard,
mouse, joystick, 3D hardware via OpenGL, and 2D video
using opengl or Direct3D.
Ruby/SDL is used for games and visual demos.
EOS
spec.license = "LGPL-3.0"
spec.author = "Ippei Obayashi"
spec.email = "[email protected]"
spec.homepage = "https://github.com/ohai/ruby-sdl2"
spec.files = `git ls-files`.split(/\n/) + C_FROM_M4_FILES
spec.test_files = []
spec.extensions = ["extconf.rb"]
end
end
task "pot" => "doc/po/rubysdl2.pot"
file "doc/po/rubysdl2.pot" => POT_SOURCES do |t|
sh "yard i18n -o #{t.name} #{POT_SOURCES.join(" ")}"
end
if locale
PO_FILE = "doc/po/#{locale}.po"
task "init-po" do
sh "rmsginit -i doc/po/rubysdl2.pot -o #{PO_FILE} -l #{locale}"
end
task "merge-po" do
sh "rmsgmerge -o #{PO_FILE} #{PO_FILE} doc/po/rubysdl2.pot"
end
task "doc" => [PO_FILE] do
sh "yard doc -o doc/doc-#{locale} --locale #{locale} --po-dir doc/po #{YARD_SOURCES}"
end
else
task "doc" => YARD_DOC_FILES do
sh "yard doc -o doc/doc-en #{YARD_SOURCES}"
end
end
task "doc-all" do
raise "Not yet implemented"
end
desc "List undocumented classes/modules/methods/constants"
task "doc-stat-undocumented" => YARD_DOC_FILES do
sh "yard stats --list-undoc --compact #{YARD_SOURCES}"
end
rule ".c" => ".c.m4" do |t|
sh "m4 #{t.prerequisites[0]} > #{t.name}"
end
file "Makefile" => "extconf.rb" do
sh "ruby extconf.rb #{extconf_options()}"
end
task "build" => C_FILES + ["Makefile"] do
sh "make"
end
Gem::PackageTask.new(gem_spec) do |pkg|
end
rule ".gem" => C_FILES
task "watch-doc" do
loop do
sh "inotifywait -e modify #{WATCH_TARGETS.join(" ")} && rake doc && notify-send -u low \"Ruby/SDL2 build doc OK\""
end
end
file YARD_CHECKSUM_FILE => YARD_DOC_FILES do
sh "yard doc -n #{YARD_SOURCES}"
end
file "sdl2.rbs" => YARD_CHECKSUM_FILE do
sh "sord --no-regenerate --rbs sdl2.rbs"
end
file "sdl2.rbi" => YARD_CHECKSUM_FILE do
sh "sord --no-regenerate --rbi sdl2.rbi"
end
task "clean" do
sh "rm -r .yardoc"
sh "rm -r doc/doc-en"
sh "rm #{C_FROM_M4_FILES.join(' ')}"
end