bin/nixenvironment in nixenvironment-0.0.68 vs bin/nixenvironment in nixenvironment-0.0.69

- old
+ new

@@ -74,44 +74,52 @@ c.option '--ci_build', 'Deprecated' # TODO: remove c.option '--icon_tagger MODE', String, 'Set XcodeIconTagger mode (full, short, off)' c.option '--app_version VERSION', String, 'Specify the version of the app (for mac and unity-winphone builds only)' c.action do |_args, options| options.default :config => 'Debug', :ipa => 'device', :icon_tagger => 'full', :unity_path => 'UNITY' - - need_to_build_ios = true - need_to_process_macos_build = false + unity_platform = options.unity_platform + is_unity_platform = unity_platform.present? + need_to_build_ios = true + need_to_process_macos_build = false need_to_process_winphone_build = false - is_unity_platform = options.unity_platform.present? if is_unity_platform unity_path = ENV[options.unity_path] || options.unity_path - unity_build(options.config, options.unity_platform, unity_path, options.development_build, options.keystore_path, options.keystore_password, options.key_alias_name, options.key_alias_password) - need_to_build_ios = options.unity_platform == 'ios' - need_to_process_macos_build = options.unity_platform == 'macos' - need_to_process_winphone_build = options.unity_platform == 'winphone' + unity_build(options.config, unity_platform, unity_path, options.development_build, options.keystore_path, options.keystore_password, options.key_alias_name, options.key_alias_password) + need_to_build_ios = unity_platform == 'ios' + need_to_process_macos_build = unity_platform == 'macos' + need_to_process_winphone_build = unity_platform == 'winphone' end if need_to_process_macos_build - build_path = File.join(UNITY_IOS_PROJECT_PATH, 'build.app') - plist_path = File.join(build_path, 'Contents/Info.plist') + plist_path = File.join(UNITY_MACOS_BUILD_PATH, 'Contents/Info.plist') info_plist = Plist.from_file(plist_path) info_plist['CFBundleVersion'] = monotonic_revision info_plist['CFBundleShortVersionString'] = options.app_version if options.app_version.present? info_plist['CFBundleName'] = $resigned_bundle_name if $resigned_bundle_name.present? info_plist['CFBundleDisplayName'] = $resigned_bundle_name if $resigned_bundle_name.present? info_plist.save(plist_path, Plist::FORMAT_XML) + + read_config_settings + + @config_settings[PRODUCT_SETTINGS_PATH_KEY] = plist_path + @config_settings[BUILT_PRODUCTS_DIR_KEY] = UNITY_MACOS_PROJECT_PATH + @config_settings[EXECUTABLE_NAME_KEY] = UNITY_MACOS_BUILD_NAME + @config_settings[CONFIGURATION_KEY] = options.development_build ? 'Debug' : 'Release' + @config_settings[SDK_NAME_KEY] = 'macosx' + + save_build_env_vars + + Archiver.make_macos_zip elsif need_to_process_winphone_build - build_path = File.join(Dir.pwd, 'Builds/WinPhone') - manifest_path = Dir.glob("#{build_path}/**/*.appxmanifest").first + manifest_path = Dir.glob("#{UNITY_WINPHONE_PROJECT_PATH}/**/*.appxmanifest").first File.open(manifest_path,'w') do |f| manifest = Nokogiri::XML(File.open(f)) manifest.at('Package/Identity')['Version'] = "#{options.app_version}.#{monotonic_revision}" end - - # TODO: update app_version elsif need_to_build_ios Dir.chdir(UNITY_IOS_PROJECT_PATH) if is_unity_platform read_config_settings @config_settings[CONFIGURATION_KEY] = options.config @@ -146,19 +154,39 @@ end command :deploy do |c| c.syntax = 'nixenvironment deploy' c.description = 'Deploy built artifacts to given server' - c.option '--unity_platform TARGET PLATFORM', String, 'Select target platform for unity deploy (ios or android)' + c.option '--unity_platform TARGET PLATFORM', String, 'Select target platform for unity deploy (ios | macos | android | winphone)' c.option '--deliver_deploy', 'Not only verify but also submit the build on iTunes Connect. (resigned_appstore builds only)' c.action do |_args, options| - need_to_deploy_ios = true - is_unity_platform = options.unity_platform.present? - need_to_deploy_ios = unity_deploy(options.unity_platform) if is_unity_platform + unity_platform = options.unity_platform + need_to_deploy_ios = false + need_to_deploy_macos_build = false + need_to_deploy_winphone_build = false - if need_to_deploy_ios - Dir.chdir(UNITY_IOS_PROJECT_PATH) if is_unity_platform + if unity_platform.present? + case unity_platform + when 'ios' + Dir.chdir(UNITY_IOS_PROJECT_PATH) + need_to_deploy_ios = true + when 'macos' + #Dir.chdir(UNITY_MACOS_PROJECT_PATH) + need_to_deploy_macos_build = true + when 'android' + system(DEPLOY_APK_SCRIPT_PATH) ? success('Unity android deploy complete!') : error('Unity android deploy error!') + when 'winphone' + #Dir.chdir(UNITY_WINPHONE_PROJECT_PATH) + need_to_deploy_winphone_build = true + else + error("Error: Unknown unity target platform '#{unity_platform}'!") + end + else + need_to_deploy_ios = true + end + + if need_to_deploy_ios || need_to_deploy_macos_build read_config_settings deploy(options.deliver_deploy) end end end @@ -239,26 +267,27 @@ break end end puts - dest_url = ask('Destination repository url: ') + dest_url = ask('Destination repository url: ') Git.ls_remote(dest_url) raise "Repository not found: '#{dest_url}'" unless Git.last_cmd_success? local_directory_to_clone = ask('Directory to clone into: ') raise 'Cloning into an existing directory is not allowed!' if Dir.exist?(local_directory_to_clone) - repo_name = File.basename(dest_url, GIT_EXT) - template_project_name = File.basename(template_project_url, GIT_EXT) + repo_name = File.basename(dest_url, GIT_EXT) + template_project_name = File.basename(template_project_url, GIT_EXT) begin - FileUtils.rm_rf(ADJUSTER_WORKING_COPY_PATH) + adjuster_working_copy_path = File.join(Dir.tmpdir, ADJUSTER_WORKING_COPY_NAME) + FileUtils.rm_rf(adjuster_working_copy_path) - Dir.mkdir(ADJUSTER_WORKING_COPY_PATH) - Dir.chdir(ADJUSTER_WORKING_COPY_PATH) do + Dir.mkdir(adjuster_working_copy_path) + Dir.chdir(adjuster_working_copy_path) do puts puts 'Cloning template project ...' Git.clone(template_project_url, nil, :r => true) raise "Authentication failed for #{template_project_url}!" unless Git.last_cmd_success? @@ -504,12 +533,11 @@ puts 'Generating IOS project from UNITY project ...' unity_success = system("#{unity_path} -projectPath '#{Dir.pwd}' -batchmode -logFile -quit -executeMethod NIXBuilder.MakeiOSBuild -customArgs:'#{build_path_arg}#{development_build_arg}'") error('iOS build unity error!') unless unity_success success('IOS project was generated.') when 'macos' - build_path = File.join(UNITY_IOS_PROJECT_PATH, 'build.app') - build_path_arg = "buildPath=#{build_path}" + build_path_arg = "buildPath=#{UNITY_MACOS_BUILD_PATH}" development_build_arg = development_build ? ';developmentBuild=' : '' unity_success = system("#{unity_path} -projectPath '#{Dir.pwd}' -batchmode -logFile -quit -executeMethod NIXBuilder.MakeMacOSBuild -customArgs:'#{build_path_arg}#{development_build_arg}'") error('iOS build unity error!') unless unity_success when 'android' @@ -521,12 +549,11 @@ build_success = system("#{UNITY_BUILD_ANDROID_SCRIPT_PATH} --configuration #{configuration} --unity-path #{unity_path}\ #{development_build_arg} #{keystore_path_arg} #{keystore_password_arg} #{key_alias_name_arg} #{key_alias_password_arg}") error('Android build unity error!') unless build_success when 'winphone' - build_path = File.join(Dir.pwd, 'Builds/WinPhone') - build_path_arg = "buildPath=#{build_path}" + build_path_arg = "buildPath=#{UNITY_WINPHONE_PROJECT_PATH}" development_build_arg = development_build ? ';developmentBuild=' : '' puts 'Generating WinPhone project from UNITY project ...' build_success = system("#{unity_path} -projectPath '#{Dir.pwd}' -batchmode -logFile -quit -executeMethod NIXBuilder.MakeWinPhoneBuild -customArgs:'#{build_path_arg}#{development_build_arg}'") error('WinPhone build unity error!') unless build_success @@ -650,35 +677,24 @@ configuration_full_path = File.join(local_path_to_build, name_for_deployment) FileUtils.mkdir(configuration_full_path) FileUtils.cp(ipa_product, File.join(configuration_full_path, executable_name) + ZIP_EXT) - if File.exist?(app_dsym) - Dir.chdir(built_products_dir) - destination = File.join(configuration_full_path, "#{executable_name + APP_EXT + DSYM_EXT + ZIP_EXT}") - system("zip -r \"#{destination}\" \"#{executable_name + APP_EXT + DSYM_EXT}\"") - end + # TODO: mds currently doesn't support dsym for mac projects. Will be implemented later. + # if File.exist?(app_dsym) + # Dir.chdir(built_products_dir) + # destination = File.join(configuration_full_path, "#{executable_name + APP_EXT + DSYM_EXT + ZIP_EXT}") + # system("zip -r '#{destination}' '#{executable_name + APP_EXT + DSYM_EXT}'") + # end deploy_path = @config_settings[DEPLOY_PATH_KEY].blank? ? MACOS_PROJECTS_DEPLOY_PATH : @config_settings[DEPLOY_PATH_KEY] deploy_success = system("#{DEPLOY_SCRIPT_PATH} #{deploy_host} #{deploy_path} #{deploy_username} #{deploy_password} #{local_path_to_app}") else deploy_path = @config_settings[DEPLOY_PATH_KEY].blank? ? ENV[DEPLOY_PATH_KEY] : @config_settings[DEPLOY_PATH_KEY] deploy_success = system("#{DEPLOY_IPA_SCRIPT_PATH} #{deploy_host} #{deploy_path} #{deploy_username} #{deploy_password} #{deploy_itunesconnect_username} #{deliver_deploy}") end deploy_success ? success('Deploy complete!') : error('Deploy error!') -end - -def unity_deploy(unity_platform) - need_to_deploy_ios = false - - case unity_platform - when 'ios' then need_to_deploy_ios = true - when 'android' then system(DEPLOY_APK_SCRIPT_PATH) ? success('Unity android deploy complete!') : error('Unity android deploy error!') - else error("Error: Unknown unity target platform '#{unity_platform}'!") - end - - need_to_deploy_ios end def clean FileUtils.rm_f(Dir.glob('*.pyc')) FileUtils.rm_f('last_revision.sh') \ No newline at end of file