cocoapods-jsource 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84f411236d55c44d8e5ded06d8c13833fb30b2012357041dba72ad0d4abea1e5
4
- data.tar.gz: fe0c3f61fde6e36456b6e87d52169a33ad0cf11846f19d4d587b1b1d8e43a396
3
+ metadata.gz: a1f41012354f907c69ab430275b225d557aae7816be39059850418b839aafda6
4
+ data.tar.gz: 8f1e481b717aae28942f3e153da93e147499524c883fc6c3fd11f664044d491f
5
5
  SHA512:
6
- metadata.gz: 0a7d9681ba01c2f683f137c22d70a69b4c917419e7d106d4013b8a6f4067260779f3d6432425c5ed811e3a958c48f2e0a160dae4dcc3f8e13a1037b40458960c
7
- data.tar.gz: 32feba2d0eaebbc6e2624412bba5cb950f26b649d06a35f39f08e9fafa081b0d2e8c5d66d1a66601502733b216083fa9043d64869efc0065d99ae928041d817c
6
+ metadata.gz: 6113c095233da159a99fad3311a1c999e377e64b4eaf4835ae3a5d7cedf687b0d8b0294c8c8e5cc8e66176b11d6b43d41f68bff094a90ec2cd029f9cad9d9733
7
+ data.tar.gz: dcf0a3f39a72152b9b985cb83340f85a487e0f4c1a6aaf27783eef3f95622514c1ec97525b8802921086ac076480fe0dadc8f5e3255f64c07be0ce6686a60643
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-jsource (0.0.1)
4
+ cocoapods-jsource (0.0.2)
5
5
  cocoapods
6
6
 
7
7
  GEM
@@ -45,23 +45,30 @@ module Pod
45
45
  pod_cache_dict = cache_dict[component_name]
46
46
  end
47
47
  version = component_version component_name
48
+ if version.length == 0
49
+ UI.puts "#{component_name} 找不到对应的版本信息,不做任何处理"
50
+ next
51
+ end
48
52
  if pod_cache_dict.has_key? version
49
- UI.puts "#{component_name} #{version} 已经存在,缓存为 #{pod_cache_dict[version][:source]}"
53
+ UI.puts "#{component_name} #{version} 已经存在,缓存为 #{pod_cache_dict[version][:sourcelist].to_s}"
50
54
  next
51
55
  end
52
56
  git = @gits[index]
53
- source_path = get_source_path_from_binary component_name
54
- if source_path.length >0 and version
57
+ # 获取subspec
58
+ source_file_list = get_source_file_list_from_binary(component_name)
59
+ if source_file_list.length == 0
60
+ UI.puts "#{component_name} 找不到对应的二进制,不做任何处理"
61
+ next
62
+ end
63
+ UI.puts "开始下载源码..."
64
+ for source_path in source_file_list
55
65
  create_working_directory source_path
56
- cmd ="git clone -b #{component_name}-#{version} --depth 1 #{git} #{source_path}/#{component_name} >/dev/null 2>&1"
57
- # UI.puts "执行:#{cmd}"
66
+ cmd ="git clone -b #{component_name}-#{version} --depth 1 #{git} #{source_path} >/dev/null 2>&1"
58
67
  `#{cmd}`
59
- pod_cache_dict[version] = {"git":git,"source":source_path,"version":version}
60
- cache_dict[component_name] = pod_cache_dict
61
- UI.puts "#{component_name} 源码创建成功,目录为 #{source_path}"
62
- else
63
- UI.puts "#{component_name} 找不到二进制组件或者找不到对应的版本信息,不做任何处理"
64
68
  end
69
+ pod_cache_dict[version] = {"git":git, "sourcelist":source_file_list, "version":version}
70
+ cache_dict[component_name] = pod_cache_dict
71
+ UI.puts "#{component_name} 源码创建成功,目录为 #{source_file_list.to_s}"
65
72
  index = index + 1
66
73
  end
67
74
  dump_to_yaml cache_dict
@@ -82,37 +89,45 @@ module Pod
82
89
  end
83
90
 
84
91
  # 根据组件名获取组件的源码调试地址
85
- def get_source_path_from_binary(component_name)
86
- source_path = ""
92
+ def get_source_file_list_from_binary(component_name)
93
+ source_file_list = []
87
94
  component_pod_path = config.sandbox_root + component_name
88
- binary_path_list = `find #{component_pod_path} -name "#{component_name}" -type f`.strip.split("\n").sort
89
- if binary_path_list.length > 0
90
- binary_file = binary_path_list[0]
91
- source_path_list = `dwarfdump -arch x86_64 #{binary_file} | grep 'DW_AT_name.*#{component_name}'`.strip.split("\n").sort
95
+ binary_path_list = `find #{component_pod_path} -name "#{component_name}*" -type l`.strip.split("\n").sort
96
+ binary_hash = {}
97
+ for path in binary_path_list
98
+ name = path.to_s.strip.split("/")[-1]
99
+ if name.to_s.include? ".a" or not name.to_s.include? "."
100
+ binary_hash[name]=path unless binary_hash.has_key? name
101
+ end
102
+ end
103
+ if binary_hash.length == 0
104
+ UI.puts "#{component_name} 找不到二进制组件或者找不到对应的版本信息,不做任何处理"
105
+ return source_file_list
106
+ end
107
+
108
+ binary_hash.each do |binary_name, binary_path|
109
+ libbinary_file_name = "lib#{component_name}.a"
110
+ source_path_list = []
111
+ UI.puts "正在解析二进制#{binary_path}源码位置"
112
+ if binary_name.to_s.end_with? libbinary_file_name
113
+ # .a 文件
114
+ source_path_list = `dwarfdump -arch x86_64 #{binary_path} | grep 'AT_name.*#{binary_name}'`.strip.split("\n").sort
115
+ else
116
+ # framework 文件
117
+ source_path_list = `dwarfdump -arch x86_64 #{binary_path} | grep 'DW_AT_name.*#{binary_name}'`.strip.split("\n").sort
118
+ end
92
119
  source_path_list.each do |tmp_source_path|
93
- if tmp_source_path.include?("Pods/#{component_name}")
94
- source_path = tmp_source_path.strip.split("(\"")[-1].split(component_name)[0]
120
+ if tmp_source_path.include?("Pods/#{binary_name}")
121
+ source_path = tmp_source_path.strip.split("(\"")[-1].split(binary_name)[0] + "#{binary_name}"
122
+ source_file_list << source_path if source_path.to_s.length > 0
95
123
  break
96
124
  end
97
125
  end
98
- else
99
- # 可能是.a
100
- binary_file_name = "lib#{component_name}.a"
101
- binary_path_list = `find #{component_pod_path} -name "#{binary_file_name}" -type f`.strip.split("\n").sort
102
- if binary_file_name.length > 0
103
- binary_file = binary_path_list[0]
104
- source_path_list = `dwarfdump -arch x86_64 #{binary_file} | grep 'AT_name.*#{component_name}'`.strip.split("\n").sort
105
- source_path_list.each do |tmp_source_path|
106
- if tmp_source_path.include?("Pods/#{component_name}")
107
- source_path = tmp_source_path.strip.split("(\"")[-1].split("component_name")[0]
108
- break
109
- end
110
- end
111
- end
112
126
  end
113
- source_path
127
+ source_file_list
114
128
  end
115
129
 
130
+
116
131
  # 创建源码的存放的目录,可能需要root权限
117
132
  def create_working_directory(source_path)
118
133
  parent = source_path.split("T")[0]
@@ -70,7 +70,13 @@ module Pod
70
70
  #
71
71
  def remove_caches(cache_descriptors)
72
72
  cache_descriptors.each do |desc|
73
- UI.puts "Removing cache #{desc[:source]} (#{desc[:version]})"
73
+ sourcelist = desc[:sourcelist]
74
+ next if sourcelist.length == 0
75
+ sourcelist.each do |source|
76
+ UI.puts "Removing cache #{source} (#{desc[:version]})"
77
+ parent = source.split("Pods")[0]
78
+ FileUtils.rm_rf(parent) if File.exist? parent
79
+ end
74
80
  if @cache_dict[@pod_name].has_key? desc[:version]
75
81
  if @cache_dict[@pod_name].length == 1
76
82
  @cache_dict.delete @pod_name
@@ -78,8 +84,6 @@ module Pod
78
84
  @cache_dict[@pod_name].delete (desc[:version]) if @cache_dict[@pod_name].has_key? desc[:version]
79
85
  end
80
86
  end
81
- parent = File.dirname desc[:source]
82
- FileUtils.rm_rf(parent) if File.exist? parent
83
87
  end
84
88
  end
85
89
 
@@ -89,11 +93,14 @@ module Pod
89
93
  git=""
90
94
  source=""
91
95
  git=pod_dict[:git] if pod_dict.has_key? :git
92
- source=pod_dict[:source] if pod_dict.has_key? :source
93
- UI.message("Removing the #{pod_name} jsource cache dir #{cache_dir}") do
94
- parent = File.dirname source
95
- FileUtils.rm_rf(parent) if File.exist? parent
96
+ sourcelist=pod_dict[:sourcelist] if pod_dict.has_key? :sourcelist
97
+ sourcelist.each do |source|
98
+ UI.message("Removing the #{pod_name} jsource cache dir #{cache_dir}") do
99
+ parent = source.split("Pods")[0]
100
+ FileUtils.rm_rf(parent) if File.exist? parent
101
+ end
96
102
  end
103
+
97
104
  end
98
105
  end
99
106
  UI.message("Removing the jsource configuration dir #{cache_file}") do
@@ -1,3 +1,3 @@
1
1
  module CocoapodsJsource
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- `cd /Users/handa/Documents/test/testZSource;pod jsource add --names=LJCache --gits=http://gerrit.lianjia.com/mobile_ios/LJCache`
2
+ `cd /Users/handa/Documents/lianjia/C/lianjia_ios_platc;pod jsource add --names=Lianjia_Beike_Home --gits=http://gerrit.lianjia.com/mobile_ios/Lianjia_Beike_Home`
3
3
 
4
4
 
5
5
  # `cd /Users/handa/Documents/test/testZSource;pod jsource list`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-jsource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - handa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-15 00:00:00.000000000 Z
11
+ date: 2019-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods