lib/u3d/installation.rb in u3d-1.2.2 vs lib/u3d/installation.rb in u3d-1.2.3

- old
+ new

@@ -103,11 +103,11 @@ def do_not_move_file_path File.join(@root_path, U3D_DO_NOT_MOVE) end end - class PlaybackEngineUtils + class IvyPlaybackEngineUtils def self.list_module_configs(playbackengine_parent_path) Dir.glob("#{playbackengine_parent_path}/PlaybackEngines/*/ivy.xml") end def self.node_value(config_path, node_name) @@ -125,10 +125,36 @@ def self.unity_version(config_path) node_value(config_path, 'ivy-module/info/@e:unityVersion') end end + class ModulePlaybackEngineUtils + def self.list_module_configs(playbackengine_parent_path) + # this should work on all platforms, non existing paths being ignored... + Dir.glob("#{playbackengine_parent_path}/PlaybackEngines/*/modules.asset") | + Dir.glob("#{playbackengine_parent_path}/Unity.app/Contents/PlaybackEngines/*/modules.asset") + end + + def self.module_name(config_path) + File.basename(File.dirname(config_path)).gsub("Support", "") + end + end + + class InstallationUtils + def self.read_version_from_unity_builtin_extra(file) + File.open(file, "rb") do |f| + f.seek(20) + s = "" + while (c = f.read(1)) + break if c == "\x00" + s += c + end + s + end + end + end + class MacInstallation < Installation require 'plist' def version plist['CFBundleVersion'] @@ -152,13 +178,17 @@ "#{@root_path}/Unity.app" end def packages pack = [] - PlaybackEngineUtils.list_module_configs(root_path).each do |mpath| - pack << PlaybackEngineUtils.module_name(mpath) + IvyPlaybackEngineUtils.list_module_configs(root_path).each do |mpath| + pack << IvyPlaybackEngineUtils.module_name(mpath) end + ModulePlaybackEngineUtils.list_module_configs(root_path).each do |mpath| + pack << ModulePlaybackEngineUtils.module_name(mpath) + end + NOT_PLAYBACKENGINE_PACKAGES.each do |module_name| pack << module_name unless Dir[module_name_pattern(module_name)].empty? end pack end @@ -234,19 +264,12 @@ end end class LinuxInstallation < Installation def version - # I don't find an easy way to extract the version on Linux - path = "#{root_path}/Editor/Data/" - package = PlaybackEngineUtils.list_module_configs(path).first - raise "Couldn't find a module under #{path}" unless package - version = PlaybackEngineUtils.unity_version(package) - if (m = version.match(/^(.*)x(.*)Linux$/)) - version = "#{m[1]}#{m[2]}" - end - version + path = "#{root_path}/Editor/Data/Resources/unity_builtin_extra" + InstallationUtils.read_version_from_unity_builtin_extra(path) end def build_number @build_number ||= LinuxInstallationHelper.new.find_build_number(root_path) end @@ -265,13 +288,16 @@ end def packages path = "#{root_path}/Editor/Data/" pack = [] - PlaybackEngineUtils.list_module_configs(path).each do |mpath| - pack << PlaybackEngineUtils.module_name(mpath) + IvyPlaybackEngineUtils.list_module_configs(path).each do |mpath| + pack << IvyPlaybackEngineUtils.module_name(mpath) end + ModulePlaybackEngineUtils.list_module_configs(root_path).each do |mpath| + pack << ModulePlaybackEngineUtils.module_name(mpath) + end NOT_PLAYBACKENGINE_PACKAGES.each do |module_name| pack << module_name unless Dir[module_name_pattern(module_name)].empty? end pack end @@ -366,13 +392,13 @@ def version version = helper.version return version unless version.nil? path = "#{root_path}/Editor/Data/" - package = PlaybackEngineUtils.list_module_configs(path).first + package = IvyPlaybackEngineUtils.list_module_configs(path).first raise "Couldn't find a module under #{path}" unless package - PlaybackEngineUtils.unity_version(package) + IvyPlaybackEngineUtils.unity_version(package) end def build_number helper.build_number end @@ -401,11 +427,14 @@ end def packages path = "#{root_path}/Editor/Data/" pack = [] - PlaybackEngineUtils.list_module_configs(path).each do |mpath| - pack << PlaybackEngineUtils.module_name(mpath) + IvyPlaybackEngineUtils.list_module_configs(path).each do |mpath| + pack << IvyPlaybackEngineUtils.module_name(mpath) + end + ModulePlaybackEngineUtils.list_module_configs(root_path).each do |mpath| + pack << ModulePlaybackEngineUtils.module_name(mpath) end NOT_PLAYBACKENGINE_PACKAGES.each do |module_name| pack << module_name unless Dir[module_name_pattern(module_name)].empty? end pack