diff options
| author | louist103 <35883445+louist103@users.noreply.github.com> | 2025-10-26 15:34:15 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-26 11:34:15 -0400 |
| commit | d14ba82e8290172da26152ca3cedc36a315b4c47 (patch) | |
| tree | fa1c5601e7de96737a19e0f1db164e5dadb19109 | |
| parent | 43fd6756030e24f49127aa8835d073038007378a (diff) | |
Use builtin extractor on linux (#1180)
* Use builtin extractor on linux
* Format
| -rw-r--r-- | CMakeLists.txt | 7 | ||||
| -rw-r--r-- | mm/2s2h/Extractor/Extract.cpp | 17 | ||||
| -rw-r--r-- | mm/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | mm/linux/2s2h.desktop | 4 | ||||
| -rw-r--r-- | mm/linux/2s2h.sh.in | 123 |
5 files changed, 13 insertions, 142 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dbbe38d4c..920907d44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,6 @@ set_property(TARGET 2ship PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/mm set_property(TARGET 2ship PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/2s2hIcon.png") if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") -install(PROGRAMS "${CMAKE_BINARY_DIR}/linux/2s2h.sh" DESTINATION . COMPONENT appimage) install(FILES "${CMAKE_BINARY_DIR}/mm/2ship.o2r" DESTINATION . COMPONENT ship) install(TARGETS ZAPD DESTINATION ./assets/extractor COMPONENT extractor) install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/extractor/" DESTINATION ./assets/ COMPONENT extractor) @@ -244,12 +243,6 @@ set(PROGRAM_PERMISSIONS_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECU install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/extractor/" DESTINATION ./assets/) install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/xml/" DESTINATION ./assets/xml) -# install(DIRECTORY ${CMAKE_BINARY_DIR}/assets -# DESTINATION . -# PATTERN ZAPD.out -# PERMISSIONS ${PROGRAM_PERMISSIONS_EXECUTE} -# ) - # Rename the installed soh binary to drop the macos suffix INSTALL(CODE "FILE(RENAME \${CMAKE_INSTALL_PREFIX}/../MacOS/2s2h-macos \${CMAKE_INSTALL_PREFIX}/../MacOS/2s2h)") install(CODE " diff --git a/mm/2s2h/Extractor/Extract.cpp b/mm/2s2h/Extractor/Extract.cpp index 63579228d..b51f533f4 100644 --- a/mm/2s2h/Extractor/Extract.cpp +++ b/mm/2s2h/Extractor/Extract.cpp @@ -536,6 +536,7 @@ std::string Extractor::Mkdtemp() { } extern "C" int zapd_main(int argc, char** argv); +static void MessageboxWorker(); bool Extractor::CallZapd(std::string installPath, std::string exportdir) { constexpr int argc = 22; @@ -597,11 +598,8 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { ShowWindow(cmdWindow, SW_SHOW); SetWindowPos(cmdWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); #else - // Show extraction in background message until linux/mac can have visual progress - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Extracting", - "Extraction will now begin in the background.\n\nPlease be patient for the process to " - "finish. Do not close the main program.", - nullptr); + std::thread mbThread(MessageboxWorker); + mbThread.detach(); #endif zapd_main(argc, (char**)argv.data()); @@ -617,5 +615,12 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { std::filesystem::current_path(curdir); std::filesystem::remove_all(tempdir); - return 0; + return false; } + +static void MessageboxWorker() { + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Extracting", + "Extraction will now begin in the background.\n\nPlease be patient for the process to " + "finish. Do not close the main program.", + nullptr); +}
\ No newline at end of file diff --git a/mm/CMakeLists.txt b/mm/CMakeLists.txt index a55c0d63a..69ebe18eb 100644 --- a/mm/CMakeLists.txt +++ b/mm/CMakeLists.txt @@ -624,10 +624,6 @@ INSTALL(FILES $<TARGET_PDB_FILE:2ship> DESTINATION ./debug COMPONENT 2s2h) INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.o2r DESTINATION . COMPONENT 2s2h) endif() -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/linux/2s2h.sh.in ${CMAKE_BINARY_DIR}/linux/2s2h.sh @ONLY) -endif() - find_program(CURL NAMES curl DOC "Path to the curl program. Used to download files.") execute_process(COMMAND ${CURL} -sSfL https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt -o ${CMAKE_BINARY_DIR}/gamecontrollerdb.txt OUTPUT_VARIABLE RESULT) diff --git a/mm/linux/2s2h.desktop b/mm/linux/2s2h.desktop index 6815fb057..e0c648810 100644 --- a/mm/linux/2s2h.desktop +++ b/mm/linux/2s2h.desktop @@ -1,8 +1,8 @@ [Desktop Entry] Version=1.0 Name=2SHIP -Exec=2s2h.sh -Terminal=false +Exec=2s2h.elf +Terminal=true Icon=2s2hIcon Type=Application Categories=Game; diff --git a/mm/linux/2s2h.sh.in b/mm/linux/2s2h.sh.in deleted file mode 100644 index 9ef42938f..000000000 --- a/mm/linux/2s2h.sh.in +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -HERE="$(dirname "$(readlink -f "${0}")")"/../.. - -export PATH="$HERE"/bin:"$HERE"/usr/bin:"$PATH" -export LD_LIBRARY_PATH="$HERE"/usr/lib:"$LD_LIBRARY_PATH" -export ZENITY=$(command -v zenity) - -if [ -z ${SHIP_HOME+x} ]; then -export SHIP_HOME=$PWD -fi - -if [ -z ${SHIP_BIN_DIR+x} ]; then -export SHIP_BIN_DIR="$HERE/usr/bin" -fi - -if [[ ! -e "$SHIP_HOME"/mods ]]; then - mkdir -p "$SHIP_HOME"/mods - touch "$SHIP_HOME"/mods/custom_mod_files_go_here.txt -fi - -while [[ (! -e "$SHIP_HOME"/mm.o2r) ]]; do - for romfile in "$SHIP_HOME"/*.*64 - do - if [[ -e "$romfile" ]] || [[ -L "$romfile" ]]; then - export ASSETDIR="$(mktemp -d /tmp/assets-XXXXX)" - ln -s "$SHIP_BIN_DIR"/{assets,2s2h.elf,ZAPD} "$ASSETDIR" - export OLDPWD="$PWD" - mkdir -p "$ASSETDIR"/tmp - if [[ -e "$romfile" ]]; then - ln -s "$romfile" "$ASSETDIR"/tmp/rom.z64 - else - ORIG_ROM_PATH=$(readlink "$romfile") - ln -s "$ORIG_ROM_PATH" "$ASSETDIR"/tmp/rom.z64 - fi - cd "$ASSETDIR" - ROMHASH=$(sha1sum -b "$ASSETDIR"/tmp/rom.z64 | awk '{ print $1 }') - - # Remap v64 and n64 hashes to their z64 hash equivalent - # ZAPD will handle converting the data into z64 format - case "$ROMHASH" in - ef6d7273a7bc1cbf778f9021753db5efddfe495e) # v64 - ROMHASH=7f5630dbc4d5d61d6276213210c4d5cdd83a47d6 - ;; - 991460c32f53c7bb0bc650baf5a40ffde6165840) # n64 - ROMHASH=7f5630dbc4d5d61d6276213210c4d5cdd83a47d6 - ;; - 22f8bfa1ab6c763013a3c2a568bb014395b12499) # v64 - ROMHASH=d6133ace5afaa0882cf214cf88daba39e266c078 - ;; - 1a26735c63cb3bdf5eb32d21acf774ee6724f227) # n64 - ROMHASH=d6133ace5afaa0882cf214cf88daba39e266c078 - ;; - 8c378b87c83b3f4de20b14accf91e7590399f5dc) # v64 - ROMHASH=9743aa026e9269b339eb0e3044cd5830a440c1fd - ;; - 8b0436e540b95a5353969d4ee360273cf33fb659) # n64 - ROMHASH=9743aa026e9269b339eb0e3044cd5830a440c1fd - ;; - esac - - case "$ROMHASH" in - 7f5630dbc4d5d61d6276213210c4d5cdd83a47d6) # uncompressed - if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then - ROM=N64_US - else - continue - fi - ;; - d6133ace5afaa0882cf214cf88daba39e266c078) # compressed - if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then - ROM=N64_US - else - continue - fi - ;; - 9743aa026e9269b339eb0e3044cd5830a440c1fd) # compressed - if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then - ROM=GC_US - else - continue - fi - ;; - *) - echo -e "\n$romfile - $ROMHASH rom hash does not match\n" - continue;; - esac - if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then - if [ -n "$ZENITY" ]; then - (echo "# 25%"; echo "25"; sleep 7; echo "# 50%"; echo "50"; sleep 7; echo "# 75%"; echo "75"; sleep 7; echo "# 100%"; echo "100"; sleep 7) | - zenity --progress --title="OTR Generating..." --timeout=28 --percentage=0 --icon-name=2s2h --window-icon=2s2h.png --height=80 --width=400 & - else - echo "Processing..." - fi - assets/extractor/ZAPD.out ed -eh -i assets/xml/"${ROM}" -b tmp/rom.z64 -fl assets/filelists -o placeholder -osf placeholder -gsf 1 -rconf assets/Config_"${ROM}".xml -se OTR --otrfile mm.o2r --portVer "@CMAKE_PROJECT_VERSION@" > /dev/null 2>&1 - cp "$ASSETDIR"/mm.o2r "$SHIP_HOME" - fi - else - if [[ (! -e "$SHIP_HOME"/mm.o2r) ]]; then - if [ -n "$ZENITY" ]; then - zenity --error --timeout=5 --text="Place ROM in $SHIP_HOME" --title="Missing ROM file" --width=500 --width=200 - else - echo -e "\nPlace ROM in this folder\n" - fi - exit - fi - fi - done - if [[ (! -e "$SHIP_HOME"/mm.o2r) ]]; then - if [ -n "$ZENITY" ]; then - zenity --error --timeout=10 --text="No valid ROMs were provided, No OTR was generated." --title="Incorrect ROM file" --width=500 --width=200 - else - echo "No valid roms provided, no OTR was generated." - fi - rm -r "$ASSETDIR" - exit - else - (cd "$SHIP_BIN_DIR"; ./2s2h.elf) - exit - fi - rm -r "$ASSETDIR" -done - (cd "$SHIP_BIN_DIR"; ./2s2h.elf) -exit |
