Skip to content

Commit e0e68ce

Browse files
Stary2001Cpasjuste
authored andcommitted
Switch
Co-authored-by: Cpasjuste <cpasjuste@gmail.com>
1 parent de2f0f1 commit e0e68ce

23 files changed

+406
-13
lines changed

.github/workflows/runner.yml

+5
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ jobs:
4444
name: 🏁 Windows
4545
needs: static-checks
4646
uses: ./.github/workflows/windows_builds.yml
47+
48+
switch-build:
49+
name: 🔄 Switch
50+
needs: static-checks
51+
uses: ./.github/workflows/switch_builds.yml

.github/workflows/switch_builds.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 🔄 Switch Builds
2+
on:
3+
workflow_call:
4+
5+
# Global Cache Settings
6+
env:
7+
GODOT_BASE_BRANCH: 3.5
8+
SCONS_CACHE_LIMIT: 4096
9+
10+
jobs:
11+
switch-template:
12+
runs-on: ubuntu-latest
13+
container: devkitpro/devkita64
14+
15+
name: Template (target=release, tools=no)
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
# Upload cache on completion and check it out now
21+
- name: Load .scons_cache directory
22+
id: switch-template-cache
23+
uses: actions/cache@v2
24+
with:
25+
path: ${{github.workspace}}/.scons_cache/
26+
key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
27+
restore-keys: |
28+
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
29+
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
30+
${{github.job}}-${{env.GODOT_BASE_BRANCH}}
31+
32+
- name: Install scons from pip
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get -y install python3-pip
36+
sudo python3 -m pip install scons
37+
38+
- name: Compilation
39+
env:
40+
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
41+
run: |
42+
scons -j2 verbose=yes warnings=all werror=no platform=switch target=release tools=no
43+
44+
- uses: actions/upload-artifact@v2
45+
with:
46+
name: ${{ github.job }}
47+
path: bin/*
48+
retention-days: 14

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,13 @@ $RECYCLE.BIN/
367367
*.msm
368368
*.msp
369369
*.lnk
370+
371+
# Templates
372+
templates/
373+
/*.zip
374+
/*.tpz
375+
376+
# Switch
377+
*.nro
378+
switch/
379+
config/nx-hbmenu/

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "platform/switch"]
2+
path = platform/switch
3+
url = https://github.com/Homebrodot/platform-switch

core/project_settings.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
420420
}
421421
#endif
422422

423+
#ifdef HORIZON_ENABLED
424+
if (!found) {
425+
if (_load_resource_pack("romfs:/game.pck")) {
426+
found = true;
427+
}
428+
}
429+
#endif
430+
423431
if (!found) {
424432
// Try to load data pack at the location of the executable.
425433
// As mentioned above, we have two potential names to attempt.

drivers/gles2/rasterizer_storage_gles2.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,20 @@ GLuint RasterizerStorageGLES2::system_fbo = 0;
9191
#ifndef GLES_OVER_GL
9292
#define glClearDepth glClearDepthf
9393

94+
#if defined IPHONE_ENABLED || defined ANDROID_ENABLED
9495
// enable extensions manually for android and ios
9596
#ifndef UWP_ENABLED
9697
#include <dlfcn.h> // needed to load extensions
9798
#endif
99+
#endif
98100

99101
#ifdef IPHONE_ENABLED
100102

101103
#include <OpenGLES/ES2/glext.h>
102104
//void *glRenderbufferStorageMultisampleAPPLE;
103105
//void *glResolveMultisampleFramebufferAPPLE;
104106
#define glRenderbufferStorageMultisample glRenderbufferStorageMultisampleAPPLE
105-
#elif defined(ANDROID_ENABLED)
107+
#elif defined ANDROID_ENABLED || defined HORIZON_ENABLED
106108

107109
#include <GLES2/gl2ext.h>
108110
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
@@ -6397,6 +6399,17 @@ void RasterizerStorageGLES2::initialize() {
63976399
config.render_to_mipmap_supported = config.extensions.has("GL_OES_fbo_render_mipmap") && config.extensions.has("GL_EXT_texture_lod");
63986400
#endif
63996401

6402+
// If the desktop build is using S3TC, and you export / run from the IDE for android, if the device supports
6403+
// S3TC it will crash trying to load these textures, as they are not exported in the APK. This is a simple way
6404+
// to prevent Android devices trying to load S3TC, by faking lack of hardware support.
6405+
6406+
// Switch: this happens on Horizon too.
6407+
#ifndef TOOLS_ENABLED
6408+
#if defined ANDROID_ENABLED || defined HORIZON_ENABLED
6409+
config.s3tc_supported = false;
6410+
#endif
6411+
#endif
6412+
64006413
#ifdef GLES_OVER_GL
64016414
config.use_rgba_2d_shadows = false;
64026415
config.support_depth_texture = true;

drivers/gles3/rasterizer_storage_gles3.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -8194,11 +8194,10 @@ void RasterizerStorageGLES3::initialize() {
81948194
// If the desktop build is using S3TC, and you export / run from the IDE for android, if the device supports
81958195
// S3TC it will crash trying to load these textures, as they are not exported in the APK. This is a simple way
81968196
// to prevent Android devices trying to load S3TC, by faking lack of hardware support.
8197-
#if defined(ANDROID_ENABLED) || defined(IPHONE_ENABLED)
8197+
#if defined(ANDROID_ENABLED) || defined(IPHONE_ENABLED) || defined(HORIZON_ENABLED)
81988198
config.s3tc_supported = false;
81998199
#endif
82008200
#endif
8201-
82028201
// not yet detected on GLES3 (is this mandated?)
82038202
config.support_npot_repeat_mipmap = true;
82048203

drivers/unix/dir_access_unix.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ String DirAccessUnix::read_link(String p_file) {
413413

414414
p_file = fix_path(p_file);
415415

416+
#ifdef HORIZON_ENABLED
417+
return p_file;
418+
#else
416419
char buf[256];
417420
memset(buf, 0, 256);
418421
ssize_t len = readlink(p_file.utf8().get_data(), buf, sizeof(buf));
@@ -421,9 +424,13 @@ String DirAccessUnix::read_link(String p_file) {
421424
link.parse_utf8(buf, len);
422425
}
423426
return link;
427+
#endif
424428
}
425429

426430
Error DirAccessUnix::create_link(String p_source, String p_target) {
431+
#ifdef HORIZON_ENABLED
432+
return FAILED;
433+
#else
427434
if (p_target.is_rel_path())
428435
p_target = get_current_dir().plus_file(p_target);
429436

@@ -435,6 +442,7 @@ Error DirAccessUnix::create_link(String p_source, String p_target) {
435442
} else {
436443
return FAILED;
437444
}
445+
#endif
438446
}
439447

440448
uint64_t DirAccessUnix::get_space_left() {

drivers/unix/file_access_unix.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#include <errno.h>
4242

43-
#if defined(UNIX_ENABLED)
43+
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
4444
#include <unistd.h>
4545
#endif
4646

@@ -130,6 +130,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
130130
return last_error;
131131
}
132132

133+
#ifndef HORIZON_ENABLED
133134
// Set close on exec to avoid leaking it to subprocesses.
134135
int fd = fileno(f);
135136

@@ -142,7 +143,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
142143
fcntl(fd, F_SETFD, opts | FD_CLOEXEC);
143144
#endif
144145
}
145-
146+
#endif
146147
last_error = OK;
147148
flags = p_mode_flags;
148149
return OK;
@@ -279,7 +280,7 @@ bool FileAccessUnix::file_exists(const String &p_path) {
279280
return false;
280281
}
281282

282-
#ifdef UNIX_ENABLED
283+
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
283284
// See if we have access to the file
284285
if (access(filename.utf8().get_data(), F_OK)) {
285286
return false;

drivers/unix/ip_unix.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "ip_unix.h"
3232

33-
#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED)
33+
#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED) || defined(HORIZON_ENABLED)
3434

3535
#include <string.h>
3636

@@ -53,8 +53,10 @@
5353
#ifdef __FreeBSD__
5454
#include <sys/types.h>
5555
#endif
56+
#ifndef HORIZON_ENABLED
5657
#include <ifaddrs.h>
5758
#endif
59+
#endif
5860
#include <arpa/inet.h>
5961
#include <sys/socket.h>
6062
#ifdef __FreeBSD__
@@ -209,6 +211,14 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
209211

210212
#else // UNIX
211213

214+
#ifdef HORIZON_ENABLED
215+
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
216+
struct ifaddrs *ifAddrStruct = nullptr;
217+
struct ifaddrs *ifa = nullptr;
218+
// todo: nifm
219+
}
220+
221+
#else
212222
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
213223
struct ifaddrs *ifAddrStruct = nullptr;
214224
struct ifaddrs *ifa = nullptr;
@@ -246,6 +256,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
246256
}
247257
}
248258
#endif
259+
#endif
249260

250261
void IP_Unix::make_default() {
251262
_create = _create_unix;

drivers/unix/ip_unix.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include "core/io/ip.h"
3535

36-
#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED)
36+
#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED) || defined(HORIZON_ENABLED)
3737

3838
class IP_Unix : public IP {
3939
GDCLASS(IP_Unix, IP);

drivers/unix/net_socket_posix.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "net_socket_posix.h"
3232

3333
#ifndef UNIX_SOCKET_UNAVAILABLE
34-
#if defined(UNIX_ENABLED)
34+
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
3535

3636
#include <errno.h>
3737
#include <netdb.h>
@@ -50,7 +50,7 @@
5050
#include <netinet/in.h>
5151

5252
#include <sys/socket.h>
53-
#ifdef JAVASCRIPT_ENABLED
53+
#if defined(JAVASCRIPT_ENABLED) || defined(HORIZON_ENABLED)
5454
#include <arpa/inet.h>
5555
#endif
5656

@@ -276,11 +276,13 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St
276276
memcpy(&greq.imr_interface, if_ip.get_ipv4(), 4);
277277
ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq));
278278
} else {
279+
#ifndef HORIZON_ENABLED
279280
struct ipv6_mreq greq;
280281
int sock_opt = p_add ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP;
281282
memcpy(&greq.ipv6mr_multiaddr, p_ip.get_ipv6(), 16);
282283
greq.ipv6mr_interface = if_v6id;
283284
ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq));
285+
#endif
284286
}
285287
ERR_FAIL_COND_V(ret != 0, FAILED);
286288

editor/export_template_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void ExportTemplateManager::_refresh_mirrors() {
230230
is_refreshing_mirrors = true;
231231

232232
String current_version = VERSION_FULL_CONFIG;
233-
const String mirrors_metadata_url = "https://godotengine.org/mirrorlist/" + current_version + ".json";
233+
const String mirrors_metadata_url = "https://9net.org/godot/" + current_version + ".json";
234234
request_mirrors->request(mirrors_metadata_url);
235235
}
236236

modules/bullet/SCsub

+5
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ if env["builtin_bullet"]:
200200
thirdparty_sources = [thirdparty_dir + file for file in bullet2_src]
201201

202202
env_bullet.Prepend(CPPPATH=[thirdparty_dir])
203+
# Treat Bullet headers as system headers to avoid raising warnings. Not supported on MSVC. (TODO SWITCH: devkitA64 issue prevents this from working)
204+
if not env.msvc and env["platform"] != "switch":
205+
env_bullet.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path])
206+
else:
207+
env_bullet.Prepend(CPPPATH=[thirdparty_dir])
203208

204209
env_bullet.Append(CPPDEFINES=["BT_USE_OLD_DAMPING_METHOD", "BT_THREADSAFE"])
205210

modules/gdnative/include/gdnative/gdnative.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
extern "C" {
3636
#endif
3737

38-
#if defined(_WIN32) || defined(__ANDROID__)
38+
#if defined(_WIN32) || defined(__ANDROID__) || defined(__SWITCH__)
3939
#define GDCALLINGCONV
4040

4141
#elif defined(__APPLE__)

platform/switch

Submodule switch added at e6cb232

scripts/create-switch-release.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ $# -eq 0 ]]; then
4+
echo "something is wrong.."
5+
fi
6+
7+
sudo apt-get update
8+
sudo apt-get -y install zip
9+
10+
version_number=`echo $1 | grep -o '[0-9]\+.[0-9]\+.[0-9]\+'`
11+
12+
mkdir -p switch/godot config/nx-hbmenu/fileassoc
13+
cp godot-forwarder.nro switch/godot/godot-forwarder.nro
14+
cp switch_release_debug.nro switch/godot/godot-${version_number}.nro
15+
cp platform/switch/godot.cfg config/nx-hbmenu/fileassoc/godot.cfg
16+
zip -r godot-switch.zip switch config

scripts/create-switch-template.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
sudo apt-get update
4+
sudo apt-get -y install zip
5+
6+
template_version=`echo $1 | grep -Po '[0-9]+.[0-9]+.[0-9]+(-[^-]*)?' | sed s/-/./`
7+
8+
mkdir templates
9+
cp switch_release_debug.nro templates/switch_release.nro
10+
cp platform/switch/romfs/applet_splash.rgba.gz templates/switch_applet_splash.rgba.gz
11+
echo $template_version > templates/version.txt
12+
zip -r godot_templates_switch_only.tpz templates

thirdparty/enet/enet/godot.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <stdint.h>
4040
#include <winsock2.h>
4141
#endif
42-
#ifdef UNIX_ENABLED
42+
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
4343
#include <arpa/inet.h>
4444
#endif
4545

0 commit comments

Comments
 (0)