Module: Pindo::CommonConfuseProj
- Includes:
- Hashhelper
- Included in:
- Pindo::Command::Deploy::Confusecode, Pindo::Command::Deploy::Confuseproj, Pindo::Command::Dev::Confusecode, Pindo::Command::Dev::Confuseproj
- Defined in:
- lib/pindo/module/build/commonconfuseproj.rb
Instance Method Summary collapse
- #_load_symash_plugin(clang_path: nil) ⇒ Object
- #_push_symash_arg(key, value) ⇒ Object
- #config_confuse_project(clang_path: nil, project_name: nil, project_path: nil, default_type: "symash1") ⇒ Object
- #config_symash(clang_path: nil, project_path: nil, confuse_type: nil, default_type: "symash1") ⇒ Object
- #confuse_version_type(path: nil, default_type: "symash1") ⇒ Object
- #external_sources(yaml_file: nil) ⇒ Object
- #install_symash(clang_path: nil) ⇒ Object
- #process_config_setting(clang_path: nil, config: nil, default_type: "symash1") ⇒ Object
- #process_root_setting(clang_path: nil, root_object: nil, default_type: "symash1") ⇒ Object
- #update_symash_config(app_config_dir: nil, project_path: nil, confuse_type: nil, force_config: nil) ⇒ Object
Methods included from Hashhelper
#deepcopy_hash, #deepcopy_hash_struct, #init_hash_value_wihtout_add_key, #init_hash_value_wihtout_exludekeys, #minus_hash
Instance Method Details
#_load_symash_plugin(clang_path: nil) ⇒ Object
20 21 22 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 20 def _load_symash_plugin(clang_path:nil) return " -Xclang -load -Xclang #{clang_path}/lib/symasher.dylib -Xclang -add-plugin -Xclang aocsr" end |
#_push_symash_arg(key, value) ⇒ Object
24 25 26 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 24 def _push_symash_arg(key, value) return " -Xclang -plugin-arg-aocsr -Xclang #{key}=#{value}" end |
#config_confuse_project(clang_path: nil, project_name: nil, project_path: nil, default_type: "symash1") ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 148 def config_confuse_project(clang_path:nil, project_name:nil, project_path:nil, default_type:"symash1") project_fullname = File.join(project_path, project_name) + ".xcodeproj" project_obj = Xcodeproj::Project.open(project_fullname) external_sources(yaml_file:File.join(project_path, "Pods/Manifest.lock")) # process_root_setting(clang_path:clang_path,root_object:project_obj.root_object, default_type:default_type) project_obj.targets.each do |target| # if target.symbol_type.to_s == "application" target.build_configurations.each do |config| process_config_setting(clang_path:clang_path, config:config, default_type:default_type) end # end end project_obj.save pods_proj_fullname = File.join(project_path, "Pods", "Pods") + ".xcodeproj" if File.exist?(pods_proj_fullname) pods_project_obj = Xcodeproj::Project.open(pods_proj_fullname) process_root_setting(clang_path:clang_path,root_object:project_obj.root_object, default_type:default_type) # process_root_setting(clang_path:clang_path, root_object:pods_project_obj.root_object, default_type:default_type) pods_project_obj.targets.each do |target| target.build_configurations.each do |config| process_config_setting(clang_path:clang_path, config:config, default_type:default_type) end end pods_project_obj.save end end |
#config_symash(clang_path: nil, project_path: nil, confuse_type: nil, default_type: "symash1") ⇒ Object
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 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 81 def config_symash(clang_path:nil, project_path:nil, confuse_type:nil, default_type:"symash1") FileUtils.cp_r(File.join(clang_path, "config", "Symash.json"), project_path) text = File.read(File.join(project_path, "Symash.json")) new_contents = text.gsub(/\"IMPORT\".*/, "\"IMPORT\":false,") new_contents = new_contents.gsub(/\"IGNORE_SYMASH_PROTOCOL\".*/, "\"IGNORE_SYMASH_PROTOCOL\":true,") new_contents = new_contents.gsub(/\"IGNORE_SYMASH_INTERFACE\".*/, "\"IGNORE_SYMASH_INTERFACE\":true,") new_contents = new_contents.gsub(/\"IGNORE_SYMASH_CATEGORY\".*/, "\"IGNORE_SYMASH_CATEGORY\":true,") new_contents = new_contents.gsub(/\"IGNORE_SYMASH_PROPERTY\".*/, "\"IGNORE_SYMASH_PROPERTY\":true,") new_contents = new_contents.gsub(/\"IGNORE_SYMASH_IVAR\".*/, "\"IGNORE_SYMASH_IVAR\":true,") new_contents = new_contents.gsub(/\"IGNORE_SYMASH_METHOD\".*/, "\"IGNORE_SYMASH_METHOD\":true,") confuse_type_temp = confuse_type # class_method_variable_protocol_property_category puts confuse_type_temp if confuse_type_temp.include? "class" puts "Open Confuse Class!" new_contents = new_contents.gsub(/\"IGNORE_SYMASH_INTERFACE\".*/, "\"IGNORE_SYMASH_INTERFACE\":false,") end if confuse_type_temp.include? "method" puts "Open Confuse Methon" new_contents = new_contents.gsub(/\"IGNORE_SYMASH_METHOD\".*/, "\"IGNORE_SYMASH_METHOD\":false,") end if confuse_type_temp.include? "variable" puts "Open Confuse Variable" new_contents = new_contents.gsub(/\"IGNORE_SYMASH_IVAR\".*/, "\"IGNORE_SYMASH_IVAR\":false,") end if confuse_type_temp.include? "protocol" puts "Open Confuse Protocol" new_contents = new_contents.gsub(/\"IGNORE_SYMASH_PROTOCOL\".*/, "\"IGNORE_SYMASH_PROTOCOL\":false,") end if confuse_type_temp.include? "property" puts "Open Confuse Property" new_contents = new_contents.gsub(/\"IGNORE_SYMASH_PROPERTY\".*/, "\"IGNORE_SYMASH_PROPERTY\":false,") end if confuse_type_temp.include? "category" puts "Open Confuse Category" new_contents = new_contents.gsub(/\"IGNORE_SYMASH_CATEGORY\".*/, "\"IGNORE_SYMASH_CATEGORY\":false,") end new_contents = new_contents.gsub(/\"ENABLE_BACKEND_SYMASH\".*/, "\"ENABLE_BACKEND_SYMASH\":true,") new_contents = new_contents.gsub(/\"ENABLE_BACKEND_SYMASH2\".*/, "\"ENABLE_BACKEND_SYMASH2\":true,") new_contents = new_contents.gsub(/\"ENABLE_DUPLICATE_METHOD\".*/, "\"ENABLE_DUPLICATE_METHOD\":true,") File.open(File.join(project_path, "Symash.json"), "w") {|file| file.puts new_contents } if default_type == "symash1" if File.exist?(File.join(project_path, "SymashCache")) FileUtils.rm_rf(File.join(project_path, "SymashCache")) end FileUtils.mkdir(File.join(project_path, "SymashCache")) else if File.exist?(File.join(project_path, "SymashData")) FileUtils.rm_rf(File.join(project_path, "SymashData")) end FileUtils.mkdir(File.join(project_path, "SymashData")) end end |
#confuse_version_type(path: nil, default_type: "symash1") ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 38 def confuse_version_type(path:nil, default_type:"symash1") symash_type = default_type if File.exist?(File.join(path, "Symash.json")) symash_json = JSON.parse(File.read(File.join(path, "Symash.json"))) if !symash_json.nil? && (symash_json.kind_of? Hash) && symash_json.has_key?('VERSION') if symash_json['VERSION'] == 2 symash_type = "symash2" else symash_type = "symash1" end else symash_type = default_type end else symash_type = default_type end return symash_type end |
#external_sources(yaml_file: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 28 def external_sources(yaml_file:nil) if @external_sources_hash.nil? if File.exist?(yaml_file) manifest_hash = YAML.load_file(yaml_file); external_sources_hash = manifest_hash["EXTERNAL SOURCES"] end end return @external_sources_hash; end |
#install_symash(clang_path: nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 13 def install_symash(clang_path:nil) if File.exist?(File.join(clang_path, 'framework-sync')) puts "Install Symash !!!" system File.join(clang_path, 'framework-sync') end end |
#process_config_setting(clang_path: nil, config: nil, default_type: "symash1") ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 204 def process_config_setting(clang_path:nil, config:nil, default_type:"symash1") # config.build_settings["VALID_ARCHS"] = "arm64 armv7 armv7s" config.build_settings["VALID_ARCHS"] = "arm64" if default_type == "symash1" config.build_settings["CC"] = "#{clang_path}/bin/symasher" else config.build_settings["CC"] = "#{clang_path}/bin/clang" end config.build_settings["ENABLE_BITCODE"] = "NO" macros=config.build_settings["GCC_PREPROCESSOR_DEFINITIONS"] case macros when nil macros = ["$(inherited)"] when String if macros != "$(inherited)" then macros = ["$(inherited)", macros] else macros = ["$(inherited)"] end else end #移除SYMASH_... macros.delete_if { |macro| macro.index("SYMASH_") == 0 } #重新安装 macros << "SYMASH_PODS_ROOT=$(PODS_ROOT)" << "SYMASH_TARGET_NAME=$(TARGET_NAME)" << "__SYMASH_XCODE__" #外部路径 temp_external_hash = @external_sources_hash case temp_external_hash when Hash temp_external_hash.each { |name, source| # 当pod由{:git,:commit}引入时不计为external if source[:path] != nil then macros << "SYMASH_EXTPOD_"+name+"="+source[:path] end } end config.build_settings["GCC_PREPROCESSOR_DEFINITIONS"] = macros setting_item = config.build_settings["OTHER_CFLAGS"] || [] if setting_item == "" setting_item = [] end unless setting_item.to_s.index "inherited" setting_item << "$(inherited)" end # unless setting_item.to_s.index "-fvisibility=hidden" # setting_item << " -fvisibility=hidden" # end config.build_settings["OTHER_CFLAGS"] = setting_item # config.build_settings["OTHER_CPLUSPLUSFLAGS"] = config.build_settings["OTHER_CPLUSPLUSFLAGS"] || [] # config.build_settings["OTHER_CPLUSPLUSFLAGS"] << "$(inherited)" # config.build_settings["OTHER_CPLUSPLUSFLAGS"] << "$(OTHER_CFLAGS)" # config.build_settings["LD"] = "/usr/bin/clang" end |
#process_root_setting(clang_path: nil, root_object: nil, default_type: "symash1") ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 178 def process_root_setting(clang_path:nil, root_object:nil, default_type:"symash1") # root_object.build_configuration_list.set_setting('VALID_ARCHS', "arm64 armv7 armv7s") root_object.build_configuration_list.set_setting('VALID_ARCHS', "arm64") if default_type == "symash1" root_object.build_configuration_list.set_setting('CC', "#{clang_path}/bin/symasher") else root_object.build_configuration_list.set_setting('CC', "#{clang_path}/bin/clang") end root_object.build_configuration_list.set_setting('ENABLE_BITCODE', "NO") origin_config = [] unless origin_config.to_s.index "inherited" origin_config << "$(inherited)" end # unless origin_config.to_s.index "-fvisibility=hidden" # origin_config << " -fvisibility=hidden" # end root_object.build_configuration_list.set_setting('OTHER_CFLAGS', origin_config) end |
#update_symash_config(app_config_dir: nil, project_path: nil, confuse_type: nil, force_config: nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pindo/module/build/commonconfuseproj.rb', line 57 def update_symash_config(app_config_dir:nil, project_path:nil, confuse_type:nil, force_config: nil) if File.exist?(File.join(project_path, "Symash.json")) proj_config_json= JSON.parse(File.read(File.join(project_path, "Symash.json"))) proj_config_json['BACKEND_SYMASH_DISABLE_SPL'] = true if File.exist?(File.join(app_config_dir, "Symash.json")) app_config_json=JSON.parse(File.read(File.join(app_config_dir, "Symash.json"))) proj_config_json = init_hash_value_wihtout_exludekeys(hash1:proj_config_json, hash2:app_config_json, exlude_keys:['VERSION','IMPORT', 'FASTPORT', 'STRICT', 'FASTPORT','IGNORE_SYMASH_MAINPROJ', 'ENABLE_BACKEND_SYMASH', 'ENABLE_BACKEND_SYMASH2', 'CONFUSE_VERSION']) end unless force_config.nil? proj_config_json = init_hash_value_wihtout_exludekeys(hash1:proj_config_json, hash2:force_config, exlude_keys:[]) end File.open(File.join(project_path, "Symash.json"), "w") do |f| f.write(JSON.pretty_generate(proj_config_json)) end end end |