bin/nixenvironment in nixenvironment-0.0.24 vs bin/nixenvironment in nixenvironment-0.0.25

- old
+ new

@@ -63,11 +63,11 @@ c.syntax = 'nixenvironment build [options]' c.description = 'Build project for selected configuration and make signed/resigned ipa' c.option '--config NAME', String, 'Select configuration' c.option '--ipa TYPE', String, 'Select sign (ipa, resigned_ipa_for_device, resigned_ipa_for_adhoc_distribution or resigned_ipa_for_appstore)' c.option '--ci_build', 'Define NIXENV_CI_BUILD environment variable' - c.option '--unity TARGET PLATFORM', String, 'Select target platform to build (ios or android)' + c.option '--unity TARGET PLATFORM', String, 'Select target platform for unity build (ios or android)' c.action do |args, options| options.default :config => 'Debug', :ipa => 'ipa' if options.unity and options.unity.length > 0 need_to_build_ios, root_working_dir, need_chdir_to_root_working_dir = unity_build(options.unity) @@ -92,13 +92,27 @@ end command :deploy do |c| c.syntax = 'nixenvironment deploy' c.description = 'Deploy built artifacts to given server' + c.option '--unity TARGET PLATFORM', String, 'Select target platform for unity deploy (ios or android)' c.action do |args, options| - read_config(options) - deploy + if options.unity and options.unity.length > 0 + need_to_deploy_ios, root_working_dir, need_chdir_to_root_working_dir = unity_deploy(options.unity) + return unless need_to_deploy_ios + end + + begin + read_config(options) + deploy + rescue + raise # re-rise exception but chdir to root_working_dir in ensure block first if needed + ensure + if need_chdir_to_root_working_dir and root_working_dir + Dir.chdir(root_working_dir) + end + end end end command :clean do |c| c.syntax = 'nixenvironment clean' @@ -477,19 +491,18 @@ end case unity when 'ios' need_to_build_ios = true + root_working_dir = Dir.pwd + ios_project_path = File.join(root_working_dir, UNITY_BUILDS_IOS_PATH) - ios_project_path = File.join(Dir.pwd, 'Builds/iOS') - p('Generating IOS project from UNITY project ...') - unity_success = system("unity -executeMethod NIXBuilder.MakeiOSBuild -batchmode -quit -customArgs:path='#{ios_project_path}'") + unity_success = system("unity -executeMethod NIXBuilder.MakeiOSBuild -projectPath #{root_working_dir} -batchmode -logFile -quit -customArgs:path='#{ios_project_path}'") abort('Build unity error!') unless unity_success p('IOS project was generated.') - root_working_dir = Dir.pwd need_chdir_to_root_working_dir = true clean_working_copy(false) Dir.chdir(ios_project_path) @@ -551,9 +564,31 @@ deploy_username = @config['DEPLOY_USERNAME'].nil? || @config['DEPLOY_USERNAME'].empty? ? ENV['DEPLOY_USERNAME'] : @config['DEPLOY_USERNAME'] deploy_password = @config['DEPLOY_PASSWORD'].nil? || @config['DEPLOY_PASSWORD'].empty? ? ENV['DEPLOY_PASSWORD'] : @config['DEPLOY_PASSWORD'] deploy_success = system("#{deploy} #{deploy_host} #{deploy_path} #{deploy_username} #{deploy_password}") abort('Deploy error!') unless deploy_success +end + +def unity_deploy(unity) + root_working_dir = nil + need_chdir_to_root_working_dir = false + need_to_deploy_ios = false + + case unity + when 'ios' + root_working_dir = Dir.pwd + need_chdir_to_root_working_dir = true + need_to_deploy_ios = true + + ios_project_path = File.join(root_working_dir, UNITY_BUILDS_IOS_PATH) + Dir.chdir(ios_project_path) + when 'android' + #TODO: implement me! + else + abort("Error: Unknown unity target platform '#{unity}'!") + end + + return need_to_deploy_ios, root_working_dir, need_chdir_to_root_working_dir end def clean remove_temporary_files = File.join(BUILD_SCRIPTS_PATH, 'RemoveTemporaryFiles.sh')