Class: Gym::BuildCommandGenerator
- Inherits:
-
Object
- Object
- Gym::BuildCommandGenerator
- Defined in:
- gym/lib/gym/generators/build_command_generator.rb
Overview
Responsible for building the fully working xcodebuild command
Class Method Summary collapse
- .archive_path ⇒ Object
-
.build_path ⇒ Object
The path where archive will be created.
- .buildactions ⇒ Object
- .generate ⇒ Object
- .legacy_xcpretty_options ⇒ Object
- .options ⇒ Object
- .pipe ⇒ Object
- .pipe_xcbeautify ⇒ Object
- .pipe_xcpretty ⇒ Object
- .post_build ⇒ 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
- .setting ⇒ Object
- .xcodebuild_log_path ⇒ Object
Class Method Details
.archive_path ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 171 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
163 164 165 166 167 168 169 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 163 def build_path unless Gym.cache[:build_path] Gym.cache[:build_path] = Gym.config[:build_path] FileUtils.mkdir_p(Gym.cache[:build_path]) end Gym.cache[:build_path] end |
.buildactions ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 52 def buildactions config = Gym.config buildactions = [] buildactions << :clean if config[:clean] buildactions << :build if config[:skip_archive] buildactions << :archive unless config[:skip_archive] buildactions end |
.generate ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 8 def generate parts = prefix parts << Gym.config[:xcodebuild_command] parts += parts += buildactions parts += setting parts += pipe parts end |
.legacy_xcpretty_options ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 108 def = [] << "xcpretty_test_format" if Gym.config[:xcpretty_test_format] << "xcpretty_formatter" if Gym.config[:xcpretty_formatter] << "xcpretty_report_junit" if Gym.config[:xcpretty_report_junit] << "xcpretty_report_html" if Gym.config[:xcpretty_report_html] << "xcpretty_report_json" if Gym.config[:xcpretty_report_json] << "xcpretty_utf" if Gym.config[:xcpretty_utf] return end |
.options ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 32 def config = Gym.config = [] += project_path_array << "-sdk '#{config[:sdk]}'" if config[:sdk] << "-toolchain '#{config[:toolchain]}'" if config[:toolchain] << "-destination '#{config[:destination]}'" if config[:destination] << "-archivePath #{archive_path.shellescape}" unless config[:skip_archive] << "-resultBundlePath '#{result_bundle_path}'" if config[:result_bundle] << "-showBuildTimingSummary" if config[:build_timing_summary] if config[:use_system_scm] && !.include?("-scmProvider system") << "-scmProvider system" end << config[:xcargs] if config[:xcargs] << "OTHER_SWIFT_FLAGS=\"\\\$(value) -Xfrontend -debug-time-function-bodies\"" if config[:analyze_build_time] end |
.pipe ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 73 def pipe pipe = [] pipe << "| tee #{xcodebuild_log_path.shellescape}" formatter = Gym.config[:xcodebuild_formatter].chomp = if Gym.config[:disable_xcpretty] || formatter == '' UI.verbose("Not using an xcodebuild formatter") elsif !.empty? UI.important("Detected legacy xcpretty being used, so formatting with xcpretty") UI.important("Option(s) used: #{.join(', ')}") pipe += pipe_xcpretty elsif formatter == 'xcpretty' pipe += pipe_xcpretty elsif formatter == 'xcbeautify' pipe += pipe_xcbeautify else pipe << "| #{formatter}" end pipe << "> /dev/null" if Gym.config[:suppress_xcode_output] pipe end |
.pipe_xcbeautify ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 98 def pipe_xcbeautify pipe = ['| xcbeautify'] if FastlaneCore::Helper.colors_disabled? pipe << '--disable-colored-output' end return pipe end |
.pipe_xcpretty ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 121 def pipe_xcpretty pipe = [] formatter = Gym.config[:xcpretty_formatter] pipe << "| xcpretty" pipe << " --test" if Gym.config[:xcpretty_test_format] pipe << " --no-color" if Helper.colors_disabled? pipe << " --formatter " if formatter pipe << formatter if formatter pipe << "--utf" if Gym.config[:xcpretty_utf] report_output_junit = Gym.config[:xcpretty_report_junit] report_output_html = Gym.config[:xcpretty_report_html] report_output_json = Gym.config[:xcpretty_report_json] if report_output_junit pipe << " --report junit --output " pipe << report_output_junit.shellescape elsif report_output_html pipe << " --report html --output " pipe << report_output_html.shellescape elsif report_output_json pipe << " --report json-compilation-database --output " pipe << report_output_json.shellescape end pipe end |
.post_build ⇒ Object
148 149 150 151 152 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 148 def post_build commands = [] commands << %{grep -E '^[0-9.]+ms' #{xcodebuild_log_path.shellescape} | grep -vE '^0\.[0-9]' | sort -nr > culprits.txt} if Gym.config[:analyze_build_time] commands end |
.prefix ⇒ Object
19 20 21 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 19 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)
26 27 28 29 30 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 26 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
184 185 186 187 188 189 190 191 192 193 194 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 184 def result_bundle_path unless Gym.cache[:result_bundle_path] path = Gym.config[:result_bundle_path] path ||= File.join(Gym.config[:output_directory], Gym.config[:output_name] + ".xcresult") if File.directory?(path) FileUtils.remove_dir(path) end Gym.cache[:result_bundle_path] = path end return Gym.cache[:result_bundle_path] end |
.setting ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 63 def setting setting = [] if Gym.config[:skip_codesigning] setting << "CODE_SIGN_IDENTITY='' CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS='' CODE_SIGNING_ALLOWED=NO" elsif Gym.config[:codesigning_identity] setting << "CODE_SIGN_IDENTITY=#{Gym.config[:codesigning_identity].shellescape}" end setting end |
.xcodebuild_log_path ⇒ Object
154 155 156 157 158 159 160 |
# File 'gym/lib/gym/generators/build_command_generator.rb', line 154 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 |