15 |
# |
# |
16 |
|
|
17 |
require 'rbconfig' |
require 'rbconfig' |
18 |
$:.unshift(File.join("freebase","lib")) |
require 'getoptlong' |
19 |
$:.unshift("redist") |
opts = GetoptLong.new(['--codebase', '-b', GetoptLong::REQUIRED_ARGUMENT ]); |
20 |
#make sure architecture specific directory is in the include path and before |
|
21 |
#all system standard path |
# See if a code base was passed as an argument. If not |
22 |
$:.unshift(File.join('redist', Config::CONFIG['arch'])) |
# default the codebase to the path of the freeride.rb script |
23 |
|
codebase = File.expand_path(File.dirname($0)) |
24 |
|
opts.each do |opt, arg| |
25 |
|
codebase = arg if (opt == "--codebase" || opt == "-b") |
26 |
|
end |
27 |
|
$FR_CODEBASE = codebase |
28 |
|
|
29 |
|
# prepend the include path that are needed by FR |
30 |
|
# make sure architecture specific directory is in the include path and before |
31 |
|
# all system standard path |
32 |
|
$:.unshift(File.join(codebase,"freebase","lib")) |
33 |
|
$:.unshift(File.join(codebase,"redist")) |
34 |
|
$:.unshift(File.join(codebase,'redist', Config::CONFIG['arch'])) |
35 |
|
|
36 |
require 'freebase/freebase' |
require 'freebase/freebase' |
37 |
|
|
47 |
## |
## |
48 |
# Start up FreeRIDE and block until shut down event is received |
# Start up FreeRIDE and block until shut down event is received |
49 |
# |
# |
50 |
# dir:: [String] The directory which holds the properties.xml and/or default.xml |
# dir:: [String] The directory which holds the FreeRIDE codebase |
51 |
|
# |
52 |
# |
# |
53 |
def FreeRIDE.startup(dir) |
def FreeRIDE.startup(dir) |
54 |
|
|
55 |
#verify the existence of the supplied directory |
# verify the existence of the config directory (relative to codebase |
56 |
|
# if relative path given) |
57 |
|
if dir[0..0] != File::SEPARATOR |
58 |
|
configDir = File.join($FR_CODEBASE,dir) |
59 |
|
else |
60 |
|
configDir = dir |
61 |
|
end |
62 |
|
|
63 |
begin |
begin |
64 |
files = Dir.entries(dir) |
files = Dir.entries(configDir) |
65 |
rescue |
rescue |
66 |
raise "Could not locate directory #{dir}" |
raise "Could not locate directory #{configDir}" |
67 |
end |
end |
68 |
|
|
69 |
#make sure that either properties.yaml exists or default.yaml |
#make sure that either properties.yaml exists or default.yaml |
70 |
unless files.include?("properties.yaml") |
unless files.include?("properties.yaml") |
71 |
raise "Could not locate default.yaml in #{dir}" unless files.include?("default.yaml") |
raise "Could not locate default.yaml in #{configDir}" unless files.include?("default.yaml") |
72 |
end |
end |
73 |
|
|
74 |
#This method will not return until FreeRIDE is closed (shut down) |
#This method will not return until FreeRIDE is closed (shut down) |