forked from ruby-gnome/ruby-gnome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
180 lines (159 loc) · 3.77 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# -*- ruby -*-
require "pathname"
require "find"
require "tmpdir"
require "open-uri"
task :default => :test
def version
@version ||= ENV["VERSION"] || guess_version
end
def guess_version
versions = {}
File.open("glib2/ext/glib2/rbglib.h") do |rbglib_h|
rbglib_h.each_line do |line|
if /#define\s+RBGLIB_([A-Z]+)_VERSION\s+(\d+)/ =~ line
versions[$1.downcase] = $2.to_i
end
end
end
["major", "minor", "micro"].collect {|type| versions[type]}.compact.join(".")
end
def gem_exist?(name, version)
gem_uri = "https://rubygems.org/gems/#{name}/versions/#{version}"
begin
URI.open(gem_uri)
true
rescue OpenURI::HTTPError
false
end
end
def gem_push(path, name, version)
return if gem_exist?(name, version)
begin
ruby("-S", "gem", "push", path)
rescue
puts("failed to push gem: #{path}")
puts("#{$!.class}: #{$!}")
end
end
default_packages = [
"adwaita",
"atk",
"cairo-gobject",
"clutter",
"clutter-gdk",
"clutter-gstreamer",
"clutter-gtk",
"gdk3",
"gdk4",
"gdk_pixbuf2",
"gegl",
"gio2",
"glib2",
"gnumeric",
"gobject-introspection",
"goffice",
"gsf",
"gstreamer",
"gtk3",
"gtk4",
"gtksourceview3",
"gtksourceview4",
"gtksourceview5",
"libhandy",
"libsecret",
"pango",
"poppler",
"rsvg2",
"vte3",
"vte4",
"webkit-gtk",
"webkit2-gtk",
"wnck3",
]
packages = (ENV["PACKAGES"] || "").split(",")
packages = default_packages if packages.empty?
desc "configure all packages"
task :configure do
ruby("extconf.rb")
end
file "Makefile" do
task(:configure).invoke
end
desc "build all packages"
task :build => ["Makefile"] do
sh("make")
end
desc "clean all packages, docs"
task :clean do
sh("make", "clean") if File.exist?("Makefile")
rm_rf("yard_docs")
end
desc "more clean all packages"
task :distclean do
sh("make", "distclean") if File.exist?("Makefile")
end
desc "run tests for all packages"
task :test => [:build] do
ruby("run-test.rb")
end
namespace :gem do
desc "build all gems"
task :build do
packages.each do |package|
cd(package) do
ruby("-S", "rake", "gem")
end
end
end
desc "document all gems"
task docs: [:girdocs, :rubydocs]
task :girdocs do
packages_rb = packages.map { |pkg|
File.join(pkg, "lib", pkg + ".rb")
}
ygir_gem = Gem::Specification.find_by_name('yard-gobject-introspection')
ygir_lib = File.expand_path('lib/yard-gobject-introspection.rb',
ygir_gem.full_gem_path)
args = [ygir_lib, * packages_rb]
all_args = %w(bundle exec yard doc -o ./yard_docs/gir/ --load).concat(args)
sh(*all_args)
end
task :rubydocs do
file_globs = packages.flat_map { |pkg|
[ File.join(pkg, "lib", pkg + ".rb"),
File.join(pkg, "lib", pkg, "**/*.rb"),
File.join(pkg, "ext", pkg, "**/*.h")
]}
all_args = %w(bundle exec yard doc -o ./yard_docs/ruby/).concat(file_globs)
sh(*all_args)
end
desc "push all gems"
task :push do
packages.each do |package|
Dir.glob(File.join(package, "pkg", "*-#{version}.gem")) do |gem_path|
gem_base_path = File.basename(gem_path, ".gem")
gem_name = gem_base_path.gsub(/-#{Regexp.escape(version)}\z/, "")
gem_push(gem_path, gem_name, version)
end
end
end
desc "install all gems"
task :install do
packages.each do |package|
ruby("-S", "gem", "install", "--user-install",
*Dir.glob(File.join(package, "pkg", "*-#{version}.gem")))
end
end
desc "uninstall all gems"
task :uninstall do
packages.each do |package|
ruby("-S", "gem", "uninstall", "--version", version, package)
end
end
end
desc "tag the current release"
task :tag do
sh("git", "tag", "-a", version, "-m", "release #{version}!!!")
sh("git", "push", "--tags")
end