Class: Jxedt::PreInstall

Inherits:
Object
  • Object
show all
Includes:
ObjectSpace
Defined in:
lib/cocoapods-jxedt/binary/hooks/pre_install.rb

Instance Method Summary collapse

Constructor Details

#initialize(installer_context) ⇒ PreInstall

Returns a new instance of PreInstall.



11
12
13
# File 'lib/cocoapods-jxedt/binary/hooks/pre_install.rb', line 11

def initialize(installer_context)
    @installer_context = installer_context
end

Instance Method Details

#log_section(message) ⇒ Object



55
56
57
58
59
# File 'lib/cocoapods-jxedt/binary/hooks/pre_install.rb', line 55

def log_section(message)
    Pod::UI.puts "-----------------------------------------"
    Pod::UI.puts message
    Pod::UI.puts "-----------------------------------------"
end

#runObject



15
16
17
18
19
20
21
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
# File 'lib/cocoapods-jxedt/binary/hooks/pre_install.rb', line 15

def run
    # check binary switch
    return unless Jxedt.config.binary_switch?

    # [Check Environment]
    podfile = @installer_context.podfile
    podfile.target_definition_list.each do |target_definition|
        raise STDERR.puts "[!] Cocoapods-binary requires `use_frameworks!`".red if not target_definition.uses_frameworks?
    end

    require_relative '../helper/prebuild_sandbox'

    # 如果是Pod::PrebuildSandbox类则直接返回
    return if @installer_context.sandbox.is_a?(Pod::PrebuildSandbox)

    # 获取原始的installer对象,必须先获取对象
    original_installer = ObjectSpace.each_object(Pod::Installer).first
    sandbox = Pod::PrebuildSandbox.from_standard_sandbox(@installer_context.sandbox)
    source_installer = Pod::Installer.new(sandbox, @installer_context.podfile, @installer_context.lockfile)
    # 设置原始的installer携带的参数
    source_installer.update = original_installer.update
    source_installer.repo_update =  original_installer.repo_update
    # 执行install
    source_installer.install!

    # 保存首次`pod install`的lockfile结果,用来验证二进制文件和后面做结果校验
    @installer_context.sandbox.source_lockfile = sandbox.source_lockfile = source_installer.lockfile

    require_relative '../helper/podfile_options'
    require_relative '../prebuild'

    # prebuild_job
    log_section "🚀  Prebuild frameworks" if Jxedt.config.prebuild_job?
    Jxedt::Prebuild.new(source_installer).build if Jxedt.config.prebuild_job?

    log_section "🤖  Resume pod installation"
    require_relative '../targets/pod_target'
    require_relative '../Intergation'
end