xccache 1.0.2 → 1.0.3

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: 2357c61b242803e69f54fe2b9a4db8eef00deabb636dbd98e84a808bd6c3d56a
4
- data.tar.gz: b4d9615136cb599bff14e73ef51472c6b6d3838acd5518d6e17ce9446275de4a
3
+ metadata.gz: ec431281d554462ef40e31a982b9198f5e0b3e8201fe26d97b29dc776595c9e6
4
+ data.tar.gz: 265f10b7ab38e2d2351e6b5b0e5f337bacbe64499263f4ce736131691646dc83
5
5
  SHA512:
6
- metadata.gz: b353117fdc74f92fe4c091d94936b55548b7f4b8450441dd51ebe6728b4513960af76f0278095b7f777aec0189c5c371c8a268a10092d1d522494b7da26e4f74
7
- data.tar.gz: ab9c2d5bb982bb0d7c86703ca4d1ca84ab1a3b8598eb671400a0eee47ac1caf26ff54cf9d2567c47d35702eca071d909b648243d2fa194f0b982b3d879ec7cbb
6
+ metadata.gz: 50a9eaba6ffeb480fd36688171fb9c97852a500f466b6b95d700dda1a134129b784bc916799a970ec9262f64e74930f497c72adfe95c1ec78f31b5ca9bbf9e9c
7
+ data.tar.gz: 45b141c6b9136dfeacce7129956c2147f8e5a20e2427206509c144ed1ca543b79c7b36c81cd1f6369a97ee639d7ad024030382fc285d261b5fe0a691fdbe5203
@@ -57,15 +57,18 @@ module XCCache
57
57
  end
58
58
 
59
59
  def get_cache_data(type)
60
- cache_data.select { |k, v| v == type && !k.end_with?(".xccache") }.keys
60
+ cache_data.select { |_, v| v == type }.keys
61
61
  end
62
62
 
63
63
  def update_from_graph(graph)
64
- cache_data = graph["cache"].to_h do |k, v|
65
- next [k, :hit] if v
66
- next [k, :ignored] if Config.instance.ignore?(k)
67
- [k, :missed]
68
- end
64
+ cache_data =
65
+ graph["cache"]
66
+ .reject { |k, _| k.end_with?(".xccache") }
67
+ .to_h do |k, v|
68
+ next [k, :hit] if v
69
+ next [k, :ignored] if Config.instance.ignore?(k)
70
+ [k, :missed]
71
+ end
69
72
 
70
73
  deps = graph["deps"]
71
74
  edges = deps.flat_map { |k, xs| xs.map { |v| { :source => k, :target => v } } }
@@ -40,11 +40,11 @@ module XCCache
40
40
  end
41
41
 
42
42
  def spm_local_pkgs_dir
43
- @spm_local_pkgs_dir ||= Dir.prepare(spm_sandbox / "local", clean: true)
43
+ @spm_local_pkgs_dir ||= Dir.prepare(spm_sandbox / "local")
44
44
  end
45
45
 
46
- def spm_xcconfig_dir
47
- @spm_xcconfig_dir ||= Dir.prepare(spm_sandbox / "xcconfigs", clean: true)
46
+ def spm_xcconfigs_dir
47
+ @spm_xcconfigs_dir ||= Dir.prepare(spm_sandbox / "xcconfigs")
48
48
  end
49
49
 
50
50
  def spm_cache_dir
@@ -52,7 +52,7 @@ module XCCache
52
52
  end
53
53
 
54
54
  def spm_binaries_dir
55
- @spm_binaries_dir ||= Dir.prepare(spm_sandbox / "binaries", clean: true)
55
+ @spm_binaries_dir ||= Dir.prepare(spm_sandbox / "binaries")
56
56
  end
57
57
 
58
58
  def spm_build_dir
@@ -11,7 +11,7 @@ module XCCache
11
11
 
12
12
  def gen_xcconfigs
13
13
  macros_config_by_targets.each do |target, hash|
14
- xcconfig_path = config.spm_xcconfig_dir / "#{target}.xcconfig"
14
+ xcconfig_path = config.spm_xcconfigs_dir / "#{target}.xcconfig"
15
15
  UI.message("XCConfig of target #{target} at: #{xcconfig_path}")
16
16
  Xcodeproj::Config.new(hash).save_as(xcconfig_path)
17
17
  end
@@ -17,6 +17,7 @@ module XCCache
17
17
 
18
18
  def perform_install
19
19
  verify_projects!
20
+ recreate_config_dirs
20
21
  projects.each { |project| migrate_umbrella_to_proxy(project) }
21
22
  UI.message("Using cache dir: #{config.spm_cache_dir}")
22
23
  config.ensure_file!
@@ -106,9 +107,9 @@ module XCCache
106
107
  end
107
108
 
108
109
  def inject_xcconfig_to_project(project)
109
- group = project.xccache_config_group.ensure_synced_group(name: "xcconfigs", path: config.spm_xcconfig_dir)
110
+ group = project.xccache_config_group.ensure_synced_group(name: "xcconfigs", path: config.spm_xcconfigs_dir)
110
111
  project.targets.each do |target|
111
- xcconfig_path = config.spm_xcconfig_dir / "#{target.name}.xcconfig"
112
+ xcconfig_path = config.spm_xcconfigs_dir / "#{target.name}.xcconfig"
112
113
  target.build_configurations.each do |build_config|
113
114
  if (existing = build_config.base_configuration_xcconfig)
114
115
  next if existing.path == xcconfig_path
@@ -145,5 +146,14 @@ module XCCache
145
146
  ref.path = "xccache/packages/proxy/Package.swift"
146
147
  end
147
148
  end
149
+
150
+ def recreate_config_dirs
151
+ [
152
+ config.spm_binaries_dir,
153
+ config.spm_local_pkgs_dir,
154
+ config.spm_xcconfigs_dir,
155
+ config.spm_metadata_dir,
156
+ ].each { |p| Dir.prepare(p, clean: true) }
157
+ end
148
158
  end
149
159
  end
@@ -9,12 +9,14 @@ module XCCache
9
9
  @module_name = @name.c99extidentifier
10
10
  @pkg_dir = Pathname(options[:pkg_dir] || ".").expand_path
11
11
  @pkg_desc = options[:pkg_desc]
12
+ @ctx_desc = options[:ctx_desc] # Context desc, could be an umbrella or a standalone pkg
12
13
  @sdks = options[:sdks] || []
13
14
  @sdk = options[:sdk] || @sdks&.first
14
15
  @config = options[:config] || "debug"
15
16
  @path = options[:path]
16
17
  @tmpdir = options[:tmpdir]
17
18
  @library_evolution = options[:library_evolution]
19
+ @sdks.each { |sdk| sdk.version = @ctx_desc.platforms[sdk.platform] } if @ctx_desc
18
20
  end
19
21
 
20
22
  def build(options = {})
@@ -41,7 +43,7 @@ module XCCache
41
43
  def swift_build_args
42
44
  [
43
45
  "--configuration", config,
44
- "--triple", sdk.triple,
46
+ "--triple", sdk.triple(with_version: true),
45
47
  ]
46
48
  end
47
49
 
@@ -19,6 +19,10 @@ module XCCache
19
19
  raw["_metadata"] ||= {}
20
20
  end
21
21
 
22
+ def platforms
23
+ @platforms ||= raw.fetch("platforms", []).to_h { |h| [h["platformName"].to_sym, h["version"]] }
24
+ end
25
+
22
26
  def dependencies
23
27
  @dependencies ||= fetch("dependencies", Dependency)
24
28
  end
@@ -62,6 +62,7 @@ module XCCache
62
62
  path: binary_path,
63
63
  tmpdir: tmpdir,
64
64
  pkg_desc: target_pkg_desc,
65
+ ctx_desc: pkg_desc || target_pkg_desc,
65
66
  library_evolution: options[:library_evolution],
66
67
  ).build(**options)
67
68
  end
@@ -75,6 +76,10 @@ module XCCache
75
76
  @resolved = true
76
77
  end
77
78
 
79
+ def pkg_desc
80
+ descs_by_name[root_dir.basename.to_s]
81
+ end
82
+
78
83
  def pkg_desc_of_target(name, **options)
79
84
  resolve
80
85
  desc = descs.find { |d| d.has_target?(name) }
@@ -30,7 +30,7 @@ module XCCache
30
30
  end
31
31
 
32
32
  def invalidate_cache(sdks: [])
33
- UI.message("Invalidating cache (sdks: #{sdks.map(&:name)})")
33
+ UI.message("Invalidating cache (sdks: #{sdks.map(&:to_s).join(', ')})")
34
34
 
35
35
  config.spm_cache_dir.glob("*/*.{xcframework,macro}").each do |p|
36
36
  cmps = p.basename(".*").to_s.split("-")
@@ -45,7 +45,7 @@ module XCCache
45
45
 
46
46
  # For regular targets, the xcframework must satisfy the sdk constraints (ie. containing all the slices)
47
47
  metadata = XCFramework::Metadata.new(p / "Info.plist")
48
- expected_triples = sdks.map { |sdk| sdk.triple(without_vendor: true) }
48
+ expected_triples = sdks.map { |sdk| sdk.triple(with_vendor: false) }
49
49
  missing_triples = expected_triples - metadata.triples
50
50
  missing_triples.empty? ? accept_cache.call : reject_cache.call
51
51
  end
@@ -33,14 +33,14 @@ module XCCache
33
33
  if use_clang?
34
34
  cmd = ["xcrun", "clang"]
35
35
  cmd << "-x" << "objective-c"
36
- cmd << "-target" << sdk.triple << "-isysroot" << sdk.sdk_path
36
+ cmd << "-target" << sdk.triple(with_version: true) << "-isysroot" << sdk.sdk_path
37
37
  cmd << "-o" << obj_path.to_s
38
38
  cmd << "-c" << source_path
39
39
  else
40
40
  cmd = ["xcrun", "swiftc"]
41
41
  cmd << "-emit-library" << "-emit-object"
42
42
  cmd << "-module-name" << module_name
43
- cmd << "-target" << sdk.triple << "-sdk" << sdk.sdk_path
43
+ cmd << "-target" << sdk.triple(with_version: true) << "-sdk" << sdk.sdk_path
44
44
  cmd << "-o" << obj_path.to_s
45
45
  cmd << source_path
46
46
  end
@@ -3,38 +3,45 @@ require "xccache/core/sh"
3
3
  module XCCache
4
4
  module Swift
5
5
  class Sdk
6
- attr_reader :name
7
-
8
- NAME_TO_TRIPLE = {
9
- :iphonesimulator => "arm64-apple-ios-simulator",
10
- :iphoneos => "arm64-apple-ios",
11
- :macos => "arm64-apple-macos",
12
- :watchos => "arm64-apple-watchos",
13
- :watchsimulator => "arm64-apple-watchos-simulator",
14
- :appletvos => "arm64-apple-tvos",
15
- :appletvsimulator => "arm64-apple-tvos-simulator",
16
- :xros => "arm64-apple-xros",
17
- :xrsimulator => "arm64-apple-xros-simulator",
6
+ attr_reader :name, :arch, :vendor, :platform
7
+ attr_accessor :version
8
+
9
+ NAME_TO_PLATFORM = {
10
+ :iphonesimulator => :ios,
11
+ :iphoneos => :ios,
12
+ :macos => :macos,
13
+ :watchos => :watchos,
14
+ :watchsimulator => :watchos,
15
+ :appletvos => :tvos,
16
+ :appletvsimulator => :tvos,
17
+ :xros => :xros,
18
+ :xrsimulator => :xros,
18
19
  }.freeze
19
20
 
20
- def initialize(name)
21
- @name = name
22
- return if NAME_TO_TRIPLE.key?(name.to_sym)
23
- raise GeneralError, "Unknown sdk: #{name}. Must be one of #{NAME_TO_TRIPLE.keys}"
21
+ def initialize(name, version: nil)
22
+ @name = name.to_sym
23
+ @vendor = "apple"
24
+ @arch = "arm64"
25
+ @platform = NAME_TO_PLATFORM.fetch(@name, @name)
26
+ @version = version
27
+ return if NAME_TO_PLATFORM.key?(@name)
28
+ raise GeneralError, "Unknown sdk: #{@name}. Must be one of #{NAME_TO_PLATFORM.keys}"
24
29
  end
25
30
 
26
31
  def to_s
27
- name
32
+ name.to_s
28
33
  end
29
34
 
30
- def triple(without_vendor: false)
31
- res = NAME_TO_TRIPLE[name.to_sym]
32
- res = res.sub("-apple", "") if without_vendor
33
- res
35
+ def triple(with_vendor: true, with_version: false)
36
+ cmps = [arch]
37
+ cmps << vendor if with_vendor
38
+ cmps << (with_version && version ? "#{platform}#{version}" : platform.to_s)
39
+ cmps << "simulator" if simulator?
40
+ cmps.join("-")
34
41
  end
35
42
 
36
43
  def sdk_name
37
- name == "macos" ? "macosx" : name
44
+ name == :macos ? :macosx : name
38
45
  end
39
46
 
40
47
  def sdk_path
@@ -56,6 +63,10 @@ module XCCache
56
63
  "-I#{developer_usr_lib_path}",
57
64
  ]
58
65
  end
66
+
67
+ def simulator?
68
+ name.to_s.end_with?("simulator")
69
+ end
59
70
  end
60
71
  end
61
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xccache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thuyen Trinh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-08 00:00:00.000000000 Z
11
+ date: 2025-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide