MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _codesign_file

Method _codesign_file

editor/export/codesign.cpp:1191–1517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189}
1190
1191Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const String &p_info, const String &p_exe_path, const String &p_bundle_path, const String &p_ent_path, bool p_ios_bundle, String &r_error_msg) {
1192#define CLEANUP() \
1193 if (files_to_sign.size() > 1) { \
1194 for (int j = 0; j < files_to_sign.size(); j++) { \
1195 da->remove(files_to_sign[j]); \
1196 } \
1197 }
1198
1199 print_verbose(vformat("CodeSign: Signing executable: %s, bundle: %s with entitlements %s", p_exe_path, p_bundle_path, p_ent_path));
1200
1201 PackedByteArray info_hash1, info_hash2;
1202 PackedByteArray res_hash1, res_hash2;
1203 String id;
1204 String main_exe = p_exe_path;
1205
1206 Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
1207 if (da.is_null()) {
1208 r_error_msg = TTR("Can't get filesystem access.");
1209 ERR_FAIL_V_MSG(ERR_CANT_CREATE, "CodeSign: Can't get filesystem access.");
1210 }
1211
1212 // Read Info.plist.
1213 if (!p_info.is_empty()) {
1214 print_verbose("CodeSign: Reading bundle info...");
1215 PList info_plist;
1216 if (info_plist.load_file(p_info)) {
1217 info_hash1 = file_hash_sha1(p_info);
1218 info_hash2 = file_hash_sha256(p_info);
1219 if (info_hash1.is_empty() || info_hash2.is_empty()) {
1220 r_error_msg = TTR("Failed to get Info.plist hash.");
1221 ERR_FAIL_V_MSG(FAILED, "CodeSign: Failed to get Info.plist hash.");
1222 }
1223
1224 if (info_plist.get_root()->data_type == PList::PLNodeType::PL_NODE_TYPE_DICT && info_plist.get_root()->data_dict.has("CFBundleExecutable")) {
1225 main_exe = p_exe_path.path_join(String::utf8(info_plist.get_root()->data_dict["CFBundleExecutable"]->data_string.get_data()));
1226 } else {
1227 r_error_msg = TTR("Invalid Info.plist, no exe name.");
1228 ERR_FAIL_V_MSG(FAILED, "CodeSign: Invalid Info.plist, no exe name.");
1229 }
1230
1231 if (info_plist.get_root()->data_type == PList::PLNodeType::PL_NODE_TYPE_DICT && info_plist.get_root()->data_dict.has("CFBundleIdentifier")) {
1232 id = info_plist.get_root()->data_dict["CFBundleIdentifier"]->data_string.get_data();
1233 } else {
1234 r_error_msg = TTR("Invalid Info.plist, no bundle id.");
1235 ERR_FAIL_V_MSG(FAILED, "CodeSign: Invalid Info.plist, no bundle id.");
1236 }
1237 } else {
1238 r_error_msg = TTR("Invalid Info.plist, can't load.");
1239 ERR_FAIL_V_MSG(FAILED, "CodeSign: Invalid Info.plist, can't load.");
1240 }
1241 }
1242
1243 // Extract fat binary.
1244 Vector<String> files_to_sign;
1245 if (LipO::is_lipo(main_exe)) {
1246 print_verbose(vformat("CodeSign: Executable is fat, extracting..."));
1247 String tmp_path_name = EditorPaths::get_singleton()->get_temp_dir().path_join("_lipo");
1248 Error err = da->make_dir_recursive(tmp_path_name);

Callers

nothing calls this directly

Calls 15

vformatFunction · 0.85
TTRFunction · 0.85
itosFunction · 0.85
CodeSignSuperBlobClass · 0.85
load_fileMethod · 0.80
path_joinMethod · 0.80
get_arch_countMethod · 0.80
extract_archMethod · 0.80
is_signedMethod · 0.80
add_rule1Method · 0.80
add_rule2Method · 0.80

Tested by

no test coverage detected