-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPrecompiledDB.rb
93 lines (76 loc) · 2.65 KB
/
PrecompiledDB.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
# List of precompiled things. New database implementation is in the Database folder
require_relative 'Database/Database'
# Dependency is a BaseDep derived class that can be used with a dependency
def getSupportedPrecompiledPackage(dependency)
# Immediately skip if not used
return if $usePrecompiled == false
files = dependency.getInstalledFiles
unless files
# Not supported
return nil
end
# Supported, now just need to find one matching ourPlatform
ourPlatform = describePlatform
fullName = dependency.getNameForPrecompiled + '_' + ourPlatform
package = getPrecompiledByName(fullName)
unless package
warning "No precompiled release of #{dependency.Name} found for current platform: " +
fullName
# TODO: list close matches
return
end
info "Found precompiled version of #{dependency.Name}: " + fullName
package.precompiled_this_is_for dependency
# Found. Determine what to do based on UsePrecompiled
if $usePrecompiled != true
# Ask
moveForward = false
until moveForward
puts ''
info "A precompiled version of #{dependency.Name} is available for your platform."
puts 'What would you like to do? (You can skip this question in the future ' \
'by specifying --precompiled or --no-precompiled on the command like)'
puts ''
puts "You can run this setup again to make a different choice if something doesn't work."
puts 'You can also press CTRL+C to cancel setup.'
puts ''
puts "[Y]es - use all available precompiled libraries\n" \
"[N]o - don't use precompiled libraries\n" \
"[O]nce - use precompiled for this and ask again for next one \n" \
"[S]kip - don't use precompiled for this dependency but ask again for next one\n"
puts ''
print '> '
choice = STDIN.gets.chomp.upcase
puts "Selection: #{choice}"
case choice
when 'Y'
puts 'Using this precompiled and all other ones'
moveForward = true
$usePrecompiled = true
when 'O'
puts 'Using this precompiled dependency'
moveForward = true
when 'N'
puts 'Not using any precompiled dependencies'
$usePrecompiled = false
return nil
when 'S'
puts 'Skipping using this precompiled dependency'
return nil
else
puts 'Invalid. Please type in Y, N, O or S'
end
end
end
# Using
info "Using precompiled binary for #{dependency.Name}"
package
end
def getPrecompiledByName(name)
databases = getDefaultDatabases
databases.each do |db|
precompiled = db.getPrecompiled name
return precompiled if precompiled
end
nil
end