cocoapods-binary-cache 0.1.7 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-binary-cache/cache/validation_result.rb +4 -0
  3. data/lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb +20 -25
  4. data/lib/cocoapods-binary-cache/dependencies_graph/graph_visualizer.rb +29 -38
  5. data/lib/cocoapods-binary-cache/diagnosis/diagnosis.rb +9 -1
  6. data/lib/cocoapods-binary-cache/diagnosis/integration.rb +3 -1
  7. data/lib/cocoapods-binary-cache/helper/podspec.rb +4 -2
  8. data/lib/cocoapods-binary-cache/hooks/post_install.rb +2 -12
  9. data/lib/cocoapods-binary-cache/hooks/pre_install.rb +19 -36
  10. data/lib/cocoapods-binary-cache/main.rb +0 -1
  11. data/lib/cocoapods-binary-cache/pod-binary/helper/build.rb +27 -29
  12. data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb +1 -1
  13. data/lib/cocoapods-binary-cache/pod-binary/helper/prebuild_sandbox.rb +14 -13
  14. data/lib/cocoapods-binary-cache/pod-binary/helper/target_checker.rb +7 -10
  15. data/lib/cocoapods-binary-cache/pod-binary/integration.rb +1 -2
  16. data/lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb +32 -15
  17. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/embed_framework_script.rb +1 -1
  18. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/resolve_dependencies.rb +0 -3
  19. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/sandbox_analyzer_state.rb +29 -0
  20. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb +25 -11
  21. data/lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb +30 -19
  22. data/lib/cocoapods-binary-cache/pod-binary/prebuild.rb +30 -108
  23. data/lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb +0 -2
  24. data/lib/cocoapods-binary-cache/pod-binary/prebuild_hook.rb +0 -1
  25. data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb +222 -146
  26. data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb +45 -32
  27. data/lib/cocoapods-binary-cache/prebuild_output/output.rb +6 -4
  28. data/lib/cocoapods-binary-cache/state_store.rb +16 -6
  29. data/lib/command/config.rb +42 -4
  30. data/lib/command/executor/base.rb +18 -1
  31. data/lib/command/executor/fetcher.rb +21 -3
  32. data/lib/command/executor/prebuilder.rb +9 -7
  33. data/lib/command/executor/pusher.rb +20 -4
  34. data/lib/command/executor/visualizer.rb +3 -2
  35. data/lib/command/prebuild.rb +6 -0
  36. metadata +17 -7
  37. data/lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb +0 -52
  38. data/lib/cocoapods-binary-cache/pod-binary/helper/passer.rb +0 -25
  39. data/lib/cocoapods-binary-cache/pod-binary/integration/remove_target_files.rb +0 -29
  40. data/lib/cocoapods-binary-cache/pod-binary/tool/tool.rb +0 -12
  41. data/lib/cocoapods-binary-cache/scheme_editor.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e068bdcb9e91a8e599e3ad1732837a1a7dbd49a4409e05b97b1cdc476bfb76a7
4
- data.tar.gz: 21d3e3fa0374a8818efa927bb822ce9386e43e18ec26a1ab5be7d8b481a688d6
3
+ metadata.gz: 116f1017bbeca303037ea4873ed6f6ec0b6ae8e9d976958f5f2b95109c50b252
4
+ data.tar.gz: 0dd220d2c51ddaa367cf7cca6b68f23f4c898fbbeddc53d025ab39ab67b2a9d6
5
5
  SHA512:
6
- metadata.gz: f5588698b1d818071b2bfb568bcbd44bc1e02084f7caf0b4b554a50277f2064209ec527339de4c8166ab74ff358b0a173f149b5db67f33a808c8d562f8d02625
7
- data.tar.gz: dd21d19ff94f2a8dcf3b4b1dd7372484993e0aba4705512fde75be14e66d72ddadc592fc88b9ea81ae3983f156e5fe251e4dbcfe8047f7904db1b0fd3cf0cbcf
6
+ metadata.gz: 1120f16b6bba0bb97db8d61d0799aebc3a395e94d6c1a0a273fe0c2d3ba9b3ffa3bd3c573ef36c7697457fc10d3546d1c92a130c8b8a4cd64b66004f3a798b50
7
+ data.tar.gz: 0efa97b49bdc34edf8ce4ebf8762b90114a2443bce9873fbb64482d0d6ab2a6e85d68c2d48904bd391d9d2d52566850abba4b7f7d6bf1f852c41e9fb3d389054
@@ -7,6 +7,10 @@ module PodPrebuild
7
7
  @hit = hit.to_set - missed_with_reasons.keys
8
8
  end
9
9
 
10
+ def all
11
+ (hit + missed).to_set
12
+ end
13
+
10
14
  def missed
11
15
  @missed_with_reasons.keys.to_set
12
16
  end
@@ -1,56 +1,50 @@
1
1
  # Copyright 2019 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
2
2
  # Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
3
3
 
4
- require 'rgl/adjacency'
5
- require 'rgl/dot'
6
- require_relative 'graph_visualizer'
4
+ require "rgl/adjacency"
5
+ require "rgl/dot"
6
+ require_relative "graph_visualizer"
7
7
 
8
- # Using RGL graph because GraphViz doesn't store adjacent of a node/vertex but we need to traverse a substree from any node
8
+ # Using RGL graph because GraphViz doesn't store adjacent of a node/vertex
9
+ # but we need to traverse a substree from any node
9
10
  # https://github.com/monora/rgl/blob/master/lib/rgl/adjacency.rb
10
11
 
11
12
  class DependenciesGraph
12
13
  def initialize(lockfile)
13
14
  @lockfile = lockfile
14
- @invert_edge = true # A normal edge is an edge (one direction) from library A to library B which is a dependency of A.
15
+ # A normal edge is an edge (one direction) from library A to library B which is a dependency of A.
16
+ @invert_edge = true
15
17
  end
16
18
 
17
19
  # Input : a list of library names.
18
20
  # Output: a set of library names which are clients (directly and indirectly) of those input libraries.
19
21
  def get_clients(libnames)
20
- result = Set.new()
22
+ result = Set.new
21
23
  libnames.each do |lib|
22
24
  if graph.has_vertex?(lib)
23
25
  result.merge(traverse_sub_tree(graph, lib))
24
26
  else
25
- puts "Warning: cannot find lib: #{lib}"
27
+ Pod::UI.puts "Warning: cannot find lib: #{lib}"
26
28
  end
27
29
  end
28
30
  result
29
31
  end
30
32
 
31
- def write_graphic_file(output_graphic_fmt, filename='graph', highlight_nodes=Set[])
32
- if !output_graphic_fmt
33
- puts 'Error: Need graphic format.'
34
- return
35
- end
36
- graph.write_to_graphic_file(output_graphic_fmt, dotfile=filename, options={}, highlight_nodes)
33
+ def write_graphic_file(options)
34
+ graph.write_to_graphic_file(options)
37
35
  end
38
36
 
39
37
  private
40
38
 
41
39
  def dependencies
42
- @dependencies ||= begin
43
- if @lockfile
44
- @lockfile.to_hash['PODS']
45
- else
46
- nil
47
- end
48
- end
40
+ @dependencies ||= (@lockfile && @lockfile.to_hash["PODS"])
49
41
  end
50
42
 
51
43
  # Convert array of dictionaries -> a dictionary with format {A: [A's dependencies]}
52
44
  def pod_to_dependencies
53
- dependencies.map { |d| d.is_a?(Hash) ? d : { d => [] } }.reduce({}) { |combined, individual| combined.merge!(individual) }
45
+ dependencies
46
+ .map { |d| d.is_a?(Hash) ? d : { d => [] } }
47
+ .reduce({}) { |combined, individual| combined.merge!(individual) }
54
48
  end
55
49
 
56
50
  def add_vertex(graph, pod)
@@ -65,14 +59,15 @@ class DependenciesGraph
65
59
 
66
60
  def graph
67
61
  @graph ||= begin
68
- graph = RGL::DirectedAdjacencyGraph.new()
69
-
62
+ graph = RGL::DirectedAdjacencyGraph.new
70
63
  pod_to_dependencies.each do |pod, dependencies|
71
64
  pod_node = add_vertex(graph, pod)
72
65
  next if pod_node.nil?
66
+
73
67
  dependencies.each do |dependency|
74
68
  dep_node = add_vertex(graph, dependency)
75
69
  next if dep_node.nil?
70
+
76
71
  if @invert_edge
77
72
  graph.add_edge(dep_node, pod_node)
78
73
  else
@@ -85,11 +80,11 @@ class DependenciesGraph
85
80
  end
86
81
 
87
82
  def traverse_sub_tree(graph, vertex)
88
- visited_nodes = Set.new()
83
+ visited_nodes = Set.new
89
84
  graph.each_adjacent(vertex) do |v|
90
85
  visited_nodes.add(v)
91
86
  visited_nodes.merge(traverse_sub_tree(graph, v))
92
87
  end
93
88
  visited_nodes
94
89
  end
95
- end
90
+ end
@@ -2,73 +2,64 @@
2
2
  # Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
3
3
  # https://github.com/monora/rgl/blob/0b526e16f9fb344abf387f4c5523d7917ce8f4b1/lib/rgl/dot.rb
4
4
 
5
- require 'rgl/rdot'
5
+ require "rgl/rdot"
6
6
 
7
7
  module RGL
8
8
  module Graph
9
- def to_dot_graph(params={}, highlight_nodes)
10
- params['name'] ||= self.class.name.gsub(/:/, '_')
11
- fontsize = params['fontsize'] ? params['fontsize'] : '12'
12
- graph = (directed? ? DOT::Digraph : DOT::Graph).new(params)
13
- edge_class = directed? ? DOT::DirectedEdge : DOT::Edge
14
- vertex_options = params['vertex'] || {}
15
- edge_options = params['edge'] || {}
9
+ def to_dot_graph(options)
10
+ highlight_nodes = options[:highlight_nodes] || Set.new
11
+ options["name"] ||= self.class.name.gsub(/:/, "_")
12
+ fontsize = options["fontsize"] || "12"
13
+ graph = (directed? ? DOT::Digraph : DOT::Graph).new(options)
14
+ edge_class = directed? ? DOT::DirectedEdge : DOT::Edge
15
+ vertex_options = options["vertex"] || {}
16
+ edge_options = options["edge"] || {}
16
17
 
17
18
  each_vertex do |v|
18
- default_vertex_options = {
19
- 'name' => vertex_id(v),
20
- 'fontsize' => fontsize,
21
- 'label' => vertex_label(v),
22
- 'style' => 'filled',
19
+ default_vertex_options = {
20
+ "name" => vertex_id(v),
21
+ "fontsize" => fontsize,
22
+ "label" => vertex_label(v),
23
+ "style" => "filled"
23
24
  }
24
- if highlight_nodes.include?(v)
25
- default_vertex_options = default_vertex_options.merge({
26
- 'color' => 'red',
27
- 'fillcolor' => 'red'
28
- })
29
- else
30
- default_vertex_options = default_vertex_options.merge({
31
- 'color' => 'blue',
32
- 'fillcolor' => 'blue'
33
- })
34
- end
35
-
25
+ default_vertex_options.merge!("color" => "red", "fillcolor" => "red") if highlight_nodes.include?(v)
36
26
  each_vertex_options = default_vertex_options.merge(vertex_options)
37
- vertex_options.each{|option, val| each_vertex_options[option] = val.call(v) if val.is_a?(Proc)}
27
+ vertex_options.each { |option, val| each_vertex_options[option] = val.call(v) if val.is_a?(Proc) }
38
28
  graph << DOT::Node.new(each_vertex_options)
39
29
  end
40
30
 
41
31
  each_edge do |u, v|
42
32
  default_edge_options = {
43
- 'from' => vertex_id(u),
44
- 'to' => vertex_id(v),
45
- 'fontsize' => fontsize
33
+ "from" => vertex_id(u),
34
+ "to" => vertex_id(v),
35
+ "fontsize" => fontsize
46
36
  }
47
37
  each_edge_options = default_edge_options.merge(edge_options)
48
- edge_options.each{|option, val| each_edge_options[option] = val.call(u, v) if val.is_a?(Proc)}
38
+ edge_options.each { |option, val| each_edge_options[option] = val.call(u, v) if val.is_a?(Proc) }
49
39
  graph << edge_class.new(each_edge_options)
50
40
  end
51
41
 
52
42
  graph
53
43
  end
54
44
 
55
- def write_to_graphic_file(fmt='png', dotfile="graph", options={}, highlight_nodes)
56
- src = dotfile + ".dot"
57
- dot = dotfile + "." + fmt
45
+ def write_to_graphic_file(options)
46
+ output_path = Pathname.new(options[:output_path])
47
+ fmt = output_path.extname.delete_prefix(".")
48
+ dotfile = output_path.sub_ext(".dot")
58
49
 
59
- File.open(src, 'w') do |f|
60
- f << self.to_dot_graph(params=options, highlight_nodes=highlight_nodes).to_s << "\n"
50
+ File.open(dotfile, "w") do |f|
51
+ f << to_dot_graph(options).to_s
61
52
  end
62
53
 
63
- unless system("dot -T#{fmt} #{src} -o #{dot}")
64
- message = <<-HEREDOC # Use <<- to indent End of String terminator
54
+ unless system("dot -T#{fmt} #{dotfile} -o #{output_path}")
55
+ message = <<~HEREDOC
65
56
  Error executing dot. Did you install GraphViz?
66
57
  Try installing it via Homebrew: `brew install graphviz`.
67
58
  Visit https://graphviz.org/download/ for more installation instructions.
68
59
  HEREDOC
69
60
  raise message
70
61
  end
71
- dot
62
+ output_path
72
63
  end
73
64
  end
74
65
  end
@@ -10,7 +10,15 @@ module PodPrebuild
10
10
  end
11
11
 
12
12
  def run
13
- @diagnosers.each(&:run)
13
+ diagnosis = @diagnosers.map(&:run)
14
+ errors = diagnosis.select { |d| d[0] == :error }.map { |d| d[1] }
15
+ warnings = diagnosis.select { |d| d[0] == :error }.map { |d| d[1] }
16
+
17
+ warnings.each { |d| Pod::UI.puts "⚠️ #{d[1]}" }
18
+ errors.each { |d| Pod::UI.puts "🚩 #{d[1]}" }
19
+ return if errors.empty? || !PodPrebuild.config.strict_diagnosis?
20
+
21
+ raise "There are #{errors.count} error(s) spotted after the diagnosis"
14
22
  end
15
23
  end
16
24
  end
@@ -15,7 +15,9 @@ module PodPrebuild
15
15
  PodPrebuild.config.prebuilt_path(path: "#{module_name}.framework")
16
16
  framework_path.exist?
17
17
  end
18
- Pod::UI.puts "🚩 Unintegrated frameworks: #{unintegrated}".yellow unless unintegrated.empty?
18
+ return [] if unintegrated.empty?
19
+
20
+ [[:error, "Unintegrated frameworks: #{unintegrated}"]]
19
21
  end
20
22
  end
21
23
  end
@@ -1,8 +1,10 @@
1
1
  module Pod
2
2
  class Specification
3
- # TODO: this detect objc lib as empty source, eg. Realm
4
3
  def empty_source_files?
5
- return subspecs.all?(&:empty_source_files?) unless subspecs.empty?
4
+ unless subspecs.empty?
5
+ # return early if there are some files in subpec(s) but process the spec itself
6
+ return false unless subspecs.all?(&:empty_source_files?)
7
+ end
6
8
 
7
9
  check = lambda do |patterns|
8
10
  patterns = [patterns] if patterns.is_a?(String)
@@ -5,29 +5,19 @@ module PodPrebuild
5
5
  end
6
6
 
7
7
  def run
8
- edit_scheme_for_code_coverage if PodPrebuild::Env.prebuild_stage?
9
8
  diagnose if PodPrebuild::Env.integration_stage?
10
9
  end
11
10
 
12
11
  private
13
12
 
14
13
  def diagnose
15
- Pod::UI.section("Diagnosing cocoapods-binary-cache") do
14
+ Pod::UI.title("Diagnosing cocoapods-binary-cache") do
16
15
  PodPrebuild::Diagnosis.new(
17
- cache_validation: PodPrebuild::StateStore.cache_validation,
16
+ cache_validation: PodPrebuild.state.cache_validation,
18
17
  standard_sandbox: @installer_context.sandbox,
19
18
  specs: @installer_context.umbrella_targets.map(&:specs).flatten
20
19
  ).run
21
20
  end
22
21
  end
23
-
24
- def edit_scheme_for_code_coverage
25
- return unless PodPrebuild.config.dev_pods_enabled? && @installer_context.sandbox.instance_of?(Pod::PrebuildSandbox)
26
-
27
- # Modify pods scheme to support code coverage
28
- # If we don't prebuild dev pod -> no need to care about this in Pod project
29
- # because we setup in the main project (ex. DriverCI scheme)
30
- SchemeEditor.edit_to_support_code_coverage(@installer_context.sandbox)
31
- end
32
22
  end
33
23
  end
@@ -2,32 +2,30 @@ module PodPrebuild
2
2
  class PreInstallHook
3
3
  include ObjectSpace
4
4
 
5
- attr_reader :installer_context, :podfile, :prebuild_sandbox, :cache_validation
5
+ attr_reader :installer_context, :podfile, :prebuild_sandbox, :standard_sandbox, :cache_validation
6
6
 
7
7
  def initialize(installer_context)
8
8
  @installer_context = installer_context
9
9
  @podfile = installer_context.podfile
10
10
  @pod_install_options = {}
11
11
  @prebuild_sandbox = nil
12
+ @standard_sandbox = installer_context.sandbox
12
13
  @cache_validation = nil
13
14
  end
14
15
 
15
16
  def run
16
17
  return if @installer_context.sandbox.is_a?(Pod::PrebuildSandbox)
17
18
 
18
- require_relative "../pod-binary/helper/feature_switches"
19
-
20
19
  log_section "🚀 Prebuild frameworks"
21
20
  ensure_valid_podfile
22
21
  save_installation_states
23
- Pod::UI.section("Prepare environment") { prepare_environment }
24
22
  create_prebuild_sandbox
25
- Pod::UI.section("Detect implicit dependencies") { detect_implicit_dependencies }
26
- Pod::UI.section("Validate prebuilt cache") { validate_cache }
23
+ Pod::UI.title("Detect implicit dependencies") { detect_implicit_dependencies }
24
+ Pod::UI.title("Validate prebuilt cache") { validate_cache }
27
25
  prebuild! if PodPrebuild.config.prebuild_job?
28
- Pod::UI.section("Reset environment") { reset_environment }
29
26
 
30
27
  PodPrebuild::Env.next_stage!
28
+ prepare_for_integration
31
29
  log_section "🤖 Resume pod installation"
32
30
  require_relative "../pod-binary/integration"
33
31
  end
@@ -36,7 +34,6 @@ module PodPrebuild
36
34
 
37
35
  def save_installation_states
38
36
  save_pod_install_options
39
- save_states_from_dsl
40
37
  end
41
38
 
42
39
  def save_pod_install_options
@@ -55,28 +52,7 @@ module PodPrebuild
55
52
  end
56
53
  end
57
54
 
58
- def prepare_environment
59
- Pod::Installer.force_disable_integration true # don't integrate targets
60
- Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile
61
- Pod::Installer.disable_install_complete_message true # disable install complete message
62
- end
63
-
64
- def reset_environment
65
- Pod::Installer.force_disable_integration false
66
- Pod::Config.force_disable_write_lockfile false
67
- Pod::Installer.disable_install_complete_message false
68
- Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
69
- end
70
-
71
- def save_states_from_dsl
72
- # Note: DSL is reloaded when creating an installer (Pod::Installer.new).
73
- # Any mutation to DSL is highly discouraged
74
- # --> Rather, perform mutation on PodPrebuild::StateStore instead
75
- PodPrebuild::StateStore.excluded_pods += PodPrebuild.config.excluded_pods
76
- end
77
-
78
55
  def create_prebuild_sandbox
79
- standard_sandbox = installer_context.sandbox
80
56
  @prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
81
57
  Pod::UI.message "Create prebuild sandbox at #{@prebuild_sandbox.root}"
82
58
  end
@@ -88,11 +64,9 @@ module PodPrebuild
88
64
  .group_by { |spec| spec.name.split("/")[0] }
89
65
  .select { |_, specs| specs.all?(&:empty_source_files?) }
90
66
  .keys
91
-
92
- PodPrebuild::StateStore.excluded_pods += pods_with_empty_source_files
67
+ PodPrebuild.config.update_detected_excluded_pods!(pods_with_empty_source_files)
68
+ PodPrebuild.config.update_detected_prebuilt_pod_names!(@original_installer.prebuilt_pod_names)
93
69
  Pod::UI.puts "Exclude pods with empty source files: #{pods_with_empty_source_files.to_a}"
94
-
95
- # TODO (thuyen): Detect dependencies of a prebuilt pod and treat them as prebuilt pods as well
96
70
  end
97
71
 
98
72
  def validate_cache
@@ -104,13 +78,13 @@ module PodPrebuild
104
78
  validate_prebuilt_settings: PodPrebuild.config.validate_prebuilt_settings,
105
79
  generated_framework_path: prebuild_sandbox.generate_framework_path,
106
80
  sandbox_root: prebuild_sandbox.root,
107
- ignored_pods: PodPrebuild::StateStore.excluded_pods,
108
- prebuilt_pod_names: @original_installer.prebuilt_pod_names
81
+ ignored_pods: PodPrebuild.config.excluded_pods,
82
+ prebuilt_pod_names: PodPrebuild.config.prebuilt_pod_names
109
83
  ).validate
110
84
  path_to_save_cache_validation = PodPrebuild.config.save_cache_validation_to
111
85
  @cache_validation.update_to(path_to_save_cache_validation) unless path_to_save_cache_validation.nil?
112
86
  cache_validation.print_summary
113
- PodPrebuild::StateStore.cache_validation = cache_validation
87
+ PodPrebuild.state.update(:cache_validation => cache_validation)
114
88
  end
115
89
 
116
90
  def prebuild!
@@ -129,6 +103,15 @@ module PodPrebuild
129
103
  end
130
104
  end
131
105
 
106
+ def prepare_for_integration
107
+ # Remove local podspec of external sources so that it downloads sources correctly.
108
+ # Otherwise, with incremental pod installation, CocoaPods downloads the sources
109
+ # based on the `s.source` declaration in the podspecs which are sometimes incorrect.
110
+ PodPrebuild.config.prebuilt_pod_names.each do |name|
111
+ @standard_sandbox.remove_local_podspec(name) if @standard_sandbox.checkout_sources.key?(name)
112
+ end
113
+ end
114
+
132
115
  def log_section(message)
133
116
  Pod::UI.puts "-----------------------------------------"
134
117
  Pod::UI.puts message
@@ -18,5 +18,4 @@ require_relative "pod-binary/prebuild_hook"
18
18
  require_relative "pod-binary/prebuild"
19
19
  require_relative "prebuild_output/metadata"
20
20
  require_relative "prebuild_output/output"
21
- require_relative "scheme_editor"
22
21
  require_relative "diagnosis/diagnosis"
@@ -1,39 +1,37 @@
1
1
  require_relative "../../pod-rome/xcodebuild_raw"
2
2
  require_relative "../../pod-rome/xcodebuild_command"
3
3
 
4
- module Pod
5
- class Prebuild
6
- def self.build(options)
7
- target = options[:target]
8
- return if target.nil?
4
+ module PodPrebuild
5
+ def self.build(options)
6
+ targets = options[:targets] || []
7
+ return if targets.empty?
9
8
 
10
- options[:sandbox] = Pod::Sandbox.new(Pathname(options[:sandbox])) unless options[:sandbox].is_a?(Pod::Sandbox)
11
- options[:build_dir] = build_dir(options[:sandbox].root)
9
+ options[:sandbox] = Pod::Sandbox.new(Pathname(options[:sandbox])) unless options[:sandbox].is_a?(Pod::Sandbox)
10
+ options[:build_dir] = build_dir(options[:sandbox].root)
12
11
 
13
- case target.platform.name
14
- when :ios, :tvos, :watchos
15
- XcodebuildCommand.new(options).run
16
- when :osx
17
- xcodebuild(
18
- sandbox: options[:sandbox],
19
- target: target.label,
20
- configuration: options[:configuration],
21
- sdk: "macosx",
22
- args: options[:args]
23
- )
24
- else
25
- raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'"
26
- end
27
- raise "The build directory was not found in the expected location" unless options[:build_dir].directory?
12
+ case targets[0].platform.name
13
+ when :ios, :tvos, :watchos
14
+ PodPrebuild::XcodebuildCommand.new(options).run
15
+ when :osx
16
+ xcodebuild(
17
+ sandbox: options[:sandbox],
18
+ targets: targets,
19
+ configuration: options[:configuration],
20
+ sdk: "macosx",
21
+ args: options[:args]
22
+ )
23
+ else
24
+ raise "Unsupported platform for '#{targets[0].name}': '#{targets[0].platform.name}'"
28
25
  end
26
+ raise "The build directory was not found in the expected location" unless options[:build_dir].directory?
27
+ end
29
28
 
30
- def self.remove_build_dir(sandbox_root)
31
- path = build_dir(sandbox_root)
32
- path.rmtree if path.exist?
33
- end
29
+ def self.remove_build_dir(sandbox_root)
30
+ path = build_dir(sandbox_root)
31
+ path.rmtree if path.exist?
32
+ end
34
33
 
35
- def self.build_dir(sandbox_root)
36
- sandbox_root.parent + "build"
37
- end
34
+ def self.build_dir(sandbox_root)
35
+ sandbox_root.parent + "build"
38
36
  end
39
37
  end