cocoapods-spm 0.1.6 → 0.1.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: e1e1e2bd492fb8080c1d1d0ab60b4abe580d3540559ba11085b0b2a93826de54
4
- data.tar.gz: 1a30fc92b2e7cdc5082f6fea26635f55345a9ae08d835450e66041028b862036
3
+ metadata.gz: c4fe180c87aca4c93c0309f995109ef39507f5e5f82183a1e6e15d247e153a3b
4
+ data.tar.gz: 8f913beccd589a820ec92b4a5ef6af7c0373f3b878cd3e78eac18720e3383b8b
5
5
  SHA512:
6
- metadata.gz: f7941760c3ec1e4be209ba35108e80db527218f6862f1fd4ffa87cbfde60688bd9e1aa735193f2018abd77593d0e8c47bfe652a60c577391a758cff7b47c8ccb
7
- data.tar.gz: 21df8075d35796d309ed868cbfe7f07b53c57c325c3e3a298b7eabab3239d658805a54d291ed6f9fdf3bc06605210940f55f636c6e362e1932e828e72ad77985
6
+ metadata.gz: '064788c5e4bbc60ebbcf3bb3f9334c8f30a75d1102c26181299978894e42554f9430adda3d1e7c8b17c9572f146e9a6fa3a0179f20db7be7cf1f95e9c31601b8'
7
+ data.tar.gz: 53adc8060fe965e1ef8566a8fbf1844ac9adbf3adddd93fcab6e52afd4750adb97273379247bbb3d13e5c5492622b2763c9b7e4682ee365cf96f706076ed7180
@@ -0,0 +1,27 @@
1
+ module Pod
2
+ module SPM
3
+ module MacroConfigMixin
4
+ include Config::Mixin
5
+
6
+ def macro_downloaded_dir
7
+ spm_config.macro_downloaded_root_dir / name
8
+ end
9
+
10
+ def macro_dir
11
+ @macro_dir ||= spm_config.macro_root_dir / name
12
+ end
13
+
14
+ def macro_prebuilt_dir
15
+ spm_config.macro_prebuilt_root_dir / name
16
+ end
17
+
18
+ def metadata_path
19
+ macro_dir / "metadata.json"
20
+ end
21
+
22
+ def metadata
23
+ @metadata ||= MacroMetadata.for_pod(name)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,7 +1,10 @@
1
+ require "cocoapods-spm/macro/metadata"
2
+ require_relative "config"
3
+
1
4
  module Pod
2
5
  module SPM
3
6
  class MacroFetcher
4
- include Config::Mixin
7
+ include MacroConfigMixin
5
8
 
6
9
  attr_reader :name
7
10
 
@@ -13,6 +16,7 @@ module Pod
13
16
  end
14
17
 
15
18
  def run
19
+ UI.puts "Fetching macro #{name}...".magenta
16
20
  download_macro_source
17
21
  macro_dir = spm_config.macro_root_dir / name
18
22
  macro_downloaded_dir = spm_config.macro_downloaded_root_dir / name
@@ -20,6 +24,17 @@ module Pod
20
24
  macro_downloaded_dir / "Sources" / name,
21
25
  macro_dir / "Sources" / name
22
26
  )
27
+ generate_metadata
28
+ end
29
+
30
+ private
31
+
32
+ def generate_metadata
33
+ raise "Package.swift not exist in #{macro_downloaded_dir}" \
34
+ unless (macro_downloaded_dir / "Package.swift").exist?
35
+
36
+ raw = Dir.chdir(macro_downloaded_dir) { `swift package dump-package` }
37
+ metadata_path.write(raw)
23
38
  end
24
39
 
25
40
  def download_macro_source
@@ -4,7 +4,13 @@ module Pod
4
4
  module SPM
5
5
  class MacroMetadata < Swift::PackageDescription
6
6
  def self.for_pod(name)
7
- from_file(Config.instance.macro_root_dir / name / "metadata.json")
7
+ path = Config.instance.macro_root_dir / name / "metadata.json"
8
+ unless path.exist?
9
+ UI.message "Will fetch macro #{name} because its metadata does not exist at #{path}"
10
+ require "cocoapods-spm/macro/fetcher"
11
+ MacroFetcher.new(name: name, can_cache: true).run
12
+ end
13
+ from_file(path)
8
14
  end
9
15
  end
10
16
  end
@@ -1,9 +1,10 @@
1
1
  require "cocoapods-spm/macro/metadata"
2
+ require_relative "config"
2
3
 
3
4
  module Pod
4
5
  module SPM
5
6
  class MacroPrebuilder
6
- include Config::Mixin
7
+ include MacroConfigMixin
7
8
  include Executables
8
9
 
9
10
  attr_reader :name
@@ -13,40 +14,14 @@ module Pod
13
14
  end
14
15
 
15
16
  def run
16
- generate_metadata
17
17
  prebuild_macro_impl
18
18
  end
19
19
 
20
- def macro_downloaded_dir
21
- spm_config.macro_downloaded_root_dir / name
22
- end
23
-
24
- def macro_dir
25
- @macro_dir ||= spm_config.macro_root_dir / name
26
- end
27
-
28
- def macro_prebuilt_dir
29
- spm_config.macro_prebuilt_root_dir / name
30
- end
31
-
32
- def metadata_path
33
- macro_dir / "metadata.json"
34
- end
35
-
36
- def generate_metadata
37
- raise "Package.swift not exist in #{macro_downloaded_dir}" \
38
- unless (macro_downloaded_dir / "Package.swift").exist?
39
-
40
- raw = Dir.chdir(macro_downloaded_dir) { `swift package dump-package` }
41
- metadata_path.write(raw)
42
- @metadata = MacroMetadata.from_s(raw)
43
- end
44
-
45
20
  def prebuild_macro_impl
46
21
  return if spm_config.dont_prebuild_macros?
47
22
 
48
23
  config = spm_config.macro_config
49
- impl_module_name = @metadata.macro_impl_name
24
+ impl_module_name = metadata.macro_impl_name
50
25
  prebuilt_binary = macro_prebuilt_dir / "#{impl_module_name}-#{config}"
51
26
  return if spm_config.dont_prebuild_macros_if_exist? && prebuilt_binary.exist?
52
27
 
@@ -35,11 +35,15 @@ module Pod
35
35
  end
36
36
  end
37
37
 
38
- def header_search_path_arg
39
- return nil if public_headers_path.nil?
38
+ def public_headers_path_expr
39
+ @public_headers_path_expr ||= public_headers_path.to_s.sub(
40
+ root.checkouts_dir.to_s,
41
+ "${SOURCE_PACKAGES_CHECKOUTS_DIR}"
42
+ )
43
+ end
40
44
 
41
- path = public_headers_path.to_s.sub(root.checkouts_dir.to_s, "${SOURCE_PACKAGES_CHECKOUTS_DIR}")
42
- "\"#{path}\""
45
+ def header_search_path_arg
46
+ "\"#{public_headers_path_expr}\"" unless public_headers_path.nil?
43
47
  end
44
48
 
45
49
  def public_headers_path
@@ -53,17 +57,18 @@ module Pod
53
57
  path unless path.glob("**/*.h*").empty?
54
58
  end
55
59
 
56
- def use_generated_modulemap?
57
- return false if public_headers_path.nil?
60
+ def modulemap_path
61
+ @modulemap_path ||= public_headers_path&.glob("*.modulemap")&.first
62
+ end
63
+
64
+ def clang_modulemap_path_expr
65
+ return "#{public_headers_path_expr}/#{modulemap_path.basename}" unless modulemap_path.nil?
58
66
 
59
- # If there exists module.modulemap, it'll be auto picked up during compilation
60
- true if public_headers_path.glob("module.modulemap").empty?
67
+ "${GENERATED_MODULEMAP_DIR}/#{name}.modulemap" unless binary?
61
68
  end
62
69
 
63
70
  def clang_modulemap_arg
64
- return nil unless use_generated_modulemap?
65
-
66
- "-fmodule-map-file=\"${GENERATED_MODULEMAP_DIR}/#{name}.modulemap\""
71
+ "-fmodule-map-file=\"#{clang_modulemap_path_expr}\"" unless clang_modulemap_path_expr.nil?
67
72
  end
68
73
 
69
74
  def resources
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-spm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thuyen Trinh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-18 00:00:00.000000000 Z
11
+ date: 2024-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -59,6 +59,7 @@ files:
59
59
  - lib/cocoapods-spm/hooks/post_integrate/5.update_settings.rb
60
60
  - lib/cocoapods-spm/hooks/post_integrate/6.update_embed_frameworks_script.rb
61
61
  - lib/cocoapods-spm/hooks/post_integrate/7.update_copy_resources_script.rb
62
+ - lib/cocoapods-spm/macro/config.rb
62
63
  - lib/cocoapods-spm/macro/fetcher.rb
63
64
  - lib/cocoapods-spm/macro/metadata.rb
64
65
  - lib/cocoapods-spm/macro/pod_installer.rb