Class: Gear
- Inherits:
-
Object
show all
- Defined in:
- lib/gear.rb
Constant Summary
collapse
- @@install_path =
"#{Dir.pwd}/vendor"
- @@initialized =
false
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Gear
Returns a new instance of Gear.
47
48
49
50
51
52
53
54
|
# File 'lib/gear.rb', line 47
def initialize()
@obtained = @built = @installed = @checked = false
@build_path = _root_path() + "/build/#{name()}"
_setup_paths()
Dir.chdir(_root_path() + "/build")
@@initialized = true
end
|
Class Attribute Details
.gear_name ⇒ Object
Returns the value of attribute gear_name.
22
23
24
|
# File 'lib/gear.rb', line 22
def gear_name
@gear_name
end
|
Instance Attribute Details
#build_path ⇒ Object
attribute list ========#
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
12
13
14
|
# File 'lib/gear.rb', line 12
def build_path
@build_path
end
|
#built ⇒ Object
attribute list ========#
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
12
13
14
|
# File 'lib/gear.rb', line 12
def built
@built
end
|
#checked ⇒ Object
attribute list ========#
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
12
13
14
|
# File 'lib/gear.rb', line 12
def checked
@checked
end
|
attribute list ========#
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
12
13
14
|
# File 'lib/gear.rb', line 12
def
@headers
end
|
#installed ⇒ Object
attribute list ========#
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
12
13
14
|
# File 'lib/gear.rb', line 12
def installed
@installed
end
|
#libs ⇒ Object
attribute list ========#
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
12
13
14
|
# File 'lib/gear.rb', line 12
def libs
@libs
end
|
#obtained ⇒ Object
attribute list ========#
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
12
13
14
|
# File 'lib/gear.rb', line 12
def obtained
@obtained
end
|
Class Method Details
.initialized? ⇒ Boolean
30
31
32
|
# File 'lib/gear.rb', line 30
def self.initialized?
@@initialized
end
|
.install_path(new_path = nil) ⇒ Object
25
26
27
28
|
# File 'lib/gear.rb', line 25
def self.install_path(new_path = nil)
@@install_path = new_path unless new_path.nil?
@@install_path
end
|
Instance Method Details
#build ⇒ Object
62
63
64
65
66
|
# File 'lib/gear.rb', line 62
def build()
STDERR.puts "WARNING: Gear did not override build method. Nothing was built."
@built = false
return false
end
|
#check ⇒ Object
74
75
76
77
78
|
# File 'lib/gear.rb', line 74
def check()
STDERR.puts "WARNING: Gear did not override check method. Status is unknown."
@checked = false
return false
end
|
#disengage ⇒ Object
101
102
103
104
|
# File 'lib/gear.rb', line 101
def disengage()
uninstall &&
remove
end
|
#engage ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/gear.rb', line 80
def engage()
!check && obtain &&
build &&
install &&
check
end
|
#gear_exec(command = "") ⇒ Object
Prefixes a command with the gearbox prefixed in the load path
152
153
154
|
# File 'lib/gear.rb', line 152
def gear_exec(command = "")
`LD_LIBRARY_PATH=#{@@install_path}/lib:$LD_LIBRARY_PATH C_INCLUDE_PATH=#{@@install_path}/include:$C_INCLUDE_PATH PATH=#{@@install_path}/bin:$PATH #{command}`
end
|
#gear_exec_mac ⇒ Object
156
157
158
|
# File 'lib/gear.rb', line 156
def gear_exec_mac()
`mdfind -onlyin #{@@install_path} -name #{name} -count`.chomp.to_i
end
|
#git_obtain(repository, branch) ⇒ Object
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
|
# File 'lib/gear.rb', line 107
def git_obtain(repository, branch)
Dir.chdir(_root_path + '/build')
begin
if Dir.exist? build_path
@git = Git.open(build_path)
@git.reset("HEAD", hard: true)
@git.clean(force: true, d: true, x:true)
else
@git = Git.clone(repository, build_path)
end
rescue StandardError => e
STDERR.puts "Could not obtain repository #{repository}.\n#{e}"
@obtained = false
return false
end
@git.checkout(branch)
@git.pull
Dir.chdir(@build_path)
`git submodule update --init --recursive`
@obtained = true
return true
end
|
#github_obtain(user, repository, branch = 'master') ⇒ Object
133
134
135
|
# File 'lib/gear.rb', line 133
def github_obtain(user, repository, branch = 'master')
git_obtain("https://github.com/#{user}/#{repository}.git", branch)
end
|
#install ⇒ Object
68
69
70
71
72
|
# File 'lib/gear.rb', line 68
def install()
STDERR.puts "WARNING: Gear did not override install method. Nothing has been installed."
@installed = false
return false
end
|
#name ⇒ Object
38
39
40
|
# File 'lib/gear.rb', line 38
def name()
self.class.gear_name
end
|
#obtain ⇒ Object
56
57
58
59
60
|
# File 'lib/gear.rb', line 56
def obtain()
STDERR.puts "WARNING: Gear did not override obtain method. No sources were obtained."
@obtained = false
return false
end
|
#remove ⇒ Object
88
89
90
91
92
93
|
# File 'lib/gear.rb', line 88
def remove()
Dir.chdir(_root_path + '/build')
FileUtils.rm_rf("#{@build_path}")
@obtained = false
return true
end
|
#std_config_make(flags = "") ⇒ Object
137
138
139
140
141
142
|
# File 'lib/gear.rb', line 137
def std_config_make(flags = "")
Dir.chdir(@build_path)
`autoconf` if !File.exist? 'configure'
`./confirgure --prefix#{@@install_path}`
`make`
end
|
#std_make_install ⇒ Object
144
145
146
147
148
149
|
# File 'lib/gear.rb', line 144
def std_make_install()
Dir.chdir(@build_path)
`make install`
@installed = true
return true
end
|
#target(new_target = nil) ⇒ Object
42
43
44
45
|
# File 'lib/gear.rb', line 42
def target(new_target = nil)
@@install_path = new_target unless new_target.nil?
@@install_path
end
|
#uninstall ⇒ Object
95
96
97
98
99
|
# File 'lib/gear.rb', line 95
def uninstall()
STDERR.puts "WARNING: Gear did not override uninstall method."
return false
end
|