Class: CBin::BuildAll::Builder

Inherits:
Object
  • Object
show all
Includes:
Pod
Defined in:
lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb

Instance Method Summary collapse

Methods included from Pod

match_version?

Constructor Details

#initialize(pod_target, checkout_sources, skip_simulator = false, configuration = 'Debug') ⇒ Builder

Returns a new instance of Builder.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 8

def initialize(pod_target, checkout_sources, skip_simulator = false, configuration = 'Debug')
  @pod_target = pod_target
  @checkout_sources = checkout_sources
  @skip_simulator = skip_simulator
  @configuration = configuration
  @file_accessors = pod_target.file_accessors unless pod_target.nil?
  @base_dir = "#{Pathname.pwd}/build_pods"
  if PodUpdateConfig.shell_project
    @base_dir = "#{Pathname.pwd}/all_build/Build"
  end
end

Instance Method Details

#buildObject

构建



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 21

def build
  UI.info "编译`#{@pod_target}`".yellow
  dir = result_product_dir
  FileUtils.rm_rf(dir) if File.exist?(dir)
  # 编译模拟器
  unless @skip_simulator
    result = build_pod_target
    return false unless result
  end
  # 编译真机
  build_pod_target(false)
end

#build_as_framework?Boolean

是否以framework形式构建

Returns:

  • (Boolean)


67
68
69
70
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 67

def build_as_framework?
  path = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.framework_name}"
  File.exist?(path)
end

#create_binaryObject

创建binary



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
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 35

def create_binary
  UI.info "创建`#{@pod_target.framework_name}`".yellow
  # 如果是framework需要先copy
  if build_as_framework?
    copy_framework
  else
    create_framework_dir
    copy_headers
    copy_headers(false )
    generate_umbrella_header
    generate_module_map
    compile_resources
    if @pod_target.uses_swift?
      copy_iphoneos_swiftmodules
      copy_simulator_swiftmodules unless @skip_simulator
    end
    if @skip_simulator
      device_lib = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.static_library_name}"
      output = "#{result_product_dir}/#{@pod_target.product_module_name}"
      `cp -f #{device_lib} #{output}`
    end
  end
  # 合并真机模拟器
  merge_device_sim unless @skip_simulator
  # 拷贝资源文件
  copy_resources
  # 拷贝 vendored_frameworks 和 vendored_libraries
  copy_vendored_frameworks
  copy_vendored_libraries
end

#headers_dirObject

xxx.framework/Headers



78
79
80
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 78

def headers_dir
  "#{result_product_dir}/Headers"
end

#iphoneosObject



108
109
110
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 108

def iphoneos
  "#{@configuration}-iphoneos"
end

#iphonesimulatorObject



112
113
114
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 112

def iphonesimulator
  "#{@configuration}-iphonesimulator"
end

#modules_dirObject

xxx.framework/Modules



73
74
75
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 73

def modules_dir
  "#{result_product_dir}/Modules"
end

#private_headers_dirObject

xxx.framework/PrivateHeaders



83
84
85
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 83

def private_headers_dir
  "#{result_product_dir}/PrivateHeaders"
end

#product_dirObject

xxx.framework 所在目录



98
99
100
101
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 98

def product_dir
  @product_dir = "#{@base_dir}/Products"
  @product_dir
end

#reject_resource_extObject

需要排除的资源文件后缀



117
118
119
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 117

def reject_resource_ext
  %w[.xcdatamodeld .xcdatamodel .xcmappingmodel .xib .storyboard]
end

#resources_dirObject

xxx.framework/resources



88
89
90
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 88

def resources_dir
  "#{result_product_dir}/resources"
end

#result_product_dirObject

xxx.framework



93
94
95
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 93

def result_product_dir
  "#{product_dir}/#{@pod_target.framework_name}"
end

#temp_dirObject

构建临时产物目录



104
105
106
# File 'lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb', line 104

def temp_dir
  "#{@base_dir}/#{@pod_target}/Temp"
end