24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/cocoapods-xlbuild/Integration.rb', line 24
def install_for_prebuild!(standard_sanbox)
return if standard_sanbox.local? self.name
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
target_names = prebuild_sandbox.existed_target_names_for_pod_name(self.name)
def walk(path, &action)
return unless path.exist?
path.children.each do |child|
result = action.call(child, &action)
if child.directory?
walk(child, &action) if result
end
end
end
def make_link(source, target, uselink)
source = Pathname.new(source)
target = Pathname.new(target)
target.parent.mkpath unless target.parent.exist?
relative_source = source.relative_path_from(target.parent)
if uselink
FileUtils.ln_sf(relative_source, target)
else
if File.directory?(source)
FileUtils.cp_r source, target, :remove_destination => true
else
FileUtils.cp source, target
end
if not target.exist?
raise "资源导入失败:#{target}"
end
end
end
def mirror_with_symlink(source, basefolder, target_folder, uselink)
target = target_folder + source.relative_path_from(basefolder)
make_link(source, target, uselink)
end
target_names.each do |name|
real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)
target_folder = standard_sanbox.pod_dir(self.name)
if target_names.count > 1
target_folder += real_file_folder.basename
end
target_folder.rmtree if target_folder.exist?
target_folder.mkpath
walk(real_file_folder) do |child|
source = child
if child.directory?
if [".framework"].include? child.extname
mirror_with_symlink(source, real_file_folder, target_folder, true)
next false elsif [".dSYM"].include? child.extname
mirror_with_symlink(source, real_file_folder, target_folder, false)
next false elsif [".bundle"].include? child.extname
mirror_with_symlink(source, real_file_folder, target_folder, false)
next false
else
next true
end
elsif child.file?
mirror_with_symlink(source, real_file_folder, target_folder, false)
next true
else
next true
end
end
hash = Prebuild::Passer.resources_to_copy_for_static_framework || {}
path_objects = hash[name]
if path_objects != nil
path_objects.each do |object|
if object.real_file_path != nil
real_path = Pathname.new(object.target_file_path)
real_path.rmtree if real_path.exist?
make_link(object.real_file_path, object.target_file_path, false)
end
end
end
end
end
|