Skip to content

Commit

Permalink
[sailfishos] dirty commit
Browse files Browse the repository at this point in the history
try build 3.5 port code in 4.x branch
  • Loading branch information
savegame committed Oct 31, 2023
1 parent 985efea commit 54b5d07
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 169 deletions.
2 changes: 1 addition & 1 deletion platform/sailfish/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ common_sdl = [
"os_sdl.cpp",
"key_mapping_sdl.cpp",
"joypad_linux.cpp",
"power_sdl.cpp",
# "power_sdl.cpp",
]

if env['udev'] :
Expand Down
58 changes: 29 additions & 29 deletions platform/sailfish/context_gl_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// #include <GLES2/gl2.h>
#include "servers/display_server.h"
#include "helper_macros.h"
#include <EGL/egl.h>
#include <SDL_opengles2.h>
Expand All @@ -50,7 +50,7 @@
struct ContextGL_SDL_Private {
SDL_GLContext gl_context;
int display_index;
OS::ScreenOrientation allowed_orientation_enum;
DisplayServer::ScreenOrientation allowed_orientation_enum;
std::string allowed_orientation_str;
int wl_allowed_orientation;
};
Expand Down Expand Up @@ -184,7 +184,7 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
#endif
mprint_verbose2("OS current screen orientation is \"%i\"\n", screen_orientation);
switch (p->allowed_orientation_enum) {
case OS::SCREEN_SENSOR_LANDSCAPE: {
case DisplayServer::SCREEN_SENSOR_LANDSCAPE: {
switch (sdl_orientation) {
case SDL_ORIENTATION_LANDSCAPE_FLIPPED:
// qt_extended_surface_set_content_orientation(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION);
Expand All @@ -193,8 +193,8 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_270;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_Screen_orientation OS::SCREEN_LANDSCAPE\n");
screen_orientation = (OS::SCREEN_LANDSCAPE);
OS::get_singleton()->print("set_Screen_orientation DisplayServer::SCREEN_LANDSCAPE\n");
screen_orientation = (DisplayServer::SCREEN_LANDSCAPE);
break;
case SDL_ORIENTATION_LANDSCAPE:
// qt_extended_surface_set_content_orientation(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION);
Expand All @@ -203,12 +203,12 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_90;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_Screen_orientation OS::SCREEN_REVERSE_LANDSCAPE\n");
screen_orientation = (OS::SCREEN_REVERSE_LANDSCAPE);
OS::get_singleton()->print("set_Screen_orientation DisplayServer::SCREEN_REVERSE_LANDSCAPE\n");
screen_orientation = (DisplayServer::SCREEN_REVERSE_LANDSCAPE);
break;
}
} break;
case OS::SCREEN_SENSOR_PORTRAIT: {
case DisplayServer::SCREEN_SENSOR_PORTRAIT: {
switch (sdl_orientation) {
case SDL_ORIENTATION_PORTRAIT:
// qt_extended_surface_set_content_orientation(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION);
Expand All @@ -217,8 +217,8 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_NORMAL;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_screen_orientation OS::SCREEN_PORTRAIT\n");
screen_orientation = (OS::SCREEN_PORTRAIT);
OS::get_singleton()->print("set_screen_orientation DisplayServer::SCREEN_PORTRAIT\n");
screen_orientation = (DisplayServer::SCREEN_PORTRAIT);
break;
case SDL_ORIENTATION_PORTRAIT_FLIPPED:
// qt_extended_surface_set_content_orientation(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION);
Expand All @@ -227,12 +227,12 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_180;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_screen_orientation OS::SCREEN_REVERSE_PORTRAIT\n");
screen_orientation = (OS::SCREEN_REVERSE_PORTRAIT);
OS::get_singleton()->print("set_screen_orientation DisplayServer::SCREEN_REVERSE_PORTRAIT\n");
screen_orientation = (DisplayServer::SCREEN_REVERSE_PORTRAIT);
break;
}
} break;
case OS::SCREEN_SENSOR:
case DisplayServer::SCREEN_SENSOR:
switch (sdl_orientation) {
case SDL_ORIENTATION_LANDSCAPE_FLIPPED:
// qt_extended_surface_set_content_orientation(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION);
Expand All @@ -241,8 +241,8 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_270;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_screen_orientation OS::SCREEN_LANDSCAPE\n");
screen_orientation = (OS::SCREEN_LANDSCAPE);
OS::get_singleton()->print("set_screen_orientation DisplayServer::SCREEN_LANDSCAPE\n");
screen_orientation = (DisplayServer::SCREEN_LANDSCAPE);
break;
case SDL_ORIENTATION_LANDSCAPE:
// qt_extended_surface_set_content_orientation(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION);
Expand All @@ -251,8 +251,8 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_90;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_screen_orientation OS::SCREEN_REVERSE_LANDSCAPE\n");
screen_orientation = (OS::SCREEN_REVERSE_LANDSCAPE);
OS::get_singleton()->print("set_screen_orientation DisplayServer::SCREEN_REVERSE_LANDSCAPE\n");
screen_orientation = (DisplayServer::SCREEN_REVERSE_LANDSCAPE);
break;
case SDL_ORIENTATION_PORTRAIT:
// qt_extended_surface_set_content_orientation0(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION);
Expand All @@ -261,8 +261,8 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_NORMAL;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_screen_orientation OS::SCREEN_PORTRAIT\n");
screen_orientation = (OS::SCREEN_PORTRAIT);
OS::get_singleton()->print("set_screen_orientation DisplayServer::SCREEN_PORTRAIT\n");
screen_orientation = (DisplayServer::SCREEN_PORTRAIT);
break;
case SDL_ORIENTATION_PORTRAIT_FLIPPED:
// qt_extended_surface_set_content_orientation(p->qt_ext_surface, QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION);
Expand All @@ -271,8 +271,8 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
wl_orientation = WL_OUTPUT_TRANSFORM_180;
#endif
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("set_screen_orientation OS::SCREEN_REVERSE_PORTRAIT\n");
screen_orientation = (OS::SCREEN_REVERSE_PORTRAIT);
OS::get_singleton()->print("set_screen_orientation DisplayServer::SCREEN_REVERSE_PORTRAIT\n");
screen_orientation = (DisplayServer::SCREEN_REVERSE_PORTRAIT);
break;
}
break;
Expand All @@ -298,34 +298,34 @@ void ContextGL_SDL::set_ext_surface_orientation(int sdl_orientation) {
OS::get_singleton()->set_screen_orientation(screen_orientation);
}

void ContextGL_SDL::set_screen_orientation(OS::ScreenOrientation p_orientation) {
void ContextGL_SDL::set_screen_orientation(DisplayServer::ScreenOrientation p_orientation) {
#if SAILFISH_FORCE_LANDSCAPE
switch (p_orientation) {
case OS::SCREEN_LANDSCAPE:
case DisplayServer::SCREEN_LANDSCAPE:
p->allowed_orientation_str = "landscape";
p->wl_allowed_orientation = WL_OUTPUT_TRANSFORM_90;
break;
case OS::SCREEN_PORTRAIT:
case DisplayServer::SCREEN_PORTRAIT:
p->allowed_orientation_str = "portrait";
p->wl_allowed_orientation = WL_OUTPUT_TRANSFORM_NORMAL;
break;
case OS::SCREEN_REVERSE_LANDSCAPE:
case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
p->allowed_orientation_str = "inverted-landscape";
p->wl_allowed_orientation = WL_OUTPUT_TRANSFORM_270;
break;
case OS::SCREEN_REVERSE_PORTRAIT:
case DisplayServer::SCREEN_REVERSE_PORTRAIT:
p->allowed_orientation_str = "inverted-portrait";
p->wl_allowed_orientation = WL_OUTPUT_TRANSFORM_180;
break;
case OS::SCREEN_SENSOR_LANDSCAPE:
case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
p->allowed_orientation_str = "landscape";
p->wl_allowed_orientation = WL_OUTPUT_TRANSFORM_90;
break;
case OS::SCREEN_SENSOR_PORTRAIT:
case DisplayServer::SCREEN_SENSOR_PORTRAIT:
p->allowed_orientation_str = "portrait";
p->wl_allowed_orientation = WL_OUTPUT_TRANSFORM_NORMAL;
break;
case OS::SCREEN_SENSOR:
case DisplayServer::SCREEN_SENSOR:
p->allowed_orientation_str = "primary";
p->wl_allowed_orientation = WL_OUTPUT_TRANSFORM_NORMAL;
break;
Expand Down
2 changes: 1 addition & 1 deletion platform/sailfish/context_gl_sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ContextGL_SDL {
virtual bool is_using_vsync() const;
virtual SDL_Window *get_window_pointer();

void set_screen_orientation(OS::ScreenOrientation p_orientation);
void set_screen_orientation(DisplayServer::ScreenOrientation p_orientation);
// is SDL_DisplayOrientation value
void set_ext_surface_orientation(int orientation);

Expand Down
118 changes: 72 additions & 46 deletions platform/sailfish/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,59 @@ def get_name():


def can_build():

is_ok = True
if (os.name != "posix" or sys.platform == "darwin"):
return False

clang_error = os.system("clang++ --version &>/dev/null")
if(clang_error):
print("clang++ compiller not found. Install clang for all your targets in MerSDK.")
is_ok = False
else:
print("clang++ compiller is found")

# Check the minimal dependencies
sdl_error = os.system("pkg-config --version > /dev/null")
sdl_error = os.system("pkg-config --version &>/dev/null")
if (sdl_error):
print("pkg-config not found...")
return False


sdl_error = os.system("pkg-config sdl2 --modversion > /dev/null ")
sdl_error = os.system("pkg-config sdl2 --modversion &>/dev/null ")
if (sdl_error):
print("SDL2 not found. Sailfish build disabled. Install SDL2-devel for all your targets in MerSDK ")
return False
is_ok = False
else:
print("SDL2-devel is found")

# ar_error = os.system("pkg-config audioresource --modversion > /dev/null")
# if(ar_error):
# print("libaudioresource-devel not found. Install libaudioresource-devel for all your targets in MerSDK")
# return False;
# else:
# print("libaudioresource-devel is found")
libpng_error = os.system("pkg-config libpng --modversion &>/dev/null")
if(libpng_error):
print("libpng not found. Install libpng-devel for all your targets in MerSDK")
is_ok = False
else:
print("libpng is found")

glib_error = os.system("pkg-config glib-2.0 --modversion > /dev/null")
zlib_error = os.system("pkg-config zlib --modversion &>/dev/null")
if(zlib_error):
print("zlib not found. Install zlib-devel for all your targets in MerSDK")
is_ok = False
else:
print("zlib is found")

glib_error = os.system("pkg-config glib-2.0 --modversion &>/dev/null")
if(glib_error):
print("glib2-devel not found. Install glib2-devel for all your targets in MerSDK")
return False;
is_ok = False
else:
print("glib2-devel is found")

wayland_error = os.system("pkg-config wayland-client --modversion &>/dev/null")
if(wayland_error):
print("wayland-client.pc not found. Install wayland-devel for all your targets in MerSDK.")
is_ok = False
else:
print("wayland-client.pc is found")

udev_error = os.system("pkg-config libudev --modversion > /dev/null")
udev_error = os.system("pkg-config libudev --modversion &>/dev/null")
if(udev_error):
print("libudev.pc not found. Install systemd-devel for all your targets in MerSDK. Joypad support is disabled.")
# return False; # not critical
Expand All @@ -56,7 +76,14 @@ def can_build():
# print("libwebp-devel not found. Install libwebp-devel for all your targets in MerSDK\n")
# return False;

return True
openssl_error = os.system("pkg-config openssl --modversion &>/dev/null")
if(openssl_error):
print("openssl.pc not found. Install openssl-devel for all your targets in MerSDK.")
is_ok = False;
else:
print("openssl.pc is found")

return is_ok

def get_opts():
from SCons.Variables import BoolVariable, EnumVariable, PathVariable
Expand All @@ -67,8 +94,8 @@ def get_opts():
BoolVariable('use_sanitizer', 'Use LLVM compiler address sanitizer', False),
BoolVariable('use_leak_sanitizer', 'Use LLVM compiler memory leaks sanitizer (implies use_sanitizer)', False),
BoolVariable('pulseaudio', 'Detect & use pulseaudio', True),
BoolVariable('udev', 'Use udev for gamepad connection callbacks', True),
EnumVariable('debug_symbols', 'Add debug symbols to release version', 'no', ('yes', 'no', 'full')),
BoolVariable('udev', 'Use udev for gamepad connection callbacks', False),
# EnumVariable('debug_symbols', 'Add debug symbols to release version', False, [True, False]),
BoolVariable('separate_debug_symbols', 'Create a separate file with the debug symbols', False),
BoolVariable('touch', 'Enable touch events', True),
BoolVariable('tools', 'Enable editor tools', False),
Expand Down Expand Up @@ -97,14 +124,14 @@ def configure(env):
# -O3 -ffast-math is identical to -Ofast. We need to split it out so we can selectively disable
# -ffast-math in code for which it generates wrong results.
env.Prepend(CCFLAGS=['-O3', '-ffast-math', '-DGLES_ENABLED'])
if (env["debug_symbols"] == "yes"):
if (env["debug_symbols"]):
env.Prepend(CCFLAGS=['-g1'])
if (env["debug_symbols"] == "full"):
env.Prepend(CCFLAGS=['-g2'])

elif (env["target"] == "release_debug"):
env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED', '-DGLES_ENABLED'])
if (env["debug_symbols"] == "yes"):
if (env["debug_symbols"]):
env.Prepend(CCFLAGS=['-g1'])
if (env["debug_symbols"] == "full"):
env.Prepend(CCFLAGS=['-g2'])
Expand All @@ -116,8 +143,8 @@ def configure(env):
## Architecture

is64 = sys.maxsize > 2**32
if (env["bits"] == "default"):
env["bits"] = "64" if is64 else "32"
# if (env["bits"] == "default"):
env["bits"] = "64" if is64 else "32"

## Compiler configuration

Expand All @@ -142,15 +169,15 @@ def configure(env):
env.Append(CCFLAGS=['-fsanitize=leak'])
env.Append(LINKFLAGS=['-fsanitize=leak'])

if env['use_lto']:
env.Append(CCFLAGS=['-flto'])
if not env['use_llvm'] and env.GetOption("num_jobs") > 1:
env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))])
else:
env.Append(LINKFLAGS=['-flto'])
if not env['use_llvm']:
env['RANLIB'] = 'gcc-ranlib'
env['AR'] = 'gcc-ar'
# if env['use_lto']:
# env.Append(CCFLAGS=['-flto'])
# if not env['use_llvm'] and env.GetOption("num_jobs") > 1:
# env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))])
# else:
# env.Append(LINKFLAGS=['-flto'])
# if not env['use_llvm']:
# env['RANLIB'] = 'gcc-ranlib'
# env['AR'] = 'gcc-ar'

env.Append(CCFLAGS=['-pipe'])
env.Append(LINKFLAGS=['-pipe'])
Expand Down Expand Up @@ -197,15 +224,15 @@ def configure(env):
if not env['builtin_libpng']:
env.ParseConfig('pkg-config libpng --cflags --libs')

if not env['builtin_bullet']:
# We need at least version 2.88
import subprocess
bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip()
if bullet_version < "2.88":
# Abort as system bullet was requested but too old
print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.88"))
sys.exit(255)
env.ParseConfig('pkg-config bullet --cflags --libs')
# if not env['builtin_bullet']:
# # We need at least version 2.88
# import subprocess
# bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip()
# if bullet_version < "2.88":
# # Abort as system bullet was requested but too old
# print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.88"))
# sys.exit(255)
# env.ParseConfig('pkg-config bullet --cflags --libs')

if not env['builtin_enet']:
env.ParseConfig('pkg-config libenet --cflags --libs')
Expand All @@ -224,16 +251,16 @@ def configure(env):
env['builtin_libvorbis'] = False # Needed to link against system libtheora
env.ParseConfig('pkg-config theora theoradec --cflags --libs')

if not env['builtin_libvpx']:
env.ParseConfig('pkg-config vpx --cflags --libs')
# if not env['builtin_libvpx']:
# env.ParseConfig('pkg-config vpx --cflags --libs')

if not env['builtin_libvorbis']:
env['builtin_libogg'] = False # Needed to link against system libvorbis
env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs')

if not env['builtin_opus']:
env['builtin_libogg'] = False # Needed to link against system opus
env.ParseConfig('pkg-config opus opusfile --cflags --libs')
# if not env['builtin_opus']:
# env['builtin_libogg'] = False # Needed to link against system opus
# env.ParseConfig('pkg-config opus opusfile --cflags --libs')

if not env['builtin_libogg']:
env.ParseConfig('pkg-config ogg --cflags --libs')
Expand Down Expand Up @@ -266,9 +293,8 @@ def configure(env):
print("PulseAudio development libraries not found, disabling driver")

if (platform.system() == "Linux"):
env.Append(CPPFLAGS=["-DJOYDEV_ENABLED", '-DGLES_ENABLED'])

if env['udev']:
env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"])
if (os.system("pkg-config --exists libudev") == 0): # 0 means found
print("Enabling udev support")
env.Append(CPPFLAGS=["-DUDEV_ENABLED"])
Expand Down
Loading

0 comments on commit 54b5d07

Please sign in to comment.