Class: Pod::Installer::PodSourceInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary/Integration.rb

Instance Method Summary collapse

Instance Method Details

#install_for_prebuild!(standard_sanbox) ⇒ Object



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

def install_for_prebuild!(standard_sanbox)
    return if standard_sanbox.local? self.name

    # make a symlink to target folder
    prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
    folder = prebuild_sandbox.framework_folder_path_for_pod_name(self.name)

    target_folder = standard_sanbox.pod_dir(self.name)
    target_folder.rmtree if target_folder.exist?
    target_folder.mkdir

    # make a relatvie symbol link for all children
    def walk(path, &action)
        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, basefolder, target_folder)
        target = target_folder + source.relative_path_from(basefolder)
        target.parent.mkpath unless target.parent.exist?
        relative_source = source.relative_path_from(target.parent)
        FileUtils.ln_sf(relative_source, target)
    end

    walk(folder) do |child|
        source = child
        # only make symlink to file and `.framework` folder
        if child.directory? and child.extname == ".framework"
            make_link(source, folder, target_folder)
            next false  # return false means don't go deeper
        elsif child.file?
            make_link(source, folder, target_folder)
            next true
        else
            next true
        end
    end
end


42
43
44
45
46
47
# File 'lib/cocoapods-binary/Integration.rb', line 42

def make_link(source, basefolder, target_folder)
    target = target_folder + source.relative_path_from(basefolder)
    target.parent.mkpath unless target.parent.exist?
    relative_source = source.relative_path_from(target.parent)
    FileUtils.ln_sf(relative_source, target)
end

#walk(path, &action) ⇒ Object

make a relatvie symbol link for all children



34
35
36
37
38
39
40
41
# File 'lib/cocoapods-binary/Integration.rb', line 34

def walk(path, &action)
    path.children.each do |child|
        result = action.call(child, &action)
        if child.directory?
            walk(child, &action) if result
        end
    end
end