Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ jobs:
echo "ANGLE_ENABLED=no" >> "$GITHUB_OUTPUT"
fi

- name: Download WinRT components
shell: sh
run: python ./misc/scripts/install_winrt.py
continue-on-error: true

- name: Download pre-built AccessKit
shell: sh
id: accesskit-sdk
Expand Down
4 changes: 4 additions & 0 deletions core/os/spin_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ static_assert(std::atomic_bool::is_always_lock_free);

class SpinLock {
union {
#if __cplusplus >= 202002L
mutable std::atomic<bool> locked = false;
#else
mutable std::atomic<bool> locked = ATOMIC_VAR_INIT(false);
#endif
char aligner[Thread::CACHE_LINE_BYTES];
};

Expand Down
48 changes: 48 additions & 0 deletions misc/scripts/install_winrt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3

if __name__ != "__main__":
raise SystemExit(f'Utility script "{__file__}" should not be used as a module!')

import os
import shutil
import sys
import urllib.request

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../"))


# Base Godot dependencies path
# If cross-compiling (no LOCALAPPDATA), we install in `bin`
deps_folder = os.getenv("LOCALAPPDATA")
if deps_folder:
deps_folder = os.path.join(deps_folder, "Godot", "build_deps")
else:
deps_folder = os.path.join("bin", "build_deps")

# WinRT
winrt_version = "72"

# Create dependencies folder
if not os.path.exists(deps_folder):
os.makedirs(deps_folder)

winrt_filename = "winrt-headers.zip"
winrt_archive = os.path.join(deps_folder, winrt_filename)
winrt_folder = os.path.join(deps_folder, "winrt_mingw")

if os.path.isfile(winrt_archive):
os.remove(winrt_archive)

print(f"Downloading WinRT {winrt_filename} ...")
urllib.request.urlretrieve(
f"https://github.com/bruvzg/winrt_mingw/releases/download/{winrt_version}/{winrt_filename}",
winrt_archive,
)
if os.path.exists(winrt_folder):
print(f"Removing existing local WinRT installation in {winrt_folder} ...")
shutil.rmtree(winrt_folder)
print(f"Extracting WinRT {winrt_filename} to {winrt_folder} ...")
shutil.unpack_archive(winrt_archive, winrt_folder)
os.remove(winrt_archive)

print("WinRT installed successfully.\n")
25 changes: 24 additions & 1 deletion platform/windows/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ common_win = [
"os_windows.cpp",
"display_server_windows.cpp",
"key_mapping_windows.cpp",
"tts_windows.cpp",
"windows_terminal_logger.cpp",
"windows_utils.cpp",
"native_menu_windows.cpp",
Expand Down Expand Up @@ -81,6 +80,30 @@ res_obj = env.RES(res_target, res_file)
env.Depends(res_obj, "#core/version_generated.gen.h")

env.add_source_files(sources, common_win)

env_winrt = env.Clone()
if not env_winrt.msvc:
if "-std=gnu++17" in env_winrt["CXXFLAGS"]:
env_winrt["CXXFLAGS"].remove("-std=gnu++17")
env_winrt.Append(CXXFLAGS=["-std=gnu++20"])
if "-fno-exceptions" in env_winrt["CXXFLAGS"]:
env_winrt["CXXFLAGS"].remove("-fno-exceptions")
env_winrt.Append(CXXFLAGS=["-fexceptions"])
else:
if "/std:c++17" in env_winrt["CXXFLAGS"]:
env_winrt["CXXFLAGS"].remove("/std:c++17")
env_winrt.Append(CXXFLAGS=["/std:c++20"])
if "_HAS_EXCEPTIONS" in env_winrt["CPPDEFINES"]:
env_winrt["CPPDEFINES"].remove("_HAS_EXCEPTIONS")
env_winrt.Append(CXXFLAGS=["/EHsc"])
tts_sources = ["tts_windows.cpp", "tts_driver_sapi.cpp"]
if env_winrt["winrt_path"] != "" or env_winrt.msvc:
if not env_winrt.msvc:
env_winrt.Append(CPPPATH=[env["winrt_path"]])
env_winrt.AppendUnique(CPPDEFINES=["WINRT_ENABLED"])
tts_sources += ["tts_driver_onecore.cpp"]
env_winrt.add_source_files(sources, tts_sources)

sources += res_obj

if env["accesskit"] and not env.msvc:
Expand Down
9 changes: 9 additions & 0 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,18 @@ def get_opts():
"Path to the AccessKit C SDK",
os.path.join(deps_folder, "accesskit"),
),
# OpenGL over Direct3D 11.
(
"angle_libs",
"Path to the ANGLE static libraries",
os.path.join(deps_folder, "angle"),
),
# WinRT.
(
"winrt_path",
"Path to the WinRT headers",
os.path.join(deps_folder, "winrt_mingw"),
),
# Direct3D 12 support.
(
"mesa_libs",
Expand Down Expand Up @@ -418,6 +425,7 @@ def spawn_capture(sh, escape, cmd, args, env):
"wbemuuid",
"ntdll",
"hid",
"mincore",
]

if env.debug_features:
Expand Down Expand Up @@ -811,6 +819,7 @@ def configure_mingw(env: "SConsEnvironment"):
"wbemuuid",
"ntdll",
"hid",
"mincore",
]
)

Expand Down
53 changes: 53 additions & 0 deletions platform/windows/tts_driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**************************************************************************/
/* tts_driver.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#pragma once

#include "core/object/object.h"

class TTSDriver : public Object {
GDSOFTCLASS(TTSDriver, Object);

public:
virtual bool is_speaking() const = 0;
virtual bool is_paused() const = 0;
virtual Array get_voices() const = 0;

virtual void speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int64_t p_utterance_id = 0, bool p_interrupt = false) = 0;
virtual void pause() = 0;
virtual void resume() = 0;
virtual void stop() = 0;

virtual void process_events() = 0;

virtual bool init() = 0;

virtual ~TTSDriver() {}
};
Loading
Loading