Class: Pod::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary/helper/feature_switches.rb,
lib/cocoapods-binary/Prebuild.rb,
lib/cocoapods-binary/Integration.rb,
lib/cocoapods-binary/Integration.rb,
lib/cocoapods-binary/helper/podfile_options.rb,
lib/cocoapods-binary/helper/feature_switches.rb

Overview

a option to disable install complete message

Defined Under Namespace

Classes: PodSourceInstaller

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disable_install_complete_message(value) ⇒ Object



70
71
72
# File 'lib/cocoapods-binary/helper/feature_switches.rb', line 70

def self.disable_install_complete_message(value)
    @@disable_install_complete_message = value
end

.force_disable_integration(value) ⇒ Object



55
56
57
# File 'lib/cocoapods-binary/helper/feature_switches.rb', line 55

def self.force_disable_integration(value)
    @@force_disable_integration = value
end

Instance Method Details

#have_exact_prebuild_cache?Boolean

check if need to prebuild

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cocoapods-binary/Prebuild.rb', line 36

def have_exact_prebuild_cache?
    # check if need build frameworks
    return false if local_manifest == nil
    
    changes = prebuild_pods_changes
    added = changes.added
    changed = changes.changed 
    unchanged = changes.unchanged
    deleted = changes.deleted 
    
    unchange_framework_names = (added + unchanged)

    exsited_framework_names = sandbox.exsited_framework_names
    missing = unchanged.select do |pod_name|
        not exsited_framework_names.include?(pod_name)
    end

    needed = (added + changed + deleted + missing)
    return needed.empty?
end

#install_when_cache_hit!Object

The install method when have completed cache



59
60
61
62
63
64
# File 'lib/cocoapods-binary/Prebuild.rb', line 59

def install_when_cache_hit!
    # just print log
    self.sandbox.exsited_framework_names.each do |name|
        UI.puts "Using #{name}"
    end
end

#prebuild_frameworks!Object

Build the needed framework files



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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/cocoapods-binary/Prebuild.rb', line 68

def prebuild_frameworks! 

    # build options
    sandbox_path = sandbox.root
    existed_framework_folder = sandbox.generate_framework_path
    bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled
    targets = []
    
    if local_manifest != nil

        changes = prebuild_pods_changes
        added = changes.added
        changed = changes.changed 
        unchanged = changes.unchanged
        deleted = changes.deleted 
    
        existed_framework_folder.mkdir unless existed_framework_folder.exist?
        exsited_framework_names = sandbox.exsited_framework_names
        
        # deletions
        # remove all frameworks except ones to remain
        unchange_framework_names = (added + unchanged)
        to_delete = exsited_framework_names.select do |framework_name|
            not unchange_framework_names.include?(framework_name)
        end
        to_delete.each do |framework_name|
            path = sandbox.framework_folder_path_for_pod_name(framework_name)
            path.rmtree if path.exist?
        end
    
        # additions
        missing = unchanged.select do |pod_name|
            not exsited_framework_names.include?(pod_name)
        end


        root_names_to_update = (added + changed + missing)

        # transform names to targets
        name_to_target_hash = self.pod_targets.reduce({}) do |sum, target|
            sum[target.name] = target
            sum
        end
        targets = root_names_to_update.map do |root_name|
            name_to_target_hash[root_name]
        end || []

        # add the dendencies
        dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
        targets = (targets + dependency_targets).uniq
    else
        targets = self.pod_targets
    end

    targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }

    
    
    # build!
    Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
    Pod::Prebuild.remove_build_dir(sandbox_path)
    targets.each do |target|
        next unless target.should_build?
        output_path = sandbox.framework_folder_path_for_pod_name(target.name)
        output_path.mkpath unless output_path.exist?
        Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled)
    end            
    Pod::Prebuild.remove_build_dir(sandbox_path)


    # copy vendored libraries and frameworks
    targets.each do |target|
        root_path = self.sandbox.pod_dir(target.name)
        target.spec_consumers.each do |consumer|
            file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
            lib_paths = file_accessor.vendored_frameworks || []
            lib_paths += file_accessor.vendored_libraries
            # @TODO dSYM files
            lib_paths.each do |lib_path|
                relative = lib_path.relative_path_from(root_path)
                destination = sandbox.framework_folder_path_for_pod_name(target.name) + relative
                destination.dirname.mkpath unless destination.dirname.exist?
                FileUtils.cp_r(lib_path, destination, :remove_destination => true)
            end
        end
    end
    
    # Remove useless files
    # only keep manifest.lock and framework folder
    to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
    to_delete_files = sandbox_path.children.select do |file|
        filename = File.basename(file)
        not to_remain_files.include?(filename)
    end
    to_delete_files.each do |path|
        path.rmtree if path.exist?
    end

end

#prebuild_pod_namesObject

the root names who needs prebuild, including dependency pods.



99
100
101
# File 'lib/cocoapods-binary/helper/podfile_options.rb', line 99

def prebuild_pod_names 
   @prebuild_pod_names ||= self.prebuild_pod_targets.map(&:pod_name)
end

#prebuild_pod_targetsObject



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
# File 'lib/cocoapods-binary/helper/podfile_options.rb', line 70

def prebuild_pod_targets

    all = []

    aggregate_targets = self.aggregate_targets.select { |a| a.platform.name != :watchos }
    aggregate_targets.each do |aggregate_target|
        target_definition = aggregate_target.target_definition
        targets = aggregate_target.pod_targets || []

        # filter prebuild
        prebuild_names = target_definition.prebuild_framework_names
        if not Podfile::DSL.prebuild_all
            targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) } 
        end
        dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
        targets = (targets + dependency_targets).uniq

        # filter should not prebuild
        explict_should_not_names = target_definition.should_not_prebuild_framework_names
        targets = targets.reject { |pod_target| explict_should_not_names.include?(pod_target.pod_name) } 

        all += targets
    end

    all = all.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
    all.uniq
end

#remove_target_files_if_neededObject

Remove the old target files if prebuild frameworks changed



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
# File 'lib/cocoapods-binary/Integration.rb', line 57

def remove_target_files_if_needed

    changes = Pod::Prebuild::Passer.prebuild_pods_changes
    updated_names = []
    if changes == nil
        updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_names
    else
        added = changes.added
        changed = changes.changed 
        deleted = changes.deleted 
        updated_names = added + changed + deleted
    end

    updated_names.each do |name|
        root_name = Specification.root_name(name)
        next if self.sandbox.local?(root_name)

        # delete the cached files
        target_path = self.sandbox.pod_dir(root_name)
        target_path.rmtree if target_path.exist?

        support_path = sandbox.target_support_files_dir(root_name)
        support_path.rmtree if support_path.exist?
    end

end