Skip to content

Detect 2019 modules and allow to install 2019, skipping dmg install for now #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/u3d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,15 @@
module U3d
Helper = U3dCore::Helper
UI = U3dCore::UI

def self.const_missing(const_name)
deprecated = {
PlaybackEngineUtils: IvyPlaybackEngineUtils,
INIParser: INIModulesParser
}
Comment on lines +53 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this out of the method, maybe to a constant like DEPRECATED_CLASSES or something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in a future cleanup.

super unless deprecated.keys.include? const_name
replacement = deprecated[const_name]
UI.deprecated "DEPRECATION WARNING: the class U3d::#{const_name} is deprecated. Use #{replacement} instead."
replacement
end
end
3 changes: 1 addition & 2 deletions lib/u3d/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,8 @@ def check_unity_presence(version: nil)
UI.verbose "Version #{version} of Unity is not installed yet"
else
UI.verbose "Unity #{version} is installed at #{unity.root_path}"
return unity
end
nil
unity
end

# rubocop:disable Metrics/BlockNesting
Expand Down
2 changes: 1 addition & 1 deletion lib/u3d/downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module Downloader
# Regex to get the name of a localization asset
UNITY_LANGUAGE_FILE_REGEX = %r{\/\d+/[0-9\.]+\/([\w-]+)$}
# Regex to get the name of a package out of its file name
UNITY_MODULE_FILE_REGEX = %r{\/([\w\-_\.\+]+\.(?:pkg|exe|zip|sh|deb|msi|xz))[^\/]*$}
UNITY_MODULE_FILE_REGEX = %r{\/([\w\-_\.\+]+\.(?:pkg|dmg|exe|zip|sh|deb|msi|xz))[^\/]*$}

class << self
def download_directory
Expand Down
24 changes: 0 additions & 24 deletions lib/u3d/ini_modules_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,6 @@
require 'u3d_core/helper'

module U3d
# Backwards compatibility
module INIParser
class << self
def method_missing(method_name, *arguments, &block)
UI.deprecated 'INIParser is obsolete, Use INIModulesParser instead'
if INIModulesParser.respond_to?(method_name)
INIModulesParser.send(method_name, *arguments, &block)
else
super
end
end

def respond_to?(method_name, include_private = false)
UI.deprecated 'INIParser is obsolete, Use INIModulesParser instead'
INIModulesParser.respond_to?(method_name, include_private)
end

def respond_to_missing?(method_name, include_private = false)
UI.deprecated 'INIParser is obsolete, Use INIModulesParser instead'
INIModulesParser.respond_to_missing?(method_name, include_private)
end
end
end

# Load and parse INI files
module INIModulesParser
#####################################################
Expand Down
65 changes: 47 additions & 18 deletions lib/u3d/installation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def do_not_move_file_path
end
end

class PlaybackEngineUtils
class IvyPlaybackEngineUtils
def self.list_module_configs(playbackengine_parent_path)
Dir.glob("#{playbackengine_parent_path}/PlaybackEngines/*/ivy.xml")
end
Expand All @@ -127,6 +127,32 @@ def self.unity_version(config_path)
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'

Expand Down Expand Up @@ -154,9 +180,13 @@ def path

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
Expand Down Expand Up @@ -236,15 +266,8 @@ def find_build_number_in(path = nil)

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
Expand All @@ -267,8 +290,11 @@ def path
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?
Expand Down Expand Up @@ -368,9 +394,9 @@ def 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
Expand Down Expand Up @@ -403,8 +429,11 @@ def path
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?
Expand Down
4 changes: 3 additions & 1 deletion lib/u3d/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,14 @@ def installed
def install(file_path, version, installation_path: nil, info: nil)
# rubocop:enable UnusedMethodArgument
extension = File.extname(file_path)
raise "Installation of #{extension} files is not supported on Mac" unless %w[.zip .po .pkg].include? extension
raise "Installation of #{extension} files is not supported on Mac" unless %w[.zip .po .pkg .dmg].include? extension
path = installation_path || DEFAULT_MAC_INSTALL
if extension == '.po'
install_po(file_path, version, info: info)
elsif extension == '.zip'
install_zip(file_path, version, info: info)
elsif extension == '.dmg'
UI.important "Skipping installation of #{file_path} for now"
else
install_pkg(file_path, version: version, target_path: path)
end
Expand Down