Class: Commands::XcodeBuild
- Inherits:
-
Object
- Object
- Commands::XcodeBuild
- Defined in:
- lib/commands/xcode_build.rb
Instance Method Summary collapse
-
#do_build(build, archivePath) ⇒ Object
prepare a single repo and create a local and tracking branch if it should have one if the repo specifies a branch then we will do the initial fetch from that branch if the create_dev_branch flag is set, we will create a local and tracking branch with the developer initials prepended.
-
#options ⇒ Object
holds the options that were passed you can set any initial defaults here.
- #register(opts, global_options) ⇒ Object
-
#required_options ⇒ Object
required options.
- #run(global_options) ⇒ Object
Instance Method Details
#do_build(build, archivePath) ⇒ Object
prepare a single repo and create a local and tracking branch if it should have one if the repo specifies a branch then we will do the initial fetch from that branch if the create_dev_branch flag is set, we will create a local and tracking branch with the developer initials prepended
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/commands/xcode_build.rb', line 47 def do_build(build, archivePath) workspace = build[:workspace] scheme = build[:scheme] xcconfig = build[:xcconfig] archiveName = build[:archiveName] exportName = build[:exportName] configuration = build[:configuration] extra_configs = build[:extra_configs] provisioning_file = build[:provisioning_file] if !archivePath.empty? then archive = 'archive' else archive = '' end cmd = "xcodebuild #{archive} -workspace #{workspace} -scheme #{scheme} -xcconfig '#{xcconfig}' -configuration #{configuration} -derivedDataPath build -archivePath '#{archivePath}/#{archiveName}' #{extra_configs}" if EcbSharedLib::CL.do_cmd_result(cmd, '.') != 0 raise "Xcode Build failed." end if !archivePath.empty? then cmd = "xcodebuild -exportArchive -exportFormat IPA -archivePath '#{archivePath}/#{archiveName}' -exportPath '#{archivePath}/#{exportName}' -exportProvisioningProfile '#{provisioning_file}'" if EcbSharedLib::CL.do_cmd_result(cmd, '.') != 0 raise "Xcode Export Archive failed." end end end |
#options ⇒ Object
holds the options that were passed you can set any initial defaults here
13 14 15 16 |
# File 'lib/commands/xcode_build.rb', line 13 def @options ||= { } end |
#register(opts, global_options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/commands/xcode_build.rb', line 25 def register(opts, ) opts. = "Usage: xcode_archive [options]" opts.description = "Build an Xcode deliverable from the specified config." opts.on('-c', "--config name", "Required - Name of the config we are building from.") do |v| [:config] = v end opts.on('-r', "--config-repo name", EcbSharedLib::REPO_COMMAND_DETAILS) do |v| [:config_repo] = v end opts.on('-a', "--archive archivePath", "Path to build the archive") do |v| [:archive] = v end end |
#required_options ⇒ Object
required options
19 20 21 22 23 |
# File 'lib/commands/xcode_build.rb', line 19 def @required_options ||= Set.new [ :config, ] end |
#run(global_options) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/commands/xcode_build.rb', line 76 def run() # see if we can open the config file - we append the .config suffix # the file is expected to be in JSON format config_name = [:config] archivePath = [:archive] config_repo = [:config_repo] config_repo_url = EcbSharedLib.prepare_config_repo(config_repo) info = EcbSharedLib.read_repo_config(config_repo_url, config_name) build_config = EcbSharedLib.read_build_config(config_repo_url) # Now that we have the json, prepare the world by creating a directory with the config name and placing # the various repos beneath that. The directory is created relative to the current directory. cmd = "security unlock-keychain -p #{build_config[:login_password]} ~/Library/Keychains/login.keychain" EcbSharedLib::CL.do_cmd(cmd, '.') cmd = "rm -Rf build" EcbSharedLib::CL.do_cmd(cmd, '.') if !archivePath.empty? then cmd = "rm -Rf #{archivePath}" EcbSharedLib::CL.do_cmd(cmd, '.') end builds = info[:builds] builds.each do |build| do_build(build, archivePath) cmd = "git checkout ." EcbSharedLib::CL.do_cmd(cmd, '.') end # finish up by writing settings settings = { :config_repo_url => config_repo_url, :config_name => config_name, } # saves the settings to .ecb-settings.json file. # currently inside a git repo, which is probably not the desired behavior. # don't think this is needed for ecb. #top_dir = "#{Dir.pwd}/#{config_name}" #EcbSharedLib.write_settings(settings, top_dir, err_msg = nil) end |