bin/nixenvironment in nixenvironment-0.0.27 vs bin/nixenvironment in nixenvironment-0.0.28
- old
+ new
@@ -73,13 +73,13 @@
need_to_build_ios, root_working_dir, need_chdir_to_root_working_dir = unity_build(options.unity)
return unless need_to_build_ios
end
begin
- read_config
+ read_config_settings
enable_ci_build(options.ci_build)
- setup(options.config)
+ supplement_config_settings(options.config)
prebuild(options.config)
build(options.config, options.ipa)
restore_info_plist
rescue
raise # re-rise exception but chdir to root_working_dir in ensure block first if needed
@@ -100,11 +100,11 @@
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
+ read_config_settings
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
@@ -124,29 +124,29 @@
command :test do |c|
c.syntax = 'nixenvironment test'
c.description = 'Build xctest unit tests and run them in simulator'
c.action do |args, options|
- read_config
+ read_config_settings
test
end
end
command :code_coverage do |c|
c.syntax = 'nixenvironment code_coverage'
c.description = 'Generate xctest unit tests code coverage report'
c.action do |args, options|
- read_config
+ read_config_settings
code_coverage
end
end
command :code_duplication_report do |c|
c.syntax = 'nixenvironment code_duplication_report'
c.description = 'Generate code duplication report for xctest'
c.action do |args, options|
- read_config
+ read_config_settings
code_duplication_report
end
end
command :tag do |c|
@@ -201,11 +201,11 @@
end
end
system("git fetch -t")
tags = IO.popen('git tag').readlines
- tags.map! { |tag| tag = tag.strip }
+ tags.map! { |tag| tag.strip! }
if tags.size > 0
p("Checkout newest #{repo_name} tag...")
system("git checkout #{tags.last}")
else
@@ -222,45 +222,45 @@
p(@error_message) if @error_message
Dir.chdir(root_working_directory)
end
end
-def read_config
+def read_config_settings
begin
@config_settings = YAML.load(File.read(File.join(File.dirname(__FILE__), 'Config')))
rescue
abort('Config file processing error!')
end
- update_config('PROJECT_TO_BUILD', $project_to_build)
- update_config('PROJECT_TARGET_TO_BUILD', $project_target_to_build)
- update_config('PROJECT_TARGET_TO_TEST', $project_target_to_test)
- update_config('WORKSPACE_TO_BUILD', $workspace_to_build)
- update_config('WORKSPACE_SCHEME_TO_BUILD', $workspace_scheme_to_build)
- update_config('WORKSPACE_SCHEME_TO_TEST', $workspace_scheme_to_test)
- update_config('SDK', $sdk)
- update_config('SDK_FOR_TESTS', $sdk_for_tests)
- update_config('EXCLUDE_PATTERN_FOR_CODE_COVERAGE', $exclude_pattern_for_code_coverage)
- update_config('EXCLUDE_PATTERN_FOR_CODE_DUPLICATION', $exclude_pattern_for_code_duplication)
- update_config('DEPLOY_HOST', $deploy_host)
- update_config('DEPLOY_PATH', $deploy_path)
- update_config('DEPLOY_USERNAME', $deploy_username)
- update_config('DEPLOY_PASSWORD', $deploy_password)
- update_config('ICONS_PATH', $icons_path)
- update_config('XCTEST_DESTINATION_DEVICE', $xctest_destination_device)
- update_config('CONFIGURATION_FILES_PATH', $configuration_files_path)
- update_config('CODE_COVERAGE_CONFIGURATION', $code_coverage_configuration)
- update_config('CODE_COVERAGE_OUTPUT_DIRECTORY', $code_coverage_output_directory)
- update_config('ENV_VAR_PREFIX', $env_var_prefix)
- update_config('INFOPLIST_PATH', $infoplist_path)
- update_config('BUNDLE_ID', $bundle_id)
- update_config('RESIGNED_BUNDLE_ID', $resigned_bundle_id)
- update_config('RESIGNED_BUNDLE_NAME', $resigned_bundle_name)
- update_config('RESIGNED_ENTITLEMENTS_PATH', $resigned_entitlements_path)
+ update_config_settings('PROJECT_TO_BUILD', $project_to_build)
+ update_config_settings('PROJECT_TARGET_TO_BUILD', $project_target_to_build)
+ update_config_settings('PROJECT_TARGET_TO_TEST', $project_target_to_test)
+ update_config_settings('WORKSPACE_TO_BUILD', $workspace_to_build)
+ update_config_settings('WORKSPACE_SCHEME_TO_BUILD', $workspace_scheme_to_build)
+ update_config_settings('WORKSPACE_SCHEME_TO_TEST', $workspace_scheme_to_test)
+ update_config_settings('SDK', $sdk)
+ update_config_settings('SDK_FOR_TESTS', $sdk_for_tests)
+ update_config_settings('EXCLUDE_PATTERN_FOR_CODE_COVERAGE', $exclude_pattern_for_code_coverage)
+ update_config_settings('EXCLUDE_PATTERN_FOR_CODE_DUPLICATION', $exclude_pattern_for_code_duplication)
+ update_config_settings('DEPLOY_HOST', $deploy_host)
+ update_config_settings('DEPLOY_PATH', $deploy_path)
+ update_config_settings('DEPLOY_USERNAME', $deploy_username)
+ update_config_settings('DEPLOY_PASSWORD', $deploy_password)
+ update_config_settings('ICONS_PATH', $icons_path)
+ update_config_settings('XCTEST_DESTINATION_DEVICE', $xctest_destination_device)
+ update_config_settings('CONFIGURATION_FILES_PATH', $configuration_files_path)
+ update_config_settings('CODE_COVERAGE_CONFIGURATION', $code_coverage_configuration)
+ update_config_settings('CODE_COVERAGE_OUTPUT_DIRECTORY', $code_coverage_output_directory)
+ update_config_settings('ENV_VAR_PREFIX', $env_var_prefix)
+ update_config_settings('INFOPLIST_PATH', $infoplist_path)
+ update_config_settings('BUNDLE_ID', $bundle_id)
+ update_config_settings('RESIGNED_BUNDLE_ID', $resigned_bundle_id)
+ update_config_settings('RESIGNED_BUNDLE_NAME', $resigned_bundle_name)
+ update_config_settings('RESIGNED_ENTITLEMENTS_PATH', $resigned_entitlements_path)
end
-def update_config(key, value)
+def update_config_settings(key, value)
if value
@config_settings[key] = value
p("#{key} |SPECIFIED| directly: #{value}")
else
p("#{key} |NOT specified| directly. Used from Config: #{@config_settings[key]}")
@@ -276,11 +276,11 @@
p('CI_BUILD disabled.')
end
end
def working_copy_is_clean?
- is_clean = system("
+ system("
LAST_REVISION_FILE=\"_last_revision.sh\"
source ${LAST_REVISION_FILE}
if [ ${WORKING_COPY_IS_CLEAN} -eq 1 ]; then
@@ -289,29 +289,15 @@
echo \"error: working copy must not have local modifications.\" 1>&2
echo \"You must add following files and folders to .gitignore:\"
echo \"$(git status --porcelain)\"
exit 1
fi")
-
- return is_clean
end
-def setup(config)
- # Parse information about project
- cmd_output = %x[ xcodebuild -list ]
- cmd_output = cmd_output.lines.to_a[1..-1].join # TODO: handle if to_a returns 0 or count less than expected
- info = {}
- cmd_output.split(/\n\n/).each do |pair|
- key,value = pair.split(/:/)
- next unless key and value
- lines = value.lines.map { |line| line.strip }
- lines.reject! { |line| line.empty? }
- info[key.strip] = lines
- end
+def supplement_config_settings(config)
+ abort("Build error! Configuration #{config} doesn't exist") unless xcode_project_contains_config?(config)
- abort("Build error! Configuration #{config} doesn't exist") unless info['Build Configurations'].include?(config)
-
if @config_settings['PROJECT_TO_BUILD'] and @config_settings['PROJECT_TO_BUILD'].length > 0
if @config_settings['PROJECT_TARGET_TO_BUILD'] and @config_settings['PROJECT_TARGET_TO_BUILD'].length > 0
cmd_output = %x[ xcodebuild -project #{@config_settings['PROJECT_TO_BUILD']}\
-target #{@config_settings['PROJECT_TARGET_TO_BUILD']}\
-configuration #{config}\
@@ -332,29 +318,50 @@
-showBuildSettings ]
else
abort('Build error! Either PROJECT_TO_BUILD or WORKSPACE_TO_BUILD must be specified!')
end
+ # Parse build settings
env_vars_list = cmd_output.split(/\n/).reject(&:empty?)
if env_vars_list and env_vars_list.length > 0
build_settings_to_strip = Hash[env_vars_list.map { |it| it.split('=', 2) }]
build_settings_to_strip.each do |key, value|
if key and value
stripped_key = key.strip
stripped_value = value.strip
- @config_settings[stripped_key] ||= stripped_value.shellescape # assign new value only if @config_settings[stripped_key] is nil
+ @config_settings[stripped_key] ||= stripped_value.shellescape # Assign new value only if assignee is nil
end
end
end
build_directory = File.join(Dir.pwd, 'build').shellescape
@config_settings['CONFIGURATION_BUILD_DIR'] = build_directory
@config_settings['BUILT_PRODUCTS_DIR'] = build_directory
@config_settings['DWARF_DSYM_FOLDER_PATH'] = build_directory
end
+def xcode_project_contains_config?(config)
+ # Parse information about project
+ cmd_output = %x[ xcodebuild -list 2>&1 ]
+ abort("Validate configuration error! #{cmd_output}") if cmd_output.include?('error')
+
+ cmd_output = cmd_output.lines[1..-1].join # Get all lines except first in order to ignore description message
+
+ info = {}
+
+ cmd_output.split(/\n\n/).each do |pair|
+ key,value = pair.split(/:/)
+ next unless key and value
+ lines = value.lines.map { |line| line.strip }
+ lines.reject! { |line| line.empty? }
+ info[key.strip] = lines
+ end
+
+ info['Build Configurations'].include?(config)
+end
+
def save_build_env_vars
app_product = File.join(@config_settings['BUILT_PRODUCTS_DIR'], @config_settings['EXECUTABLE_NAME']) + '.app'
system("
echo \"#!/bin/sh\
@@ -516,11 +523,11 @@
end
def backup_info_plist
p('Backuping Info.plist ...')
- @info_plist_backup_name = @config_settings['INFOPLIST_PATH'] + '.backup'
+ @info_plist_backup_name = @config_settings['INFOPLIST_PATH'] + '.backup' # PRODUCT_SETTINGS_PATH
FileUtils.cp(@config_settings['INFOPLIST_PATH'], @info_plist_backup_name)
p('Info.plist was backuped.')
end
@@ -544,10 +551,10 @@
end
def restore_info_plist
p('Restoring Info.plist ...')
- File.delete(@config_settings['INFOPLIST_PATH'])
+ File.delete(@config_settings['INFOPLIST_PATH']) # PRODUCT_SETTINGS_PATH
File.rename(@info_plist_backup_name, @config_settings['INFOPLIST_PATH'])
p('Info.plist was restored.')
end