forked from rhomobile/rhodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rhodes-setup
executable file
·123 lines (95 loc) · 4.65 KB
/
rhodes-setup
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
#!/usr/bin/env ruby
require 'yaml'
require 'fileutils'
include FileUtils
def prompt_for(question, suggestion, required, validation = "")
newanswer = "X"
if required
while not File.exists? newanswer + validation
print "JDK path (required) (#{suggestion}): "
newanswer = gets.chomp!
newanswer = suggestion if newanswer == ""
puts "Invalid JDK path" unless File.exists? newanswer + validation
end
else
while newanswer != "" and not File.exists? newanswer + validation
print "#{question} (blank to skip) (#{suggestion}): "
newanswer = gets.chomp!
puts "Invalid #{question}" if newanswer != "" and not File.exists? newanswer + validation
end
end
suggestion = newanswer unless newanswer == ""
File.expand_path(suggestion) unless suggestion == ""
end
rhobuildyml = File.expand_path(File.dirname(__FILE__) + "/../") + "/rhobuild.yml"
puts "We will ask you a few questions below about your dev environment.\n\n"
#first try and find java
java = ""
if ENV['JAVA_HOME']
java = ENV['JAVA_HOME']
elsif File.exists? "/Library/Java/Home"
java = "/Library/Java/Home"
elsif File.exists? "/Program Files/Java"
start = pwd
chdir "/Program Files/Java"
Dir.glob("**/jdk1.6*") { |f| java = File.expand_path(f) }
chdir start
end
java = java.gsub(/\\/,"/")
java = "" unless File.exists? java + "/lib/dt.jar"
java = prompt_for("JDK Path", java, true, "/lib/dt.jar")
java = java + "/bin"
#now try and find android
android = ""
if ENV['ANDROID_HOME']
android = ENV['ANDROID_HOME']
end
android = prompt_for("Android SDK path", android, false)
# try to detect android ndk
ndk = ""
unless android.nil?
ndks = Dir.glob(File.dirname(android) + "/android-ndk-*").sort
ndk = ndks.last if ndks.size > 0
end
androidndk = prompt_for("Android NDK path", ndk, false)
#now cabwiz
cabwiz = ""
cabwiz = "/Program Files/Windows Mobile 6 SDK/Tools/CabWiz" if File.exists? "/Program Files/Windows Mobile 6 SDK/Tools/CabWiz"
cabwiz = "C:/Program Files/Windows Mobile 6 SDK/Tools/CabWiz" if File.exists? "C:/Program Files/Windows Mobile 6 SDK/Tools/CabWiz"
cabwiz = prompt_for("Windows Mobile 6 SDK CabWiz", cabwiz, false)
#now blackberry
jde46 = ""
jde46 = File.expand_path("/Program Files/Research In Motion/BlackBerry JDE 4.6.0") if File.exists? "/Program Files/Research In Motion/BlackBerry JDE 4.6.0"
jde46 = File.expand_path("C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0") if File.exists? "C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0"
jde46 = prompt_for("BlackBerry JDE 4.6", jde46, false)
jde46mds = ""
jde46mds = File.expand_path("/Program Files/Research In Motion/BlackBerry JDE 4.6.0/MDS") if File.exists? "/Program Files/Research In Motion/BlackBerry JDE 4.6.0/MDS"
jde46mds = File.expand_path("C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0/MDS") if File.exists? "C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0/MDS"
jde46mds = prompt_for("BlackBerry JDE 4.6 MDS", jde46mds, false)
jde42 = ""
jde42 = File.expand_path("/Program Files/Research In Motion/BlackBerry JDE 4.2.0") if File.exists? "/Program Files/Research In Motion/BlackBerry JDE 4.2.0"
jde42 = File.expand_path("/Program Files/Research In Motion/BlackBerry JDE 4.2.0") if File.exists? "C:/Program Files/Research In Motion/BlackBerry JDE 4.2.0"
jde42 = prompt_for("BlackBerry JDE 4.2", jde42, false)
jde42mds = ""
jde42mds = File.expand_path("/Program Files/Research In Motion/BlackBerry Email and MDS Services Simulators 4.1.2/MDS") if File.exists? "/Program Files/Research In Motion/BlackBerry Email and MDS Services Simulators 4.1.2/MDS"
jde42mds = File.expand_path("C:/Program Files/Research In Motion/BlackBerry Email and MDS Services Simulators 4.1.2/MDS") if File.exists? "C:/Program Files/Research In Motion/BlackBerry Email and MDS Services Simulators 4.1.2/MDS"
jde42mds = prompt_for("BlackBerry JDE 4.2 MDS", jde42mds, false)
puts "\nIf you want to build with other BlackBerry SDK versions edit: #{rhobuildyml}\n\n"
if File.exists? rhobuildyml
config = YAML::load_file(rhobuildyml)
else
config = YAML::load_file(File.expand_path(File.dirname(__FILE__) + "/../") + "/rhobuild.yml.example")
end
config["env"]["paths"]["java"] = java
config["env"]["paths"]["android"] = android
config["env"]["paths"]["android-ndk"] = androidndk
config["env"]["paths"]["cabwiz"] = cabwiz
config["env"]["paths"][4.2] = {} if config["env"]["paths"][4.2].nil?
config["env"]["paths"][4.6] = {} if config["env"]["paths"][4.6].nil?
config["env"]["paths"][4.6]["jde"] = jde46
config["env"]["paths"][4.6]["mds"] = jde46mds
config["env"]["paths"][4.2]["jde"] = jde42
config["env"]["paths"][4.2]["mds"] = jde42mds
File.open( rhobuildyml, 'w' ) do |out|
YAML.dump( config, out )
end