-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathRakefile
121 lines (103 loc) · 2.82 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
require 'rake'
windows = false
processor, platform, *rest = RUBY_PLATFORM.split("-")
windows = true if platform =~ /mswin32/ or platform =~ /mingw32/
if windows
MAKE = 'mingw32-make'
SLASH = '\\'
COPY = 'copy'
DEL = 'del'
else
MAKE = 'make'
SLASH = '/'
COPY = 'cp'
DEL = 'rm'
end
def warn_version
puts 'Warning: VERSION not specified' unless ENV['VERSION']
end
def set_version
if ENV['VERSION']
File.open('lib/qtbindings_version.rb', 'w') do |file|
file.write("QTBINDINGS_VERSION = '#{ENV['VERSION']}'\n")
file.write("QTBINDINGS_RELEASE_DATE = '#{Time.now}'\n")
end
File.open('qtlib/qtbindings_qt_version.rb', 'w') do |file|
file.write("QTBINDINGS_QT_VERSION = '#{ENV['VERSION']}'\n")
file.write("QTBINDINGS_QT_RELEASE_DATE = '#{Time.now}'\n")
end
end
end
def clear_version
if ENV['VERSION']
File.open('lib/qtbindings_version.rb', 'w') do |file|
file.write("QTBINDINGS_VERSION = '0.0.0.0'\n")
file.write("QTBINDINGS_RELEASE_DATE = ''\n")
end
File.open('qtlib/qtbindings_qt_version.rb', 'w') do |file|
file.write("QTBINDINGS_QT_VERSION = '0.0.0.0'\n")
file.write("QTBINDINGS_QT_RELEASE_DATE = ''\n")
end
end
end
task :build_examples do
# Go into the examples directory and look for all the makefiles and build them
Dir['examples/**/makefile'].each do |file|
if windows
system("cd #{File.dirname(file).gsub('/', '\\')} && #{MAKE}")
else
system("cd #{File.dirname(file)} && #{MAKE}")
end
end
end
task :examples => [:build_examples] do
system('cd examples && ruby run_all.rb')
end
task :default => [:all]
task :extconf do
system('ruby extconf.rb')
end
# All calls 'make clean' and 'make build'
task :all => [:extconf] do
system("#{MAKE} all")
end
task :clean => [:extconf] do
system("#{MAKE} clean")
end
task :distclean => [:extconf] do
system("#{MAKE} distclean")
end
task :make_build => [:extconf] do
system("#{MAKE} build")
end
task :install => [:extconf] do
system("#{MAKE} install")
end
task :gem => [:distclean] do
warn_version()
set_version()
system("gem build qtbindings.gemspec")
clear_version()
end
task :gemnative do
warn_version()
set_version()
system("#{COPY} gemspecs#{SLASH}qtbindingsnative.gemspec .")
system("gem build qtbindingsnative.gemspec")
system("#{DEL} qtbindingsnative.gemspec")
clear_version()
end
task :gemqt do
warn_version()
set_version()
system("#{MAKE} installqt")
system("#{COPY} gemspecs#{SLASH}qtbindings-qt.gemspec .")
system("gem build qtbindings-qt.gemspec")
system("#{DEL} qtbindings-qt.gemspec")
clear_version()
end
task :build do
Rake::Task[:extconf].execute
Rake::Task[:all].execute
Rake::Task[:install].execute
end