Browse Source

scripts: sailfish: initial SailfishOS support

pull/2/head
Alibek Omarov 1 year ago
parent
commit
8caa2d142f
  1. 2
      engine/wscript
  2. 2
      filesystem/wscript
  3. 13
      game_launch/game.cpp
  4. 4
      game_launch/wscript
  5. 1
      public/wscript
  6. 79
      scripts/sailfish/build.sh
  7. 21
      scripts/sailfish/deploy.sh
  8. 17
      scripts/sailfish/harbour-xash3d-fwgs.desktop
  9. 83
      scripts/sailfish/harbour-xash3d-fwgs.spec
  10. 31
      scripts/sailfish/run.sh
  11. 3
      scripts/waifulib/xcompile.py
  12. 19
      wscript

2
engine/wscript

@ -263,5 +263,5 @@ def build(bld):
use = libs, use = libs,
install_path = install_path, install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM, subsystem = bld.env.MSVC_SUBSYSTEM,
rpath = '$ORIGIN', rpath = bld.env.DEFAULT_RPATH,
) )

2
filesystem/wscript

@ -45,6 +45,6 @@ def build(bld):
source = tests[i], source = tests[i],
target = 'test_%s' % i, target = 'test_%s' % i,
use = libs + ['DL'], use = libs + ['DL'],
rpath = '$ORIGIN', rpath = bld.env.DEFAULT_RPATH,
subsystem = bld.env.CONSOLE_SUBSYSTEM, subsystem = bld.env.CONSOLE_SUBSYSTEM,
install_path = None) install_path = None)

13
game_launch/game.cpp

@ -153,6 +153,19 @@ _inline int Sys_Start( void )
pfnChangeGame changeGame = NULL; pfnChangeGame changeGame = NULL;
const char *game = getenv( E_GAME ); const char *game = getenv( E_GAME );
#ifdef XASH_SAILFISH
const char *home = getenv( "HOME" );
char buf[1024];
snprintf( buf, sizeof( buf ), "%s/xash", home );
setenv( "XASH3D_BASEDIR", buf, true );
#if XASH_SAILFISH == aurora
setenv( "XASH3D_RODIR", "/usr/share/su.xash.Engine/rodir", true );
#else
setenv( "XASH3D_RODIR", "/usr/share/harbour-xash3d-fwgs/rodir", true );
#endif
#endif // SAILFISH
if( !game ) if( !game )
game = XASH_GAMEDIR; game = XASH_GAMEDIR;

4
game_launch/wscript

@ -23,6 +23,7 @@ def configure(conf):
def build(bld): def build(bld):
libs = ['sdk_includes'] libs = ['sdk_includes']
source = ['game.cpp'] source = ['game.cpp']
defines = []
if bld.env.DEST_OS != 'win32': if bld.env.DEST_OS != 'win32':
libs += [ 'DL' ] libs += [ 'DL' ]
@ -34,7 +35,8 @@ def build(bld):
target = 'xash3d', # hl.exe target = 'xash3d', # hl.exe
features = 'c cxx cxxprogram', features = 'c cxx cxxprogram',
use = libs, use = libs,
rpath = '$ORIGIN', defines = defines,
rpath = bld.env.DEFAULT_RPATH,
install_path = bld.env.BINDIR, install_path = bld.env.BINDIR,
subsystem = bld.env.MSVC_SUBSYSTEM subsystem = bld.env.MSVC_SUBSYSTEM
) )

1
public/wscript

@ -35,6 +35,5 @@ def build(bld):
source = tests[i], source = tests[i],
target = 'test_%s' % i, target = 'test_%s' % i,
use = 'public', use = 'public',
rpath = '$ORIGIN',
subsystem = bld.env.CONSOLE_SUBSYSTEM, subsystem = bld.env.CONSOLE_SUBSYSTEM,
install_path = None) install_path = None)

79
scripts/sailfish/build.sh

@ -0,0 +1,79 @@
#!/bin/bash
. scripts/lib.sh
download_sign_key()
{
echo -n "Downloading $1: "
curl https://community.omprussia.ru/documentation/files/doc/$1 -o $1 &> /dev/null || die "Can't download $1" && echo "OK"
}
pack_sources()
{
echo "Packing sources to $1..."
git ls-files --recurse-submodules | tar caf "$1" -T-
}
dependencies="SDL2-devel ImageMagick"
build_dir="build_rpm"
if [ "$1" == "aurora" ]; then
name="su.xash.Engine"
flavor="aurora"
else
name="harbour-xash3d-fwgs"
flavor="sailfish"
fi
if [ $flavor == 'aurora' ]; then
download_sign_key regular_key.pem
download_sign_key regular_cert.pem
fi
rm -fr ${build_dir}/{BUILD,SRPMS}
mkdir -p ${build_dir}/SOURCES
pack_sources ${build_dir}/SOURCES/${name}.tar
git clone https://github.com/FWGS/hlsdk-portable -b mobile_hacks
pushd hlsdk-portable
pack_sources ../${build_dir}/SOURCES/hlsdk-portable.tar
popd
sfdk_targets=`sfdk engine exec sb2-config -l | grep default | grep -v i486`
for each in $sfdk_targets; do
target_arch=${each##*-}
target_arch=${target_arch/.default/}
echo "Build for '$each' target with '$target_arch' architecture"
# install deps for current target
sfdk engine exec sb2 -t $each -R -m sdk-install zypper in -y ${dependencies}
# build RPM for current target
sfdk engine exec sb2 -t $each rpmbuild \
--define "_topdir `pwd`/${build_dir}" \
--define "_arch $target_arch" \
--define "_packagename $name" \
--define "_flavor $flavor" \
-ba scripts/sailfish/harbour-xash3d-fwgs.spec || die "Build for ${each}: FAIL"
# sign RPM packacge
if [ "$flavor" == "aurora" ]; then
echo -n "Signing RPMs: "
sfdk engine exec sb2 -t $each rpmsign-external sign --key `pwd`/regular_key.pem --cert `pwd`/regular_cert.pem `pwd`/${build_dir}/RPMS/${target_arch}/$name-0*.rpm || die "FAIL" && echo "OK"
fi
echo -n "Validate RPM: "
if [ "$flavor" == "aurora" ]; then
validator_output=`sfdk engine exec rpm-validator -p regular $(pwd)/${build_dir}/RPMS/${target_arch}/$name-0* 2>&1`
else
sfdk config target=${each/.default/}
validator_output=`sfdk check $(pwd)/${build_dir}/RPMS/${target_arch}/$name-0* 2>&1`
fi
if [ $? -ne 0 ] ; then
echo "FAIL"
echo "${validator_output}"
break;
fi
echo "OK"
done
echo "All build done! All your packages in `pwd`/build_rpm/RPMS"

21
scripts/sailfish/deploy.sh

@ -0,0 +1,21 @@
#!/bin/bash
PASSWORD="12345"
IP="192.168.1.10"
if [ "$1" == "aurora" ]; then
name="su.xash.Engine"
arch="armv7hl" # lame!
else
name="harbour-xash3d-fwgs"
arch="aarch64" # absolutely lame...
fi
package=$(ls build_rpm/RPMS/$arch/$name-0*.rpm)
sshpass -p $PASSWORD scp $package defaultuser@$IP:~/
# sandwich of programs:
# 1. Call sshpass to automatically fill password for ssh session
# 2. Call devel-su that reads password from stdin
# 3. devel-su calls pkcon install-local -y and installs the package
echo $PASSWORD | sshpass -p $PASSWORD ssh defaultuser@$IP devel-su pkcon install-local -y $(basename $package)

17
scripts/sailfish/harbour-xash3d-fwgs.desktop

@ -0,0 +1,17 @@
[Desktop Entry]
Categories=Game;Shooter;
Comment=Half-Life compatible game engine
Exec=__REPLACE_EXEC__
Icon=__REPLACE_ICON__
Keywords=first;person;shooter;multiplayer;half-life;halflife;singleplayer;
Name=Xash3D FWGS
Name[en]=Xash3D FWGS
PrefersNonDefaultGPU=true
Terminal=false
Type=Application
X-Nemo-Application-Type=silica-qt5
[X-Sailjail]
Permissions=Audio;Internet;Microphone;PublicDir;
OrganizationName=su.xash
ApplicationName=Engine

83
scripts/sailfish/harbour-xash3d-fwgs.spec

@ -0,0 +1,83 @@
# Based on harbour-quake2 spec file
Name: %{_packagename}
Summary: Xash3D FWGS
Release: 1
Version: 0.20
Group: Amusements/Games
License: GPLv2
BuildArch: %{_arch}
URL: https://github.com/FWGS/xash3d-fwgs
Source0: %{name}.tar
Source1: hlsdk-portable.tar
BuildRequires: SDL2-devel ImageMagick
%define __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$
%description
Xash3D FWGS is a game engine compatible with Half-Life 1 and mods.
%prep
tar -xf %{_topdir}/SOURCES/%{name}.tar
python3 waf configure \
-T release \
--sailfish=%{_flavor} \
--enable-stbtt \
--enable-bundled-deps \
--enable-packaging \
--disable-gl \
--enable-gles2 \
--enable-gl4es \
--prefix=/usr \
--libdir=%{_datadir}/%{name}/lib \
--bindir=%{_bindir}
mkdir -p hlsdk-portable
pushd hlsdk-portable
tar -xf %{_topdir}/SOURCES/hlsdk-portable.tar
python3 waf configure -T release
popd
%build
python3 waf build -j$(($(nproc)+1))
pushd hlsdk-portable
python3 waf build -j$(($(nproc)+1))
popd
%install
python3 waf install --destdir=%{buildroot}
pushd hlsdk-portable
python3 waf install --destdir=%{buildroot}%{_datadir}/%{name}/rodir
popd
# rename real binary
mv %{buildroot}/usr/bin/xash3d %{buildroot}/usr/bin/%{name}
install -d %{buildroot}/%{_datadir}/applications
sed "s/__REPLACE_ICON__/su.xash.Engine/g;s/__REPLACE_EXEC__/su.xash.Engine/g;" scripts/sailfish/harbour-xash3d-fwgs.desktop > %{buildroot}/%{_datadir}/applications/%{name}.desktop
chmod 644 %{buildroot}/%{_datadir}/applications/%{name}.desktop
install -d %{buildroot}/%{_datadir}/icons/hicolor/86x86/apps
install -d %{buildroot}/%{_datadir}/icons/hicolor/108x108/apps
install -d %{buildroot}/%{_datadir}/icons/hicolor/128x128/apps
install -d %{buildroot}/%{_datadir}/icons/hicolor/172x172/apps
convert game_launch/icon-xash-material.png -resize 86x86 %{buildroot}/%{_datadir}/icons/hicolor/86x86/apps/%{name}.png
convert game_launch/icon-xash-material.png -resize 108x108 %{buildroot}/%{_datadir}/icons/hicolor/108x108/apps/%{name}.png
convert game_launch/icon-xash-material.png -resize 128x128 %{buildroot}/%{_datadir}/icons/hicolor/128x128/apps/%{name}.png
convert game_launch/icon-xash-material.png -resize 172x172 %{buildroot}/%{_datadir}/icons/hicolor/172x172/apps/%{name}.png
%files
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{name}
%attr(755,root,root) %{_datadir}/%{name}/lib/*
%attr(644,root,root) %{_datadir}/%{name}/rodir/valve/extras.pk3
%attr(755,root,root) %{_datadir}/%{name}/rodir/valve/cl_dlls/*
%attr(755,root,root) %{_datadir}/%{name}/rodir/valve/dlls/*
%attr(644,root,root) %{_datadir}/icons/hicolor/86x86/apps/%{name}.png
%attr(644,root,root) %{_datadir}/icons/hicolor/108x108/apps/%{name}.png
%attr(644,root,root) %{_datadir}/icons/hicolor/128x128/apps/%{name}.png
%attr(644,root,root) %{_datadir}/icons/hicolor/172x172/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop
%changelog
* Thu Jun 1 2023 a1batross <a1ba.omarov@gmail.com>
- initial port

31
scripts/sailfish/run.sh

@ -0,0 +1,31 @@
#!/bin/sh
die()
{
echo "$@"
exit 1
}
echo "Xash3D FWGS installed as Sailfish RPM"
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
# $XDG_DATA_HOME defines the base directory relative to which user-specific data files should be stored.
# If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
if [ -z "$XDG_DATA_HOME" ]; then
export XDG_DATA_HOME="$HOME/.local/share"
fi
if [ -z "$XASH3D_BASEDIR" ]; then
export XASH3D_BASEDIR="$XDG_DATA_HOME/xash3d-fwgs/"
fi
mkdir -p "$XASH3D_BASEDIR"
cd "$XASH3D_BASEDIR" || die "Can't cd into $XASH3D_BASEDIR"
echo "XASH3D_BASEDIR is $XASH3D_BASEDIR"
#if [ -z "$XASH3D_EXTRAS_PAK1" ]; then
# export XASH3D_EXTRAS_PAK1=/app/share/xash3d/valve/extras.pk3
#fi
#echo "XASH3D_EXTRAS_PAK1 is $XASH3D_EXTRAS_PAK1"
exec $DEBUGGER /app/lib32/xash3d/xash3d "$@"

3
scripts/waifulib/xcompile.py

@ -510,6 +510,8 @@ def options(opt):
help='enable building for Nintendo Switch [default: %default]') help='enable building for Nintendo Switch [default: %default]')
xc.add_option('--psvita', action='store_true', dest='PSVITA', default = False, xc.add_option('--psvita', action='store_true', dest='PSVITA', default = False,
help='enable building for PlayStation Vita [default: %default]') help='enable building for PlayStation Vita [default: %default]')
xc.add_option('--sailfish', action='store', dest='SAILFISH', default = None,
help='enable building for Sailfish/Aurora')
def configure(conf): def configure(conf):
if conf.options.ANDROID_OPTS: if conf.options.ANDROID_OPTS:
@ -593,6 +595,7 @@ def configure(conf):
conf.env.MAGX = conf.options.MAGX conf.env.MAGX = conf.options.MAGX
conf.env.MSVC_WINE = conf.options.MSVC_WINE conf.env.MSVC_WINE = conf.options.MSVC_WINE
conf.env.SAILFISH = conf.options.SAILFISH
MACRO_TO_DESTOS = OrderedDict({ '__ANDROID__' : 'android', '__SWITCH__' : 'nswitch', '__vita__' : 'psvita' }) MACRO_TO_DESTOS = OrderedDict({ '__ANDROID__' : 'android', '__SWITCH__' : 'nswitch', '__vita__' : 'psvita' })
for k in c_config.MACRO_TO_DESTOS: for k in c_config.MACRO_TO_DESTOS:
MACRO_TO_DESTOS[k] = c_config.MACRO_TO_DESTOS[k] # ordering is important MACRO_TO_DESTOS[k] = c_config.MACRO_TO_DESTOS[k] # ordering is important

19
wscript

@ -261,6 +261,13 @@ def configure(conf):
# check if we're in a sgug environment # check if we're in a sgug environment
if 'sgug' in os.environ['LD_LIBRARYN32_PATH']: if 'sgug' in os.environ['LD_LIBRARYN32_PATH']:
linkflags.append('-lc') linkflags.append('-lc')
elif conf.env.SAILFISH != None:
# TODO: enable XASH_MOBILE_PLATFORM
conf.env.append_unique('DEFINES', 'XASH_SAILFISH=%s' % conf.env.SAILFISH)
# Do not warn us about bug in SDL_Audio headers
conf.env.append_unique('CFLAGS', ['-Wno-attributes'])
conf.env.append_unique('CXXFLAGS', ['-Wno-attributes'])
conf.check_cc(cflags=cflags, linkflags=linkflags, msg='Checking for required C flags') conf.check_cc(cflags=cflags, linkflags=linkflags, msg='Checking for required C flags')
conf.check_cxx(cxxflags=cxxflags, linkflags=linkflags, msg='Checking for required C++ flags') conf.check_cxx(cxxflags=cxxflags, linkflags=linkflags, msg='Checking for required C++ flags')
@ -335,6 +342,11 @@ def configure(conf):
conf.env.DEDICATED = conf.options.DEDICATED conf.env.DEDICATED = conf.options.DEDICATED
conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED
if conf.env.SAILFISH == 'aurora':
conf.env.DEFAULT_RPATH = '/usr/share/su.xash.Engine/lib'
else:
conf.env.DEFAULT_RPATH = '$ORIGIN'
setattr(conf, 'refdlls', REFDLLS) setattr(conf, 'refdlls', REFDLLS)
for refdll in REFDLLS: for refdll in REFDLLS:
@ -432,8 +444,13 @@ int main(int argc, char **argv) { strchrnul(argv[1], 'x'); return 0; }'''
conf.env.PACKAGING = conf.options.PACKAGING conf.env.PACKAGING = conf.options.PACKAGING
if conf.options.PACKAGING: if conf.options.PACKAGING:
conf.env.PREFIX = conf.options.prefix conf.env.PREFIX = conf.options.prefix
conf.env.LIBDIR = conf.env.BINDIR = conf.env.LIBDIR + '/xash3d' if conf.env.SAILFISH == "aurora":
conf.env.SHAREDIR = '${PREFIX}/share/su.xash.Engine/rodir'
elif conf.env.SAILFISH == "sailfish":
conf.env.SHAREDIR = '${PREFIX}/share/harbour-xash3d-fwgs/rodir'
else:
conf.env.SHAREDIR = '${PREFIX}/share/xash3d' conf.env.SHAREDIR = '${PREFIX}/share/xash3d'
conf.env.LIBDIR += '/xash3d'
else: else:
conf.env.SHAREDIR = conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX conf.env.SHAREDIR = conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX

Loading…
Cancel
Save