-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
82 lines (71 loc) · 2.65 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
require 'rake'
require 'fileutils'
require 'json'
PALM_SDK = "/opt/PalmSDK/Current/bin/"
PALM_SDK_BINARIES = %w[ palm-emulator palm-help palm-launch palm-package palm-worm palm-generate palm-install palm-log palm-run ]
PALM_SDK_BINARIES.map! { |bin| PALM_SDK + bin }
INDEX_PATH = File.expand_path "src/index.html"
DEBUG_FRAMEWORK_CONFIG = {
:debuggingEnabled => true,
:escapeHTMLInTemplates => true,
:logEvents => true,
:logLevel => 99,
:timingEnabled => true,
:useNativeJSONParser => true
}
RELEASE_FRAMEWORK_CONFIG = {
:debuggingEnabled => false,
:escapeHTMLInTemplates => true,
:logEvents => false,
:logLevel => 0,
:timingEnabled => false,
:useNativeJSONParser => true
}
desc "Makes sure that the PalmSDK is installed"
task :sdk? do
PALM_SDK_BINARIES.each do |bin|
raise "PalmSDK is not properly installed." unless File.exists? bin
end
end
desc "Build the source in some context, e.g., rake build[Debug]."
task :build, :context do |cmd, args|
Rake::Task[:sdk?]
build_output_dir = File.expand_path "bin/#{args[:context]}"
FileUtils.mkdir_p build_output_dir unless File.exists? build_output_dir
`palm-package --outdir="#{build_output_dir}" --exclude="resources" src` =~ /((\b\S*(?=_\d))\S*\b)/i
IPK_FILE = [build_output_dir, $1].join "/"
APP_ID = $2
end
namespace :install do
desc "Install *.ipk on the device, e.g., rake install:device[Debug]"
task :device, :context do |cmd, args|
Rake::Task[:build].invoke(args[:context])
`palm-install -d usb #{IPK_FILE}`
end
desc "Install *.ipk on the emulator, e.g., rake install:emulator[Debug]"
task :emulator, :context do |cmd, args|
Rake::Task[:build].invoke(args[:context])
`palm-install -d tcp #{IPK_FILE}`
end
end
namespace :launch do
desc "Lauch on device, e.g., rake launch:device[Debug]"
task :device, :context do |cmd, args|
Rake::Task["install:device"].invoke(args[:context])
framework_config = args[:context] =~ /debug/i ? DEBUG_FRAMEWORK_CONFIG : RELEASE_FRAMEWORK_CONFIG
puts framework_config.to_json
`palm-launch -p #{framework_config.to_json} #{APP_ID}`
end
desc "Lauch in emulator, e.g., rake launch:emulator[Debug]"
task :emulator, :context do |cmd, args|
Rake::Task["install:emulator"].invoke(args[:context])
framework_config = args[:context] =~ /debug/i ? DEBUG_FRAMEWORK_CONFIG : RELEASE_FRAMEWORK_CONFIG
puts framework_config.to_json
`palm-launch -p #{framework_config.to_json} #{APP_ID}`
end
desc "Launch in Webkit browser, e.g., rake launch:webkit[Safari]."
task :webkit, :browser do |cmd, args|
`google-chrome --disable-web-security --enable-file-cookies #{INDEX_PATH}`
end
end
task :default => "launch:webkit"