xccache 0.0.1a1 → 0.0.1a3

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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xccache/assets/templates/cachemap.html.template +55 -0
  3. data/lib/xccache/assets/templates/cachemap.js.template +95 -0
  4. data/lib/xccache/assets/templates/cachemap.style.css.template +94 -0
  5. data/lib/xccache/assets/templates/framework.info.plist.template +25 -0
  6. data/lib/xccache/assets/templates/framework.modulemap.template +6 -0
  7. data/lib/xccache/assets/templates/resource_bundle_accessor.m.template +27 -0
  8. data/lib/xccache/assets/templates/resource_bundle_accessor.swift.template +24 -0
  9. data/lib/xccache/assets/templates/umbrella.Package.swift.template +183 -0
  10. data/lib/xccache/cache/cachemap.rb +56 -0
  11. data/lib/xccache/command/base.rb +29 -0
  12. data/lib/xccache/command/build.rb +41 -0
  13. data/lib/xccache/command/pkg/build.rb +30 -0
  14. data/lib/xccache/command/pkg.rb +1 -0
  15. data/lib/xccache/command/remote/pull.rb +15 -0
  16. data/lib/xccache/command/remote/push.rb +15 -0
  17. data/lib/xccache/command/remote.rb +39 -0
  18. data/lib/xccache/command/rollback.rb +14 -0
  19. data/lib/xccache/command/use.rb +19 -0
  20. data/lib/xccache/command.rb +27 -1
  21. data/lib/xccache/core/cacheable.rb +28 -0
  22. data/lib/xccache/core/config.rb +110 -0
  23. data/lib/xccache/core/error.rb +7 -0
  24. data/lib/xccache/core/git.rb +27 -0
  25. data/lib/xccache/core/hash.rb +21 -0
  26. data/lib/xccache/core/lockfile.rb +40 -0
  27. data/lib/xccache/core/log.rb +51 -0
  28. data/lib/xccache/core/parallel.rb +10 -0
  29. data/lib/xccache/core/sh.rb +51 -0
  30. data/lib/xccache/core/syntax/hash.rb +31 -0
  31. data/lib/xccache/core/syntax/json.rb +16 -0
  32. data/lib/xccache/core/syntax/plist.rb +17 -0
  33. data/lib/xccache/core/syntax/yml.rb +16 -0
  34. data/lib/xccache/core/syntax.rb +1 -0
  35. data/lib/xccache/core/system.rb +62 -0
  36. data/lib/xccache/core.rb +1 -0
  37. data/lib/xccache/installer/build.rb +23 -0
  38. data/lib/xccache/installer/rollback.rb +37 -0
  39. data/lib/xccache/installer/use.rb +28 -0
  40. data/lib/xccache/installer.rb +113 -0
  41. data/lib/xccache/main.rb +3 -1
  42. data/lib/xccache/spm/build.rb +53 -0
  43. data/lib/xccache/spm/desc/base.rb +68 -0
  44. data/lib/xccache/spm/desc/dep.rb +40 -0
  45. data/lib/xccache/spm/desc/desc.rb +126 -0
  46. data/lib/xccache/spm/desc/product.rb +36 -0
  47. data/lib/xccache/spm/desc/target/binary.rb +8 -0
  48. data/lib/xccache/spm/desc/target/macro.rb +8 -0
  49. data/lib/xccache/spm/desc/target.rb +164 -0
  50. data/lib/xccache/spm/desc.rb +1 -0
  51. data/lib/xccache/spm/macro.rb +44 -0
  52. data/lib/xccache/spm/mixin.rb +12 -0
  53. data/lib/xccache/spm/pkg/base.rb +107 -0
  54. data/lib/xccache/spm/pkg/umbrella/build.rb +30 -0
  55. data/lib/xccache/spm/pkg/umbrella/cachemap.rb +110 -0
  56. data/lib/xccache/spm/pkg/umbrella/descs.rb +35 -0
  57. data/lib/xccache/spm/pkg/umbrella/manifest.rb +83 -0
  58. data/lib/xccache/spm/pkg/umbrella/viz.rb +40 -0
  59. data/lib/xccache/spm/pkg/umbrella/xcconfigs.rb +31 -0
  60. data/lib/xccache/spm/pkg/umbrella.rb +91 -0
  61. data/lib/xccache/spm/pkg.rb +1 -0
  62. data/lib/xccache/spm/xcframework/metadata.rb +41 -0
  63. data/lib/xccache/spm/xcframework/slice.rb +180 -0
  64. data/lib/xccache/spm/xcframework/xcframework.rb +56 -0
  65. data/lib/xccache/spm/xcframework.rb +2 -0
  66. data/lib/xccache/spm.rb +1 -0
  67. data/lib/xccache/storage/base.rb +26 -0
  68. data/lib/xccache/storage/git.rb +46 -0
  69. data/lib/xccache/storage/s3.rb +53 -0
  70. data/lib/xccache/storage.rb +1 -0
  71. data/lib/xccache/swift/sdk.rb +49 -0
  72. data/lib/xccache/swift/swiftc.rb +16 -0
  73. data/lib/xccache/utils/template.rb +21 -0
  74. data/lib/xccache/xcodeproj/build_configuration.rb +20 -0
  75. data/lib/xccache/xcodeproj/config.rb +9 -0
  76. data/lib/xccache/xcodeproj/file_system_synchronized_root_group.rb +17 -0
  77. data/lib/xccache/xcodeproj/group.rb +26 -0
  78. data/lib/xccache/xcodeproj/pkg.rb +73 -0
  79. data/lib/xccache/xcodeproj/pkg_product_dependency.rb +19 -0
  80. data/lib/xccache/xcodeproj/project.rb +83 -0
  81. data/lib/xccache/xcodeproj/target.rb +52 -0
  82. data/lib/xccache/xcodeproj.rb +2 -0
  83. metadata +107 -2
@@ -0,0 +1,73 @@
1
+ require "xcodeproj"
2
+
3
+ module Xcodeproj
4
+ class Project
5
+ module Object
6
+ module PkgRefMixin
7
+ def id
8
+ local? ? (relative_path || path) : repositoryURL
9
+ end
10
+
11
+ def slug
12
+ File.basename(id, File.extname(id))
13
+ end
14
+
15
+ def local?
16
+ is_a?(XCLocalSwiftPackageReference)
17
+ end
18
+
19
+ def xccache_pkg?
20
+ local? && id == "xccache/packages/umbrella"
21
+ end
22
+
23
+ def non_xccache_pkg?
24
+ !xccache_pkg?
25
+ end
26
+
27
+ def create_pkg_product_dependency_ref(product)
28
+ ref = project.new(XCSwiftPackageProductDependency)
29
+ ref.package = self
30
+ ref.product_name = product
31
+ ref
32
+ end
33
+
34
+ def create_target_dependency_ref(product)
35
+ ref = project.new(PBXTargetDependency)
36
+ ref.name = product
37
+ ref.product_ref = create_pkg_product_dependency_ref(product)
38
+ ref
39
+ end
40
+ end
41
+
42
+ class XCLocalSwiftPackageReference
43
+ include PkgRefMixin
44
+
45
+ def ascii_plist_annotation
46
+ # Workaround: Xcode is using display_name while Xcodeproj is using File.basename(display_name)
47
+ # Here, the plugin forces to use display_name so that updates either by Xcode or Xcodeproj are consistent
48
+ " #{isa} \"#{display_name}\" "
49
+ end
50
+
51
+ def to_h
52
+ {
53
+ "relative_path" => relative_path,
54
+ "path" => path,
55
+ "path_from_root" => absolute_path.relative_path_from(Pathname(".").expand_path).to_s,
56
+ }
57
+ end
58
+
59
+ def absolute_path
60
+ path.nil? ? project.dir / relative_path : path
61
+ end
62
+ end
63
+
64
+ class XCRemoteSwiftPackageReference
65
+ include PkgRefMixin
66
+
67
+ def to_h
68
+ { "repositoryURL" => repositoryURL, "requirement" => requirement }
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,19 @@
1
+ require "xcodeproj"
2
+
3
+ module Xcodeproj
4
+ class Project
5
+ module Object
6
+ class XCSwiftPackageProductDependency
7
+ def full_name
8
+ "#{pkg.slug}/#{product_name}"
9
+ end
10
+
11
+ def pkg
12
+ return package unless package.nil?
13
+
14
+ Log.warn("Missing pkg for #{inspect}")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,83 @@
1
+ require "xcodeproj"
2
+
3
+ module Xcodeproj
4
+ class Project
5
+ Log = XCCache::UI
6
+
7
+ def display_name
8
+ relative_path.to_s
9
+ end
10
+
11
+ def relative_path
12
+ @relative_path ||= path.relative_path_from(Pathname(".").expand_path)
13
+ end
14
+
15
+ def dir
16
+ path.parent
17
+ end
18
+
19
+ def pkgs
20
+ root_object.package_references
21
+ end
22
+
23
+ def xccache_pkg
24
+ pkgs.find(&:xccache_pkg?)
25
+ end
26
+
27
+ def non_xccache_pkgs
28
+ pkgs.reject(&:xccache_pkg?)
29
+ end
30
+
31
+ def has_pkg?(hash)
32
+ id = hash[pkg_key_in_hash(hash)]
33
+ pkgs.any? { |p| p.id == id }
34
+ end
35
+
36
+ def has_xccache_pkg?
37
+ pkgs.any?(&:xccache_pkg?)
38
+ end
39
+
40
+ def add_pkg(hash)
41
+ key = pkg_key_in_hash(hash)
42
+ is_local = ["relative_path", "path"].include?(key)
43
+
44
+ Log.message("Add package #{hash[key].bold} to project #{display_name.bold}")
45
+ cls = is_local ? XCLocalSwiftPackageReference : XCRemoteSwiftPackageReference
46
+ ref = new(cls)
47
+ custom_keys = ["path_from_root"]
48
+ hash.each { |k, v| ref.send("#{k}=", v) unless custom_keys.include?(k) }
49
+ root_object.package_references << ref
50
+ ref
51
+ end
52
+
53
+ def add_xccache_pkg
54
+ sandbox_path = XCCache::Config.instance.spm_umbrella_sandbox
55
+ add_pkg("relative_path" => sandbox_path.relative_path_from(path.parent).to_s)
56
+ end
57
+
58
+ def remove_pkgs(&block)
59
+ pkgs.select(&block).each do |pkg|
60
+ XCCache::UI.info("(-) Remove #{pkg.display_name.red} from package refs of project #{display_name.bold}")
61
+ pkg.remove_from_project
62
+ end
63
+ end
64
+
65
+ def get_target(name)
66
+ targets.find { |t| t.name == name }
67
+ end
68
+
69
+ def get_pkg(name)
70
+ pkgs.find { |p| p.slug == name }
71
+ end
72
+
73
+ def xccache_config_group
74
+ self["xccache.config"] || new_group("xccache.config")
75
+ end
76
+
77
+ private
78
+
79
+ def pkg_key_in_hash(hash)
80
+ ["repositoryURL", "relative_path", "path"].find { |k| hash.key?(k) }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,52 @@
1
+ require "xcodeproj"
2
+
3
+ module Xcodeproj
4
+ class Project
5
+ module Object
6
+ class PBXNativeTarget
7
+ alias pkg_product_dependencies package_product_dependencies
8
+
9
+ def non_xccache_pkg_product_dependencies
10
+ pkg_product_dependencies.reject { |d| d.pkg&.xccache_pkg? }
11
+ end
12
+
13
+ def has_xccache_product_dependency?
14
+ pkg_product_dependencies.any? { |d| d.pkg&.xccache_pkg? }
15
+ end
16
+
17
+ def has_pkg_product_dependency?(name)
18
+ pkg_product_dependencies.any? { |d| d.full_name == name }
19
+ end
20
+
21
+ def add_pkg_product_dependency(name)
22
+ Log.message("(+) Add dependency #{name.blue} to target #{display_name.bold}")
23
+ pkg_name, product_name = name.split("/")
24
+ pkg = project.get_pkg(pkg_name)
25
+ pkg_product_dependencies << pkg.create_target_dependency_ref(product_name).product_ref
26
+ end
27
+
28
+ def add_xccache_product_dependency
29
+ add_pkg_product_dependency("umbrella/#{name}.xccache")
30
+ end
31
+
32
+ def remove_xccache_product_dependencies
33
+ remove_pkg_product_dependencies { |d| d.pkg.xccache_pkg? }
34
+ end
35
+
36
+ def remove_pkg_product_dependencies(&block)
37
+ package_product_dependencies.select(&block).each do |d|
38
+ XCCache::UI.info(
39
+ "(-) Remove #{d.product_name.red} from product dependencies of target #{display_name.bold}"
40
+ )
41
+ build_phases.each do |phase|
42
+ phase.files.select { |f| f.remove_from_project if f.product_ref == d }
43
+ end
44
+ # Remove it from target dependencies
45
+ dependencies.each { |x| x.remove_from_project if x.product_ref == d }
46
+ d.remove_from_project
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,2 @@
1
+ require "xccache/core"
2
+ Dir["#{__dir__}/#{File.basename(__FILE__, '.rb')}/*.rb"].sort.each { |f| require f }
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: 0.0.1a1
4
+ version: 0.0.1a3
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-03-28 00:00:00.000000000 Z
11
+ date: 2025-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: parallel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: xcodeproj
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.26.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.26.0
27
55
  description: A Ruby gem
28
56
  email:
29
57
  - trinhngocthuyen@gmail.com
@@ -34,10 +62,87 @@ extra_rdoc_files: []
34
62
  files:
35
63
  - bin/xccache
36
64
  - lib/xccache.rb
65
+ - lib/xccache/assets/templates/cachemap.html.template
66
+ - lib/xccache/assets/templates/cachemap.js.template
67
+ - lib/xccache/assets/templates/cachemap.style.css.template
68
+ - lib/xccache/assets/templates/framework.info.plist.template
69
+ - lib/xccache/assets/templates/framework.modulemap.template
70
+ - lib/xccache/assets/templates/resource_bundle_accessor.m.template
71
+ - lib/xccache/assets/templates/resource_bundle_accessor.swift.template
72
+ - lib/xccache/assets/templates/umbrella.Package.swift.template
73
+ - lib/xccache/cache/cachemap.rb
37
74
  - lib/xccache/command.rb
75
+ - lib/xccache/command/base.rb
76
+ - lib/xccache/command/build.rb
38
77
  - lib/xccache/command/pkg.rb
39
78
  - lib/xccache/command/pkg/build.rb
79
+ - lib/xccache/command/remote.rb
80
+ - lib/xccache/command/remote/pull.rb
81
+ - lib/xccache/command/remote/push.rb
82
+ - lib/xccache/command/rollback.rb
83
+ - lib/xccache/command/use.rb
84
+ - lib/xccache/core.rb
85
+ - lib/xccache/core/cacheable.rb
86
+ - lib/xccache/core/config.rb
87
+ - lib/xccache/core/error.rb
88
+ - lib/xccache/core/git.rb
89
+ - lib/xccache/core/hash.rb
90
+ - lib/xccache/core/lockfile.rb
91
+ - lib/xccache/core/log.rb
92
+ - lib/xccache/core/parallel.rb
93
+ - lib/xccache/core/sh.rb
94
+ - lib/xccache/core/syntax.rb
95
+ - lib/xccache/core/syntax/hash.rb
96
+ - lib/xccache/core/syntax/json.rb
97
+ - lib/xccache/core/syntax/plist.rb
98
+ - lib/xccache/core/syntax/yml.rb
99
+ - lib/xccache/core/system.rb
100
+ - lib/xccache/installer.rb
101
+ - lib/xccache/installer/build.rb
102
+ - lib/xccache/installer/rollback.rb
103
+ - lib/xccache/installer/use.rb
40
104
  - lib/xccache/main.rb
105
+ - lib/xccache/spm.rb
106
+ - lib/xccache/spm/build.rb
107
+ - lib/xccache/spm/desc.rb
108
+ - lib/xccache/spm/desc/base.rb
109
+ - lib/xccache/spm/desc/dep.rb
110
+ - lib/xccache/spm/desc/desc.rb
111
+ - lib/xccache/spm/desc/product.rb
112
+ - lib/xccache/spm/desc/target.rb
113
+ - lib/xccache/spm/desc/target/binary.rb
114
+ - lib/xccache/spm/desc/target/macro.rb
115
+ - lib/xccache/spm/macro.rb
116
+ - lib/xccache/spm/mixin.rb
117
+ - lib/xccache/spm/pkg.rb
118
+ - lib/xccache/spm/pkg/base.rb
119
+ - lib/xccache/spm/pkg/umbrella.rb
120
+ - lib/xccache/spm/pkg/umbrella/build.rb
121
+ - lib/xccache/spm/pkg/umbrella/cachemap.rb
122
+ - lib/xccache/spm/pkg/umbrella/descs.rb
123
+ - lib/xccache/spm/pkg/umbrella/manifest.rb
124
+ - lib/xccache/spm/pkg/umbrella/viz.rb
125
+ - lib/xccache/spm/pkg/umbrella/xcconfigs.rb
126
+ - lib/xccache/spm/xcframework.rb
127
+ - lib/xccache/spm/xcframework/metadata.rb
128
+ - lib/xccache/spm/xcframework/slice.rb
129
+ - lib/xccache/spm/xcframework/xcframework.rb
130
+ - lib/xccache/storage.rb
131
+ - lib/xccache/storage/base.rb
132
+ - lib/xccache/storage/git.rb
133
+ - lib/xccache/storage/s3.rb
134
+ - lib/xccache/swift/sdk.rb
135
+ - lib/xccache/swift/swiftc.rb
136
+ - lib/xccache/utils/template.rb
137
+ - lib/xccache/xcodeproj.rb
138
+ - lib/xccache/xcodeproj/build_configuration.rb
139
+ - lib/xccache/xcodeproj/config.rb
140
+ - lib/xccache/xcodeproj/file_system_synchronized_root_group.rb
141
+ - lib/xccache/xcodeproj/group.rb
142
+ - lib/xccache/xcodeproj/pkg.rb
143
+ - lib/xccache/xcodeproj/pkg_product_dependency.rb
144
+ - lib/xccache/xcodeproj/project.rb
145
+ - lib/xccache/xcodeproj/target.rb
41
146
  homepage: https://github.com/trinhngocthuyen/xccache
42
147
  licenses:
43
148
  - MIT