taisei/src/arch_switch.c
Andrei Alexeyev 267f47fc0e
build,ci: Build system maintenance (#350)
Squashed commit of the following:

commit 9ab0197ee1
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 28 23:05:58 2022 +0100

    build: add dummy descriptions for deprecated options

commit b0c41d4719
Author: Alice D <alice@starwitch.productions>
Date:   Mon Dec 26 15:18:09 2022 -0500

    update docker containers with ones containing meson 0.63.3

commit a2dd4173fc
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:20:44 2022 +0100

    build: featurize audio options

commit 7c59e2a569
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:20:35 2022 +0100

    build: remove dead code

commit cf500af137
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:07:37 2022 +0100

    doc: update BUILD.rst

commit 9764ac706f
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 17:12:37 2022 +0100

    ci: disable WGI joystick backend for SDL

    Fails to build with latest llvm-mingw

commit 2d4f310b90
Author: p-sam <p-sam@d3vs.net>
Date:   Sun Dec 25 17:03:47 2022 +0100

    switch: fix missing include

commit 9264f1649d
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 24 14:36:41 2022 +0100

    ci: update meson to 0.63.3 due to a bug

commit 3e37be3d8f
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 24 13:42:34 2022 +0100

    ci: update build options

commit 281a39a4f5
Author: Alice D <alice@starwitch.productions>
Date:   Sun Dec 18 00:17:07 2022 -0500

    ci: change when apt is cleaned up for switch image

commit 2f2100a84c
Author: Alice D <alice@starwitch.productions>
Date:   Sun Dec 18 00:11:08 2022 -0500

    ci: bump switch homebrew container version

commit ebaff59260
Author: Alice D <alice@starwitch.productions>
Date:   Sat Dec 17 22:55:39 2022 -0500

    ci: bump windows container version

commit 7ce6f23419
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 07:36:28 2022 +0100

    build: featurize renderer options

commit a345f21b35
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 07:33:30 2022 +0100

    build: revert to explicit fallback for libzstd

    Implicit fallback causes conflicts in the basis_universal subproject

    https://github.com/mesonbuild/meson/issues/11189

commit b2de61f5c5
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 05:29:29 2022 +0100

    build: remove debug_opengl

    This option was always misdocumented, as it only controlled whether GL
    debugging is on by default. You can still control it with the
    TAISEI_GL_DEBUG environment variable, which is set to 1 in meson devenv.

commit 4c659ba195
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Fri Dec 16 08:03:37 2022 +0100

    build: set up useful env vars for meson devenv

    Makes Taisei load resources from the source tree, making live reload
    work; enables OpenGL debugging by default; works around ASan stack use
    after return false positives.

commit 1ddc58b84a
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 08:06:32 2022 +0100

    build: featurize docs; always install licenses

commit c3a94d7f5b
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:46:28 2022 +0100

    build: featurize shader_transpiler

commit 619d82ae36
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:38:30 2022 +0100

    build: allow libzip fallback by default

commit 79ab72292a
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:35:51 2022 +0100

    build: featurize use_libcrypto

commit b393077f71
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 05:03:20 2022 +0100

    build: featurize validate_glsl

commit 7d76484079
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 04:34:31 2022 +0100

    build: featurize some more installation options

commit 17c0bda205
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 03:24:46 2022 +0100

    build: deprecate enable_zip for vfs_zip; convert package_data into feature

commit 9a4ef8c091
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 02:37:55 2022 +0100

    build: deprecate developer=auto; default to false

commit 807240e508
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 02:24:04 2022 +0100

    build: move subproject fallback info into wraps

commit 08c953f487
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:57:33 2022 +0100

    build: deprecate 'static' option

    Meson has a built-in `prefer_static` now

commit c575601537
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:49:31 2022 +0100

    build: remove complicated shaderc detection logic

    Meson does all of this internally since 0.51.0

commit cd2d460d4b
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:45:17 2022 +0100

    build: Require meson >=0.63.0

commit 10abd790f7
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 05:16:47 2022 +0100

    ci: remove meson dist version workaround from release workflow

    Meson should know the correct version now

commit 31a07d8c3c
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 03:46:28 2022 +0100

    build: use built-in summary() function

commit 0c47f6d14b
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 04:33:01 2022 +0100

    build: remove -Dversion_fallback and introduce .VERSION file

    The version script will now first try to read the version from a
    .VERSION file in the source root. If that file does not exist, it will
    query git. The .VERSION file is not included in the git repository, it
    is generated for inclusion in source tarballs.

    Package maintainers who had any use for -Dversion_fallback may want to
    create the .VERSION file themselves.

    Additionally, some git-specific files have been removed from source
    tarballs.

commit d32332a5e3
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 03:00:07 2022 +0100

    build: set the "real" version in project()

commit f9a3fbc729
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 01:50:08 2022 +0100

    build: raise meson_version and remove some legacy workarounds

    Effectively 0.56.0 was already required since we started using some of
    its features at some point.

    This also fixes all current meson warnings.
2022-12-28 23:15:55 +01:00

118 lines
2.7 KiB
C

/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2019, p-sam <p-sam@d3vs.net>.
*/
#include "taisei.h"
#include "arch_switch.h"
#include "renderer/glcommon/debug.h"
#include <unistd.h>
#include <switch/services/applet.h>
#include <switch/services/fs.h>
#include <switch/services/ssl.h>
#include <switch/services/nifm.h>
#include <switch/runtime/devices/socket.h>
#include <switch/runtime/nxlink.h>
#define NX_LOG_FMT(fmt, ...) tsfprintf(stdout, "[NX] " fmt "\n", ##__VA_ARGS__)
#define NX_LOG(str) NX_LOG_FMT("%s", str)
#define NX_SETENV(name, val) NX_LOG_FMT("Setting env var %s to %s", name, val);env_set_string(name, val, true)
uint32_t __nx_fs_num_sessions = 1;
static nxAtExitFn g_nxAtExitFn = NULL;
static char g_programDir[FS_MAX_PATH] = {0};
static AppletHookCookie g_hookCookie;
static void onAppletHook(AppletHookType hook, void *param) {
switch (hook) {
case AppletHookType_OnExitRequest:
NX_LOG("Got AppletHook OnExitRequest, exiting.\n");
taisei_quit();
break;
default:
break;
}
}
attr_used
void userAppInit(void) {
socketInitializeDefault();
appletLockExit();
appletHook(&g_hookCookie, onAppletHook, NULL);
#ifdef DEBUG
dup2(1, 2);
NX_LOG("stderr -> stdout");
nxlinkStdio();
NX_LOG("nxlink enabled");
#endif
NX_SETENV("TAISEI_NOASYNC", "1");
appletInitializeGamePlayRecording();
appletSetGamePlayRecordingState(1);
getcwd(g_programDir, FS_MAX_PATH);
if(glcommon_debug_requested()) {
// enable Mesa logging:
NX_SETENV("EGL_LOG_LEVEL", "debug");
NX_SETENV("MESA_VERBOSE", "all");
NX_SETENV("MESA_DEBUG", "1");
NX_SETENV("MESA_INFO", "1");
NX_SETENV("MESA_GLSL", "errors");
NX_SETENV("NOUVEAU_MESA_DEBUG", "1");
NX_SETENV("LIBGL_DEBUG", "verbose");
// enable shader debugging in Nouveau:
NX_SETENV("NV50_PROG_OPTIMIZE", "0");
NX_SETENV("NV50_PROG_DEBUG", "1");
NX_SETENV("NV50_PROG_CHIPSET", "0x120");
} else {
// disable error checking and save CPU time
NX_SETENV("MESA_NO_ERROR", "1");
}
}
attr_used
void userAppExit(void) {
socketExit();
appletUnlockExit();
}
int nxAtExit(nxAtExitFn fn) {
if(g_nxAtExitFn == NULL) {
NX_LOG("got exit callback");
g_nxAtExitFn = fn;
return 0;
}
return -1;
}
void __attribute__((weak)) noreturn __libnx_exit(int rc);
void noreturn nxExit(int rc) {
if(g_nxAtExitFn != NULL) {
NX_LOG("calling exit callback");
g_nxAtExitFn();
g_nxAtExitFn = NULL;
}
__libnx_exit(rc);
}
void noreturn nxAbort(void) {
/* Using abort would not give us correct offsets in crash reports,
* nor code region name, so we use __builtin_trap instead */
__builtin_trap();
}
const char* nxGetProgramDir(void) {
return g_programDir;
}