xcode-archive-cache 0.0.6 → 0.0.7

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: 49b93ea668f7de9a3723feec1518e934f0b46755afaf941866cf028ed0cc7f0b
4
- data.tar.gz: 16c0538e9665fe7f7c95c747d34f8ae48a3d8c2c5ed7adb1cc865dbbcbe0c43f
3
+ metadata.gz: 95a23e762c8efb7296e5d0faa4387c4ed39f4e373a821437f0440e7bdf759d8f
4
+ data.tar.gz: 933fae20075b13c5447217e38f917a35c8b42b9999076316ffdb264043e6b532
5
5
  SHA512:
6
- metadata.gz: 07424e1f9f50852d8d3a2fb873454d6e441860d33d220a6b37aeb11bb5dd6e90a872bbd37f8c749bb3b0e6a0693fe9aab8fb6c344f7294127861f7ddd9321e8f
7
- data.tar.gz: 670815a9f5e0bf971f5f0868e42bdeb0b2d0f12b745572688c0022914f57d6d0ba3016cddd54b5aca92203101df21c52b84d6c01de9c080bfa6eb3be1e9b0273
6
+ metadata.gz: 926f44d73815c5bdaf3e535bbb01e0c3d7aaa8a1c1e813baf054d85e1ab08904b2066975be0866c51f6e474a7ce3a2236c044c1a06486adc480b4eaf90d9ba2b
7
+ data.tar.gz: 81d379f00051d87a5c6440a9f5c6648fedad99d75c36f39f21f59443c786de4b614e2ecd37f7d2014643b99bac9e8a2dbcb0637decdb114772d59f9779e23e43
@@ -18,6 +18,9 @@ module XcodeArchiveCache
18
18
  File.exist?(path) ? path : nil
19
19
  end
20
20
 
21
+ # @param [XcodeArchiveCache::BuildGraph::Node] node
22
+ # @param [String] path
23
+ #
21
24
  def store(node, path)
22
25
  archive_path = path_inside_cache_dir(node)
23
26
  archive_directory = File.expand_path("..", archive_path)
@@ -26,6 +29,7 @@ module XcodeArchiveCache
26
29
  end
27
30
 
28
31
  archiver.archive(path, archive_path)
32
+ save_state(node, archive_path)
29
33
  end
30
34
 
31
35
  private
@@ -38,9 +42,34 @@ module XcodeArchiveCache
38
42
  #
39
43
  attr_reader :archiver
40
44
 
45
+ # @param [XcodeArchiveCache::BuildGraph::Node] node
46
+ #
47
+ # @return [String]
48
+ #
41
49
  def path_inside_cache_dir(node)
42
50
  File.join(cache_dir_path, node.name, node.sha)
43
51
  end
52
+
53
+ # @param [XcodeArchiveCache::BuildGraph::Node] node
54
+ # @param [String] archive_path
55
+ #
56
+ # Simply writes build settings and dependency SHAs to a file
57
+ # Useful for debugging and investigation purposes
58
+ #
59
+ def save_state(node, archive_path)
60
+ state_file_path = archive_path + ".state"
61
+
62
+ if File.exist?(state_file_path)
63
+ raise ArgumentError.new, "State file already exists: #{state_file_path}"
64
+ end
65
+
66
+ dependency_shas = node.dependencies
67
+ .map {|dependency| dependency.name + ": " + dependency.sha}
68
+ .join("\n")
69
+ state = node.build_settings.filtered_to_string + "\n\nDependencies:\n" + dependency_shas + "\n"
70
+
71
+ File.write(state_file_path, state)
72
+ end
44
73
  end
45
74
  end
46
75
  end
@@ -19,11 +19,10 @@ module XcodeArchiveCache
19
19
  def build_graph(dependent_target, dependency_target)
20
20
  native_target_finder.set_platform_name_filter(dependency_target.platform_name)
21
21
 
22
- build_settings = load_setting_for_target(dependent_target)
23
- graph = Graph.new(dependency_target.project, build_settings)
22
+ graph = Graph.new(dependency_target.project)
24
23
 
25
24
  add_to_graph(dependency_target, graph, true)
26
- load_settings(graph)
25
+ load_settings(graph, dependent_target)
27
26
  calculate_shas(graph)
28
27
 
29
28
  graph
@@ -122,32 +121,33 @@ module XcodeArchiveCache
122
121
  end
123
122
 
124
123
  # @param [XcodeArchiveCache::BuildGraph::Graph] graph
124
+ # @param [Xcodeproj::Project::Object::PBXNativeTarget] dependent_target
125
125
  #
126
- def load_settings(graph)
127
- counter = 1
128
-
129
- graph.nodes.each do |node|
130
- node_settings = load_setting_for_target(node.native_target)
131
- unless node_settings
132
- raise Informative, "No build settings loaded for #{node.name}"
133
- end
134
-
135
- node.build_settings = node_settings
136
-
137
- debug("settings loaded for #{node.name} (#{counter} / #{graph.nodes.length})")
138
- counter += 1
139
- end
126
+ def load_settings(graph, dependent_target)
127
+ project_paths = graph.nodes
128
+ .map {|node| node.native_target}
129
+ .push(dependent_target)
130
+ .map {|target| target.project.path}
131
+ .sort
132
+ .uniq
133
+ info("loading settings for #{project_paths.length} projects")
134
+ build_settings_loader.load_settings(project_paths)
135
+
136
+ graph.dependent_build_settings = get_settings(dependent_target)
137
+ graph.nodes.each {|node| node.build_settings = get_settings(node.native_target)}
140
138
  end
141
139
 
142
140
 
143
141
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
144
142
  #
145
- def load_setting_for_target(target)
146
- info("loading settings for #{target.display_name}")
143
+ def get_settings(target)
144
+ info("getting settings for #{target.display_name}")
145
+ build_settings = build_settings_loader.get_settings(target.project.path, target.display_name)
146
+ unless build_settings
147
+ raise Informative, "No build settings loaded for #{target.display_name}"
148
+ end
147
149
 
148
- project_path = target.project.path
149
- build_settings_loader.load_settings(project_path)
150
- build_settings_loader.get_settings(project_path, target.display_name)
150
+ build_settings
151
151
  end
152
152
  end
153
153
  end
@@ -11,24 +11,30 @@ module XcodeArchiveCache
11
11
 
12
12
  # @return [XcodeArchiveCache::BuildSettings::Container] root target build settings
13
13
  #
14
- attr_reader :dependent_build_settings
14
+ attr_accessor :dependent_build_settings
15
15
 
16
16
  # @param [Xcodeproj::Project] project
17
- # @param [XcodeArchiveCache::BuildSettings::Container] dependent_build_settings
18
17
  #
19
- def initialize(project, dependent_build_settings)
18
+ def initialize(project)
20
19
  @nodes = []
21
20
  @project = project
22
- @dependent_build_settings = dependent_build_settings
23
21
  end
24
22
 
25
23
  # @param [String] name
26
24
  # Native target display name
27
25
  #
26
+ # @return [XcodeArchiveCache::BuildGraph::Node]
27
+ #
28
28
  def node_by_name(name)
29
29
  nodes.select {|node| node.name == name}.first
30
30
  end
31
31
 
32
+ # @return [XcodeArchiveCache::BuildGraph::Node]
33
+ #
34
+ def root_node
35
+ nodes.select {|node| node.is_root}.first
36
+ end
37
+
32
38
  def to_s
33
39
  nodes.map(&:to_s).join("\n")
34
40
  end
@@ -14,7 +14,7 @@ module XcodeArchiveCache
14
14
  end
15
15
 
16
16
  auxiliary_file = Tempfile.new(node.name)
17
- build_settings = settings_hash_to_string(node.build_settings.filtered)
17
+ build_settings = node.build_settings.filtered_to_string
18
18
  save_auxiliary_data(build_settings, dependency_shas, auxiliary_file)
19
19
 
20
20
  input_paths = list_input_paths(node)
@@ -66,14 +66,6 @@ module XcodeArchiveCache
66
66
  end
67
67
  end
68
68
 
69
- # @param [Hash{String => String}] hash
70
- #
71
- # @return [String]
72
- #
73
- def settings_hash_to_string(hash)
74
- hash.map {|name, value| "#{name} = #{value}"}.join("\n")
75
- end
76
-
77
69
  # @param [Tempfile] tempfile
78
70
  # @param [String] build_settings
79
71
  # @param [Array<String>] dependency_shas
@@ -29,6 +29,12 @@ module XcodeArchiveCache
29
29
  def ==(other)
30
30
  other && other.all == all && other.filtered == filtered
31
31
  end
32
+
33
+ # @return [String]
34
+ #
35
+ def filtered_to_string
36
+ filtered.map {|name, value| "#{name} = #{value}"}.join("\n")
37
+ end
32
38
  end
33
39
 
34
40
  class Loader
@@ -41,21 +47,29 @@ module XcodeArchiveCache
41
47
  @settings = Hash.new
42
48
  end
43
49
 
44
- # @param [String] project_path
50
+ # @param [Array<String>] project_paths
45
51
  #
46
- # @return [Hash{String => String}]
47
- # Target build settings keyed by target name
48
- #
49
- def load_settings(project_path)
50
- return if settings[project_path]
51
-
52
- all_targets_settings = executor.load_build_settings(project_path)
53
- settings[project_path] = extractor.extract_per_target(all_targets_settings)
52
+ def load_settings(project_paths)
53
+ paths_without_settings = project_paths.select {|path| settings[path] == nil}
54
+
55
+ threads = paths_without_settings.map do |path|
56
+ Thread.new(path) do |project_path|
57
+ Thread.current.abort_on_exception = true
58
+ [project_path, executor.load_build_settings(project_path)]
59
+ end
60
+ end
61
+
62
+ threads.each do |thread|
63
+ project_path, all_targets_settings = thread.value
64
+ settings[project_path] = extractor.extract_per_target(all_targets_settings)
65
+ end
54
66
  end
55
67
 
56
68
  # @param [String] project_path
57
69
  # @param [String] target_name
58
70
  #
71
+ # @return [Hash{String => String}] build settings for target or nil
72
+ #
59
73
  def get_settings(project_path, target_name)
60
74
  return nil unless settings[project_path]
61
75
 
data/lib/config/dsl.rb CHANGED
@@ -64,6 +64,10 @@ module XcodeArchiveCache
64
64
  def cache(name)
65
65
  current_target.dependencies.push(name)
66
66
  end
67
+
68
+ def cache_itself
69
+ current_target.dependencies.push(current_target.name)
70
+ end
67
71
  end
68
72
  end
69
73
  end
@@ -12,6 +12,8 @@ module XcodeArchiveCache
12
12
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
13
13
  #
14
14
  def embed(framework_file_paths, target)
15
+ return unless target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]
16
+
15
17
  dynamic_framework_file_paths = framework_file_paths.select do |path|
16
18
  binary_name = File.basename(path, ".framework")
17
19
  binary_path = File.join(path, binary_name)
@@ -29,6 +29,11 @@ module XcodeArchiveCache
29
29
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
30
30
  #
31
31
  def perform_outgoing_injection(graph, target)
32
+ root_node = graph.root_node
33
+ if root_node.native_target.project == target.project && root_node.native_target.uuid == target.uuid
34
+ return
35
+ end
36
+
32
37
  graph.nodes.each do |node|
33
38
  headers_mover.prepare_headers_for_injection(node)
34
39
  add_as_prebuilt_dependency(node, target, node.is_root)
@@ -61,7 +66,7 @@ module XcodeArchiveCache
61
66
  attr_reader :configuration_name
62
67
 
63
68
  # @return [Storage]
64
- #
69
+ #
65
70
  attr_reader :storage
66
71
 
67
72
  # @return [HeadersMover]
@@ -101,7 +106,7 @@ module XcodeArchiveCache
101
106
 
102
107
  nodes
103
108
  .select {|node| node.rebuild}
104
- .each { |node| add_header_paths_to_target(node.native_target, header_storage_paths) }
109
+ .each {|node| add_header_paths_to_target(node.native_target, header_storage_paths)}
105
110
  end
106
111
 
107
112
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
data/lib/runner/runner.rb CHANGED
@@ -29,7 +29,7 @@ module XcodeArchiveCache
29
29
  file_path = File.absolute_path(config.file_path)
30
30
 
31
31
  if config.is_a?(XcodeArchiveCache::Config::Project)
32
- return [Xcodeproj::Project.new(file_path)]
32
+ return [Xcodeproj::Project.open(file_path)]
33
33
  elsif config.is_a?(XcodeArchiveCache::Config::Workspace)
34
34
  workspace = Xcodeproj::Workspace.new_from_xcworkspace(file_path)
35
35
  workspace_dir = File.expand_path("..", file_path)
@@ -37,7 +37,7 @@ module XcodeArchiveCache
37
37
  return workspace.file_references.map {|file_reference| Xcodeproj::Project.open(file_reference.absolute_path(workspace_dir))}
38
38
  end
39
39
 
40
- raise Informative, "Configuration misses no entry point -- must have either a project or a workspace"
40
+ raise Informative, "Configuration misses entry point -- must have either a project or a workspace"
41
41
  end
42
42
 
43
43
  def run
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Dyakonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-11 00:00:00.000000000 Z
11
+ date: 2019-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -107,8 +107,9 @@ files:
107
107
  - lib/shell/executor.rb
108
108
  - lib/xcode-archive-cache.rb
109
109
  - lib/xcodebuild/executor.rb
110
- homepage:
111
- licenses: []
110
+ homepage: https://github.com/sweatco/xcode-archive-cache
111
+ licenses:
112
+ - MIT
112
113
  metadata: {}
113
114
  post_install_message:
114
115
  rdoc_options: []
@@ -118,16 +119,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
119
  requirements:
119
120
  - - ">="
120
121
  - !ruby/object:Gem::Version
121
- version: '0'
122
+ version: 2.0.0
122
123
  required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  requirements:
124
125
  - - ">="
125
126
  - !ruby/object:Gem::Version
126
127
  version: '0'
127
128
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.7.7
129
+ rubygems_version: 3.0.4
130
130
  signing_key:
131
131
  specification_version: 4
132
- summary: Xcode archive cache
132
+ summary: Native targets cache for Xcode archive builds.
133
133
  test_files: []