cocoapods-podspec-binary 0.0.2 → 0.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: e577e29dc2968b4ae3fa28ca13146e1125644a0c2b73590886d77798ff8f4d6d
4
- data.tar.gz: 8d6c0451acf9fe9288775f98ecbaf247b1ba34d0a63332276bf688fd93f745c8
3
+ metadata.gz: a707c45e3a241257145669a488280b89c94d5dcdb876d2785729769be26aeb36
4
+ data.tar.gz: d80296da812976f9ed81a638efd5bf98c3470e666a5d9e8e4824306c3bb0d327
5
5
  SHA512:
6
- metadata.gz: 31fa892c3ef8edca940e7b7c434b5952c2eb655feb122c8ddb4cae9dabd5f20b0ac44d4b3451eb873f6208cb8b64f8335fd2fe602202e9bcbabc563f633d0c0f
7
- data.tar.gz: 43e98f93f0ffc1931be88d2a93bbb90ac87e09e5080e2d7f352f0dac9b680b7bffe8482a7992b7771466627f6d5b911d460ea4b6a50113666b941e0d552382dc
6
+ metadata.gz: cab2706fad887f1f3ae8e162772534e4073801e4d628ac51899df6855f1ec44d94c23b5a22c8a8f8546ddc8c53f982c2200bc73476d3324c20f77d83b447270c
7
+ data.tar.gz: 19634aaa4c56e96b3653e1708bfc35b3b6c14eb91525661a992d3b8631a6c5eb14dd06152abee60ebb1be7d8e195dc8a9a4a761077f0015f6a3c60bc9575348b
@@ -42,6 +42,7 @@ module Pod
42
42
  @pod_version = argv.shift_argument
43
43
  @config_instance = MBuildConfig.instance
44
44
  @build_dir = @config_instance.mbuild_dir
45
+ @sources = argv.option('sources')
45
46
  super
46
47
  end
47
48
 
@@ -49,7 +50,7 @@ module Pod
49
50
  [
50
51
  ['--framework', 'Used to generate the framework '],
51
52
  ['--xcframework', 'Used to generate the xcframework '],
52
- ['--sources', 'The sources from which to pull dependent pods ']
53
+ ['--sources=[sources]', 'The sources from which to pull dependent pods ']
53
54
  ].concat(super).reject { |(name, _)| name == 'name' }
54
55
  end
55
56
 
@@ -61,12 +62,10 @@ module Pod
61
62
  end
62
63
 
63
64
  def prepare
64
- puts 'prepare begin'
65
65
  init_config
66
66
  MBuildFileUtils.create_folder(@build_dir)
67
67
  Dir.chdir(@build_dir)
68
68
  BuildProject.new.prepare_project
69
- puts 'prepare end'
70
69
  end
71
70
 
72
71
  def init_config
@@ -77,6 +76,10 @@ module Pod
77
76
  @config_instance.command_config(@pod_name, @pod_version)
78
77
  end
79
78
  @config_instance.library_type = @xcframework ? BinaryType::XCFRAMEWORK : BinaryType::FRAMEWORK
79
+ puts "Preparing to generate the binary version of #{@pod_name}:#{@pod_version}."
80
+ return unless @sources
81
+
82
+ @config_instance.sources = @sources
80
83
  end
81
84
 
82
85
  def generate_project
@@ -84,16 +87,21 @@ module Pod
84
87
  end
85
88
 
86
89
  def build_binary
87
- project_dir = File.join(@build_dir, 'project')
90
+ puts "Commencing the build of #{@pod_name}:#{@pod_version}."
91
+ project_dir = File.join(@build_dir, 'BinaryProj/Example')
88
92
  Dir.chdir(project_dir)
89
93
  binary_type = @xcframework ? BinaryType::XCFRAMEWORK : BinaryType::FRAMEWORK
90
94
  build_binary = BuildBinary.new(binary_type)
91
95
  build_binary.build
96
+ puts "The successful build of the #{@pod_name}:#{@pod_version} #{@binary_type}."
92
97
  end
93
98
 
94
99
  def export_binary
100
+ puts 'Exporting binary files.'
95
101
  export_dir = @config_instance.root_dir
96
- FileUtils.cp_r("#{@build_dir}/#{@pod_name}", export_dir)
102
+ FileUtils.cp_r("#{@build_dir}/#{@pod_name}-#{@pod_version}", export_dir)
103
+ FileUtils.rm_rf("#{@build_dir}/#{@pod_name}-#{@pod_version}")
104
+ puts 'Task execution completed.'
97
105
  end
98
106
  end
99
107
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPodspecBinary
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -56,14 +56,16 @@ class BuildBinary
56
56
  end
57
57
 
58
58
  def generate_final_binary(framework)
59
- binary_dir = "#{@config_instance.mbuild_dir}/#{@pod_name}"
60
- Dir.mkdir(binary_dir) if Dir.exist? binary_dir
59
+ binary_dir = "#{@config_instance.mbuild_dir}/#{@pod_name}-#{@pod_version}"
60
+ Dir.mkdir(binary_dir) unless Dir.exist? binary_dir
61
61
  FileUtils.cp_r(framework, binary_dir)
62
+ podspec_file = "#{Dir.pwd}/#{@pod_name}.podspec.json"
63
+ FileUtils.cp_r(podspec_file, binary_dir)
62
64
  end
63
65
 
64
66
  def generate_cache_file
65
- binary_dir = "#{@config_instance.mbuild_dir}/#{@pod_name}/Podfile.lock"
66
- FileUtils.cp_r("#{@config_instance.mbuild_dir}/project/Podfile.lock", binary_dir)
67
+ binary_dir = "#{@config_instance.mbuild_dir}/#{@pod_name}-#{@pod_version}/Podfile.lock"
68
+ FileUtils.cp_r("#{@config_instance.mbuild_dir}/BinaryProj/Example/Podfile.lock", binary_dir)
67
69
  end
68
70
 
69
71
  private
@@ -9,17 +9,13 @@ module Pod
9
9
  # class
10
10
  class Request
11
11
  old_method = instance_method(:validate!)
12
-
13
12
  define_method(:validate!) do
14
- puts '++++podspec hook+++++'
15
13
  pod_name = MBuildConfig.instance.pod_name
16
14
  pod_version = MBuildConfig.instance.pod_version
17
- puts "#{pod_name}:#{pod_version}"
18
- if !spec.nil? && spec.name == pod_name && spec.version == pod_version
19
- MbuildPodspec.new(spec).generate_podspec
20
- puts 'podspec hook'
15
+ if spec.name == pod_name && spec.version.to_s == pod_version
16
+ podspec_hash = spec.attributes_hash.deep_dup
17
+ Pod::MbuildPodspec.new(podspec_hash).generate_podspec
21
18
  end
22
-
23
19
  old_method.bind(self).call
24
20
  end
25
21
  end
@@ -5,31 +5,34 @@ require 'fileutils'
5
5
  module Pod
6
6
  # generate podspec
7
7
  class MbuildPodspec
8
- def initialize(podspec)
9
- @podspec = podspec
10
- @binary_type = MBuildConfig.instance.binary_type == BinaryType::FRAMEWORK ? 'framework' : 'xcframework'
8
+ def initialize(podspec_hash)
9
+ @binary_type = MBuildConfig.instance.library_type == BinaryType::FRAMEWORK ? 'framework' : 'xcframework'
11
10
  @config_instance = MBuildConfig.instance
12
11
  @pod_name = MBuildConfig.instance.pod_name
13
12
  @pod_version = MBuildConfig.instance.pod_version
14
- @podspec_hash = podspec.attributes_hash.deep_dup
13
+ @podspec_hash = podspec_hash
15
14
  end
16
15
 
17
16
  def generate_podspec
18
17
  binary_spec_version
18
+ binary_spec_source
19
19
  binary_spec_framework
20
20
  binary_spec_lib
21
21
  binary_spec_public_header_files
22
22
  binary_private_header_files
23
-
24
23
  write_podspec_to_file
25
- puts 'Generated podspec'
26
24
  end
27
25
 
28
26
  private
29
27
 
30
28
  def write_podspec_to_file
29
+ podspec_file = "#{Dir.pwd}/#{@pod_name}.podspec.json"
31
30
  podspec_json = JSON.pretty_generate(@podspec_hash)
32
- File.write("#{Dir.pwd}/#{@pod_name}.podspec.json", podspec_json)
31
+ File.write(podspec_file, podspec_json)
32
+ end
33
+
34
+ def binary_spec_source
35
+ @podspec_hash['source'] = { 'http': 'The location where files are stored' }
33
36
  end
34
37
 
35
38
  def binary_spec_version
@@ -60,7 +63,9 @@ module Pod
60
63
  end
61
64
 
62
65
  def binary_spec_public_header_files
63
- @podspec_hash.slice!('default_subspecs', 'source_files', 'public_header_files')
66
+ @podspec_hash.delete('default_subspecs') if @podspec_hash.key?('default_subspecs')
67
+ @podspec_hash.delete('source_files') if @podspec_hash.key?('source_files')
68
+ @podspec_hash.delete('public_header_files') if @podspec_hash.key?('public_header_files')
64
69
  @podspec_hash['public_header_files'] = "#{@pod_name}/Headers/*.h"
65
70
  end
66
71
  end
@@ -6,17 +6,18 @@ require 'cocoapods'
6
6
  class BuildProject
7
7
  def initialize
8
8
  @config_instance = MBuildConfig.instance
9
- @project_dir = File.join(MBuildConfig.instance.mbuild_dir, 'project')
9
+ @project_dir = File.join(MBuildConfig.instance.mbuild_dir, 'BinaryProj/Example')
10
10
  end
11
11
 
12
12
  def prepare_project
13
- example_dir = @project_dir
13
+ example_dir = File.join(MBuildConfig.instance.mbuild_dir, 'BinaryProj')
14
14
  if File.directory?(example_dir)
15
15
  Git.open(example_dir).reset_hard
16
+ Git.open(example_dir).clean(force: true)
16
17
  Git.open(example_dir).pull
17
18
  else
18
19
  MBuildFileUtils.create_folder(@project_dir)
19
- example_url = 'ssh://git@gitlab.huolala.cn:56358/group-wp-sdk/binary-example-ios.git'
20
+ example_url = 'git@github.com:HuolalaTech/hll-cocoapods-podspec-binary.git'
20
21
  Git.clone(example_url, example_dir)
21
22
  end
22
23
  end
@@ -33,10 +34,11 @@ class BuildProject
33
34
  podfile_content = File.read(podfile_path)
34
35
  pod_name = @config_instance.pod_name
35
36
  pod_version = @config_instance.pod_version
36
- puts("name:#{pod_name} version:#{pod_version}")
37
- new_content = podfile_content.gsub('BINARY_NAME', pod_name).gsub('BINARY_VERSION', pod_version).gsub(
38
- 'cocoapods-mdapbox', 'cocoapods-podspec-binary'
39
- )
37
+ new_content = podfile_content.gsub('BINARY_NAME', pod_name).gsub('BINARY_VERSION', pod_version)
38
+ if @config_instance.sources
39
+ new_content.prepend(@config_instance.sources.split(',').map { |it| "source \"#{it.strip}\"\n" }.join)
40
+ end
41
+
40
42
  File.open(podfile_path, 'w') { |file| file.puts new_content }
41
43
  end
42
44
 
@@ -5,15 +5,12 @@ require 'zlib'
5
5
  # FileUtils: A utility class for file operations.
6
6
  class MBuildFileUtils
7
7
  def self.create_folder(folder_path)
8
- if File.directory?(folder_path)
9
- puts 'Folder already exists.'
10
- else
11
- begin
12
- Dir.mkdir(folder_path)
13
- puts 'Folder created successfully!'
14
- rescue SystemCallError => e
15
- puts "Error creating folder: #{e.message}"
16
- end
8
+ return if File.directory?(folder_path)
9
+
10
+ begin
11
+ Dir.mkdir(folder_path)
12
+ rescue SystemCallError => e
13
+ puts "Error creating folder: #{e.message}"
17
14
  end
18
15
  end
19
16
 
@@ -4,5 +4,6 @@
4
4
  require 'cocoapods-podspec-binary'
5
5
  require 'cocoapods-podspec-binary/command/mbuild'
6
6
  require 'cocoapods-podspec-binary/mbuild/mbuild_hook'
7
+ require 'cocoapods-podspec-binary/mbuild/mbuild_podspec'
7
8
  require 'cocoapods-podspec-binary/utils/file_utils'
8
9
  require 'cocoapods-podspec-binary/utils/git_utils'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-podspec-binary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - pengpeng.dai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-06 00:00:00.000000000 Z
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler