bin/nixenvironment in nixenvironment-0.0.14 vs bin/nixenvironment in nixenvironment-0.0.15
- old
+ new
@@ -2,10 +2,11 @@
require 'rubygems'
require 'nixenvironment'
require 'commander/import'
require 'yaml'
+require 'FileUtils'
include Nixenvironment
# :name is optional, otherwise uses the basename of this executable
program :name, 'nixenvironment'
@@ -41,10 +42,15 @@
global_option ('--env_var_prefix VALUE') { |value| $env_var_prefix = value }
global_option ('--infoplist_path VALUE') { |value| $infoplist_path = value }
+global_option ('--bundle_id VALUE') { |value| $bundle_id = value }
+global_option ('--resigned_bundle_id VALUE') { |value| $resigned_bundle_id= value }
+global_option ('--resigned_bundle_name VALUE') { |value| $resigned_bundle_name = value }
+global_option ('--resigned_entitlements_path VALUE') { |value| $resigned_entitlements_path = value }
+
command :update do |c|
c.syntax = 'nixenvironment update'
c.description = 'Install or update ninbas and other environment stuff'
c.option '--ninbas NAME', String, 'Select ninbas branch, tag or revision to clone'
c.action do |args, options|
@@ -61,13 +67,13 @@
c.action do |args, options|
options.default :config => 'Debug', :ipa => 'ipa', :ci_build => 'yes'
read_config(options)
enable_ci_build(options.ci_build)
build_settings = setup(options.config)
- prebuild(build_settings)
+ prebuild(build_settings, options.config)
build(options.config, options.ipa)
- revert_info_plist
+ restore_info_plist
end
end
command :deploy do |c|
c.syntax = 'nixenvironment deploy'
@@ -213,10 +219,14 @@
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)
end
def update_config(key, value)
if value
@config[key] = value
@@ -332,27 +342,26 @@
RESIGNED_BUNDLE_NAME=\"#{build_settings['RESIGNED_BUNDLE_NAME']}\"
RESIGNED_ENTITLEMENTS_PATH=\"#{build_settings['RESIGNED_ENTITLEMENTS_PATH']}\"\" > _last_build_vars.sh
")
end
-def prebuild(build_settings)
+def prebuild(build_settings, config)
save_revision = File.join(BUILD_SCRIPTS_PATH, 'SaveRevision.sh')
tag_icons = File.join(BUILD_SCRIPTS_PATH, 'XcodeIconTagger/tagIcons.sh')
- update_build_number = File.join(BUILD_SCRIPTS_PATH, 'UpdateBuildNumber.sh')
- update_revision_number = File.join(BUILD_SCRIPTS_PATH, 'UpdateRevisionNumber.sh')
system("#{save_revision}")
abort unless working_copy_is_clean?
+ backup_info_plist
+
save_build_env_vars(build_settings)
+ update_info_plist(build_settings, config)
+
# TODO: rewrite tagIcons.sh
# system("#{tag_icons} @config['ICONS_PATH']")
-
- system("#{update_build_number}")
- system("#{update_revision_number}")
end
def build(config, ipa)
build = File.join(BUILD_SCRIPTS_PATH, 'Build.py')
@@ -362,28 +371,31 @@
if @config['PROJECT_TARGET_TO_BUILD'] and @config['PROJECT_TARGET_TO_BUILD'].length > 0
build_success = system("#{build} --project \"#{@config['PROJECT_TO_BUILD']}\"\
--target \"#{@config['PROJECT_TARGET_TO_BUILD']}\"\
--configuration \"#{config}\"\
--sdk \"#{@config['SDK']}\"\
- --env-var-prefix \"#{@config['ENV_VAR_PREFIX']}\"")
+ --env-var-prefix \"#{@config['ENV_VAR_PREFIX']}\"\
+ DEBUG_INFORMATION_FORMAT=\"dwarf-with-dsym\"")
else
build_success = system("#{build} --project \"#{@config['PROJECT_TO_BUILD']}\"\
--scheme \"#{@config['WORKSPACE_SCHEME_TO_BUILD']}\"\
--configuration \"#{config}\"\
--sdk \"#{@config['SDK']}\"\
- --env-var-prefix \"#{@config['ENV_VAR_PREFIX']}\"")
+ --env-var-prefix \"#{@config['ENV_VAR_PREFIX']}\"\
+ DEBUG_INFORMATION_FORMAT=\"dwarf-with-dsym\"")
end
elsif @config['WORKSPACE_TO_BUILD'] and @config['WORKSPACE_TO_BUILD'].length > 0
build_success = system("#{build} --workspace \"#{@config['WORKSPACE_TO_BUILD']}\"\
--scheme \"#{@config['WORKSPACE_SCHEME_TO_BUILD']}\"\
--configuration \"#{config}\"\
--sdk \"#{@config['SDK']}\"\
- --env-var-prefix \"#{@config['ENV_VAR_PREFIX']}\"")
+ --env-var-prefix \"#{@config['ENV_VAR_PREFIX']}\"\
+ DEBUG_INFORMATION_FORMAT=\"dwarf-with-dsym\"")
end
unless build_success
- revert_info_plist
+ restore_info_plist
abort('Build error!')
end
case ipa
# create .ipa file from last built app product
@@ -403,21 +415,51 @@
end
make_success = system("#{make}") if defined? make
unless make_success
- revert_info_plist
+ restore_info_plist
abort("#{make} error!")
end
end
-def revert_info_plist
- p('Reverting Info.plist ...')
+def backup_info_plist
+ p('Backuping Info.plist ...')
- revert_success = system("git checkout #{@config['INFOPLIST_PATH']}")
- abort('Reverting Info.plist error!') unless revert_success
+ @info_plist_backup_name = @config['INFOPLIST_PATH'] + '.backup'
+ FileUtils.cp(@config['INFOPLIST_PATH'], @info_plist_backup_name)
- p('Info.plist was reverted.')
+ p('Info.plist was backuped.')
+end
+
+def update_info_plist(build_settings, config)
+ p('Updating Info.plist ...')
+
+ update_build_number = File.join(BUILD_SCRIPTS_PATH, 'UpdateBuildNumber.sh')
+ update_revision_number = File.join(BUILD_SCRIPTS_PATH, 'UpdateRevisionNumber.sh')
+
+ update_success = system("/usr/libexec/PlistBuddy -c 'Set :CFBundleIdentifier \"#{@config['BUNDLE_ID']}\"' \"#{@config['INFOPLIST_PATH']}\"")
+ update_success &&= system("/usr/libexec/PlistBuddy -c 'Add :Configuration string \"#{config}\"' \"#{@config['INFOPLIST_PATH']}\"")
+ update_success &&= system("/usr/libexec/PlistBuddy -c 'Add :RevisionNumber string \"undefined\"' \"#{@config['INFOPLIST_PATH']}\"")
+
+ unless update_success
+ restore_info_plist
+ abort('Update Info.plist error!')
+ end
+
+ system("#{update_build_number}")
+ system("#{update_revision_number}")
+
+ p('Info.plist was updated.')
+end
+
+def restore_info_plist
+ p('Restoring Info.plist ...')
+
+ File.delete(@config['INFOPLIST_PATH'])
+ File.rename(@info_plist_backup_name, @config['INFOPLIST_PATH'])
+
+ p('Info.plist was restored.')
end
def deploy
deploy = File.join(BUILD_SCRIPTS_PATH, 'Deploy.sh')