Skip to content

Commit 210e676

Browse files
authored
utopia-riseGH-801 Exclude jvm dir from export (utopia-rise#815)
* utopia-riseGH-801 Exclude jvm dir from export * utopia-riseGH-801 Use auto export of jar files and exclude build dir and jre jar files manually instead * utopia-riseGH-801 Do not add excludes if already present * utopia-riseGH-801 Move adding exclude filter presets to a separate function
1 parent ba59c3f commit 210e676

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/kotlin_editor_export_plugin.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ void KotlinEditorExportPlugin::_export_begin(const HashSet<String>& p_features,
130130
_generate_export_configuration_file(jni::JvmType::GRAAL_NATIVE_IMAGE);
131131
}
132132
} else if (is_android_export) {
133-
files_to_add.push_back(String(RES_DIRECTORY).path_join(ANDROID_BOOTSTRAP_FILE));
134-
files_to_add.push_back(String(RES_DIRECTORY).path_join(ANDROID_USER_CODE_FILE));
135133
_generate_export_configuration_file(jni::JvmType::ART);
136134
} else if (is_ios_export) {
137135
String base_ios_build_dir {String(RES_DIRECTORY).path_join(JVM_DIRECTORY).path_join("ios")};
@@ -158,19 +156,25 @@ void KotlinEditorExportPlugin::_export_begin(const HashSet<String>& p_features,
158156
JVM_LOG_INFO("Exporting %s", file_to_add);
159157
}
160158

159+
_add_exclude_filter_preset();
160+
161161
JVM_LOG_INFO("Finished Godot-Jvm specific exports.");
162162
}
163163

164164
void KotlinEditorExportPlugin::_generate_export_configuration_file(jni::JvmType vm_type) {
165-
JvmUserConfiguration configuration = GDKotlin::get_instance().get_configuration();// Copy
166-
configuration.vm_type = vm_type;// We only need to change the vm type
165+
JvmUserConfiguration configuration = GDKotlin::get_instance().get_configuration(); // Copy
166+
configuration.vm_type = vm_type; // We only need to change the vm type
167167

168168
const char32_t* json_string {JvmUserConfiguration::export_configuration_to_json(configuration).get_data()};
169169
Vector<uint8_t> json_bytes;
170170
for (int i = 0; json_string[i] != '\0'; ++i) {
171171
json_bytes.push_back(json_string[i]);
172172
}
173173

174+
add_file(JVM_CONFIGURATION_PATH, json_bytes, false);
175+
}
176+
177+
void KotlinEditorExportPlugin::_add_exclude_filter_preset() {
174178
// only add our configuration file to the exclude filter if it is not already present
175179
if (!get_export_preset()->get_exclude_filter().contains(JVM_CONFIGURATION_PATH)) {
176180
// we manually add the configuration file to the exclude filter to prevent it from being added multiple times
@@ -179,7 +183,15 @@ void KotlinEditorExportPlugin::_generate_export_configuration_file(jni::JvmType
179183
get_export_preset()->set_exclude_filter(get_export_preset()->get_exclude_filter() + "," + JVM_CONFIGURATION_PATH);
180184
}
181185

182-
add_file(JVM_CONFIGURATION_PATH, json_bytes, false);
186+
if (const String build_dir = String {BUILD_DIRECTORY}.path_join("*"); !get_export_preset()->get_exclude_filter().contains(build_dir)) {
187+
// exclude build folder
188+
get_export_preset()->set_exclude_filter(get_export_preset()->get_exclude_filter() + "," + build_dir);
189+
}
190+
191+
if (const String jre_jars = String {"res://"} + JVM_DIRECTORY + "jre-*/**/*.jar"; !get_export_preset()->get_exclude_filter().contains(jre_jars)) {
192+
// exclude any jars in the embedded jre
193+
get_export_preset()->set_exclude_filter(get_export_preset()->get_exclude_filter() + "," + jre_jars);
194+
}
183195
}
184196

185197
String KotlinEditorExportPlugin::get_name() const {

src/kotlin_editor_export_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class KotlinEditorExportPlugin : public EditorExportPlugin {
2020

2121
private:
2222
void _generate_export_configuration_file(jni::JvmType vm_type);
23+
void _add_exclude_filter_preset();
2324
};
2425

2526
#endif// GODOT_JVM_KOTLINEDITOREXPORTPLUGIN_H

src/lifecycle/paths.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
static constexpr const char* USER_DIRECTORY {"user://"};
88
static constexpr const char* RES_DIRECTORY {"res://"};
99

10+
static constexpr const char* BUILD_DIRECTORY {"res://build"};
1011
static constexpr const char* ENTRY_DIRECTORY {"res://build/generated/ksp"};
1112
static constexpr const char* JVM_CONFIGURATION_PATH {"res://godot_kotlin_configuration.json"};
1213

0 commit comments

Comments
 (0)