mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-21 09:07:50 -06:00
chore: merge knulli and amberelec launchers
This commit is contained in:
commit
5073e4ea85
15 files changed
+3579
-76
No files matched your search
@@ -0,0 +1,345 @@
|
||||
"""AmberELEC's launcher layer, read from runemu.py and its emulator scripts.
|
||||
|
||||
The fixtures are cut-down copies of what each extractor reads at AmberELEC
|
||||
a21975bf (prerelease-20261019_1835). Records must name the files in the
|
||||
order the code writes them, cite the fixture's own lines, and a construct
|
||||
that is gone must stop the scrape.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import sys
|
||||
import textwrap
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
from scraper import amberelec_launchers as al # noqa: E402
|
||||
from scraper.configgen_launchers import LauncherShapeError # noqa: E402
|
||||
|
||||
|
||||
def text(block: str) -> str:
|
||||
return textwrap.dedent(block).lstrip("\n")
|
||||
|
||||
|
||||
RUNEMU = text(
|
||||
"""
|
||||
standalone_emulators = {
|
||||
'AMIBERRY': StandaloneEmulator('amiberry', ['/usr/bin/amiberry.sh', '<path>']),
|
||||
'HATARISA': StandaloneEmulator('hatari', ['/usr/bin/hatari.sh', '<path>']),
|
||||
'pico8': StandaloneEmulator('pico8_64', ['/usr/bin/pico-8.sh', '<path>']),
|
||||
'piemu': StandaloneEmulator('piemu', ['/usr/bin/bash', '-l', '/usr/bin/piemu.sh', '<path>']),
|
||||
'yabasanshiroSA': StandaloneEmulator('yabasanshiro', ['/usr/bin/yabasanshiro.sh', '<path>']),
|
||||
}
|
||||
|
||||
class EmuRunner():
|
||||
def get_retroarch_command(self, shader_arg):
|
||||
if self.emulator == 'mame':
|
||||
if rom_path:
|
||||
cmd = f'{mame_system} -{mame_slot} "{rom_path}" -rp /roms/bios/mame;/roms/bios -cfg_directory /x'
|
||||
else:
|
||||
cmd = f'{mame_system} -rp /roms/bios/mame;/roms/bios -cfg_directory /x'
|
||||
"""
|
||||
)
|
||||
|
||||
YABASANSHIRO = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
get_setting "use_hlebios"
|
||||
HLEBIOS='0'
|
||||
BIOS=""
|
||||
if [ "${HLEBIOS}" != 1 ]; then
|
||||
if [ -e "/storage/roms/bios/saturn_bios.bin" ]; then
|
||||
BIOS="-b /storage/roms/bios/saturn_bios.bin"
|
||||
else
|
||||
text_viewer -e -w -t "Notice! Yabasanshiro BIOS Missing!" -m "not found"
|
||||
fi
|
||||
fi
|
||||
{ yabasanshiro -r 2 -i "${1}" ${BIOS}; } > /tmp/logs/exec.log 2>&1
|
||||
"""
|
||||
)
|
||||
|
||||
PICO8 = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
mkdir -p "/storage/roms/pico-8"
|
||||
if [ ! -f "/storage/roms/pico-8/pico8_64" ] || [ ! -f "/storage/roms/pico-8/pico8.dat" ]; then
|
||||
text_viewer -e -w -t "Missing Pico-8 binaries!" -m "Extract your purchased pico8_64."
|
||||
else
|
||||
/storage/roms/pico-8/pico8_64 -home -root_path /storage/roms/pico-8 ${OPTIONS} "${CART}"
|
||||
fi
|
||||
"""
|
||||
)
|
||||
|
||||
PIEMU = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
ROMS_DIR="/storage/roms"
|
||||
BIOS_DIR="$ROMS_DIR/bios"
|
||||
if [[ "$EXTENSION" == "pfs" ]]; then
|
||||
/usr/bin/mkpfi "$BIOS_DIR/all.bin"
|
||||
fi
|
||||
"""
|
||||
)
|
||||
|
||||
HATARI_SH = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
HATARI_CONFIG_DIR=/storage/.config/hatari/conf
|
||||
cp $HATARI_CONFIG_DIR/Atari-ST-default.cfg "$HATARI_TMP_CONFIG"
|
||||
nice -n -19 hatari --configfile "$HATARI_TMP_CONFIG" --disk-a "$1" >> $HATARI_LOG 2>&1
|
||||
"""
|
||||
)
|
||||
|
||||
HATARI_CFG = text(
|
||||
"""
|
||||
[ROM]
|
||||
szTosImageFileName = /storage/roms/bios/tos.img
|
||||
bPatchTos = TRUE
|
||||
"""
|
||||
)
|
||||
|
||||
ATARI800_CFG = text(
|
||||
"""
|
||||
Atari 800 Emulator, Version 3.1.0
|
||||
ROM_OS_A_NTSC=
|
||||
ROM_OS_A_PAL=/storage/roms/bios/ATARIOSA.ROM
|
||||
ROM_5200=/storage/roms/bios/5200.rom
|
||||
"""
|
||||
)
|
||||
|
||||
ATARI800_PATCH = text(
|
||||
"""
|
||||
+ LDFLAGS += -static-libgcc
|
||||
+ CFLAGS += -DDEFAULT_CFG_NAME="\\"/storage/.config/distribution/configs/atari800.cfg\\""
|
||||
"""
|
||||
)
|
||||
|
||||
AMIBERRY_MK = text(
|
||||
"""
|
||||
makeinstall_target() {
|
||||
mkdir -p ${INSTALL}/usr/config/amiberry
|
||||
ln -s /storage/roms/bios ${INSTALL}/usr/config/amiberry/kickstarts
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
AMIBERRY_SH = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
AMIBERRY_CONFIG_DIR=$AMIBERRY_DIR/conf
|
||||
AMIBERRY_SET_CONF() {
|
||||
if [ `echo $1 | egrep 'AGA|CD32' | wc -l` -eq 1 ]; then
|
||||
cp $AMIBERRY_CONFIG_DIR/AmigaA1200-default.uae "$AMIBERRY_TMP_CONFIG"
|
||||
else
|
||||
cp $AMIBERRY_CONFIG_DIR/AmigaA500-default.uae "$AMIBERRY_TMP_CONFIG"
|
||||
fi
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def uae(rom: str) -> str:
|
||||
return f"amiberry.rom_path=/storage/.config/amiberry/kickstarts/\nkickstart_rom_file=$(FILE_PATH)/{rom}\n"
|
||||
|
||||
|
||||
SCUMMVM_SH = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
case $1 in
|
||||
"libretro")
|
||||
sed -i '2,2s/^/themepath=\\/roms\\/bios\\/scummvm\\/theme\\n/' ${BIOSPATH}/scummvm.ini
|
||||
sed -i '2,2s/^/extrapath=\\/roms\\/bios\\/scummvm\\/extra\\n/' ${BIOSPATH}/scummvm.ini
|
||||
sed -i '2,2s/^/browser_lastpath=\\/roms\\/bios\\/scummvm\\/extra\\n/' ${BIOSPATH}/scummvm.ini
|
||||
;;
|
||||
esac
|
||||
"""
|
||||
)
|
||||
|
||||
FREEJ2ME = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
if [ ! -f "/storage/roms/bios/{jar}" ]; then
|
||||
cp /usr/config/distribution/freej2me/{jar} /storage/roms/bios
|
||||
fi
|
||||
"""
|
||||
)
|
||||
|
||||
EASYRPG = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
install_bios() {
|
||||
BIOS="$1"
|
||||
curl -Lo "${BIOS}" "${PKG_URL}/${BIOS}"
|
||||
}
|
||||
INSTALLPATH="/storage/roms/bios"
|
||||
PKG_URL="https://dl.degica.com/rpgmakerweb/run-time-packages"
|
||||
install_bios rpg2000_rtp_installer.exe rtp/2000
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def tree(**overrides: str) -> dict[str, str]:
|
||||
files = {
|
||||
al.RUNEMU: RUNEMU,
|
||||
al.RETROARCH_CFG: 'savefile_directory = "~/saves"\nsystem_directory = "~/roms/bios"\n',
|
||||
al.RETRORUN: '/usr/bin/retrorun -c "${RRCONF}" -s /storage/roms/"$3" -d /roms/bios "$EMU" "$2"\n',
|
||||
al.SCRIPTS["yabasanshiroSA"]: YABASANSHIRO,
|
||||
al.SCRIPTS["pico8"]: PICO8,
|
||||
al.SCRIPTS["piemu"]: PIEMU,
|
||||
al.SCRIPTS["HATARISA"]: HATARI_SH,
|
||||
al.HATARI_CONFIG: HATARI_CFG,
|
||||
al.ATARI800_CONFIG: ATARI800_CFG,
|
||||
al.ATARI800_PATCH: ATARI800_PATCH,
|
||||
al.AMIBERRY_PACKAGE: AMIBERRY_MK,
|
||||
al.SCRIPTS["AMIBERRY"]: AMIBERRY_SH,
|
||||
f"{al.AMIBERRY_CONFIGS}/AmigaA1200-default.uae": uae("kick40068.A1200.rom"),
|
||||
f"{al.AMIBERRY_CONFIGS}/AmigaA500-default.uae": uae("kick34005.A500.rom"),
|
||||
al.SCRIPTS["SCUMMVMSA"]: SCUMMVM_SH,
|
||||
al.EASYRPG: EASYRPG,
|
||||
**{path: FREEJ2ME.replace("{jar}", f"{core}-lr.jar") for core, path in al.FREEJ2ME},
|
||||
}
|
||||
files.update(overrides)
|
||||
return files
|
||||
|
||||
|
||||
def read(**overrides: str):
|
||||
return tree(**overrides).__getitem__
|
||||
|
||||
|
||||
class Frontends(unittest.TestCase):
|
||||
def test_retroarch_system_directory(self):
|
||||
(record,) = al.retroarch(read())
|
||||
self.assertEqual(record.search_dir, "~/roms/bios")
|
||||
self.assertEqual(record.source_ref, f"{al.RETROARCH_CFG}:2")
|
||||
|
||||
def test_retrorun_directory(self):
|
||||
(record,) = al.retrorun(read())
|
||||
self.assertEqual((record.search_dir, record.passes_to), ("/roms/bios", "command line -d"))
|
||||
|
||||
def test_mame_search_path_of_both_commands(self):
|
||||
(record,) = al.mame(al.Runemu(read()))
|
||||
self.assertEqual(record.search_dir, "/roms/bios/mame;/roms/bios")
|
||||
self.assertEqual(record.depends_on_option, "self.emulator == 'mame'")
|
||||
self.assertEqual(record.source_ref, f"{al.RUNEMU}:11, 13, 15")
|
||||
|
||||
def test_a_retroarch_config_without_the_key_raises(self):
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
al.retroarch(read(**{al.RETROARCH_CFG: "x = 1\n"}))
|
||||
|
||||
|
||||
class Standalone(unittest.TestCase):
|
||||
def test_yabasanshiro_flag_after_the_presence_test(self):
|
||||
(record,) = al.yabasanshiro(read(), al.Runemu(read()))
|
||||
self.assertEqual(record.names, ["saturn_bios.bin"])
|
||||
self.assertEqual(record.passes_to, "command line -b")
|
||||
self.assertIs(record.fails_when_missing, False)
|
||||
self.assertEqual(record.depends_on_option, "use_hlebios")
|
||||
self.assertEqual(
|
||||
record.source_ref,
|
||||
f"{al.RUNEMU}:6, {al.SCRIPTS['yabasanshiroSA']}:2, 5-7, 12",
|
||||
)
|
||||
|
||||
def test_pico8_binaries_outside_bios(self):
|
||||
(record,) = al.pico8(read(), al.Runemu(read()))
|
||||
self.assertEqual(record.names, ["pico8_64", "pico8.dat"])
|
||||
self.assertEqual(record.search_dir, "/storage/roms/pico-8")
|
||||
self.assertEqual(record.fails_when_missing, "Missing Pico-8 binaries!")
|
||||
self.assertEqual(record.source_ref, f"{al.RUNEMU}:4, {al.SCRIPTS['pico8']}:3-6")
|
||||
|
||||
def test_piemu_flash_image_source(self):
|
||||
(record,) = al.piemu(read(), al.Runemu(read()))
|
||||
self.assertEqual(record.names, ["all.bin"])
|
||||
self.assertEqual(record.source_ref, f"{al.RUNEMU}:5, {al.SCRIPTS['piemu']}:2-5")
|
||||
|
||||
def test_hatari_default_config(self):
|
||||
(record,) = al.hatari(read(), al.Runemu(read()))
|
||||
self.assertEqual(record.names, ["tos.img"])
|
||||
self.assertEqual(record.passes_to, "Atari-ST-default.cfg [ROM] szTosImageFileName")
|
||||
self.assertEqual(
|
||||
record.source_ref,
|
||||
f"{al.RUNEMU}:3, {al.SCRIPTS['HATARISA']}:3-4, {al.HATARI_CONFIG}:2",
|
||||
)
|
||||
|
||||
def test_amiberry_link_and_one_kickstart_per_config(self):
|
||||
link, a1200, a500 = al.amiberry(read(), al.Runemu(read()))
|
||||
self.assertEqual(link.kind, "links")
|
||||
self.assertEqual(link.passes_to, "/usr/config/amiberry/kickstarts is a symlink to it")
|
||||
self.assertEqual((a1200.slot, a1200.names), ("A1200", ["kick40068.A1200.rom"]))
|
||||
self.assertEqual((a500.slot, a500.names), ("A500", ["kick34005.A500.rom"]))
|
||||
self.assertEqual(a500.depends_on_option, f"not ({a1200.depends_on_option})")
|
||||
|
||||
def test_a_table_running_another_script_raises(self):
|
||||
broken = RUNEMU.replace("/usr/bin/yabasanshiro.sh", "/usr/bin/yaba.sh")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
al.yabasanshiro(read(), al.Runemu(read(**{al.RUNEMU: broken})))
|
||||
|
||||
def test_a_bios_test_written_another_way_raises(self):
|
||||
broken = YABASANSHIRO.replace('if [ -e "/storage', 'if test -e "/storage')
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
al.yabasanshiro(read(**{al.SCRIPTS["yabasanshiroSA"]: broken}), al.Runemu(read()))
|
||||
|
||||
|
||||
class Cores(unittest.TestCase):
|
||||
def test_atari800_built_to_read_the_shipped_config(self):
|
||||
(record,) = al.atari800(read())
|
||||
self.assertEqual(record.names, ["ATARIOSA.ROM", "5200.rom"])
|
||||
self.assertEqual(record.source_ref, f"{al.ATARI800_PATCH}:2, {al.ATARI800_CONFIG}:3-4")
|
||||
|
||||
def test_atari800_built_for_another_config_raises(self):
|
||||
broken = ATARI800_PATCH.replace("atari800.cfg", "other.cfg")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
al.atari800(read(**{al.ATARI800_PATCH: broken}))
|
||||
|
||||
def test_scummvm_paths_written_under_bios(self):
|
||||
theme, extra = al.scummvm(read())
|
||||
self.assertEqual(theme.search_dir, "/roms/bios/scummvm/theme")
|
||||
self.assertEqual(extra.passes_to, "scummvm.ini extrapath")
|
||||
|
||||
def test_freej2me_copies_the_shipped_jar(self):
|
||||
plain, plus = al.freej2me(read())
|
||||
self.assertEqual((plain.kind, plain.names), ("copies", ["freej2me-lr.jar"]))
|
||||
self.assertEqual(plus.names, ["freej2me-plus-lr.jar"])
|
||||
self.assertEqual(plain.search_dir, "/usr/config/distribution/freej2me")
|
||||
|
||||
def test_easyrpg_download_per_runtime(self):
|
||||
(record,) = al.easyrpg(read())
|
||||
self.assertEqual(
|
||||
record.search_dir,
|
||||
"https://dl.degica.com/rpgmakerweb/run-time-packages/rpg2000_rtp_installer.exe",
|
||||
)
|
||||
self.assertEqual(record.passes_to, "/storage/roms/bios/rtp/2000")
|
||||
|
||||
def test_every_extractor_runs_on_the_fixture(self):
|
||||
records = al.extract_launchers(read())
|
||||
# One easyrpg runtime in the fixture, two at the pinned commit.
|
||||
self.assertEqual(len(records), 16)
|
||||
|
||||
|
||||
class PlatformFile(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.config = yaml.safe_load((REPO_ROOT / "platforms" / "amberelec.yml").read_text())
|
||||
|
||||
def test_the_layer_is_written(self):
|
||||
self.assertTrue(self.config["launchers"])
|
||||
|
||||
def test_every_reference_is_in_the_repository(self):
|
||||
for record in self.config["launchers"]:
|
||||
self.assertTrue(record["source_ref"].startswith("packages/"), record)
|
||||
|
||||
def test_every_emulator_is_one_amberelec_names(self):
|
||||
cores = {*self.config["cores"], *self.config.get("standalone_cores", [])}
|
||||
named = {n for record in self.config["launchers"] for n in record["emulator"].split(", ")}
|
||||
# RetroArch and retrorun themselves, the two runners of every core.
|
||||
self.assertEqual(sorted(named - cores), ["retroarch", "retrorun"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,639 @@
|
||||
"""KNULLI's launcher layer, read from its configgen and board scripts.
|
||||
|
||||
The fixtures are cut-down copies of the blocks each extractor reads at
|
||||
knulli-linux 20260511. Records must carry the names in the order the code
|
||||
writes or tries them, cite the fixture's own lines, and a construct that is
|
||||
gone must stop the scrape instead of returning nothing.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import sys
|
||||
import textwrap
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
from scraper import knulli_launchers as kl # noqa: E402
|
||||
from scraper.batocera_launchers import hatari, melonds # noqa: E402
|
||||
from scraper.configgen_launchers import LauncherShapeError # noqa: E402
|
||||
|
||||
G = kl.GENERATORS
|
||||
|
||||
|
||||
def text(block: str) -> str:
|
||||
return textwrap.dedent(block).lstrip("\n")
|
||||
|
||||
|
||||
PATHS = text(
|
||||
"""
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
KNULLI_SHARE_DIR: Final = Path('/usr/share/knulli')
|
||||
DATAINIT_DIR: Final = KNULLI_SHARE_DIR / 'datainit'
|
||||
USERDATA: Final = Path('/userdata')
|
||||
HOME: Final = USERDATA / 'system'
|
||||
CONFIGS: Final = HOME / 'configs'
|
||||
BIOS: Final = USERDATA / 'bios'
|
||||
ROMS: Final = USERDATA / 'roms'
|
||||
"""
|
||||
)
|
||||
|
||||
IMPORTER = text(
|
||||
"""
|
||||
from typing import Final
|
||||
|
||||
_GENERATOR_MAP: Final[dict[str, tuple[str, str]]] = {
|
||||
'lexaloffle': ('lexaloffle.lexaloffleGenerator', 'LexaloffleGenerator'),
|
||||
'yabasanshiro': ('yabasanshiro.yabasanshiroGenerator', 'YabasanshiroGenerator'),
|
||||
'ryujinx': ('ryujinx.ryujinxGenerator', 'RyujinxGenerator'),
|
||||
'dolphin': ('dolphin.dolphinGenerator', 'DolphinGenerator'),
|
||||
'scummvm': ('scummvm.scummvmGenerator', 'ScummVMGenerator'),
|
||||
'openmsx': ('openmsx.openmsxGenerator', 'OpenmsxGenerator'),
|
||||
'hatari': ('hatari.hatariGenerator', 'HatariGenerator'),
|
||||
'melonds': ('melonds.melondsGenerator', 'MelonDSGenerator'),
|
||||
'pcsx2': ('pcsx2.pcsx2Generator', 'Pcsx2Generator'),
|
||||
'mame': ('mame.mameGenerator', 'MameGenerator'),
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
# lexaloffleGenerator.py: the binary constants, the system branches, the two
|
||||
# checks that log and return, and the command.
|
||||
LEXALOFFLE = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS, HOME, ROMS
|
||||
|
||||
PICO8_BIN_PATH: Final = BIOS / "pico-8" / "pico8"
|
||||
VOX_BIN_PATH: Final = BIOS / "voxatron" / "vox"
|
||||
|
||||
class LexaloffleGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
if (system.name == "pico8"):
|
||||
BIN_PATH=PICO8_BIN_PATH
|
||||
elif (system.name == "voxatron"):
|
||||
BIN_PATH=VOX_BIN_PATH
|
||||
else:
|
||||
return -1
|
||||
if not BIN_PATH.exists():
|
||||
eslog.error(f"Lexaloffle official binary not found at {BIN_PATH}")
|
||||
return -1
|
||||
if not os.access(BIN_PATH, os.X_OK):
|
||||
eslog.error(f"File {BIN_PATH} is not set as executable")
|
||||
return -1
|
||||
commandArray = [BIN_PATH]
|
||||
return Command.Command(array=commandArray, env={})
|
||||
"""
|
||||
)
|
||||
|
||||
# libretroOptions.py: one function of core blocks, the option or a literal.
|
||||
OPTIONS = text(
|
||||
"""
|
||||
def generateCoreSettings(coreSettings, system, rom, guns, wheels):
|
||||
if (system.config['core'] == 'o2em'):
|
||||
coreSettings.save('o2em_vkbd_transparency', '"25"')
|
||||
if system.isOptSet('o2em_bios'):
|
||||
coreSettings.save('o2em_bios', '"' + system.config['o2em_bios'] + '"')
|
||||
elif system.name == 'videopacplus':
|
||||
coreSettings.save('o2em_bios', '"g7400.bin"')
|
||||
else:
|
||||
coreSettings.save('o2em_bios', '"o2rom.bin"')
|
||||
if (system.config['core'] == 'neocd'):
|
||||
if system.isOptSet('neocd_bios'):
|
||||
coreSettings.save('neocd_bios', '"' + system.config['neocd_bios'] + '"')
|
||||
else:
|
||||
coreSettings.save('neocd_bios', '"neocd_z.rom (CDZ)"')
|
||||
"""
|
||||
)
|
||||
|
||||
PICO8 = text(
|
||||
"""
|
||||
#!/bin/sh
|
||||
|
||||
TARGET_DIR="/userdata/bios"
|
||||
PICO_DIR="$TARGET_DIR/pico-8"
|
||||
ROMS_DIR="/userdata/roms/pico8"
|
||||
TEMP_INSTALL_DIR="$ROMS_DIR/pico8-install"
|
||||
PICO_8_64_FILE="$TEMP_INSTALL_DIR/pico-8/pico8_64"
|
||||
PICO_8_DAT_FILE="$TEMP_INSTALL_DIR/pico-8/pico8.dat"
|
||||
PICO_8_ZIPFILE=$(ls -d /userdata/roms/pico8/pico-8*raspi*.zip 2>/dev/null | head -1)
|
||||
|
||||
if [ -z $PICO_8_ZIPFILE ] || [ ! -f "$PICO_8_ZIPFILE" ]; then
|
||||
echo "Please add the Raspberry Pi version of Pico-8 to roms/pico8 and try again."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mv $PICO_8_64_FILE "$PICO_DIR/pico8"
|
||||
mv $PICO_8_DAT_FILE "$PICO_DIR/"
|
||||
"""
|
||||
)
|
||||
|
||||
YABASANSHIRO = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS
|
||||
|
||||
YABA_BIOS: Final = BIOS / "saturn_bios.bin"
|
||||
|
||||
class YabasanshiroGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
commandArray = ["yabasanshiro", "-i", rom]
|
||||
|
||||
if not (system.isOptSet('yaba_bios_hle') and system.config['yaba_bios_hle'] == '1'):
|
||||
if YABA_BIOS.exists():
|
||||
commandArray[1:1] = ["-b", str(YABA_BIOS)]
|
||||
return Command.Command(array=commandArray)
|
||||
"""
|
||||
)
|
||||
|
||||
RYUJINX = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS, CONFIGS
|
||||
|
||||
ryujinxConf: Final = CONFIGS / "Ryujinx"
|
||||
ryujinxKeys: Final = BIOS / "switch" / "prod.keys"
|
||||
|
||||
class RyujinxGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
if ryujinxKeys.exists():
|
||||
shutil.copyfile(ryujinxKeys, ryujinxConf / "system" / "prod.keys")
|
||||
"""
|
||||
)
|
||||
|
||||
DOLPHIN_PATHS = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS
|
||||
|
||||
DOLPHIN_BIOS: Final = BIOS / "GC"
|
||||
"""
|
||||
)
|
||||
|
||||
DOLPHIN = text(
|
||||
"""
|
||||
from .dolphinPaths import DOLPHIN_BIOS
|
||||
|
||||
class DolphinGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
if system.isOptSet("dolphin_SkipIPL") and system.getOptBoolean("dolphin_SkipIPL"):
|
||||
ipl_regions = ["USA", "EUR", "JAP"]
|
||||
if any((DOLPHIN_BIOS / region / "IPL.bin").exists() for region in ipl_regions):
|
||||
dolphinSettings.set("Core", "SkipIPL", "False")
|
||||
else:
|
||||
dolphinSettings.set("Core", "SkipIPL", "True")
|
||||
"""
|
||||
)
|
||||
|
||||
SCUMMVM = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS
|
||||
|
||||
scummExtra: Final = BIOS / "scummvm" / "extra"
|
||||
|
||||
class ScummVMGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
mkdir_if_not_exists(scummExtra)
|
||||
commandArray = ["/usr/bin/scummvm", "-f"]
|
||||
commandArray.extend(
|
||||
[f"--joystick={id}",
|
||||
f"--extrapath={scummExtra}",
|
||||
f"{romName}"]
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
OPENMSX = text(
|
||||
"""
|
||||
class OpenmsxGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
with settings_tcl.open("a") as file:
|
||||
file.write("filepool add -path /userdata/bios/Machines -types system_rom -position 1\\n")
|
||||
"""
|
||||
)
|
||||
|
||||
LIBRETRO_CONFIG = text(
|
||||
"""
|
||||
def writeLibretroConfigToFile(retroarchConfig, system, rom):
|
||||
if (system.config['core'] == 'puae') or (system.config['core'] == 'uae4arm'):
|
||||
retroarchConfig['system_directory'] = '"/userdata/bios/amiga/"'
|
||||
if system.config['core'] in [ 'mame', 'mess' ]:
|
||||
libretroMAMEConfig.generateMAMEConfigs(controllers, system, rom, guns)
|
||||
"""
|
||||
)
|
||||
|
||||
MAME_CONFIG = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS
|
||||
|
||||
def generateMAMEConfigs(playersControllers, system, rom, guns):
|
||||
if system.name in [ 'mame', 'neogeo' ]:
|
||||
commandLine += [ '-rompath', f'"{rom.parent};/userdata/bios/mame/;/userdata/bios/"' ]
|
||||
if not system.isOptSet("sharemameart"):
|
||||
artPath = f"/usr/bin/mame/artwork/;{BIOS / 'mame' / 'artwork'}"
|
||||
else:
|
||||
artPath = f"/usr/bin/mame/artwork/"
|
||||
commandLine += [ '-artpath', artPath ]
|
||||
mkdir_if_not_exists(BIOS / "mame" / "samples")
|
||||
"""
|
||||
)
|
||||
|
||||
# hatariGenerator.py in KNULLI's older form: the language and model read
|
||||
# with subscripts, the name built bare and joined to BIOS on the command line.
|
||||
HATARI = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS
|
||||
|
||||
class HatariGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
model_mapping = {"520st_auto": { "machine": "st", "tos": "auto" }}
|
||||
commandArray = ["hatari", "--fullscreen"]
|
||||
machine = "st"
|
||||
tosversion = "auto"
|
||||
if system.isOptSet("model") and system.config["model"] in model_mapping:
|
||||
machine = model_mapping[system.config["model"]]["machine"]
|
||||
tosversion = model_mapping[system.config["model"]]["tos"]
|
||||
toslang = "us"
|
||||
if system.isOptSet("language"):
|
||||
toslang = system.config["language"]
|
||||
commandArray += ["--machine", machine]
|
||||
tos = HatariGenerator.findBestTos(BIOS, machine, tosversion, toslang)
|
||||
commandArray += [ "--tos", BIOS / tos]
|
||||
|
||||
@staticmethod
|
||||
def findBestTos(biosdir, machine, tos_version, language) -> str:
|
||||
all_languages = ["us", "uk", ""]
|
||||
all_machines_bios = {
|
||||
"st": ["etos256", "104"],
|
||||
}
|
||||
if machine in all_machines_bios:
|
||||
for v_tos_version in l_tos:
|
||||
for v_language in l_lang:
|
||||
if "etos" in v_tos_version:
|
||||
biosversion = v_tos_version
|
||||
else:
|
||||
biosversion = f"tos{v_tos_version}"
|
||||
filename = f"{biosversion}{v_language}.img"
|
||||
if os.path.exists(f"{biosdir}/{filename}"):
|
||||
return filename
|
||||
raise Exception(f"no bios found for machine {machine}")
|
||||
"""
|
||||
)
|
||||
|
||||
MELONDS = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS
|
||||
|
||||
class MelonDSGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
base_config = {
|
||||
"DS": {
|
||||
"FirmwarePath": str(BIOS / "firmware.bin"),
|
||||
"BIOS7Path": str(BIOS / "bios7.bin"),
|
||||
},
|
||||
"Emu": {
|
||||
"ExternalBIOSEnable": True
|
||||
},
|
||||
}
|
||||
if system.isOptSet("melonds_console"):
|
||||
base_config["Emu"]["ConsoleType"] = int(system.config["melonds_console"])
|
||||
else:
|
||||
base_config["Emu"]["ConsoleType"] = 0
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
# pcsx2Generator.py: the default patches copied into BIOS when absent, and
|
||||
# the BIOS folder written relative to the config folder.
|
||||
PCSX2 = text(
|
||||
"""
|
||||
from ...batoceraPaths import BIOS, CONFIGS, DATAINIT_DIR
|
||||
|
||||
_PCSX2_CONFIG: Final = CONFIGS / "PCSX2"
|
||||
_PCSX2_BIOS: Final = BIOS / "ps2"
|
||||
|
||||
class Pcsx2Generator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
pcsx2Patches = _PCSX2_BIOS / "patches.zip"
|
||||
configureINI(_PCSX2_CONFIG, _PCSX2_BIOS, system)
|
||||
if not pcsx2Patches.exists():
|
||||
shutil.copy(DATAINIT_DIR / "bios" / "ps2" / "patches.zip", pcsx2Patches)
|
||||
|
||||
def configureINI(config_directory, bios_directory, system):
|
||||
configFileName = config_directory / 'inis' / "PCSX2.ini"
|
||||
pcsx2INIConfig.set("Folders", "Bios", "../../../bios/ps2")
|
||||
pcsx2INIConfig.set("Folders", "Logs", "../../logs")
|
||||
"""
|
||||
)
|
||||
|
||||
# mameGenerator.py: the Macintosh boot disk named from the bootdisk option.
|
||||
MAME = text(
|
||||
"""
|
||||
class MameGenerator(Generator):
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
|
||||
if system.name == "macintosh" and system.isOptSet("bootdisk"):
|
||||
if system.config["bootdisk"] in [ "macos30", "macos608" ]:
|
||||
bootType = "-flop1"
|
||||
bootDisk = "/userdata/bios/" + system.config["bootdisk"] + ".img"
|
||||
else:
|
||||
bootType = "-hard"
|
||||
bootDisk = "/userdata/bios/" + system.config["bootdisk"] + ".chd"
|
||||
commandArray += [ bootType, bootDisk ]
|
||||
"""
|
||||
)
|
||||
|
||||
FEATURES = text(
|
||||
"""
|
||||
mame:
|
||||
systems:
|
||||
macintosh:
|
||||
cfeatures:
|
||||
bootdisk:
|
||||
prompt: BOOT DISK
|
||||
choices:
|
||||
"System 3.0 (LD Floppy)": macos3
|
||||
"System 6.0.8 (LD Floppy)": macos608
|
||||
"System 7.5.5 (Hard Drive)": mac755
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def tree(**overrides: str) -> dict[str, str]:
|
||||
files = {
|
||||
f"{kl.CONFIGGEN}/batoceraPaths.py": PATHS,
|
||||
f"{G}/importer.py": IMPORTER,
|
||||
f"{G}/lexaloffle/lexaloffleGenerator.py": LEXALOFFLE,
|
||||
kl.LIBRETRO_OPTIONS: OPTIONS,
|
||||
kl.PICO8_INSTALLER: PICO8,
|
||||
f"{G}/yabasanshiro/yabasanshiroGenerator.py": YABASANSHIRO,
|
||||
f"{G}/ryujinx/ryujinxGenerator.py": RYUJINX,
|
||||
f"{G}/dolphin/dolphinPaths.py": DOLPHIN_PATHS,
|
||||
f"{G}/dolphin/dolphinGenerator.py": DOLPHIN,
|
||||
f"{G}/scummvm/scummvmGenerator.py": SCUMMVM,
|
||||
f"{G}/openmsx/openmsxGenerator.py": OPENMSX,
|
||||
f"{G}/libretro/libretroConfig.py": LIBRETRO_CONFIG,
|
||||
f"{G}/libretro/libretroMAMEConfig.py": MAME_CONFIG,
|
||||
f"{G}/hatari/hatariGenerator.py": HATARI,
|
||||
f"{G}/melonds/melondsGenerator.py": MELONDS,
|
||||
f"{G}/pcsx2/pcsx2Generator.py": PCSX2,
|
||||
f"{G}/mame/mameGenerator.py": MAME,
|
||||
kl.ES_FEATURES: FEATURES,
|
||||
}
|
||||
files.update(overrides)
|
||||
return files
|
||||
|
||||
|
||||
def configgen(**overrides: str) -> kl.Configgen:
|
||||
files = tree(**overrides)
|
||||
return kl.configgen(files.__getitem__)
|
||||
|
||||
|
||||
def sites(path: str, kind: str, **fields: object) -> list[dict]:
|
||||
spec = kl.GenericSites(path, kind, **fields) # type: ignore[arg-type]
|
||||
return [launcher.entry() for launcher in kl.bios_sites(configgen(), spec)]
|
||||
|
||||
|
||||
class SharedExtractors(unittest.TestCase):
|
||||
"""Batocera's extractors read KNULLI's older generator forms."""
|
||||
|
||||
def test_hatari_with_a_bare_name_joined_to_bios(self):
|
||||
(st,) = hatari(configgen())
|
||||
self.assertEqual(st.names, ["etos256{L}.img", "tos104{L}.img"])
|
||||
self.assertEqual(st.expands, {"L": ["us", "uk", ""]})
|
||||
self.assertEqual(st.passes_to, "--machine st --tos <file>")
|
||||
self.assertEqual(st.fails_when_missing, "no bios found for machine st")
|
||||
self.assertEqual(st.depends_on_option, "model, language")
|
||||
self.assertTrue(st.source_ref.startswith(f"{G}/hatari/hatariGenerator.py:"))
|
||||
|
||||
def test_hatari_reads_the_knulli_package(self):
|
||||
(st,) = hatari(configgen())
|
||||
self.assertNotIn("package/batocera", st.source_ref)
|
||||
|
||||
def test_hatari_name_built_another_way_raises(self):
|
||||
broken = HATARI.replace('filename = f"{biosversion}{v_language}.img"', "filename = x")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
hatari(configgen(**{f"{G}/hatari/hatariGenerator.py": broken}))
|
||||
|
||||
def test_melonds_console_read_by_subscript(self):
|
||||
(ds,) = melonds(configgen())
|
||||
self.assertEqual(ds.names, ["firmware.bin", "bios7.bin"])
|
||||
self.assertEqual(ds.depends_on_option, "melonds_console")
|
||||
self.assertEqual(ds.source_ref, f"{G}/melonds/melondsGenerator.py:6-12, 15")
|
||||
|
||||
def test_a_configgen_without_the_plain_map_raises(self):
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
configgen(**{f"{G}/importer.py": "X = 1\n"})
|
||||
|
||||
|
||||
class Lexaloffle(unittest.TestCase):
|
||||
def test_each_system_runs_its_binary(self):
|
||||
pico8, vox = kl.lexaloffle(configgen())
|
||||
self.assertEqual((pico8.slot, pico8.names), ("pico8", ["pico-8/pico8"]))
|
||||
self.assertEqual((vox.slot, vox.names), ("voxatron", ["voxatron/vox"]))
|
||||
self.assertEqual(pico8.search_dir, "/userdata/bios")
|
||||
self.assertEqual(pico8.passes_to, "exec")
|
||||
|
||||
def test_the_two_checks_are_the_failure(self):
|
||||
pico8, _ = kl.lexaloffle(configgen())
|
||||
self.assertEqual(
|
||||
pico8.fails_when_missing,
|
||||
"Lexaloffle official binary not found at /userdata/bios/pico-8/pico8, "
|
||||
"File /userdata/bios/pico-8/pico8 is not set as executable",
|
||||
)
|
||||
|
||||
def test_the_lines_cited(self):
|
||||
pico8, vox = kl.lexaloffle(configgen())
|
||||
path = f"{G}/lexaloffle/lexaloffleGenerator.py"
|
||||
self.assertEqual(pico8.source_ref, f"{path}:3, 8-9, 14-20")
|
||||
self.assertEqual(vox.source_ref, f"{path}:4, 10-11, 14-20")
|
||||
|
||||
def test_a_raise_in_place_of_the_log_raises(self):
|
||||
broken = LEXALOFFLE.replace(
|
||||
'eslog.error(f"Lexaloffle official binary not found at {BIN_PATH}")\n return -1',
|
||||
'raise BatoceraException(f"Lexaloffle official binary not found at {BIN_PATH}")',
|
||||
)
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
kl.lexaloffle(configgen(**{f"{G}/lexaloffle/lexaloffleGenerator.py": broken}))
|
||||
|
||||
|
||||
class PicoInstaller(unittest.TestCase):
|
||||
def test_the_files_moved_into_bios(self):
|
||||
(record,) = kl.pico8_installer(tree().__getitem__, "/userdata/bios")
|
||||
self.assertEqual(record.kind, "moves")
|
||||
self.assertEqual(record.names, ["pico-8/pico8", "pico-8/pico8.dat"])
|
||||
self.assertEqual(
|
||||
record.passes_to,
|
||||
"moved from /userdata/roms/pico8/pico-8*raspi*.zip into /userdata/bios/pico-8",
|
||||
)
|
||||
self.assertEqual(
|
||||
record.fails_when_missing,
|
||||
"Please add the Raspberry Pi version of Pico-8 to roms/pico8 and try again.",
|
||||
)
|
||||
self.assertEqual(record.source_ref, f"{kl.PICO8_INSTALLER}:3-12, 16-17")
|
||||
|
||||
def test_an_installer_that_moves_nothing_into_bios_raises(self):
|
||||
broken = PICO8.replace('"$PICO_DIR/', '"/tmp/')
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
kl.pico8_installer(tree(**{kl.PICO8_INSTALLER: broken}).__getitem__, "/userdata/bios")
|
||||
|
||||
|
||||
class CoreFileOptions(unittest.TestCase):
|
||||
def test_option_then_literal_defaults(self):
|
||||
o2em, neocd = kl.core_file_options(configgen())
|
||||
self.assertEqual(o2em.emulator, "o2em")
|
||||
self.assertEqual(o2em.names, ["g7400.bin", "o2rom.bin"])
|
||||
self.assertEqual(o2em.depends_on_option, "o2em_bios (default by system.name == 'videopacplus')")
|
||||
self.assertEqual(o2em.source_ref, f"{kl.LIBRETRO_OPTIONS}:2, 4-9")
|
||||
self.assertEqual((neocd.names, neocd.depends_on_option), (["neocd_z.rom (CDZ)"], "neocd_bios"))
|
||||
|
||||
def test_a_default_that_is_no_literal_raises(self):
|
||||
broken = OPTIONS.replace("'\"o2rom.bin\"'", "default_bios")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
kl.core_file_options(configgen(**{kl.LIBRETRO_OPTIONS: broken}))
|
||||
|
||||
|
||||
class BiosSites(unittest.TestCase):
|
||||
def test_a_flag_on_the_command_line_under_a_presence_test(self):
|
||||
(record,) = sites("yabasanshiro/yabasanshiroGenerator.py", "fixed_name")
|
||||
self.assertEqual(record["names"], ["saturn_bios.bin"])
|
||||
self.assertEqual(record["passes_to"], "command line -b")
|
||||
self.assertEqual(
|
||||
record["depends_on_option"],
|
||||
"not (system.isOptSet('yaba_bios_hle') and system.config['yaba_bios_hle'] == '1')",
|
||||
)
|
||||
self.assertEqual(record["source_ref"], f"{G}/yabasanshiro/yabasanshiroGenerator.py:9-11")
|
||||
|
||||
def test_a_copy_out_of_bios(self):
|
||||
(record,) = sites("ryujinx/ryujinxGenerator.py", "fixed_name")
|
||||
self.assertEqual(record["kind"], "copies")
|
||||
self.assertEqual(record["names"], ["switch/prod.keys"])
|
||||
self.assertEqual(record["search_dir"], "/userdata/bios")
|
||||
self.assertEqual(record["passes_to"], "/userdata/system/configs/Ryujinx/system/prod.keys")
|
||||
self.assertEqual(record["depends_on_option"], "ryujinxKeys.exists()")
|
||||
|
||||
def test_a_presence_test_over_a_literal_list(self):
|
||||
(record,) = sites("dolphin/dolphinGenerator.py", "fixed_name")
|
||||
self.assertEqual(record["names"], ["GC/{region}/IPL.bin"])
|
||||
self.assertEqual(record["expands"], {"region": ["USA", "EUR", "JAP"]})
|
||||
self.assertEqual(record["passes_to"], "presence sets [Core] SkipIPL = False")
|
||||
self.assertEqual(record["source_ref"], f"{G}/dolphin/dolphinGenerator.py:5, 7-8")
|
||||
|
||||
def test_a_flag_written_into_the_argument(self):
|
||||
(record,) = sites("scummvm/scummvmGenerator.py", "passes_path")
|
||||
self.assertEqual(record["search_dir"], "/userdata/bios/scummvm/extra")
|
||||
self.assertEqual(record["passes_to"], "command line --extrapath")
|
||||
|
||||
def test_a_line_written_to_a_config(self):
|
||||
(record,) = sites("openmsx/openmsxGenerator.py", "passes_path")
|
||||
self.assertEqual(record["search_dir"], "/userdata/bios/Machines")
|
||||
self.assertTrue(record["passes_to"].startswith("written: filepool add -path"))
|
||||
|
||||
def test_a_core_test_names_the_emulator(self):
|
||||
(record,) = sites("libretro/libretroConfig.py", "passes_path", build="libretro")
|
||||
self.assertEqual(record["emulator"], "puae, uae4arm")
|
||||
self.assertEqual(record["passes_to"], "system_directory")
|
||||
|
||||
def test_a_helper_takes_the_cores_of_its_caller(self):
|
||||
records = sites(
|
||||
"libretro/libretroMAMEConfig.py", "passes_path", build="libretro",
|
||||
caller=("libretro/libretroConfig.py", "generateMAMEConfigs"),
|
||||
)
|
||||
self.assertEqual({r["emulator"] for r in records}, {"mame, mess"})
|
||||
# The else branch binds an art path outside /userdata/bios: no record.
|
||||
rompath, art = records
|
||||
self.assertEqual(rompath["search_dir"], "<rom.parent>;/userdata/bios/mame/;/userdata/bios/")
|
||||
self.assertEqual(rompath["passes_to"], "command line -rompath")
|
||||
self.assertEqual(art["search_dir"], "/usr/bin/mame/artwork/;/userdata/bios/mame/artwork")
|
||||
self.assertEqual(art["depends_on_option"], "not system.isOptSet('sharemameart')")
|
||||
self.assertEqual(art["source_ref"], f"{G}/libretro/libretroMAMEConfig.py:6-7, 10")
|
||||
|
||||
def test_a_generator_without_a_bios_path_raises(self):
|
||||
files = tree(**{f"{G}/openmsx/openmsxGenerator.py": "def generate():\n return 1\n"})
|
||||
spec = kl.GenericSites("openmsx/openmsxGenerator.py", "passes_path")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
kl.bios_sites(kl.configgen(files.__getitem__), spec)
|
||||
|
||||
|
||||
class CopiesAndFolders(unittest.TestCase):
|
||||
def test_a_copy_into_bios_reads_from_the_folder_it_comes_from(self):
|
||||
(record,) = sites("pcsx2/pcsx2Generator.py", "fixed_name")
|
||||
self.assertEqual(record["kind"], "copies")
|
||||
self.assertEqual(record["names"], ["patches.zip"])
|
||||
self.assertEqual(record["search_dir"], "/usr/share/knulli/datainit/bios/ps2")
|
||||
self.assertEqual(record["passes_to"], "/userdata/bios/ps2/patches.zip")
|
||||
self.assertEqual(record["depends_on_option"], "not pcsx2Patches.exists()")
|
||||
|
||||
def test_a_relative_folder_resolved_against_the_config_folder(self):
|
||||
(record,) = kl.relative_folders(configgen(), kl.RELATIVE_FOLDERS[:1])
|
||||
self.assertEqual(record.kind, "passes_path")
|
||||
self.assertEqual(record.search_dir, "/userdata/bios/ps2")
|
||||
self.assertEqual(
|
||||
record.passes_to,
|
||||
"inis/PCSX2.ini [Folders] Bios = ../../../bios/ps2, relative to /userdata/system/configs/PCSX2",
|
||||
)
|
||||
self.assertEqual(record.source_ref, f"{G}/pcsx2/pcsx2Generator.py:9, 14-15")
|
||||
|
||||
def test_a_folder_written_outside_bios_raises(self):
|
||||
broken = PCSX2.replace("../../../bios/ps2", "../../../saves/ps2")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
kl.relative_folders(
|
||||
configgen(**{f"{G}/pcsx2/pcsx2Generator.py": broken}), kl.RELATIVE_FOLDERS[:1]
|
||||
)
|
||||
|
||||
|
||||
class BootDisks(unittest.TestCase):
|
||||
def records(self, **overrides: str) -> list:
|
||||
files = tree(**overrides)
|
||||
return kl.boot_disks(kl.configgen(files.__getitem__), files.__getitem__, kl.BOOT_DISKS[:1])
|
||||
|
||||
def test_each_branch_is_a_template_over_the_values_that_reach_it(self):
|
||||
floppy, hard = self.records()
|
||||
self.assertEqual((floppy.names, floppy.passes_to), (["{bootdisk}.img"], "command line -flop1"))
|
||||
self.assertEqual(floppy.expands, {"bootdisk": ["macos30", "macos608"]})
|
||||
# The values the menu offers that the code's list does not take.
|
||||
self.assertEqual((hard.names, hard.passes_to), (["{bootdisk}.chd"], "command line -hard"))
|
||||
self.assertEqual(hard.expands, {"bootdisk": ["macos3", "mac755"]})
|
||||
self.assertTrue(hard.depends_on_option.startswith("bootdisk (system.name == 'macintosh'"))
|
||||
self.assertEqual(
|
||||
hard.source_ref,
|
||||
f"{G}/mame/mameGenerator.py:3-4, 9-10, {kl.ES_FEATURES}:8-10",
|
||||
)
|
||||
|
||||
def test_a_name_built_another_way_raises(self):
|
||||
broken = MAME.replace('"/userdata/bios/" + system.config["bootdisk"] + ".chd"', "disk")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
self.records(**{f"{G}/mame/mameGenerator.py": broken})
|
||||
|
||||
def test_an_option_the_menu_no_longer_offers_raises(self):
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
self.records(**{kl.ES_FEATURES: FEATURES.replace("bootdisk:", "other:")})
|
||||
|
||||
|
||||
class PlatformFile(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.config = yaml.safe_load((REPO_ROOT / "platforms" / "knulli.yml").read_text())
|
||||
|
||||
def test_the_layer_is_written(self):
|
||||
self.assertTrue(self.config["launchers"])
|
||||
|
||||
def test_every_reference_is_in_knulli_code(self):
|
||||
for record in self.config["launchers"]:
|
||||
self.assertTrue(
|
||||
record["source_ref"].startswith((f"{kl.CONFIGGEN}/", kl.PICO8_INSTALLER)), record
|
||||
)
|
||||
|
||||
def test_every_emulator_is_one_knulli_names(self):
|
||||
cores = {*self.config["cores"], *self.config.get("standalone_cores", [])}
|
||||
named = {n for record in self.config["launchers"] for n in record["emulator"].split(", ")}
|
||||
# RetroArch itself, and the MAME core names configgen tests that
|
||||
# KNULLI's es_systems.yml never offers.
|
||||
self.assertEqual(sorted(named - cores), ["mamevirtual", "mess", "retroarch"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1042,7 +1042,10 @@ class HelpersAndCopies(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(segaboot["kind"], "copies")
|
||||
self.assertEqual(segaboot["names"], ["triforce/segaboot.gcm", "segaboot.gcm"])
|
||||
self.assertEqual(segaboot["depends_on_option"], "_triforce, !_crediar")
|
||||
self.assertEqual(
|
||||
segaboot["depends_on_option"],
|
||||
"_triforce, !_crediar, first name found, the target is absent, smaller or older",
|
||||
)
|
||||
|
||||
def test_dosbox_copies_grouped_by_target_folder(self):
|
||||
sources = _sources(
|
||||
@@ -1055,16 +1058,17 @@ class HelpersAndCopies(unittest.TestCase):
|
||||
(
|
||||
"dosbox-pure",
|
||||
["MT32_CONTROL.ROM"],
|
||||
"copied to <emulator>/mt32-roms/<name>, only when the target does not exist",
|
||||
"<emulator>/mt32-roms/<name>",
|
||||
),
|
||||
(
|
||||
"dosbox-pure",
|
||||
["Roland_SC-55.sf2"],
|
||||
"copied to <emulator>/soundfonts/<name>, only when the target does not exist",
|
||||
"<emulator>/soundfonts/<name>",
|
||||
),
|
||||
],
|
||||
)
|
||||
self.assertEqual(records[0]["search_dir"], "bios/scummvm/extra")
|
||||
self.assertEqual(records[0]["depends_on_option"], "the target does not exist")
|
||||
|
||||
def test_tsugaru_folder_chain(self):
|
||||
[record] = rl.tsugaru(_sources(**{f"{G}/Tsugaru.Generator.cs": TSUGARU}))
|
||||
|
||||
Reference in new issue
Block a user