class U3d::LinuxInstallationHelper

Constants

STRINGS_FULL_VERSION_MATCHER

Public Instance Methods

find_build_number(root) click to toggle source
# File lib/u3d/installation.rb, line 228
def find_build_number(root)
  known_rev_locations.each do |p|
    rev = find_build_number_in("#{root}#{p}")
    return rev if rev
  end
  nil
end

Private Instance Methods

binutils_strings(path) click to toggle source
# File lib/u3d/installation.rb, line 246
def binutils_strings(path)
  command = "strings #{path.shellescape}"
  `#{command}`.split("\n")
end
find_build_number_in(path = nil) click to toggle source
# File lib/u3d/installation.rb, line 259
def find_build_number_in(path = nil)
  return nil unless File.exist? path
  str = strings(path)
  lines = str.select { |l| l =~ STRINGS_FULL_VERSION_MATCHER }
  lines.empty? ? nil : lines[0].split('_')[1]
end
known_rev_locations() click to toggle source

sorted by order of speed to fetch the strings data

# File lib/u3d/installation.rb, line 252
def known_rev_locations
  ['/Editor/BugReporter/unity.bugreporter',
   '/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/lib/UnityNativeJs/UnityNative.js.mem',
   '/Editor/Data/PlaybackEngines/LinuxStandaloneSupport/Variations/linux32_headless_nondevelopment_mono/LinuxPlayer',
   '/Editor/Unity']
end
strings(path) click to toggle source
# File lib/u3d/installation.rb, line 238
def strings(path)
  if `which strings` != ''
    binutils_strings(path)
  else
    Utils.strings(path).to_a
  end
end