Class: KZ::KZGlobalHelper
- Inherits:
-
Object
- Object
- KZ::KZGlobalHelper
- Defined in:
- lib/cocoapods-kz/helpers/kz_global_helper.rb
Constant Summary collapse
- @@instance =
nil
Instance Attribute Summary collapse
-
#arm64_simulator ⇒ Object
Returns the value of attribute arm64_simulator.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#disable_generate_framework ⇒ Object
Returns the value of attribute disable_generate_framework.
-
#generate_kz_pod_targets ⇒ Object
Returns the value of attribute generate_kz_pod_targets.
-
#kz_analyzer ⇒ Object
Returns the value of attribute kz_analyzer.
-
#kz_config_lock ⇒ Object
Returns the value of attribute kz_config_lock.
-
#kz_generator ⇒ Object
Returns the value of attribute kz_generator.
-
#kz_pod_config ⇒ Object
Returns the value of attribute kz_pod_config.
-
#kz_pod_enable ⇒ Object
Returns the value of attribute kz_pod_enable.
-
#on_demand_resources_info ⇒ Object
Returns the value of attribute on_demand_resources_info.
-
#specify_pod_mode ⇒ Object
Returns the value of attribute specify_pod_mode.
-
#specify_pod_names ⇒ Object
Returns the value of attribute specify_pod_names.
Class Method Summary collapse
Instance Method Summary collapse
- #analyze_special_parameters(use_code_tag, use_framework_tag, pod_names) ⇒ Object
- #check_and_copy_flex_compiler ⇒ Object
- #handle_flexCompiler ⇒ Object
- #have_flexLib_pod_target ⇒ Object
-
#initialize ⇒ KZGlobalHelper
constructor
A new instance of KZGlobalHelper.
- #olde_lock_file_content ⇒ Object
- #pod_config_result_with_target(kz_pod_target) ⇒ Object
- #prepare ⇒ Object
- #write_lock_file ⇒ Object
Constructor Details
#initialize ⇒ KZGlobalHelper
Returns a new instance of KZGlobalHelper.
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 77 def initialize @kz_pod_enable = false @specify_pod_mode = :kz_pod_origin_mode @pods_config_cache = {} @debug = false @kz_config_lock = {} @disable_generate_framework = false @generate_kz_pod_targets = false @olde_lock_file_content = nil @arm64_simulator = false @on_demand_resources_info = KZOnDemandResourcesInfo.new end |
Instance Attribute Details
#arm64_simulator ⇒ Object
Returns the value of attribute arm64_simulator.
72 73 74 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 72 def arm64_simulator @arm64_simulator end |
#debug ⇒ Object
Returns the value of attribute debug.
68 69 70 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 68 def debug @debug end |
#disable_generate_framework ⇒ Object
Returns the value of attribute disable_generate_framework.
70 71 72 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 70 def disable_generate_framework @disable_generate_framework end |
#generate_kz_pod_targets ⇒ Object
Returns the value of attribute generate_kz_pod_targets.
71 72 73 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 71 def generate_kz_pod_targets @generate_kz_pod_targets end |
#kz_analyzer ⇒ Object
Returns the value of attribute kz_analyzer.
64 65 66 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 64 def kz_analyzer @kz_analyzer end |
#kz_config_lock ⇒ Object
Returns the value of attribute kz_config_lock.
69 70 71 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 69 def kz_config_lock @kz_config_lock end |
#kz_generator ⇒ Object
Returns the value of attribute kz_generator.
65 66 67 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 65 def kz_generator @kz_generator end |
#kz_pod_config ⇒ Object
Returns the value of attribute kz_pod_config.
63 64 65 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 63 def kz_pod_config @kz_pod_config end |
#kz_pod_enable ⇒ Object
Returns the value of attribute kz_pod_enable.
62 63 64 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 62 def kz_pod_enable @kz_pod_enable end |
#on_demand_resources_info ⇒ Object
Returns the value of attribute on_demand_resources_info.
73 74 75 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 73 def on_demand_resources_info @on_demand_resources_info end |
#specify_pod_mode ⇒ Object
Returns the value of attribute specify_pod_mode.
67 68 69 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 67 def specify_pod_mode @specify_pod_mode end |
#specify_pod_names ⇒ Object
Returns the value of attribute specify_pod_names.
66 67 68 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 66 def specify_pod_names @specify_pod_names end |
Class Method Details
.instance ⇒ Object
98 99 100 101 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 98 def self.instance FileUtils.mkdir_p(KZ_POD_CONFIG_ROOT) unless File.exist?(KZ_POD_CONFIG_ROOT) @@instance ||= new end |
Instance Method Details
#analyze_special_parameters(use_code_tag, use_framework_tag, pod_names) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 163 def analyze_special_parameters(use_code_tag, use_framework_tag, pod_names) specify_pod_names = [] if pod_names.count > 0 pod_names.each do |param| if param.include?(',') specify_pod_names.concat(param.split(",")) else specify_pod_names << param end end end @specify_pod_names = specify_pod_names if use_code_tag @specify_pod_mode = :kz_pod_code_mode elsif use_framework_tag @specify_pod_mode = :kz_pod_framework_mode end end |
#check_and_copy_flex_compiler ⇒ Object
198 199 200 201 202 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 198 def check_and_copy_flex_compiler @kz_analyzer.all_kz_pod_targets.values.each do |target| return true if target.root_name == 'FlexLib' || target.root_name == 'KZSwiftUI' end end |
#handle_flexCompiler ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 145 def handle_flexCompiler flexlib_info = @kz_analyzer.pod_of_flexlib_info FileUtils.rm(FLEX_COMPLIER_PATH) if File.exist?(FLEX_COMPLIER_PATH) if flexlib_info.have_flexLib_pod if flexlib_info.flexLib_version.major >= 4 KZLog.log("当前使用Flexlib使用4.0及以上版本,xml解析器使用新版", :info) FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler_V1', FLEX_COMPLIER_PATH) else KZLog.log("当前使用Flexlib使用4.0以下版本,xml解析器使用旧版", :info) FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', FLEX_COMPLIER_PATH) end elsif flexlib_info.have_kzswiftui_pod KZLog.log("当前使用KZSwiftUI,xml解析器使用新版", :info) FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler_V1', FLEX_COMPLIER_PATH) end system("chmod +x #{FLEX_COMPLIER_PATH}") if File.exist?(FLEX_COMPLIER_PATH) end |
#have_flexLib_pod_target ⇒ Object
194 195 196 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 194 def have_flexLib_pod_target return @kz_analyzer.pod_of_flexlib_info.have_kzswiftui_pod || @kz_analyzer.pod_of_flexlib_info.have_flexLib_pod end |
#olde_lock_file_content ⇒ Object
226 227 228 229 230 231 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 226 def olde_lock_file_content if File.exist?(KZ_LOCK_FILE_PATH) @olde_lock_file_content ||= JSON.parse(File.read(KZ_LOCK_FILE_PATH)) end @olde_lock_file_content end |
#pod_config_result_with_target(kz_pod_target) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 182 def pod_config_result_with_target(kz_pod_target) return nil unless @kz_pod_enable return nil unless kz_pod_target && kz_pod_target.config_pod_mode == :kz_pod_framework_mode return @pods_config_cache[kz_pod_target.name] if @pods_config_cache.has_key?(kz_pod_target.name) result = KZFrameworkManager.validate_framework_and_get_result(kz_pod_target) @pods_config_cache[kz_pod_target.name] = result if result result end |
#prepare ⇒ Object
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 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 103 def prepare if Pod::Config.instance.podfile && Pod::Config.instance.podfile.plugins.has_key?("cocoapods-kz") @kz_pod_enable = true @generate_kz_pod_targets = true if olde_lock_file_content == nil || olde_lock_file_content['version'] != KZ_POD_CONFIG_VERSION FileUtils.rm_rf(KZ_POD_CONFIG_ROOT) FileUtils.mkdir_p(KZ_POD_CONFIG_ROOT) end FileUtils.mkdir_p(KZ_POD_CONFIG_SUPPORT_FILES) unless File.exist?(KZ_POD_CONFIG_SUPPORT_FILES) FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TARGETS) unless File.exist?(KZ_POD_CONFIG_POD_TARGETS) FileUtils.rm_rf(KZ_POD_CONFIG_POD_TEMPDIR) if File.exist?(KZ_POD_CONFIG_POD_TEMPDIR) FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TEMPDIR) FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_generate_framework.sh', KZ_GENERATE_FRAMEWORK_PATH) system("chmod +x #{KZ_GENERATE_FRAMEWORK_PATH}") FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_xml_build.sh', KZ_XML_BUILD_PATH) system("chmod +x #{KZ_XML_BUILD_PATH}") FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_fix_force_load_exe.sh', KZ_FIX_FORCE_LOAD_EXE) system("chmod +x #{KZ_FIX_FORCE_LOAD_EXE}") FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_refresh_pods_pbxproj.rb', KZ_FEFRESH_PODS_PBXPROJ) FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_improve_custom_yaml.sh', KZ_IMPROVE_CUSTOM_YAML_PATH) system("chmod +x #{KZ_IMPROVE_CUSTOM_YAML_PATH}") Pod::Config.instance.podfile.use_frameworks!(:linkage => :static) FileUtils.rm_r(KZ_ON_DEMAND_RESOURCES) if File.exist?(KZ_ON_DEMAND_RESOURCES) if on_demand_resources_info.enable FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/on_demand_resources/', KZ_ON_DEMAND_RESOURCES) system("chmod +x #{KZ_ON_DEMAND_RESOURCES_SHELL}") end KZLog.log("cocoapods-kz已启用,已完成环境配置", :success) else @kz_pod_enable = false @generate_kz_pod_targets = false end end |
#write_lock_file ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 204 def write_lock_file self.kz_analyzer.all_kz_pod_targets.values.each do |kz_pod_target| result = pod_config_result_with_target(kz_pod_target) @kz_config_lock['version'] = KZ_POD_CONFIG_VERSION @kz_config_lock['pod_targets'] ||= {} @kz_config_lock['pod_targets'][kz_pod_target.name] ||= {} @kz_config_lock['pod_targets'][kz_pod_target.name]["dev_pod"] = kz_pod_target.is_dev_pod @kz_config_lock['pod_targets'][kz_pod_target.name]["use_framework"] = (result != nil) @kz_config_lock['pod_targets'][kz_pod_target.name]["version"] = kz_pod_target.version end if @kz_config_lock.count > 0 lock_file_content = JSON.pretty_generate(@kz_config_lock) File.open(KZ_LOCK_FILE_PATH, 'w') do |file| file.write(lock_file_content) end KZLog.log("Lock File文件保存成功", :success) end end |