-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsakefile.rb
326 lines (269 loc) · 8.11 KB
/
sakefile.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# -*- ruby -*-
# sake variant sake4
require 'sake4/component'
def try_load file
begin
load file
rescue LoadError; end
end
$pys60_version = ($sake_op[:pys60] ? $sake_op[:pys60].to_i : 1)
case $pys60_version
when 1
$uid_v8 = 0x08430009
when 2
$uid_v8 = 0x0843000b
else
raise "unsupported PyS60 version"
end
$basename = "pyswinst"
load("version")
$version = PYSWINSTVER.to_s.split(".").map {|x| x.to_i}
$proj = Sake::Project.new(:basename => $basename,
:name => "SW Inst API for PyS60v#{$pys60_version}",
:version => $version,
# This is a test UID.
:uid => Sake::Uid.v8($uid_v8),
:vendor => "HIIT")
class <<$proj
def pkg_in_file
group_dir + ("module.pkg.in")
end
end
$pyd = Sake::Component.new(:project => $proj,
:target_type => :pyd,
:basename => $basename,
:bin_basename => $basename,
:uid3 => Sake::Uid.v8($uid_v8),
:caps => Sake::ALL_CAPS)
class <<$pyd
def mmp_in_file
group_dir + ("module.mmp.in")
end
end
$comp_list = [$pyd].compact
if $sake_op[:kits]
$kits = Sake::DevKits::get_exact_set($sake_op[:kits].strip.split(/,/))
else
$kits = Sake::DevKits::get_all
end
$kits.delete_if do |kit|
!kit.supports_python_v?($pys60_version)
end
if $sake_op[:comps]
comps = $sake_op[:comps].strip.split(/,/)
$comp_list.delete_if do |comp|
!comps.include?(comp.basename)
end
end
$builds = $kits.map do |kit|
build = Sake::ProjBuild.new(:project => $proj,
:devkit => kit)
if build.v9_up?
build.handle = (build.handle + ("_py%d" % $pys60_version))
end
build.abld_platform = (build.v9_up? ? "gcce" : "armi")
build.abld_build = ($sake_op[:udeb] ? "udeb" : "urel")
if $sake_op[:udeb]
build.handle = (build.handle + "_udeb")
end
if $sake_op[:span_5th]
build.handle = (build.handle + "_5th")
$span_s60_5th = true
end
if build.v9_up?
build.gcc_version = ($sake_op[:gcce] ? $sake_op[:gcce].to_i : 3)
if build.gcc_version > 3
build.handle = (build.handle + ("_gcce%d" % build.gcc_version))
end
end
build
end
# For any v9 builds, configure certificate info for signing.
try_load('local/signing.rb')
$builds.delete_if do |build|
# Only v9 builds supported, actually.
# Maybe even not all of them, due to the SWInst API instability.
!build.v9_up? or (build.sign and !build.cert_file)
end
if $sake_op[:builds]
blist = $sake_op[:builds]
$builds.delete_if do |build|
!blist.include?(build.handle)
end
end
desc "Prints a list of possible builds."
task :builds do
for build in $builds
puts build.handle
end
end
desc "Prints info about possible builds."
task :build_info do
for build in $builds
puts "#{build.handle}:"
puts " project name #{build.project.name}"
puts " basename #{build.project.basename}"
puts " target #{build.target.handle}"
puts " devkit #{build.devkit.handle}"
puts " abld platform #{build.abld_platform}"
puts " abld build #{build.abld_build}"
puts " sign SIS? #{build.sign}"
puts " cert file #{build.cert_file}"
puts " privkey file #{build.key_file}"
puts " cert caps #{build.max_caps.inspect}"
puts " components #{build.comp_builds.map {|x| x.component.basename}.inspect}"
end
end
class HexNum
def initialize num
@num = num
end
def to_s
"0x%08x" % @num
end
end
class Sake::ProjBuild
def needs_pyd_wrapper?
# Some problems with imp.load_dynamic, better avoid the issue for
# now, especially as we are not using the wrapper to include pure
# Python code yet.
false # v9_up?
end
end
class Sake::CompBuild
def binary_prefix
return "" if v8_down?
pfx =
case $pys60_version
when 1 then ""
when 2 then "kf_"
else raise end
pfx += "_" if needs_pyd_wrapper?
pfx
end
def binary_suffix
return "" unless needs_pyd_wrapper?
"_" + uid3.chex_string
end
def binary_file
generated_file("%s%s%s.%s" % [binary_prefix,
bin_basename,
binary_suffix,
target_ext])
end
def pyd_wrapper_basename
bin_basename
end
def pyd_wrapper_file
generated_file(pyd_wrapper_basename + ".py")
end
def pyd_wrapper_path_in_pkg
# To look for suitable paths, use
#
# import sys
# sys.path
#
# Yes, it seems putting wrappers on E: is not an option.
case $pys60_version
when 1 then "c:\\resource\\"
when 2 then "c:\\resource\\python25\\"
else raise end
end
end
$cbuild_by_pbuild = Hash.new
for pbuild in $builds
map = pbuild.trait_map
# To define __UID__ for header files.
if pbuild.uid
map[:uid] = HexNum.new(pbuild.uid.number)
end
map[:pys60_version] = $pys60_version
map[($basename + "_version").to_sym] = ($version[0] * 100 + $version[1])
modname = (pbuild.needs_pyd_wrapper? ? ("_" + $basename) : $basename)
map[:module_name] = modname
map[:init_func_name] = ("init" + modname).to_sym
# NDEBUG controls whether asserts are to be compiled in (NDEBUG is
# defined in UDEB builds). Normally an assert results in something
# being printed to the console. To also have the errors logged, you
# will want to enable logging by setting "logging=true". Without
# this setting, there will be no dependency on the (deprecated) file
# logger API, and errors are still displayed on the console (if you
# have one and have time to read it). "logging=true" has no effect
# if your SDK does not have the required API.
if $sake_op[:logging] and map[:has_flogger]
map[:do_logging] = :define
end
# Each build variant shall have all of the components.
pbuild.comp_builds = $comp_list.map do |comp|
b = Sake::CompBuild.new(:proj_build => pbuild,
:component => comp)
$cbuild_by_pbuild[pbuild] = b
b
end
end
task :default => [:bin, :sis]
require 'sake4/tasks'
Sake::Tasks::def_list_devices_tasks(:builds => $builds)
Sake::Tasks::def_makefile_tasks(:builds => $builds)
Sake::Tasks::def_binary_tasks(:builds => $builds)
Sake::Tasks::def_sis_tasks(:builds => $builds)
Sake::Tasks::def_clean_tasks(:builds => $builds)
task :all => [:makefiles, :bin, :sis]
$doc_build = $builds.last
if $doc_build
# C++ API documentation.
Sake::Tasks::def_doxygen_tasks(:build => $doc_build)
task :all => :cxxdoc
end
# Configure any rules related to releasing and uploading and such
# things. Probably at least involves copying or uploading the
# distribution files somewhere.
try_load('local/releasing.rb')
desc "Prepares web pages."
task :web do
srcfiles = Dir['web/*.txt2tags.txt']
sh("darcs changes > web/changelog.txt")
for srcfile in srcfiles
htmlfile = srcfile.sub(/\.txt2tags\.txt$/, ".html")
sh("tools/txt2tags --target xhtml --infile %s --outfile %s --encoding utf-8 --verbose" % [srcfile, htmlfile])
end
end
dl_dir = $proj.download_dir
dl_path = $proj.to_proj_rel(dl_dir).to_s
desc "Prepares downloads for the current version."
task :release => :web do
mkdir_p dl_path
for build in $builds
## Unsigned.
if (not build.sign_sis?) or (build.sign_sis? and ($cert_name == "dev"))
src_sis_file = build.to_proj_rel(build.long_sis_file).to_s
sis_basename = File.basename(src_sis_file)
download_file = File.join(dl_path, sis_basename)
ln(src_sis_file, download_file, :force => true)
end
## Signed.
if build.sign_sis? and ($cert_name == "self")
src_sis_file = build.to_proj_rel(build.long_sisx_file).to_s
sis_basename = File.basename(src_sis_file)
download_file = File.join(dl_path, sis_basename)
ln(src_sis_file, download_file, :force => true)
end
end
end
Sake::Tasks::force_uncurrent_on_op_change
def sis_info opt
for build in $builds
if build.short_sisx_file.exist?
sh("sisinfo -f #{build.short_sisx_file} #{opt}")
end
end
end
task :sis_ls do
sis_info "-i"
end
task :sis_cert do
sis_info "-c"
end
task :sis_struct do
sis_info "-s"
end