xcode-archive-cache 0.0.8.pre.2 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/artifact_cache/archiver.rb +2 -1
- data/lib/artifact_cache/local_storage.rb +2 -1
- data/lib/build/performer.rb +1 -1
- data/lib/build/product_extractor.rb +88 -5
- data/lib/build_graph/builder.rb +5 -1
- data/lib/build_graph/native_target_finder.rb +46 -11
- data/lib/build_graph/node.rb +50 -2
- data/lib/build_graph/rebuild_evaluator.rb +30 -4
- data/lib/build_graph/sha_calculator.rb +22 -1
- data/lib/build_settings/extractor.rb +21 -1
- data/lib/build_settings/filter.rb +7 -3
- data/lib/build_settings/loader.rb +8 -1
- data/lib/build_settings/parser.rb +1 -1
- data/lib/injection/build_flags_changer.rb +173 -4
- data/lib/injection/dependency_remover.rb +22 -1
- data/lib/injection/headers_mover.rb +27 -3
- data/lib/injection/injector.rb +69 -20
- data/lib/injection/storage.rb +47 -6
- data/lib/modulemap/file_handler.rb +20 -0
- data/lib/modulemap/header_path_extractor.rb +67 -0
- data/lib/modulemap/header_path_fixer.rb +65 -0
- data/lib/runner/runner.rb +31 -24
- data/lib/shell/executor.rb +2 -2
- data/lib/xcode-archive-cache.rb +4 -0
- data/lib/xcodebuild/executor.rb +4 -0
- metadata +32 -17
data/lib/injection/storage.rb
CHANGED
@@ -23,18 +23,42 @@ module XcodeArchiveCache
|
|
23
23
|
# @param [String] path
|
24
24
|
# @param [Array<String>] file_paths
|
25
25
|
#
|
26
|
-
def store_headers(node, path, file_paths)
|
27
|
-
storage_path = get_full_header_storage_path(path)
|
26
|
+
def store_headers(node, path, file_paths, save_path = true)
|
27
|
+
storage_path = Pathname.new(path).absolute? ? path : get_full_header_storage_path(path)
|
28
28
|
|
29
29
|
unless File.exist?(storage_path)
|
30
30
|
FileUtils.mkdir_p(storage_path)
|
31
31
|
end
|
32
32
|
|
33
33
|
file_paths.each do |file_path|
|
34
|
-
FileUtils.cp(file_path,
|
34
|
+
FileUtils.cp(file_path, get_stored_file_path(storage_path, file_path))
|
35
35
|
end
|
36
36
|
|
37
|
-
save_header_storage_path(storage_path, node)
|
37
|
+
save_header_storage_path(storage_path, node) if save_path
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
41
|
+
# @param [Array<String>] file_paths
|
42
|
+
#
|
43
|
+
def store_default_headers(node, file_paths)
|
44
|
+
store_headers(node, get_default_headers_storage_path(node), file_paths)
|
45
|
+
end
|
46
|
+
|
47
|
+
def store_modulemap_headers(node, file_paths)
|
48
|
+
store_headers(node, get_storage_path(node), file_paths, false)
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
52
|
+
#
|
53
|
+
# @return [String]
|
54
|
+
#
|
55
|
+
def get_modulemap_path(node)
|
56
|
+
modulemap_file_name = node.resulting_modulemap_file_name
|
57
|
+
return if modulemap_file_name == nil
|
58
|
+
|
59
|
+
storage_path = get_storage_path(node)
|
60
|
+
stored_modulemap_file_path = get_stored_file_path(storage_path, modulemap_file_name)
|
61
|
+
File.exist?(stored_modulemap_file_path) ? stored_modulemap_file_path : nil
|
38
62
|
end
|
39
63
|
|
40
64
|
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
@@ -70,7 +94,7 @@ module XcodeArchiveCache
|
|
70
94
|
|
71
95
|
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
72
96
|
#
|
73
|
-
# @return [
|
97
|
+
# @return [String]
|
74
98
|
#
|
75
99
|
def get_headers_storage_paths(node)
|
76
100
|
headers_storage_dir_paths[node.name]
|
@@ -78,11 +102,19 @@ module XcodeArchiveCache
|
|
78
102
|
|
79
103
|
def get_all_headers_storage_paths
|
80
104
|
headers_storage_dir_paths
|
81
|
-
.map {|_, path| path}
|
105
|
+
.map { |_, path| path }
|
82
106
|
.flatten
|
83
107
|
.uniq
|
84
108
|
end
|
85
109
|
|
110
|
+
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
111
|
+
#
|
112
|
+
# @return [String]
|
113
|
+
#
|
114
|
+
def get_default_headers_storage_path(node)
|
115
|
+
"include/#{node.name}"
|
116
|
+
end
|
117
|
+
|
86
118
|
private
|
87
119
|
|
88
120
|
def prepare_container_dir
|
@@ -99,6 +131,15 @@ module XcodeArchiveCache
|
|
99
131
|
File.absolute_path(path, container_dir_path)
|
100
132
|
end
|
101
133
|
|
134
|
+
# @param [String] storage_path
|
135
|
+
# @param [String] file_path
|
136
|
+
#
|
137
|
+
# @return [String]
|
138
|
+
#
|
139
|
+
def get_stored_file_path(storage_path, file_path)
|
140
|
+
File.join(storage_path, File.basename(file_path))
|
141
|
+
end
|
142
|
+
|
102
143
|
# @param [String] path
|
103
144
|
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
104
145
|
#
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module XcodeArchiveCache
|
2
|
+
module Modulemap
|
3
|
+
class FileHandler
|
4
|
+
# @param [String] modulemap_path
|
5
|
+
#
|
6
|
+
# @return [Array<String>]
|
7
|
+
#
|
8
|
+
def read_modulemap_lines(modulemap_path)
|
9
|
+
File.read(modulemap_path).split("\n")
|
10
|
+
end
|
11
|
+
|
12
|
+
# @param [Array<String>] lines
|
13
|
+
# @param [String] modulemap_path
|
14
|
+
#
|
15
|
+
def write_modulemap_lines(lines, modulemap_path)
|
16
|
+
File.open(modulemap_path, "w") { |file| file.puts lines.join("\n") }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module XcodeArchiveCache
|
2
|
+
module Modulemap
|
3
|
+
class HeaderPathDeclaration
|
4
|
+
# @return [String]
|
5
|
+
#
|
6
|
+
attr_reader :type
|
7
|
+
|
8
|
+
# @return [String]
|
9
|
+
#
|
10
|
+
attr_reader :path
|
11
|
+
|
12
|
+
# @param [String] type
|
13
|
+
# @param [String] path
|
14
|
+
#
|
15
|
+
def initialize(type, path)
|
16
|
+
@type = type
|
17
|
+
@path = path
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class HeaderPathExtractor
|
22
|
+
|
23
|
+
include XcodeArchiveCache::Logs
|
24
|
+
|
25
|
+
# @param [String] modulemap_path
|
26
|
+
#
|
27
|
+
# @return [Array<String>]
|
28
|
+
#
|
29
|
+
def extract_all_paths(modulemap_path)
|
30
|
+
modulemap_dir = File.dirname(modulemap_path)
|
31
|
+
modulemap_lines = FileHandler.new.read_modulemap_lines(modulemap_path)
|
32
|
+
header_paths = []
|
33
|
+
|
34
|
+
modulemap_lines.each do |line|
|
35
|
+
header_declaration = extract_header_declaration(line)
|
36
|
+
if header_declaration
|
37
|
+
header_paths << get_full_header_path(modulemap_dir, header_declaration.path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
debug("modulemap header paths: #{header_paths}")
|
42
|
+
|
43
|
+
header_paths
|
44
|
+
end
|
45
|
+
|
46
|
+
# @param [String] modulemap_dir
|
47
|
+
# @param [String] path
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
#
|
51
|
+
def get_full_header_path(modulemap_dir, path)
|
52
|
+
Pathname.new(path).absolute? ? path : File.join(modulemap_dir, path)
|
53
|
+
end
|
54
|
+
|
55
|
+
# @param [String] line
|
56
|
+
#
|
57
|
+
# @return [XcodeArchiveCache::Modulemap::HeaderPathDeclaration]
|
58
|
+
#
|
59
|
+
def extract_header_declaration(line)
|
60
|
+
if line.include?("header") && !line.include?("exclude")
|
61
|
+
components = line.split("\"")
|
62
|
+
HeaderPathDeclaration.new(components[0], components[1])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module XcodeArchiveCache
|
2
|
+
module Modulemap
|
3
|
+
class HeaderPathFixer
|
4
|
+
|
5
|
+
include XcodeArchiveCache::Logs
|
6
|
+
|
7
|
+
# @param [Storage] storage
|
8
|
+
#
|
9
|
+
def initialize(storage)
|
10
|
+
@storage = storage
|
11
|
+
@header_path_extractor = HeaderPathExtractor.new
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param [XcodeArchiveCache::BuildGraph::Node] node
|
15
|
+
#
|
16
|
+
def fix_modulemap(node)
|
17
|
+
return unless node.has_static_library_product?
|
18
|
+
|
19
|
+
injected_modulemap_file_path = storage.get_modulemap_path(node)
|
20
|
+
return if injected_modulemap_file_path == nil
|
21
|
+
|
22
|
+
file_handler = FileHandler.new
|
23
|
+
|
24
|
+
modulemap_dir = File.dirname(injected_modulemap_file_path)
|
25
|
+
modulemap_lines = file_handler.read_modulemap_lines(injected_modulemap_file_path)
|
26
|
+
|
27
|
+
updated_lines = modulemap_lines.map do |line|
|
28
|
+
declaration = header_path_extractor.extract_header_declaration(line)
|
29
|
+
next line unless declaration
|
30
|
+
|
31
|
+
# absolute paths depend on machine and derived data dir
|
32
|
+
#
|
33
|
+
full_header_path = header_path_extractor.get_full_header_path(modulemap_dir, declaration.path)
|
34
|
+
should_replace = Pathname.new(declaration.path).absolute? || !File.exist?(full_header_path)
|
35
|
+
next line unless should_replace
|
36
|
+
|
37
|
+
header_file_name = File.basename(declaration.path)
|
38
|
+
injected_header_path = File.join(modulemap_dir, header_file_name)
|
39
|
+
next line if injected_header_path == declaration.path
|
40
|
+
|
41
|
+
if File.exist?(injected_header_path)
|
42
|
+
debug("substituting #{declaration.path} with #{injected_header_path} in #{File.basename(injected_modulemap_file_path)}")
|
43
|
+
"#{declaration.type}\"#{injected_header_path}\""
|
44
|
+
else
|
45
|
+
error("failed to substitute missing header #{declaration.path} with another missing header in #{File.basename(injected_modulemap_file_path)}")
|
46
|
+
error("leaving the path as it is")
|
47
|
+
line
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
file_handler.write_modulemap_lines(updated_lines, injected_modulemap_file_path)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# @return [Storage]
|
57
|
+
#
|
58
|
+
attr_accessor :storage
|
59
|
+
|
60
|
+
# @return [XcodeArchiveCache::Modulemap::HeaderPathExtractor]
|
61
|
+
#
|
62
|
+
attr_accessor :header_path_extractor
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/runner/runner.rb
CHANGED
@@ -68,42 +68,49 @@ module XcodeArchiveCache
|
|
68
68
|
raise Informative, "Target not found for #{target_config.name}"
|
69
69
|
end
|
70
70
|
|
71
|
+
xcodebuild_executor = XcodeArchiveCache::Xcodebuild::Executor.new(config.active_configuration.build_configuration,
|
72
|
+
target.platform_name,
|
73
|
+
config.settings.destination,
|
74
|
+
config.active_configuration.action,
|
75
|
+
config.active_configuration.xcodebuild_args)
|
76
|
+
graph_builder = XcodeArchiveCache::BuildGraph::Builder.new(@native_target_finder, xcodebuild_executor)
|
77
|
+
|
78
|
+
dependency_targets = Hash.new
|
79
|
+
build_graphs = Hash.new
|
80
|
+
|
81
|
+
target_config.dependencies.each do |dependency_name|
|
82
|
+
info("creating build graph for #{dependency_name}")
|
83
|
+
|
84
|
+
dependency_target = find_dependency_target(target, dependency_name)
|
85
|
+
dependency_targets[dependency_name] = dependency_target
|
86
|
+
build_graphs[dependency_name] = graph_builder.build_graph(target, dependency_target)
|
87
|
+
end
|
88
|
+
|
71
89
|
target_config.dependencies.each do |dependency_name|
|
72
|
-
|
90
|
+
info("processing #{dependency_name}")
|
91
|
+
|
92
|
+
dependency_target = dependency_targets[dependency_name]
|
93
|
+
build_graph = build_graphs[dependency_name]
|
94
|
+
|
95
|
+
@rebuild_evaluator.evaluate_build_graph(build_graph)
|
96
|
+
unpack_cached_artifacts(build_graph)
|
97
|
+
rebuild_if_needed(xcodebuild_executor, dependency_target, build_graph)
|
98
|
+
@injector.perform_outgoing_injection(build_graph, target)
|
73
99
|
end
|
74
100
|
end
|
75
101
|
|
76
102
|
# @param [Xcodeproj::Project::Object::PBXNativeTarget] target
|
77
103
|
# @param [String] dependency_name
|
78
104
|
#
|
79
|
-
|
80
|
-
|
81
|
-
|
105
|
+
# @return [Xcodeproj::Project::Object::PBXNativeTarget]
|
106
|
+
#
|
107
|
+
def find_dependency_target(target, dependency_name)
|
82
108
|
dependency_target = @native_target_finder.find_for_product_name(dependency_name)
|
83
109
|
unless dependency_target
|
84
110
|
raise Informative, "Target not found for #{dependency_name} of #{target.display_name}"
|
85
111
|
end
|
86
112
|
|
87
|
-
|
88
|
-
dependency_target.platform_name,
|
89
|
-
config.settings.destination,
|
90
|
-
config.active_configuration.action,
|
91
|
-
config.active_configuration.xcodebuild_args)
|
92
|
-
graph_builder = XcodeArchiveCache::BuildGraph::Builder.new(@native_target_finder, xcodebuild_executor)
|
93
|
-
graph = graph_builder.build_graph(target, dependency_target)
|
94
|
-
|
95
|
-
evaluate_for_rebuild(graph)
|
96
|
-
unpack_cached_artifacts(graph)
|
97
|
-
rebuild_if_needed(xcodebuild_executor, dependency_target, graph)
|
98
|
-
@injector.perform_outgoing_injection(graph, target)
|
99
|
-
end
|
100
|
-
|
101
|
-
# @param [XcodeArchiveCache::BuildGraph::Graph] graph
|
102
|
-
#
|
103
|
-
def evaluate_for_rebuild(graph)
|
104
|
-
graph.nodes.each do |node|
|
105
|
-
@rebuild_evaluator.evaluate(node)
|
106
|
-
end
|
113
|
+
dependency_target
|
107
114
|
end
|
108
115
|
|
109
116
|
# @param [XcodeArchiveCache::BuildGraph::Graph] graph
|
data/lib/shell/executor.rb
CHANGED
@@ -57,12 +57,12 @@ module XcodeArchiveCache
|
|
57
57
|
# @return [String]
|
58
58
|
#
|
59
59
|
def pipefail_flags(print_command)
|
60
|
-
flags =
|
60
|
+
flags = ["e", "o pipefail"]
|
61
61
|
if print_command
|
62
62
|
flags.insert(1, "x")
|
63
63
|
end
|
64
64
|
|
65
|
-
"-" + flags.join("")
|
65
|
+
"-" + flags.join(" -")
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/lib/xcode-archive-cache.rb
CHANGED
@@ -46,6 +46,10 @@ require 'injection/headers_mover'
|
|
46
46
|
require 'injection/storage'
|
47
47
|
require 'injection/framework_embedder'
|
48
48
|
|
49
|
+
require 'modulemap/file_handler'
|
50
|
+
require 'modulemap/header_path_extractor'
|
51
|
+
require 'modulemap/header_path_fixer'
|
52
|
+
|
49
53
|
require 'runner/runner'
|
50
54
|
|
51
55
|
require 'shell/executor'
|
data/lib/xcodebuild/executor.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcode-archive-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Dyakonov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '2.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
29
|
+
version: '1.10'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rubyzip
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
39
|
+
version: '1.3'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
|
-
- - "
|
47
|
+
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
49
|
+
version: '1.3'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.0'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: xcpretty
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,8 +78,8 @@ dependencies:
|
|
66
78
|
- - "~>"
|
67
79
|
- !ruby/object:Gem::Version
|
68
80
|
version: '1.0'
|
69
|
-
description:
|
70
|
-
email:
|
81
|
+
description:
|
82
|
+
email:
|
71
83
|
executables:
|
72
84
|
- xcode-archive-cache
|
73
85
|
extensions: []
|
@@ -103,6 +115,9 @@ files:
|
|
103
115
|
- lib/injection/pods_script_fixer.rb
|
104
116
|
- lib/injection/storage.rb
|
105
117
|
- lib/logs/logs.rb
|
118
|
+
- lib/modulemap/file_handler.rb
|
119
|
+
- lib/modulemap/header_path_extractor.rb
|
120
|
+
- lib/modulemap/header_path_fixer.rb
|
106
121
|
- lib/runner/runner.rb
|
107
122
|
- lib/shell/executor.rb
|
108
123
|
- lib/xcode-archive-cache.rb
|
@@ -111,7 +126,7 @@ homepage: https://github.com/sweatco/xcode-archive-cache
|
|
111
126
|
licenses:
|
112
127
|
- MIT
|
113
128
|
metadata: {}
|
114
|
-
post_install_message:
|
129
|
+
post_install_message:
|
115
130
|
rdoc_options: []
|
116
131
|
require_paths:
|
117
132
|
- lib
|
@@ -122,12 +137,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
137
|
version: 2.0.0
|
123
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
139
|
requirements:
|
125
|
-
- - "
|
140
|
+
- - ">="
|
126
141
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
142
|
+
version: '0'
|
128
143
|
requirements: []
|
129
144
|
rubygems_version: 3.0.4
|
130
|
-
signing_key:
|
145
|
+
signing_key:
|
131
146
|
specification_version: 4
|
132
147
|
summary: Native targets cache for Xcode archive builds.
|
133
148
|
test_files: []
|