summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/README.md14
-rw-r--r--platform/android/export/export_plugin.cpp30
-rw-r--r--platform/android/export/export_plugin.h7
-rw-r--r--platform/android/export/gradle_export_util.cpp3
-rw-r--r--platform/android/export/gradle_export_util.h6
-rw-r--r--platform/android/java/app/assetPacks/installTime/build.gradle8
-rw-r--r--platform/android/java/app/build.gradle2
-rw-r--r--platform/android/java/app/settings.gradle4
-rw-r--r--platform/android/java/settings.gradle3
-rw-r--r--platform/android/logo.pngbin951 -> 968 bytes
-rw-r--r--platform/javascript/README.md15
-rw-r--r--platform/javascript/api/javascript_tools_editor_plugin.cpp4
-rw-r--r--platform/javascript/display_server_javascript.cpp21
-rw-r--r--platform/javascript/js/libs/audio.worklet.js14
-rw-r--r--platform/linuxbsd/README.md11
-rw-r--r--platform/linuxbsd/detect.py49
16 files changed, 141 insertions, 50 deletions
diff --git a/platform/android/README.md b/platform/android/README.md
new file mode 100644
index 0000000000..343e588553
--- /dev/null
+++ b/platform/android/README.md
@@ -0,0 +1,14 @@
+# Android platform port
+
+This folder contains the Java and C++ (JNI) code for the Android platform port,
+using [Gradle](https://gradle.org/) as a build system.
+
+## Artwork license
+
+[`logo.png`](logo.png) and [`run_icon.png`](run_icon.png) are licensed under
+[Creative Commons Attribution 3.0 Unported](https://developer.android.com/distribute/marketing-tools/brand-guidelines#android_robot)
+per the Android logo usage guidelines:
+
+> The Android robot is reproduced or modified from work created and shared by
+> Google and used according to terms described in the Creative Commons 3.0
+> Attribution License.
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index e5422a28af..60ba1c558a 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -221,6 +221,9 @@ static const LauncherIcon launcher_adaptive_icon_backgrounds[icon_densities_coun
static const int EXPORT_FORMAT_APK = 0;
static const int EXPORT_FORMAT_AAB = 1;
+static const char *APK_ASSETS_DIRECTORY = "res://android/build/assets";
+static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/installTime/src/main/assets";
+
void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
@@ -426,6 +429,11 @@ String EditorExportPlatformAndroid::get_package_name(const String &p_package) co
return pname;
}
+String EditorExportPlatformAndroid::get_assets_directory(const Ref<EditorExportPreset> &p_preset) const {
+ int export_format = int(p_preset->get("custom_template/export_format"));
+ return export_format == EXPORT_FORMAT_AAB ? AAB_ASSETS_DIRECTORY : APK_ASSETS_DIRECTORY;
+}
+
bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package, String *r_error) const {
String pname = p_package;
@@ -2335,11 +2343,21 @@ Error EditorExportPlatformAndroid::sign_apk(const Ref<EditorExportPreset> &p_pre
void EditorExportPlatformAndroid::_clear_assets_directory() {
DirAccessRef da_res = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- if (da_res->dir_exists("res://android/build/assets")) {
- print_verbose("Clearing assets directory..");
- DirAccessRef da_assets = DirAccess::open("res://android/build/assets");
+
+ // Clear the APK assets directory
+ if (da_res->dir_exists(APK_ASSETS_DIRECTORY)) {
+ print_verbose("Clearing APK assets directory..");
+ DirAccessRef da_assets = DirAccess::open(APK_ASSETS_DIRECTORY);
+ da_assets->erase_contents_recursive();
+ da_res->remove(APK_ASSETS_DIRECTORY);
+ }
+
+ // Clear the AAB assets directory
+ if (da_res->dir_exists(AAB_ASSETS_DIRECTORY)) {
+ print_verbose("Clearing AAB assets directory..");
+ DirAccessRef da_assets = DirAccess::open(AAB_ASSETS_DIRECTORY);
da_assets->erase_contents_recursive();
- da_res->remove("res://android/build/assets");
+ da_res->remove(AAB_ASSETS_DIRECTORY);
}
}
@@ -2459,6 +2477,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
return ERR_UNCONFIGURED;
}
}
+ const String assets_directory = get_assets_directory(p_preset);
String sdk_path = EDITOR_GET("export/android/android_sdk_path");
ERR_FAIL_COND_V_MSG(sdk_path.is_empty(), ERR_UNCONFIGURED, "Android SDK path must be configured in Editor Settings at 'export/android/android_sdk_path'.");
print_verbose("Android sdk path: " + sdk_path);
@@ -2480,6 +2499,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
if (!apk_expansion) {
print_verbose("Exporting project files..");
CustomExportData user_data;
+ user_data.assets_directory = assets_directory;
user_data.debug = p_debug;
err = export_project_files(p_preset, rename_and_store_file_in_gradle_project, &user_data, copy_gradle_so);
if (err != OK) {
@@ -2501,7 +2521,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
}
}
print_verbose("Storing command line flags..");
- store_file_at_path("res://android/build/assets/_cl_", command_line_flags);
+ store_file_at_path(assets_directory + "/_cl_", command_line_flags);
print_verbose("Updating ANDROID_HOME environment to " + sdk_path);
OS::get_singleton()->set_environment("ANDROID_HOME", sdk_path); //set and overwrite if required
diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h
index b061ee4e04..d33f616f11 100644
--- a/platform/android/export/export_plugin.h
+++ b/platform/android/export/export_plugin.h
@@ -87,11 +87,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
EditorProgress *ep = nullptr;
};
- struct CustomExportData {
- bool debug;
- Vector<String> libs;
- };
-
Vector<PluginConfigAndroid> plugins;
String last_plugin_names;
uint64_t last_custom_build_time = 0;
@@ -109,6 +104,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String get_package_name(const String &p_package) const;
+ String get_assets_directory(const Ref<EditorExportPreset> &p_preset) const;
+
bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const;
static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data);
diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp
index 6fbdf73cd0..851bd0ac52 100644
--- a/platform/android/export/gradle_export_util.cpp
+++ b/platform/android/export/gradle_export_util.cpp
@@ -121,7 +121,8 @@ Error store_string_at_path(const String &p_path, const String &p_data) {
// It's functionality mirrors that of the method save_apk_file.
// This method will be called ONLY when custom build is enabled.
Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) {
- String dst_path = p_path.replace_first("res://", "res://android/build/assets/");
+ CustomExportData *export_data = (CustomExportData *)p_userdata;
+ String dst_path = p_path.replace_first("res://", export_data->assets_directory + "/");
print_verbose("Saving project files from " + p_path + " into " + dst_path);
Error err = store_file_at_path(dst_path, p_data);
return err;
diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h
index 8a93c25d79..744022f1f9 100644
--- a/platform/android/export/gradle_export_util.h
+++ b/platform/android/export/gradle_export_util.h
@@ -44,6 +44,12 @@ const String godot_project_name_xml_string = R"(<?xml version="1.0" encoding="ut
</resources>
)";
+struct CustomExportData {
+ String assets_directory;
+ bool debug;
+ Vector<String> libs;
+};
+
int _get_android_orientation_value(DisplayServer::ScreenOrientation screen_orientation);
String _get_android_orientation_label(DisplayServer::ScreenOrientation screen_orientation);
diff --git a/platform/android/java/app/assetPacks/installTime/build.gradle b/platform/android/java/app/assetPacks/installTime/build.gradle
new file mode 100644
index 0000000000..b06faac374
--- /dev/null
+++ b/platform/android/java/app/assetPacks/installTime/build.gradle
@@ -0,0 +1,8 @@
+apply plugin: 'com.android.asset-pack'
+
+assetPack {
+ packName = "installTime" // Directory name for the asset pack
+ dynamicDelivery {
+ deliveryType = "install-time" // Delivery mode
+ }
+}
diff --git a/platform/android/java/app/build.gradle b/platform/android/java/app/build.gradle
index 9640887399..a391a3ca9a 100644
--- a/platform/android/java/app/build.gradle
+++ b/platform/android/java/app/build.gradle
@@ -72,6 +72,8 @@ android {
targetCompatibility versions.javaVersion
}
+ assetPacks = [":assetPacks:installTime"]
+
defaultConfig {
// The default ignore pattern for the 'assets' directory includes hidden files and directories which are used by Godot projects.
aaptOptions {
diff --git a/platform/android/java/app/settings.gradle b/platform/android/java/app/settings.gradle
index 33b863c7bf..e38d7b2ba6 100644
--- a/platform/android/java/app/settings.gradle
+++ b/platform/android/java/app/settings.gradle
@@ -1,2 +1,2 @@
-// Empty settings.gradle file to denote this directory as being the root project
-// of the Godot custom build.
+// This is the root directory of the Godot custom build.
+include ':assetPacks:installTime'
diff --git a/platform/android/java/settings.gradle b/platform/android/java/settings.gradle
index 524031d93f..584b626900 100644
--- a/platform/android/java/settings.gradle
+++ b/platform/android/java/settings.gradle
@@ -4,3 +4,6 @@ rootProject.name = "Godot"
include ':app'
include ':lib'
include ':nativeSrcsConfigs'
+
+include ':assetPacks:installTime'
+project(':assetPacks:installTime').projectDir = file("app/assetPacks/installTime")
diff --git a/platform/android/logo.png b/platform/android/logo.png
index f44d360a25..9c8be93646 100644
--- a/platform/android/logo.png
+++ b/platform/android/logo.png
Binary files differ
diff --git a/platform/javascript/README.md b/platform/javascript/README.md
new file mode 100644
index 0000000000..f181bea9e0
--- /dev/null
+++ b/platform/javascript/README.md
@@ -0,0 +1,15 @@
+# HTML5 platform port
+
+This folder contains the C++ and JavaScript code for the HTML5/WebAssembly platform port,
+compiled using [Emscripten](https://emscripten.org/).
+
+It also contains a ESLint linting setup (see [`package.json`](package.json)).
+
+See also [`misc/dist/html`](/misc/dist/html) folder for files used by this platform
+such as the HTML5 shell.
+
+## Artwork license
+
+[`logo.png`](logo.png) and [`run_icon.png`](run_icon.png) are licensed under
+[Creative Commons Attribution 3.0 Unported](https://www.w3.org/html/logo/faq.html#how-licenced)
+per the HTML5 logo usage guidelines.
diff --git a/platform/javascript/api/javascript_tools_editor_plugin.cpp b/platform/javascript/api/javascript_tools_editor_plugin.cpp
index c50195639c..45a2cd595a 100644
--- a/platform/javascript/api/javascript_tools_editor_plugin.cpp
+++ b/platform/javascript/api/javascript_tools_editor_plugin.cpp
@@ -71,8 +71,8 @@ void JavaScriptToolsEditorPlugin::_download_zip(Variant p_v) {
// Replace characters not allowed (or risky) in Windows file names with safe characters.
// In the project name, all invalid characters become an empty string so that a name
// like "Platformer 2: Godette's Revenge" becomes "platformer_2-_godette-s_revenge".
- const String project_name_safe =
- GLOBAL_GET("application/config/name").to_lower().replace(" ", "_");
+ const String project_name = GLOBAL_GET("application/config/name");
+ const String project_name_safe = project_name.to_lower().replace(" ", "_");
const String datetime_safe =
Time::get_singleton()->get_datetime_string_from_system(false, true).replace(" ", "_");
const String output_name = OS::get_singleton()->get_safe_dir_name(vformat("%s_%s.zip"));
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index fda18a5c19..b43614eb99 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -158,6 +158,10 @@ EM_BOOL DisplayServerJavaScript::keydown_callback(int p_event_type, const Emscri
return false;
}
Input::get_singleton()->parse_input_event(ev);
+
+ // Make sure to flush all events so we can call restricted APIs inside the event.
+ Input::get_singleton()->flush_buffered_events();
+
return true;
}
@@ -165,6 +169,10 @@ EM_BOOL DisplayServerJavaScript::keypress_callback(int p_event_type, const Emscr
DisplayServerJavaScript *display = get_singleton();
display->deferred_key_event->set_unicode(p_event->charCode);
Input::get_singleton()->parse_input_event(display->deferred_key_event);
+
+ // Make sure to flush all events so we can call restricted APIs inside the event.
+ Input::get_singleton()->flush_buffered_events();
+
return true;
}
@@ -172,6 +180,10 @@ EM_BOOL DisplayServerJavaScript::keyup_callback(int p_event_type, const Emscript
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(false);
Input::get_singleton()->parse_input_event(ev);
+
+ // Make sure to flush all events so we can call restricted APIs inside the event.
+ Input::get_singleton()->flush_buffered_events();
+
return ev->get_keycode() != KEY_UNKNOWN && ev->get_keycode() != (Key)0;
}
@@ -245,6 +257,10 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
ev->set_button_mask(mask);
input->parse_input_event(ev);
+
+ // Make sure to flush all events so we can call restricted APIs inside the event.
+ Input::get_singleton()->flush_buffered_events();
+
// Prevent multi-click text selection and wheel-click scrolling anchor.
// Context menu is prevented through contextmenu event.
return true;
@@ -507,6 +523,10 @@ EM_BOOL DisplayServerJavaScript::touch_press_callback(int p_event_type, const Em
Input::get_singleton()->parse_input_event(ev);
}
+
+ // Make sure to flush all events so we can call restricted APIs inside the event.
+ Input::get_singleton()->flush_buffered_events();
+
// Resume audio context after input in case autoplay was denied.
return true;
}
@@ -1019,6 +1039,7 @@ bool DisplayServerJavaScript::can_any_window_draw() const {
}
void DisplayServerJavaScript::process_events() {
+ Input::get_singleton()->flush_buffered_events();
if (godot_js_display_gamepad_sample() == OK) {
process_joypads();
}
diff --git a/platform/javascript/js/libs/audio.worklet.js b/platform/javascript/js/libs/audio.worklet.js
index 866f845139..df475ba52d 100644
--- a/platform/javascript/js/libs/audio.worklet.js
+++ b/platform/javascript/js/libs/audio.worklet.js
@@ -66,17 +66,17 @@ class RingBuffer {
const mw = this.buffer.length - this.wpos;
if (mw >= to_write) {
this.buffer.set(p_buffer, this.wpos);
+ this.wpos += to_write;
+ if (mw === to_write) {
+ this.wpos = 0;
+ }
} else {
- const high = p_buffer.subarray(0, to_write - mw);
- const low = p_buffer.subarray(to_write - mw);
+ const high = p_buffer.subarray(0, mw);
+ const low = p_buffer.subarray(mw);
this.buffer.set(high, this.wpos);
this.buffer.set(low);
+ this.wpos = low.length;
}
- let diff = to_write;
- if (this.wpos + diff >= this.buffer.length) {
- diff -= this.buffer.length;
- }
- this.wpos += diff;
Atomics.add(this.avail, 0, to_write);
Atomics.notify(this.avail, 0);
}
diff --git a/platform/linuxbsd/README.md b/platform/linuxbsd/README.md
new file mode 100644
index 0000000000..0d3fb37be5
--- /dev/null
+++ b/platform/linuxbsd/README.md
@@ -0,0 +1,11 @@
+# Linux/*BSD platform port
+
+This folder contains the C++ code for the Linux/*BSD platform port.
+
+## Artwork license
+
+[`logo.png`](logo.png) is derived from the [Linux logo](https://isc.tamu.edu/~lewing/linux/):
+
+> Permission to use and/or modify this image is granted provided you acknowledge me
+ <lewing@isc.tamu.edu> and [The GIMP](https://isc.tamu.edu/~lewing/gimp/)
+ if someone asks.
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 3e3ed469ed..8eb22c1c72 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -18,40 +18,42 @@ def can_build():
# Check the minimal dependencies
x11_error = os.system("pkg-config --version > /dev/null")
if x11_error:
+ print("Error: pkg-config not found. Aborting.")
return False
- x11_error = os.system("pkg-config x11 --modversion > /dev/null ")
+ x11_error = os.system("pkg-config x11 --modversion > /dev/null")
if x11_error:
+ print("Error: X11 libraries not found. Aborting.")
return False
- x11_error = os.system("pkg-config xcursor --modversion > /dev/null ")
+ x11_error = os.system("pkg-config xcursor --modversion > /dev/null")
if x11_error:
- print("xcursor not found.. x11 disabled.")
+ print("Error: Xcursor library not found. Aborting.")
return False
- x11_error = os.system("pkg-config xinerama --modversion > /dev/null ")
+ x11_error = os.system("pkg-config xinerama --modversion > /dev/null")
if x11_error:
- print("xinerama not found.. x11 disabled.")
+ print("Error: Xinerama library not found. Aborting.")
return False
- x11_error = os.system("pkg-config xext --modversion > /dev/null ")
+ x11_error = os.system("pkg-config xext --modversion > /dev/null")
if x11_error:
- print("xext not found.. x11 disabled.")
+ print("Error: Xext library not found. Aborting.")
return False
- x11_error = os.system("pkg-config xrandr --modversion > /dev/null ")
+ x11_error = os.system("pkg-config xrandr --modversion > /dev/null")
if x11_error:
- print("xrandr not found.. x11 disabled.")
+ print("Error: XrandR library not found. Aborting.")
return False
- x11_error = os.system("pkg-config xrender --modversion > /dev/null ")
+ x11_error = os.system("pkg-config xrender --modversion > /dev/null")
if x11_error:
- print("xrender not found.. x11 disabled.")
+ print("Error: XRender library not found. Aborting.")
return False
- x11_error = os.system("pkg-config xi --modversion > /dev/null ")
+ x11_error = os.system("pkg-config xi --modversion > /dev/null")
if x11_error:
- print("xi not found.. Aborting.")
+ print("Error: Xi library not found. Aborting.")
return False
return True
@@ -138,7 +140,7 @@ def configure(env):
# A convenience so you don't need to write use_lto too when using SCons
env["use_lto"] = True
else:
- print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.")
+ print("Using LLD with GCC is not supported yet. Try compiling with 'use_llvm=yes'.")
sys.exit(255)
if env["use_coverage"]:
@@ -201,11 +203,6 @@ def configure(env):
env.Append(CCFLAGS=["-pipe"])
env.Append(LINKFLAGS=["-pipe"])
- # -fpie and -no-pie is supported on GCC 6+ and Clang 4+, both below our
- # minimal requirements.
- env.Append(CCFLAGS=["-fpie"])
- env.Append(LINKFLAGS=["-no-pie"])
-
## Dependencies
env.ParseConfig("pkg-config x11 --cflags --libs")
@@ -334,36 +331,32 @@ def configure(env):
## Flags
if os.system("pkg-config --exists alsa") == 0: # 0 means found
- print("Enabling ALSA")
env["alsa"] = True
env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"])
else:
- print("ALSA libraries not found, disabling driver")
+ print("Warning: ALSA libraries not found. Disabling the ALSA audio driver.")
if env["pulseaudio"]:
if os.system("pkg-config --exists libpulse") == 0: # 0 means found
- print("Enabling PulseAudio")
env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"])
env.ParseConfig("pkg-config --cflags libpulse")
else:
- print("PulseAudio development libraries not found, disabling driver")
+ print("Warning: PulseAudio development libraries not found. Disabling the PulseAudio audio driver.")
if env["dbus"]:
if os.system("pkg-config --exists dbus-1") == 0: # 0 means found
- print("Enabling D-Bus")
env.Append(CPPDEFINES=["DBUS_ENABLED"])
env.ParseConfig("pkg-config --cflags --libs dbus-1")
else:
- print("D-Bus development libraries not found, disabling dependent features")
+ print("Warning: D-Bus development libraries not found. Disabling screensaver prevention.")
if platform.system() == "Linux":
env.Append(CPPDEFINES=["JOYDEV_ENABLED"])
if env["udev"]:
if os.system("pkg-config --exists libudev") == 0: # 0 means found
- print("Enabling udev support")
env.Append(CPPDEFINES=["UDEV_ENABLED"])
else:
- print("libudev development libraries not found, disabling udev support")
+ print("Warning: libudev development libraries not found. Disabling controller hotplugging support.")
else:
env["udev"] = False # Linux specific
@@ -412,7 +405,7 @@ def configure(env):
gnu_ld_version = re.search("^GNU ld [^$]*(\d+\.\d+)$", linker_version_str, re.MULTILINE)
if not gnu_ld_version:
print(
- "Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld"
+ "Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld, not gold or LLD."
)
else:
if float(gnu_ld_version.group(1)) >= 2.30: