Class: Gym::BuildCommandGenerator
- Inherits:
-
Object
- Object
- Gym::BuildCommandGenerator
- Defined in:
- lib/gym/generators/build_command_generator.rb
Overview
Responsible for building the fully working xcodebuild command
Class Method Summary collapse
- .actions ⇒ Object
- .archive_path ⇒ Object
-
.build_path ⇒ Object
The path where archive will be created.
- .generate ⇒ Object
- .options ⇒ Object
- .pipe ⇒ Object
- .prefix ⇒ Object
-
.project_path_array ⇒ Array
Path to the project or workspace as parameter This will also include the scheme (if given).
- .result_bundle_path ⇒ Object
- .suffix ⇒ Object
- .xcodebuild_log_path ⇒ Object
Class Method Details
.actions ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/gym/generators/build_command_generator.rb', line 48 def actions config = Gym.config actions = [] actions << :clean if config[:clean] actions << :archive actions end |
.archive_path ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/gym/generators/build_command_generator.rb', line 94 def archive_path Gym.cache[:archive_path] ||= Gym.config[:archive_path] unless Gym.cache[:archive_path] file_name = [Gym.config[:output_name], Time.now.strftime("%F %H.%M.%S")] # e.g. 2015-08-07 14.49.12 Gym.cache[:archive_path] = File.join(build_path, file_name.join(" ") + ".xcarchive") end if File.extname(Gym.cache[:archive_path]) != ".xcarchive" Gym.cache[:archive_path] += ".xcarchive" end return Gym.cache[:archive_path] end |
.build_path ⇒ Object
The path where archive will be created
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/gym/generators/build_command_generator.rb', line 82 def build_path unless Gym.cache[:build_path] Gym.cache[:build_path] = Gym.config[:build_path] unless Gym.cache[:build_path] day = Time.now.strftime("%F") # e.g. 2015-08-07 Gym.cache[:build_path] = File.("~/Library/Developer/Xcode/Archives/#{day}/") end FileUtils.mkdir_p Gym.cache[:build_path] end Gym.cache[:build_path] end |
.generate ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gym/generators/build_command_generator.rb', line 7 def generate parts = prefix parts << "xcodebuild" parts += parts += actions parts += suffix parts += pipe parts end |
.options ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gym/generators/build_command_generator.rb', line 31 def config = Gym.config = [] += project_path_array << "-configuration '#{config[:configuration]}'" if config[:configuration] << "-sdk '#{config[:sdk]}'" if config[:sdk] << "-destination '#{config[:destination]}'" if config[:destination] << "-xcconfig '#{config[:xcconfig]}'" if config[:xcconfig] << "-archivePath '#{archive_path}'" << "-derivedDataPath '#{config[:derived_data_path]}'" if config[:derived_data_path] << "-resultBundlePath '#{result_bundle_path}'" if config[:result_bundle] << config[:xcargs] if config[:xcargs] end |
.pipe ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/gym/generators/build_command_generator.rb', line 64 def pipe pipe = [] pipe << "| tee #{xcodebuild_log_path.shellescape} | xcpretty" pipe << "--no-color" if Helper.colors_disabled? pipe << "> /dev/null" if Gym.config[:suppress_xcode_output] pipe end |
.prefix ⇒ Object
18 19 20 |
# File 'lib/gym/generators/build_command_generator.rb', line 18 def prefix ["set -o pipefail &&"] end |
.project_path_array ⇒ Array
Path to the project or workspace as parameter This will also include the scheme (if given)
25 26 27 28 29 |
# File 'lib/gym/generators/build_command_generator.rb', line 25 def project_path_array proj = Gym.project.xcodebuild_parameters return proj if proj.count > 0 UI.user_error!("No project/workspace found") end |
.result_bundle_path ⇒ Object
107 108 109 110 111 112 |
# File 'lib/gym/generators/build_command_generator.rb', line 107 def result_bundle_path unless Gym.cache[:result_bundle_path] Gym.cache[:result_bundle_path] = File.join(Gym.config[:output_directory], Gym.config[:output_name]) + ".result" end return Gym.cache[:result_bundle_path] end |
.suffix ⇒ Object
58 59 60 61 62 |
# File 'lib/gym/generators/build_command_generator.rb', line 58 def suffix suffix = [] suffix << "CODE_SIGN_IDENTITY='#{Gym.config[:codesigning_identity]}'" if Gym.config[:codesigning_identity] suffix end |
.xcodebuild_log_path ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/gym/generators/build_command_generator.rb', line 73 def xcodebuild_log_path file_name = "#{Gym.project.app_name}-#{Gym.config[:scheme]}.log" containing = File.(Gym.config[:buildlog_path]) FileUtils.mkdir_p(containing) return File.join(containing, file_name) end |