xcode-archive-cache 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c3de4b956fe76ce673329ecf9977a911d3c6bb3055c00e59c3e6903cb16e6b2
4
- data.tar.gz: 92253d7316a2a716b71a053f182483e7af54aeb1662111175f3e071909d79998
3
+ metadata.gz: 1c30a0e4a847e52d32192c31fe3cdf3c7b0ff61cabc81e413e4fe416edbda1a8
4
+ data.tar.gz: 31925913e15ec55cf8b94dfd9940604cbc34cc98c0f1b76317cf0d05d8c202a7
5
5
  SHA512:
6
- metadata.gz: 88b0a7e44eecbdc426755761dd5df10fb0e1cff4a00c44f915df1f65515685ce3f2527d8d9b1173ea439bff032d49f4875f32a859291a702f829d378103c8234
7
- data.tar.gz: c63650b58e921da5e38bb8648d0e6e3cfeddb55165e72f8984511c769a139b6ab3108350c0e684ed27ed9dbf9e02ef46135cc315a182ebc00586bb33c3fdae1f
6
+ metadata.gz: 5a8fcfa4fd8a2da9cfadf202aaa3be88f4c54ddf3979aa4ac1c500e61b0a9d41f07bf43420fb0ec6332fd491b634a4d4f28ff1aebeaf273c79ded3a950a0d763
7
+ data.tar.gz: c6f6f0351aa9b02165637e93cd65b4938f2888bdb0cb7c599f8de0592a0ae4d85092508b73fb4a2b117c226287a64ccface769afd6e4c81626cd6b8d8e253297
@@ -6,9 +6,10 @@ module XcodeArchiveCache
6
6
 
7
7
  # @param [String] derived_data_path
8
8
  #
9
- def initialize(xcodebuild_executor, derived_data_path)
9
+ def initialize(xcodebuild_executor, derived_data_path, workspace_path=nil)
10
10
  @xcodebuild_executor = xcodebuild_executor
11
11
  @derived_data_path = derived_data_path
12
+ @workspace_path = workspace_path
12
13
  end
13
14
 
14
15
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
@@ -23,7 +24,12 @@ module XcodeArchiveCache
23
24
  .join(", ")
24
25
  info("going to rebuild:\n#{rebuild_list}")
25
26
 
26
- build_result = xcodebuild_executor.build(target.project.path, target.name, derived_data_path)
27
+ if workspace_path
28
+ build_result = xcodebuild_executor.build_from_workspace(workspace_path, target.name, derived_data_path)
29
+ else
30
+ build_result = xcodebuild_executor.build_from_project(target.project.path, target.name, derived_data_path)
31
+ end
32
+
27
33
  unless build_result
28
34
  raise StandardError.new, "Failed to perform rebuild"
29
35
  end
@@ -47,6 +53,10 @@ module XcodeArchiveCache
47
53
  # @return [XcodeArchiveCache::Xcodebuild::Executor]
48
54
  #
49
55
  attr_reader :xcodebuild_executor
56
+
57
+ # @return [String]
58
+ #
59
+ attr_reader :workspace_path
50
60
  end
51
61
  end
52
62
  end
@@ -122,10 +122,12 @@ module XcodeArchiveCache
122
122
  # @return [String]
123
123
  #
124
124
  def get_main_product_glob(built_node)
125
- product_name = built_node.native_target.product_reference.name ?
126
- built_node.native_target.product_reference.name :
127
- built_node.native_target.product_reference.path
128
- get_product_glob(File.basename(product_name))
125
+ product_names = [File.basename(built_node.native_target.product_reference.path)]
126
+ if built_node.native_target.product_reference.name
127
+ product_names.push(File.basename(built_node.native_target.product_reference.name))
128
+ end
129
+
130
+ get_product_glob(product_names.select { |name| File.extname(name).length > 0 })
129
131
  end
130
132
 
131
133
  # @param [XcodeArchiveCache::BuildGraph::Node] built_node
@@ -133,7 +135,7 @@ module XcodeArchiveCache
133
135
  # @return [String]
134
136
  #
135
137
  def get_swift_objc_interface_header_glob(built_node)
136
- get_product_glob(File.basename(built_node.swift_objc_interface_header_file))
138
+ get_product_glob([File.basename(built_node.swift_objc_interface_header_file)])
137
139
  end
138
140
 
139
141
  # @param [XcodeArchiveCache::BuildGraph::Node] built_node
@@ -142,7 +144,7 @@ module XcodeArchiveCache
142
144
  #
143
145
  def get_swiftmodule_glob(built_node)
144
146
  if built_node.module_name
145
- get_product_glob(built_node.module_name + ".swiftmodule")
147
+ get_product_glob([built_node.module_name + ".swiftmodule"])
146
148
  end
147
149
  end
148
150
 
@@ -153,24 +155,24 @@ module XcodeArchiveCache
153
155
  def get_modulemap_glob(built_node)
154
156
  resulting_modulemap_file_name = built_node.resulting_modulemap_file_name
155
157
  if resulting_modulemap_file_name
156
- get_product_glob(resulting_modulemap_file_name)
158
+ get_product_glob([resulting_modulemap_file_name])
157
159
  else
158
160
  modulemap_file_path = built_node.original_modulemap_file_path
159
161
  if modulemap_file_path && File.exist?(modulemap_file_path)
160
162
  modulemap_file_name = File.basename(modulemap_file_path)
161
- get_product_glob(modulemap_file_name)
163
+ get_product_glob([modulemap_file_name])
162
164
  end
163
165
  end
164
166
  end
165
167
 
166
- # @param [String] file_name
168
+ # @param [Array<String>] file_names
167
169
  #
168
170
  # @return [String]
169
171
  #
170
- def get_product_glob(file_name)
172
+ def get_product_glob(file_names)
171
173
  File.join(derived_data_path,
172
174
  "**",
173
- file_name)
175
+ "{#{file_names.join(",")}}")
174
176
  end
175
177
 
176
178
  # @param [String] framework_path
@@ -123,7 +123,7 @@ module XcodeArchiveCache
123
123
  #
124
124
  def find_for_product_name(product_name)
125
125
  canonical = all_targets
126
- .select {|native_target| native_target.name == product_name || native_target.product_reference.display_name == product_name}
126
+ .select {|native_target| native_target.name == product_name || native_target.product_reference.display_name == product_name || native_target.product_reference.path == product_name }
127
127
  .first
128
128
 
129
129
  parsed = @product_name_to_target[product_name]
@@ -93,7 +93,6 @@ module XcodeArchiveCache
93
93
  CLONE_HEADERS
94
94
  COMBINE_HIDPI_IMAGES
95
95
  COMPRESS_PNG_FILES
96
- CONFIGURATION
97
96
  COPYING_PRESERVES_HFS_DATA
98
97
  COPY_HEADERS_RUN_UNIFDEF
99
98
  COPY_PHASE_STRIP
@@ -13,7 +13,7 @@ module XcodeArchiveCache
13
13
  @headers_mover = HeadersMover.new(storage)
14
14
  @dependency_remover = DependencyRemover.new
15
15
  @build_flags_changer = BuildFlagsChanger.new
16
- @pods_fixer = PodsScriptFixer.new
16
+ @pods_fixer = PodsScriptFixer.new(storage)
17
17
  @modulemap_fixer = XcodeArchiveCache::Modulemap::HeaderPathFixer.new(storage)
18
18
  @framework_embedder = FrameworkEmbedder.new
19
19
  end
@@ -55,8 +55,8 @@ module XcodeArchiveCache
55
55
  # are covered by "Embed Pods Frameworks" script
56
56
  #
57
57
  if graph.node_by_name(get_pods_target_name(target))
58
- pods_fixer.fix_embed_frameworks_script(target, graph, storage.container_dir_path)
59
- pods_fixer.fix_copy_resources_script(target, graph, storage.container_dir_path)
58
+ pods_fixer.fix_embed_frameworks_script(target, graph)
59
+ pods_fixer.fix_copy_resources_script(target, graph)
60
60
  else
61
61
  framework_nodes = graph.nodes.select { |node| node.has_framework_product? }
62
62
  framework_file_paths = framework_nodes.map { |node| File.join(storage.get_storage_path(node), node.product_file_name) }
@@ -4,36 +4,41 @@ module XcodeArchiveCache
4
4
 
5
5
  include XcodeArchiveCache::Logs
6
6
 
7
- def initialize
7
+ # @param [XcodeArchiveCache::Injection::Storage] storage
8
+ #
9
+ def initialize(storage)
10
+ @storage = storage
8
11
  @build_settings_interpolator = XcodeArchiveCache::BuildSettings::StringInterpolator.new
9
12
  end
10
13
 
11
14
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
12
15
  # @param [XcodeArchiveCache::BuildGraph::Graph] graph
13
- # @param [String] products_dir
14
16
  #
15
- def fix_embed_frameworks_script(target, graph, products_dir)
17
+ def fix_embed_frameworks_script(target, graph)
16
18
  build_settings = graph.dependent_build_settings
17
19
  file_path = find_embed_frameworks_script(target, build_settings)
18
20
  return unless file_path
19
21
 
20
- fix_script(file_path, graph, products_dir)
22
+ fix_script(file_path, graph)
21
23
  end
22
24
 
23
25
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
24
26
  # @param [XcodeArchiveCache::BuildGraph::Graph] graph
25
- # @param [String] products_dir
26
27
  #
27
- def fix_copy_resources_script(target, graph, products_dir)
28
+ def fix_copy_resources_script(target, graph)
28
29
  build_settings = graph.dependent_build_settings
29
30
  file_path = find_copy_resources_script(target, build_settings)
30
31
  return unless file_path
31
32
 
32
- fix_script(file_path, graph, products_dir)
33
+ fix_script(file_path, graph)
33
34
  end
34
35
 
35
36
  private
36
37
 
38
+ # @return [XcodeArchiveCache::Injection::Storage]
39
+ #
40
+ attr_reader :storage
41
+
37
42
  # @return [XcodeArchiveCache::BuildSettings::StringInterpolator]
38
43
  #
39
44
  attr_reader :build_settings_interpolator
@@ -57,16 +62,14 @@ module XcodeArchiveCache
57
62
  end
58
63
 
59
64
  # @param [String] file_path
60
- # @param [XcodeArchiveCache::BuildGraph::Node] graph
61
- # @param [String] products_dir
65
+ # @param [XcodeArchiveCache::BuildGraph::Graph] graph
62
66
  #
63
- def fix_script(file_path, graph, products_dir)
67
+ def fix_script(file_path, graph)
64
68
  info("fixing #{file_path}")
65
69
  script = File.read(file_path)
66
70
  graph.nodes.each do |node|
67
- relative_product_path = "#{node.native_target.display_name}/#{node.product_file_name}"
68
- absolute_product_path = File.join(products_dir, relative_product_path)
69
- script = script.gsub(Regexp.new("\"[^\"]+\/#{node.product_file_name}\""), "\"#{absolute_product_path}\"")
71
+ product_path = File.join(storage.get_storage_path(node), node.product_file_name)
72
+ script = script.gsub(Regexp.new("\"[^\"]+\/#{node.product_file_name}\""), "\"#{product_path}\"")
70
73
  end
71
74
 
72
75
  File.open(file_path, "w") {|file| file.puts(script)}
@@ -18,7 +18,7 @@ module XcodeArchiveCache
18
18
  end
19
19
 
20
20
  # @param [Xcodeproj::Project::Object::PBXAbstractTarget] target
21
- # @param [XcodeArchiveCache::BuildSettings::Container] build_settings
21
+ # @param [XcodeArchiveCache::BuildSettings::Loader] build_settings_loader
22
22
  #
23
23
  def fix(target, build_settings_loader)
24
24
  checked_targets.push(target.equatable_identifier)
@@ -77,7 +77,7 @@ module XcodeArchiveCache
77
77
  def prepare_storage(node)
78
78
  path = get_storage_path(node)
79
79
  if File.exist?(path)
80
- raise StandardError.new, "Injection storage path is already busy"
80
+ raise StandardError.new, "Injection storage path is already busy: #{path}"
81
81
  end
82
82
 
83
83
  FileUtils.mkdir_p(path)
@@ -89,7 +89,12 @@ module XcodeArchiveCache
89
89
  # @return [String]
90
90
  #
91
91
  def get_storage_path(node)
92
- File.join(container_dir_path, node.name)
92
+ path = File.join(container_dir_path, node.name)
93
+ if node.native_target
94
+ path += "-#{node.native_target.uuid}"
95
+ end
96
+
97
+ path
93
98
  end
94
99
 
95
100
  # @param [XcodeArchiveCache::BuildGraph::Node] node
data/lib/runner/runner.rb CHANGED
@@ -133,7 +133,8 @@ module XcodeArchiveCache
133
133
  # @param [XcodeArchiveCache::BuildGraph::Graph] graph
134
134
  #
135
135
  def rebuild_if_needed(xcodebuild_executor, root_target, graph)
136
- rebuild_performer = XcodeArchiveCache::Build::Performer.new(xcodebuild_executor, config.settings.derived_data_path)
136
+ workspace_path = config.is_a?(XcodeArchiveCache::Config::Workspace) ? File.absolute_path(config.file_path) : nil
137
+ rebuild_performer = XcodeArchiveCache::Build::Performer.new(xcodebuild_executor, config.settings.derived_data_path, workspace_path)
137
138
  return unless rebuild_performer.should_rebuild?(graph)
138
139
 
139
140
  @injector.perform_internal_injection(graph)
@@ -43,8 +43,30 @@ module XcodeArchiveCache
43
43
  # @param [String] scheme
44
44
  # @param [String] derived_data_path
45
45
  #
46
- def build(project_path, scheme, derived_data_path)
47
- flags = [project_flag(project_path),
46
+ def build_from_project(project_path, scheme, derived_data_path)
47
+ build(project_flag(project_path), scheme, derived_data_path)
48
+ end
49
+
50
+ # @param [String] workspace_flag
51
+ # @param [String] scheme
52
+ # @param [String] derived_data_path
53
+ #
54
+ def build_from_workspace(workspace_path, scheme, derived_data_path)
55
+ build(workspace_flag(workspace_path), scheme, derived_data_path)
56
+ end
57
+
58
+ def set_up_for_simulator?
59
+ destination_flag.include?("Simulator")
60
+ end
61
+
62
+ private
63
+
64
+ # @param [String] path_flag
65
+ # @param [String] scheme
66
+ # @param [String] derived_data_path
67
+ #
68
+ def build(path_flag, scheme, derived_data_path)
69
+ flags = [path_flag,
48
70
  configuration_flag,
49
71
  destination_flag,
50
72
  scheme_flag(scheme),
@@ -55,12 +77,6 @@ module XcodeArchiveCache
55
77
  shell_executor.execute(command, true)
56
78
  end
57
79
 
58
- def set_up_for_simulator?
59
- destination_flag.include?("Simulator")
60
- end
61
-
62
- private
63
-
64
80
  # @return [String]
65
81
  #
66
82
  attr_reader :configuration
@@ -93,6 +109,14 @@ module XcodeArchiveCache
93
109
  "xcodebuild #{flags.join(" ")}"
94
110
  end
95
111
 
112
+ # @param [String] workspace_path
113
+ #
114
+ # @return [String]
115
+ #
116
+ def workspace_flag(workspace_path)
117
+ "-workspace '#{workspace_path}'"
118
+ end
119
+
96
120
  # @param [String] project_path
97
121
  #
98
122
  # @return [String]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcode-archive-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Dyakonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-21 00:00:00.000000000 Z
11
+ date: 2022-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.0.6
147
+ rubygems_version: 3.3.22
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Native targets cache for Xcode archive builds.