MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _compile_process

Method _compile_process

editor/gdre_editor.cpp:662–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662void GodotREEditor::_compile_process() {
663 Vector<String> files = script_dialog_c->get_file_list();
664 int rev = script_dialog_c->get_bytecode_version();
665 Vector<uint8_t> key = key_dialog->get_key();
666 String dir = script_dialog_c->get_target_dir();
667 String ext = (key.size() == 32) ? ".gde" : ".gdc";
668
669 String failed_files;
670 Ref<GDScriptDecomp> dce = GDScriptDecomp::create_decomp_for_commit(rev);
671 Ref<EditorProgressGDDC> pr = memnew(EditorProgressGDDC(ne_parent, "re_compile", RTR("Compiling files..."), files.size(), true));
672
673 for (int i = 0; i < files.size(); i++) {
674 print_warning(RTR("compiling") + " " + files[i].get_file(), RTR("Compile"));
675 String target_name = dir.path_join(files[i].get_file().get_basename() + ext);
676
677 bool cancel = pr->step(files[i].get_file(), i, true);
678 if (cancel) {
679 break;
680 }
681
682 Vector<uint8_t> file = FileAccess::get_file_as_bytes(files[i]);
683 if (file.size() > 0) {
684 String txt;
685 txt.append_utf8((const char *)file.ptr(), file.size());
686 file = dce->compile_code_string(txt);
687 if (file.is_empty()) {
688 failed_files += files[i] + " (" + dce->get_error_message() + ")\n";
689 continue;
690 }
691 Ref<FileAccess> fa = FileAccess::open(target_name, FileAccess::WRITE);
692 if (fa.is_valid()) {
693 if (key.size() == 32) {
694 Ref<FileAccessEncryptedv3> fae;
695 fae.instantiate();
696 Error err = fae->open_and_parse(fa, key, FileAccessEncryptedv3::MODE_WRITE_AES256);
697 if (err == OK) {
698 fae->store_buffer(file.ptr(), file.size());
699 fae->close();
700 } else {
701 failed_files += files[i] + " (FileAccessEncrypted error)\n";
702 }
703 } else {
704 fa->store_buffer(file.ptr(), file.size());
705 fa->close();
706 }
707 } else {
708 failed_files += files[i] + " (FileAccess error)\n";
709 }
710 } else {
711 failed_files += files[i] + " (Empty file)\n";
712 }
713 }
714
715 pr.unref();
716
717 if (failed_files.length() > 0) {
718 show_warning(failed_files, RTR("Compile"), RTR("At least one error was detected!"));
719 } else {

Callers

nothing calls this directly

Calls 15

stepMethod · 0.80
compile_code_stringMethod · 0.80
lengthMethod · 0.80
EditorProgressGDDCClass · 0.50
get_file_listMethod · 0.45
get_bytecode_versionMethod · 0.45
get_keyMethod · 0.45
get_target_dirMethod · 0.45
sizeMethod · 0.45
get_fileMethod · 0.45
get_error_messageMethod · 0.45
is_validMethod · 0.45

Tested by

no test coverage detected