carthage_remote_cache 0.0.10 → 0.0.11

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: db51bc926af285ff03bc266988ab005c5f7ab4e7131aec89d12a99b1d14ea0f1
4
- data.tar.gz: 6d41c8d5b3c6b08369fe595169f53ca8c8cfbc22614726227687625efae341b4
3
+ metadata.gz: 3437fb2e13b47b5d1a5479e5d028b0e96447cc232bfa3a9b08e38e014a24bf2a
4
+ data.tar.gz: a84e8493195b8d80622ac63ec76eac05754f5917d12e634c432dcee1a5ff5558
5
5
  SHA512:
6
- metadata.gz: 2fc9aa022853786a525dc61f4bbb23f1c53ff5458b05466bdf0041ac664703118391fa1cf82671c32e39012eefa1f01f664a903b35a85142e8b18ff6ae450a1f
7
- data.tar.gz: ce992ab16d4281d7d348e3b04ef405de51a66fb1036282ae6a17055c7a0ab958aa1c7bb6b3e24a7adad2f04c6fc727938624e493fe31b3bdd4c2474cbd1b1540
6
+ metadata.gz: 5dae27cbc7028ba7ea772cabf04ff1dd750b2950e3c7e30a11e06c86ed202cfcd8b800263a2214d0475d80572007af5553c79844661d4f537fe6413004e9eed2
7
+ data.tar.gz: f04784fcf41b486a53d1706c0371ea10d3b27fe575ca9687204f9c000713fd58d199eaede9d7ca770ef7681432479b57346bf832d1b482cbb90b3dfe63815faf
@@ -0,0 +1,38 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ "master" ]
13
+ pull_request:
14
+ branches: [ "master" ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['2.7.2']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - name: Set up Ruby
30
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
+ # uses: ruby/setup-ruby@v1
33
+ uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Run tests
38
+ run: bundle exec rake test
data/.ruby-version ADDED
@@ -0,0 +1,2 @@
1
+ 2.7.2
2
+
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5.0
3
+ - 2.7.2
4
4
  script:
5
5
  - bundle exec rake test
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carthage_remote_cache (0.0.10)
4
+ carthage_remote_cache (0.0.11)
5
5
  concurrent-ruby (~> 1.0.5)
6
6
  rack (>= 2.0.6, < 2.3.0)
7
7
  rest-client (~> 2.0.2)
8
- sinatra (~> 2.0.4)
8
+ sinatra (>= 2.0.4, < 2.3.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -14,8 +14,8 @@ GEM
14
14
  concurrent-ruby (1.0.5)
15
15
  domain_name (0.5.20190701)
16
16
  unf (>= 0.0.5, < 1.0.0)
17
- ffi (1.15.0)
18
- formatador (0.2.5)
17
+ ffi (1.15.5)
18
+ formatador (1.1.0)
19
19
  guard (2.14.2)
20
20
  formatador (>= 0.2.4)
21
21
  listen (>= 2.7, < 4.0)
@@ -29,17 +29,17 @@ GEM
29
29
  guard-test (2.0.8)
30
30
  guard-compat (~> 1.2)
31
31
  test-unit (~> 3.0)
32
- http-cookie (1.0.3)
32
+ http-cookie (1.0.5)
33
33
  domain_name (~> 0.5)
34
- listen (3.5.1)
34
+ listen (3.7.1)
35
35
  rb-fsevent (~> 0.10, >= 0.10.3)
36
36
  rb-inotify (~> 0.9, >= 0.9.10)
37
37
  lumberjack (1.2.8)
38
38
  metaclass (0.0.4)
39
39
  method_source (1.0.0)
40
- mime-types (3.3.1)
40
+ mime-types (3.4.1)
41
41
  mime-types-data (~> 3.2015)
42
- mime-types-data (3.2021.0225)
42
+ mime-types-data (3.2022.0105)
43
43
  mocha (1.3.0)
44
44
  metaclass (~> 0.0.1)
45
45
  mustermann (1.1.1)
@@ -49,15 +49,15 @@ GEM
49
49
  notiffany (0.1.3)
50
50
  nenv (~> 0.1)
51
51
  shellany (~> 0.0)
52
- power_assert (2.0.0)
52
+ power_assert (2.0.1)
53
53
  pry (0.14.1)
54
54
  coderay (~> 1.1)
55
55
  method_source (~> 1.0)
56
- rack (2.2.3)
57
- rack-protection (2.0.8.1)
56
+ rack (2.2.4)
57
+ rack-protection (2.2.0)
58
58
  rack
59
- rake (13.0.3)
60
- rb-fsevent (0.11.0)
59
+ rake (13.0.6)
60
+ rb-fsevent (0.11.1)
61
61
  rb-inotify (0.10.1)
62
62
  ffi (~> 1.0)
63
63
  rerun (0.13.1)
@@ -66,21 +66,21 @@ GEM
66
66
  http-cookie (>= 1.0.2, < 2.0)
67
67
  mime-types (>= 1.16, < 4.0)
68
68
  netrc (~> 0.8)
69
- ruby2_keywords (0.0.4)
69
+ ruby2_keywords (0.0.5)
70
70
  rufo (0.13.0)
71
71
  shellany (0.0.1)
72
- sinatra (2.0.8.1)
72
+ sinatra (2.2.0)
73
73
  mustermann (~> 1.0)
74
- rack (~> 2.0)
75
- rack-protection (= 2.0.8.1)
74
+ rack (~> 2.2)
75
+ rack-protection (= 2.2.0)
76
76
  tilt (~> 2.0)
77
77
  test-unit (3.2.9)
78
78
  power_assert
79
- thor (1.1.0)
79
+ thor (1.2.1)
80
80
  tilt (2.0.10)
81
81
  unf (0.1.4)
82
82
  unf_ext
83
- unf_ext (0.0.7.7)
83
+ unf_ext (0.0.8.2)
84
84
 
85
85
  PLATFORMS
86
86
  ruby
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CarthageRemoteCache
2
2
 
3
- [![Build Status](https://travis-ci.org/kayak/carthage_remote_cache.svg?branch=master)](https://travis-ci.org/kayak/carthage_remote_cache)
3
+ [![Test Status](https://github.com/kayak/carthage_remote_cache/actions/workflows/ruby.yml/badge.svg)](https://github.com/kayak/carthage_remote_cache/actions/workflows/ruby.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/carthage_remote_cache.svg)](https://badge.fury.io/rb/carthage_remote_cache)
5
5
 
6
6
  Centralized cache to serve Carthage frameworks. Useful for distributed CI setup with several build machines. It's aware of your `xcodebuild` and `swift` versions and builds on top of Carthage's `.xyz.version` file mechanism.
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.0.5"
33
33
  spec.add_runtime_dependency "rack", ">= 2.0.6", "< 2.3.0"
34
34
  spec.add_runtime_dependency "rest-client", "~> 2.0.2"
35
- spec.add_runtime_dependency "sinatra", "~> 2.0.4"
35
+ spec.add_runtime_dependency "sinatra", ">= 2.0.4", "< 2.3.0"
36
36
  end
data/lib/api.rb CHANGED
@@ -47,13 +47,13 @@ class API
47
47
  end
48
48
 
49
49
  # @return zip archive size in Bytes
50
- def create_and_upload_archive(carthage_dependency, framework_name, platform)
51
- archive = CarthageArchive.new(framework_name, platform)
52
- archive.create_archive(@shell)
50
+ def create_and_upload_archive(carthage_dependency, framework, platform)
51
+ archive = framework.make_archive(platform)
52
+ archive.compress_archive(@shell)
53
53
  archive_size = archive.archive_size
54
54
  begin
55
55
  checksum = crc32(archive.archive_path)
56
- @networking.upload_framework_archive(archive.archive_path, carthage_dependency, framework_name, platform, checksum)
56
+ @networking.upload_framework_archive(archive.archive_path, carthage_dependency, framework.name, platform, checksum)
57
57
  ensure
58
58
  archive.delete_archive
59
59
  end
@@ -62,10 +62,10 @@ class API
62
62
 
63
63
  # @return zip archive size in Bytes
64
64
  # @raise AppError if download or checksum validation fails
65
- def download_and_unpack_archive(carthage_dependency, framework_name, platform)
66
- result = @networking.download_framework_archive(carthage_dependency, framework_name, platform)
65
+ def download_and_unpack_archive(carthage_dependency, framework, platform)
66
+ result = @networking.download_framework_archive(carthage_dependency, framework, platform)
67
67
  if result.nil?
68
- raise AppError.new, "Failed to download framework #{carthage_dependency} – #{framework_name} (#{platform}). Please `upload` the framework first."
68
+ raise AppError.new, "Failed to download framework #{carthage_dependency} – #{framework.name} (#{platform}). Please `upload` the framework first."
69
69
  end
70
70
 
71
71
  archive = result[:archive]
@@ -12,42 +12,6 @@ class CarthageArchive
12
12
  @archive_path = @archive_filename
13
13
  end
14
14
 
15
- # Aggregate following files:
16
- # - Carthage/Build/iOS/Alamofire.framework
17
- # - Carthage/Build/iOS/Alamofire.framework/Alamofire
18
- # - Carthage/Build/iOS/618BEB79-4C7F-3692-B140-131FB983AC5E.bcsymbolmap
19
- # into Alamofire-iOS.zip
20
- def create_archive(shell, carthage_build_dir = CARTHAGE_BUILD_DIR)
21
- $LOG.debug("Archiving #{@framework_name} for #{@platform}")
22
-
23
- platform_path = File.join(carthage_build_dir, platform_to_carthage_dir_string(@platform))
24
- framework_path = File.join(platform_path, "#{@framework_name}.framework")
25
- raise MissingFrameworkDirectoryError.new, "Archive can't be created, no framework directory at #{framework_path}" unless Dir.exist?(framework_path)
26
-
27
- # It's very likely, that binary releases don't contain DSYMs.
28
- dsym_path = File.join(platform_path, "#{@framework_name}.framework.dSYM")
29
- unless File.exist?(dsym_path)
30
- $LOG.error("DSYM File #{dsym_path} not found, continuing")
31
- dsym_path = nil
32
- end
33
-
34
- binary_path = File.join(framework_path, @framework_name)
35
- raise AppError.new, "Binary #{binary_path} is missing, failed to read .bcsymbolmap files" unless File.exist?(binary_path)
36
-
37
- bcsymbolmap_paths = find_bcsymbolmap_paths(shell, platform_path, binary_path)
38
-
39
- input_paths = []
40
- input_paths << framework_path
41
- input_paths << dsym_path unless dsym_path.nil?
42
- input_paths += bcsymbolmap_paths
43
-
44
- $LOG.debug("Adding > #{input_paths.inspect}")
45
-
46
- delete_archive
47
- shell.archive(input_paths, @archive_path)
48
- $LOG.debug("Created #{@archive_path} archive, file size: #{formatted_archive_size}")
49
- end
50
-
51
15
  def unpack_archive(shell, carthage_build_dir = CARTHAGE_BUILD_DIR)
52
16
  raise AppError.new, "Archive #{@archive_path} is missing" unless File.exist?(@archive_path)
53
17
 
@@ -68,28 +32,12 @@ class CarthageArchive
68
32
 
69
33
  private
70
34
 
71
- def find_bcsymbolmap_paths(shell, platform_path, binary_path)
72
- raw_dwarfdump = shell.dwarfdump(binary_path)
73
- uuids = parse_uuids(raw_dwarfdump)
74
- bcsymbolmap_paths = uuids.map { |uuid| File.join(platform_path, "#{uuid}.bcsymbolmap") }.select { |path| File.exist?(path) }
75
- bcsymbolmap_paths
76
- end
77
-
78
- # Example dwarfdump link:
79
- # UUID: 618BEB79-4C7F-3692-B140-131FB983AC5E (i386) Carthage/Build/iOS/CocoaLumberjackSwift.framework/CocoaLumberjackSwift
80
- def parse_uuids(raw_dwarfdump)
81
- lines = raw_dwarfdump.split("\n")
82
- uuids = lines.map { |line| line[/^UUID: ([A-Z0-9\-]+)\s+\(.*$/, 1] }
83
- uuids.compact
84
- end
85
-
86
35
  def formatted_archive_size
87
36
  format_file_size(archive_size)
88
37
  end
89
38
 
90
39
  def delete_existing_build_framework_if_exists(carthage_build_dir)
91
- platform_path = File.join(carthage_build_dir, platform_to_carthage_dir_string(@platform))
92
- framework_path = File.join(platform_path, "#{@framework_name}.framework")
40
+ framework_path = File.join(carthage_build_dir, "#{@framework_name}.xcframework")
93
41
  if File.exist?(framework_path)
94
42
  $LOG.debug("Deleting #{framework_path}")
95
43
  FileUtils.rm_rf(framework_path)
@@ -3,6 +3,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require "api"
5
5
  require "carthage_archive"
6
+ require "framework_carthage_archive"
7
+ require "xcframework_carthage_archive"
8
+ require "framework"
9
+ require "xcframework"
6
10
  require "carthage_dependency"
7
11
  require "constants"
8
12
  require "configuration"
@@ -76,9 +76,9 @@ class DownloadCommand
76
76
  version_file = @networking.download_version_file(carthage_dependency, @platforms)
77
77
  raise AppError.new, "Version file #{carthage_dependency.version_filename} is not present on the server, please run `carthagerc upload` first" if version_file.nil?
78
78
 
79
- version_file.frameworks_by_platform.each do |platform, framework_names|
80
- for framework_name in framework_names
81
- archive_size = @api.download_and_unpack_archive(carthage_dependency, framework_name, platform)
79
+ version_file.frameworks_by_platform.each do |platform, frameworks|
80
+ for framework in frameworks
81
+ archive_size = @api.download_and_unpack_archive(carthage_dependency, framework, platform)
82
82
  @mutex.synchronize do
83
83
  @number_of_downloaded_archives += 1
84
84
  @total_archive_size += archive_size
@@ -72,9 +72,9 @@ class UploadCommand
72
72
 
73
73
  @networking.upload_version_file(carthage_dependency)
74
74
 
75
- version_file.frameworks_by_platform.each do |platform, framework_names|
76
- for framework_name in framework_names
77
- archive_size = @api.create_and_upload_archive(carthage_dependency, framework_name, platform)
75
+ version_file.frameworks_by_platform.each do |platform, frameworks|
76
+ for framework in frameworks
77
+ archive_size = @api.create_and_upload_archive(carthage_dependency, framework, platform)
78
78
  @mutex.synchronize do
79
79
  @number_of_uploaded_archives += 1
80
80
  @total_archive_size += archive_size
data/lib/framework.rb ADDED
@@ -0,0 +1,19 @@
1
+ # Example data:
2
+ # - "name" : "Sentry",
3
+ # - "linking" : "dynamic"
4
+ class Framework
5
+ attr_reader :name
6
+
7
+ def self.parse(json)
8
+ Framework.new(json["name"], json["linking"])
9
+ end
10
+
11
+ def initialize(name, linking)
12
+ @name = name
13
+ @linking = linking
14
+ end
15
+
16
+ def make_archive(platform)
17
+ FrameworkCarthageArchive.new(name, platform)
18
+ end
19
+ end
@@ -0,0 +1,57 @@
1
+ require "fileutils"
2
+
3
+ class FrameworkCarthageArchive < CarthageArchive
4
+
5
+ # Aggregate following files:
6
+ # - Carthage/Build/iOS/Alamofire.framework
7
+ # - Carthage/Build/iOS/Alamofire.framework/Alamofire
8
+ # - Carthage/Build/iOS/618BEB79-4C7F-3692-B140-131FB983AC5E.bcsymbolmap
9
+ # into Alamofire-iOS.zip
10
+ def compress_archive(shell, carthage_build_dir = CARTHAGE_BUILD_DIR)
11
+ $LOG.debug("Archiving #{@framework_name} for #{@platform}")
12
+
13
+ platform_path = File.join(carthage_build_dir, platform_to_carthage_dir_string(@platform))
14
+ framework_path = File.join(platform_path, "#{@framework_name}.framework")
15
+ raise MissingFrameworkDirectoryError.new, "Archive can't be created, no framework directory at #{framework_path}" unless Dir.exist?(framework_path)
16
+
17
+ # It's very likely, that binary releases don't contain DSYMs.
18
+ dsym_path = File.join(platform_path, "#{@framework_name}.framework.dSYM")
19
+ unless File.exist?(dsym_path)
20
+ $LOG.error("DSYM File #{dsym_path} not found, continuing")
21
+ dsym_path = nil
22
+ end
23
+
24
+ binary_path = File.join(framework_path, @framework_name)
25
+ raise AppError.new, "Binary #{binary_path} is missing, failed to read .bcsymbolmap files" unless File.exist?(binary_path)
26
+
27
+ bcsymbolmap_paths = find_bcsymbolmap_paths(shell, platform_path, binary_path)
28
+
29
+ input_paths = []
30
+ input_paths << framework_path
31
+ input_paths << dsym_path unless dsym_path.nil?
32
+ input_paths += bcsymbolmap_paths
33
+
34
+ $LOG.debug("Adding > #{input_paths.inspect}")
35
+
36
+ delete_archive
37
+ shell.archive(input_paths, @archive_path)
38
+ $LOG.debug("Created #{@archive_path} archive, file size: #{formatted_archive_size}")
39
+ end
40
+
41
+ private
42
+
43
+ def find_bcsymbolmap_paths(shell, platform_path, binary_path)
44
+ raw_dwarfdump = shell.dwarfdump(binary_path)
45
+ uuids = parse_uuids(raw_dwarfdump)
46
+ bcsymbolmap_paths = uuids.map { |uuid| File.join(platform_path, "#{uuid}.bcsymbolmap") }.select { |path| File.exist?(path) }
47
+ bcsymbolmap_paths
48
+ end
49
+
50
+ # Example dwarfdump link:
51
+ # UUID: 618BEB79-4C7F-3692-B140-131FB983AC5E (i386) Carthage/Build/iOS/CocoaLumberjackSwift.framework/CocoaLumberjackSwift
52
+ def parse_uuids(raw_dwarfdump)
53
+ lines = raw_dwarfdump.split("\n")
54
+ uuids = lines.map { |line| line[/^UUID: ([A-Z0-9\-]+)\s+\(.*$/, 1] }
55
+ uuids.compact
56
+ end
57
+ end
data/lib/networking.rb CHANGED
@@ -64,13 +64,13 @@ class Networking
64
64
  # Archives
65
65
 
66
66
  # @return Hash with CarthageArchive and checksum or nil
67
- def download_framework_archive(carthage_dependency, framework_name, platform)
68
- url = new_framework_url(carthage_dependency, framework_name, platform)
67
+ def download_framework_archive(carthage_dependency, framework, platform)
68
+ url = new_framework_url(carthage_dependency, framework.name, platform)
69
69
  archive = perform_network_request do
70
70
  $LOG.debug("Downloading framework from #{url}")
71
71
  RestClient.get(url) do |response, request, result|
72
72
  if response.code == 200
73
- archive = CarthageArchive.new(framework_name, platform)
73
+ archive = framework.make_archive(platform)
74
74
  File.write(archive.archive_path, response.to_s)
75
75
  { :archive => archive, :checksum => response.headers[ARCHIVE_CHECKSUM_HEADER_REST_CLIENT] }
76
76
  else
@@ -4,12 +4,18 @@ require "fileutils"
4
4
  require "carthage_remote_cache"
5
5
 
6
6
  get "/" do
7
- "Welcome to carthage_remote_cache"
7
+ <<-eos
8
+ <html>
9
+ <p>Welcome to <strong>carthage_remote_cache</strong> (#{VERSION})</p>
10
+ <p>To browse cache contents visit <a href="/browser/">/browser/</a></p>
11
+ </html>
12
+ eos
8
13
  end
9
14
 
10
15
  version_path = "/version"
11
16
  versions_path = "/versions/:xcodebuild_version/:swift_version/:dependency_name/:version/:version_filename"
12
17
  frameworks_path = "/frameworks/:xcodebuild_version/:swift_version/:dependency_name/:version/:framework_name/:platform"
18
+ browser_path = "/browser/*"
13
19
 
14
20
  get version_path do
15
21
  status(200)
@@ -104,6 +110,44 @@ post frameworks_path do
104
110
  end
105
111
  end
106
112
 
113
+ # Full blown file browser.
114
+ get browser_path do
115
+ url_path = "/" + params["splat"][0]
116
+ path = File.join(SERVER_CACHE_DIR, url_path)
117
+
118
+ if File.file?(path)
119
+ status(200)
120
+ send_file(path)
121
+ else
122
+ html = "<html>"
123
+
124
+ # Current directory
125
+ html += "<h2>#{url_path}</h2>"
126
+
127
+ # ".." link
128
+ if url_path != "/"
129
+ parent = File.dirname(url_path)
130
+ parent += "/" if parent != "/"
131
+ html += "<p><a href=\"/browser#{parent}\">..</a></p>"
132
+ end
133
+
134
+ # Child links
135
+ for name in Dir.children(path).select { |name| name != ".DS_Store" }.sort
136
+ child_path = File.join(path, name)
137
+ html += "<p>"
138
+ if File.file?(child_path)
139
+ html += "<a href=\"#{name}\">#{name}</a> #{format_file_size(File.size(child_path))}"
140
+ else
141
+ html += "<a href=\"#{name}/\">#{name}/</a>"
142
+ end
143
+ html += " <span style=\"color:#777\">#{File.ctime(child_path).to_s}</span>"
144
+ html += "</p>"
145
+ end
146
+
147
+ html
148
+ end
149
+ end
150
+
107
151
  private
108
152
 
109
153
  def params_to_framework_dir(params)
data/lib/utils.rb CHANGED
@@ -71,6 +71,10 @@ end
71
71
 
72
72
  # @return string in "x.y MB" format
73
73
  def format_file_size(bytes)
74
- megabytes = bytes / 1000.0 / 1000.0
75
- "#{megabytes.round(1)} MB"
74
+ if bytes == 0
75
+ "0.0 MB"
76
+ else
77
+ megabytes = [0.1, bytes / 1000.0 / 1000.0].max
78
+ "#{megabytes.round(1)} MB"
79
+ end
76
80
  end
data/lib/version.rb CHANGED
@@ -1 +1 @@
1
- VERSION = "0.0.10"
1
+ VERSION = "0.0.11"
data/lib/version_file.rb CHANGED
@@ -22,7 +22,7 @@ class VersionFile
22
22
  def platforms_by_framework
23
23
  result = Hash.new { |h, k| h[k] = [] }
24
24
  for framework_name in framework_names
25
- @frameworks_by_platform.each do |platform, framework_names_in_platform|
25
+ framework_names_by_platform.each do |platform, framework_names_in_platform|
26
26
  if framework_names_in_platform.include?(framework_name)
27
27
  result[framework_name] << platform
28
28
  end
@@ -31,14 +31,18 @@ class VersionFile
31
31
  result
32
32
  end
33
33
 
34
+ def framework_names_by_platform
35
+ @frameworks_by_platform.map { |platform, framework| [platform, framework.map { |f| f.name }] }.to_h
36
+ end
37
+
34
38
  # Unique array of framework names.
35
39
  def framework_names
36
- @frameworks_by_platform.values.flatten.uniq.sort
40
+ framework_names_by_platform.values.flatten.uniq.sort
37
41
  end
38
42
 
39
43
  # Total number of frameworks accross all platforms.
40
44
  def number_of_frameworks
41
- @frameworks_by_platform.values.flatten.count
45
+ framework_names_by_platform.values.flatten.count
42
46
  end
43
47
 
44
48
  def move_to_build_dir
@@ -93,10 +97,38 @@ class VersionFile
93
97
  def parse_platform(platform)
94
98
  carthage_platform_name = platform_to_carthage_dir_string(platform)
95
99
  array = @json[carthage_platform_name]
96
- if array.kind_of?(Array)
97
- array.map { |entry| entry["name"] }
100
+ if array.kind_of?(Array) and array.count > 0
101
+ if array.first["linking"]
102
+ parse_frameworks(array)
103
+ elsif array.first["container"]
104
+ parse_xcframeworks(array)
105
+ else
106
+ raise AppError.new "Failed to parse framework #{json}"
107
+ end
98
108
  else
99
109
  []
100
110
  end
101
111
  end
112
+
113
+ def parse_frameworks(array)
114
+ array.map { |json| Framework.parse(json) }
115
+ end
116
+
117
+ def parse_xcframeworks(array)
118
+ # Parse the array of XCFrameworks
119
+ xcframeworks = array.map { |json| XCFramework.parse(json) }
120
+
121
+ # Merge entries with same name, but different identifiers into one.
122
+ by_name = xcframeworks.reduce({}) do |hash, xcframework|
123
+ if found = hash[xcframework.name]
124
+ hash[found.name] = found.new_xcframework_by_adding_identifiers(xcframework.identifiers)
125
+ else
126
+ hash[xcframework.name] = xcframework
127
+ end
128
+ hash
129
+ end
130
+
131
+ # Turn back into a simple array
132
+ by_name.values
133
+ end
102
134
  end
@@ -0,0 +1,29 @@
1
+ # Example data:
2
+ # - "name" : "GoogleSignIn",
3
+ # - "container" : "GoogleSignIn.xcframework",
4
+ # - "identifiers" : ["ios-arm64_i386_x86_64-simulator", "ios-arm64_armv7"]
5
+ class XCFramework
6
+ attr_reader :name, :container, :identifiers
7
+
8
+ def self.parse(json)
9
+ XCFramework.new(json["name"], json["container"], [json["identifier"]])
10
+ end
11
+
12
+ def initialize(name, container, identifiers)
13
+ @name = name
14
+ @container = container
15
+ @identifiers = identifiers
16
+ end
17
+
18
+ def ==(other)
19
+ @name == other.name && @container == other.container && @identifiers == other.identifiers
20
+ end
21
+
22
+ def make_archive(platform)
23
+ XCFrameworkCarthageArchive.new(name, platform)
24
+ end
25
+
26
+ def new_xcframework_by_adding_identifiers(identifiers_to_add)
27
+ XCFramework.new(name, container, identifiers + identifiers_to_add)
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ require "fileutils"
2
+
3
+ class XCFrameworkCarthageArchive < CarthageArchive
4
+
5
+ # Compresses `Carthage/Build/GoogleSignIn.xcframework``
6
+ # into `GoogleSignIn-iOS.zip`.`
7
+ def compress_archive(shell, carthage_build_dir = CARTHAGE_BUILD_DIR)
8
+ $LOG.debug("Archiving #{@framework_name} for #{@platform}")
9
+
10
+ framework_path = File.join(carthage_build_dir, "#{@framework_name}.xcframework")
11
+ raise MissingFrameworkDirectoryError.new, "Archive can't be created, no xcframework directory at #{framework_path}" unless Dir.exist?(framework_path)
12
+
13
+ delete_archive
14
+ shell.archive([framework_path], @archive_path)
15
+ $LOG.debug("Created #{@archive_path} archive, file size: #{formatted_archive_size}")
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carthage_remote_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juraj Blahunka
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-20 00:00:00.000000000 Z
11
+ date: 2022-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,16 +174,22 @@ dependencies:
174
174
  name: sinatra
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
- - - "~>"
177
+ - - ">="
178
178
  - !ruby/object:Gem::Version
179
179
  version: 2.0.4
180
+ - - "<"
181
+ - !ruby/object:Gem::Version
182
+ version: 2.3.0
180
183
  type: :runtime
181
184
  prerelease: false
182
185
  version_requirements: !ruby/object:Gem::Requirement
183
186
  requirements:
184
- - - "~>"
187
+ - - ">="
185
188
  - !ruby/object:Gem::Version
186
189
  version: 2.0.4
190
+ - - "<"
191
+ - !ruby/object:Gem::Version
192
+ version: 2.3.0
187
193
  description: Centralized cache to serve carthage frameworks. Useful for distributed
188
194
  CI setup with several build machines.
189
195
  email:
@@ -193,7 +199,9 @@ executables:
193
199
  extensions: []
194
200
  extra_rdoc_files: []
195
201
  files:
202
+ - ".github/workflows/ruby.yml"
196
203
  - ".gitignore"
204
+ - ".ruby-version"
197
205
  - ".travis.yml"
198
206
  - Dockerfile
199
207
  - Gemfile
@@ -221,6 +229,8 @@ files:
221
229
  - lib/constants.rb
222
230
  - lib/crc32.rb
223
231
  - lib/errors.rb
232
+ - lib/framework.rb
233
+ - lib/framework_carthage_archive.rb
224
234
  - lib/log.rb
225
235
  - lib/networking.rb
226
236
  - lib/server/config.ru
@@ -230,11 +240,13 @@ files:
230
240
  - lib/utils.rb
231
241
  - lib/version.rb
232
242
  - lib/version_file.rb
243
+ - lib/xcframework.rb
244
+ - lib/xcframework_carthage_archive.rb
233
245
  homepage: https://github.com/kayak/carthage_remote_cache
234
246
  licenses:
235
247
  - Apache-2.0
236
248
  metadata: {}
237
- post_install_message:
249
+ post_install_message:
238
250
  rdoc_options: []
239
251
  require_paths:
240
252
  - lib
@@ -249,8 +261,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
261
  - !ruby/object:Gem::Version
250
262
  version: '0'
251
263
  requirements: []
252
- rubygems_version: 3.2.4
253
- signing_key:
264
+ rubygems_version: 3.3.5
265
+ signing_key:
254
266
  specification_version: 4
255
267
  summary: Centralized cache to serve carthage frameworks. Useful for distributed CI
256
268
  setup with several build machines.