diff --git a/mupen64plus-core/.github/workflows/build.yml b/mupen64plus-core/.github/workflows/build.yml index c9c0380..6e7b4e3 100644 --- a/mupen64plus-core/.github/workflows/build.yml +++ b/mupen64plus-core/.github/workflows/build.yml @@ -3,16 +3,12 @@ name: Core on: push: paths-ignore: - - '**/*.md' - '.{gitattributes,gitignore,travis.yml}' - - 'appveyor.yml,README' + - '*.md,appveyor.yml,README' pull_request: paths-ignore: - - '**/*.md' - '.{gitattributes,gitignore,travis.yml}' - - 'appveyor.yml,README' - schedule: - - cron: '55 14 21 * *' + - '*.md,appveyor.yml,README' workflow_dispatch: jobs: @@ -23,71 +19,39 @@ jobs: matrix: include: - cc: GCC - platform: x64 - bits: 64 + arch: x64 - cc: GCC - platform: x86 - bits: 32 + arch: x86 - cc: Clang - platform: x64 - bits: 64 + arch: x64 - cc: Clang - platform: x86 - bits: 32 - name: Linux / ${{ matrix.cc }} / ${{ matrix.platform }} + arch: x86 + name: Linux / ${{ matrix.cc }} / ${{ matrix.arch }} runs-on: ubuntu-22.04 - if: (github.event_name == 'schedule' && github.repository == 'mupen64plus/mupen64plus-core') || (github.event_name != 'schedule') steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Get build dependencies and arrange the environment run: | - echo "G_REV=$(git rev-parse --short HEAD)" >> "${GITHUB_ENV}" - if [[ ${{ matrix.bits }} -eq 32 ]]; then sudo dpkg --add-architecture i386; fi - sudo apt-get update - sudo apt-get -y install libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libsdl1.2-dev libsdl2-dev libvulkan-dev nasm zlib1g-dev - if [[ ${{ matrix.bits }} -eq 32 ]]; then sudo apt-get --reinstall -y install gcc-multilib g++-multilib libc6 libc6-dev-i386 libatomic1:i386 libgcc-s1:i386 libstdc++6:i386 libfreetype6-dev:i386 libgl1-mesa-dev:i386 libglu1-mesa-dev:i386 libpng-dev:i386 libsdl1.2-dev:i386 libsdl2-dev:i386 libvulkan-dev:i386 zlib1g-dev:i386; fi - sudo ldconfig + export BUILD_DEPS="libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libsdl1.2-dev libsdl2-dev libvulkan-dev zlib1g-dev" + ./.github/workflows/scripts/ci_install_ubuntu_deps.sh ${{ matrix.arch }} ${{ matrix.cc }} - name: Build and related stuff, backup binaries run: | - if [[ ${{ matrix.bits }} -eq 32 ]]; then export PIC="1" CPU_TUNE="-msse2 -mtune=pentium4"; else CPU_TUNE="-mtune=core2"; fi - export OPTFLAGS="-O2 -flto ${CPU_TUNE}" - ORIG="$(pwd)" - CC="gcc" - CXX="g++" - if [[ "${{ matrix.cc }}" != "GCC" ]]; then - CC="clang" - CXX="clang++" - fi - ${CC} --version - SDL="sdl" - MSG="1.2" - mkdir pkg - for DYN in 0 1 0 1; do - unset POSTFIX - if [[ ${DYN} -eq 0 ]]; then export POSTFIX="-old"; else MSG="${MSG} / NEW_DYNAREC"; fi - echo "" - echo ":: ${{ matrix.cc }} ${{ matrix.platform }} / SDL${MSG} ::" - echo "" - make NEW_DYNAREC="${DYN}" -C projects/unix clean - echo "" - make CC="${CC}" CXX="${CXX}" BITS="${{ matrix.bits }}" SDL_CONFIG="${SDL}-config" NEW_DYNAREC="${DYN}" -C projects/unix all -j4 - echo "" - make BITS="${{ matrix.bits }}" NEW_DYNAREC="${DYN}" -C projects/unix install DESTDIR="${ORIG}/pkg/" - echo "" - ls -gG pkg/usr/local/lib/libmupen64plus${POSTFIX}.so* - echo "" - ldd pkg/usr/local/lib/libmupen64plus${POSTFIX}.so.2.0.0 - if [[ ${DYN} -eq 1 ]]; then - SDL="sdl2" - MSG="2" - fi - done - tar cvzf pkg/mupen64plus-core-linux-${{ matrix.platform }}-g${{ env.G_REV }}.tar.gz -C pkg/ "usr" + export PATH="$(pwd)/.github/workflows/scripts:${PATH}" + export BUILD_CONFIG="ACCURATE_FPU=0 NEW_DYNAREC=0 SDL_CONFIG=\"sdl-config\"" POSTFIX="-old" + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=1 NEW_DYNAREC=1 SDL_CONFIG=\"sdl-config\"" + unset POSTFIX + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=0 NEW_DYNAREC=0 SDL_CONFIG=\"sdl2-config\"" POSTFIX="-old" + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=1 NEW_DYNAREC=1 SDL_CONFIG=\"sdl2-config\"" MAKE_PKG=1 + unset POSTFIX + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} - name: Upload artifact if: matrix.cc == 'GCC' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: mupen64plus-core-linux-${{ matrix.platform }}-g${{ env.G_REV }} + name: mupen64plus-core-linux-${{ matrix.arch }}-g${{ env.G_REV }} path: pkg/*.tar.gz MSYS2: @@ -96,24 +60,23 @@ jobs: matrix: include: - cc: GCC - platform: x64 + arch: x64 cross: x86_64 - bits: 64 + env: MINGW64 - cc: GCC - platform: x86 + arch: x86 cross: i686 - bits: 32 - name: Windows / MSYS2 ${{ matrix.cc }} / ${{ matrix.platform }} + env: MINGW32 + name: Windows / MSYS2 ${{ matrix.cc }} / ${{ matrix.arch }} runs-on: windows-2022 - if: (github.event_name == 'schedule' && github.repository == 'mupen64plus/mupen64plus-core') || (github.event_name != 'schedule') defaults: run: shell: msys2 {0} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 with: - msystem: MINGW${{ matrix.bits }} + msystem: ${{ matrix.env }} update: true install: >- git @@ -124,46 +87,26 @@ jobs: mingw-w64-${{ matrix.cross }}-freetype mingw-w64-${{ matrix.cross }}-libpng mingw-w64-${{ matrix.cross }}-nasm + mingw-w64-${{ matrix.cross }}-ntldd mingw-w64-${{ matrix.cross }}-SDL2 + mingw-w64-${{ matrix.cross }}-vulkan-headers mingw-w64-${{ matrix.cross }}-zlib + mingw-w64-${{ matrix.cross }}-vulkan-headers - name: Build and related stuff, backup binaries run: | - echo "G_REV=$(git rev-parse --short HEAD)" >> "${GITHUB_ENV}" - if [[ ${{ matrix.bits }} -eq 32 ]]; then CPU_TUNE="-msse2 -mtune=pentium4"; else CPU_TUNE="-mtune=core2"; fi - export OPTFLAGS="-O2 -flto ${CPU_TUNE}" - ORIG="$(pwd)" - CC="gcc" - CXX="g++" - ${CC} --version - mkdir pkg - export POSTFIX="-old" - for DYN in 0 1; do - echo "" - echo ":: ${{ matrix.cc }} ${{ matrix.platform }} / SDL2${MSG} ::" - echo "" - make NEW_DYNAREC="${DYN}" -C projects/unix clean - echo "" - make CC="${CC}" CXX="${CXX}" BITS="${{ matrix.bits }}" NEW_DYNAREC="${DYN}" -C projects/unix all -j4 - echo "" - make BITS="${{ matrix.bits }}" NEW_DYNAREC="${DYN}" -C projects/unix install PLUGINDIR="" SHAREDIR="" BINDIR="" MANDIR="" LIBDIR="" APPSDIR="" ICONSDIR="icons" INCDIR="api" LDCONFIG="true" DESTDIR="${ORIG}/pkg/" - echo "" - ls -gG pkg/mupen64plus${POSTFIX}.dll - echo "" - ldd pkg/mupen64plus${POSTFIX}.dll - unset POSTFIX - MSG=" / NEW_DYNAREC" - done + export PATH="$(pwd)/.github/workflows/scripts:${PATH}" + export BUILD_CONFIG="ACCURATE_FPU=0 NEW_DYNAREC=0" POSTFIX="-old" + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=1 NEW_DYNAREC=1" + unset POSTFIX + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} - name: Backup dependencies, etc... run: | - if [[ ${{ matrix.bits }} -eq 32 ]]; then LIBGCC="libgcc_s_dw2-1"; else LIBGCC="libgcc_s_seh-1"; fi - for LIB in libbrotlicommon libbrotlidec libbz2-1 libfreetype-6 ${LIBGCC} libglib-2.0-0 libgraphite2 libharfbuzz-0 libiconv-2 libintl-8 libpcre2-8-0 libpng16-16 libstdc++-6 libwinpthread-1 SDL2 zlib1; do - echo ":: Copying ${LIB}.dll" - cp "/mingw${{ matrix.bits }}/bin/${LIB}.dll" pkg/ - done + ./.github/workflows/scripts/ci_backup_mingw_deps.sh ${{ matrix.env }} - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: mupen64plus-core-msys2-${{ matrix.platform }}-g${{ env.G_REV }} + name: mupen64plus-core-msys2-${{ matrix.arch }}-g${{ env.G_REV }} path: pkg/* MSVC: @@ -172,52 +115,32 @@ jobs: matrix: include: - toolset: v143 - platform: x64 + arch: x64 vs: 2022 - toolset: v141_xp - platform: x86 + arch: x86 vs: 2019 - name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.platform }} + name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.arch }} runs-on: windows-${{ matrix.vs }} - if: (github.event_name == 'schedule' && github.repository == 'mupen64plus/mupen64plus-core') || (github.event_name != 'schedule') defaults: run: shell: cmd steps: - - uses: actions/checkout@v3 - - uses: microsoft/setup-msbuild@v1 + - uses: actions/checkout@v4 + - uses: microsoft/setup-msbuild@v2 - name: Build and related stuff, backup binaries run: | - for /f "tokens=1" %%R in ('git rev-parse --short HEAD') do echo G_REV=%%R>> "%GITHUB_ENV%" - set "ARCH=${{ matrix.platform }}" - if [%ARCH%] == [x86] set "ARCH=Win32" - echo. - msbuild --version - echo. - git clone --depth 1 https://github.com/mupen64plus/mupen64plus-win32-deps.git ..\mupen64plus-win32-deps - md pkg - for %%B in (Release New_Dynarec_Release) do ( - echo. - msbuild projects\msvc\mupen64plus-core.vcxproj /p:Configuration=%%B;Platform=%ARCH%;PlatformToolset=${{ matrix.toolset }} /t:Rebuild - echo. - copy "projects\msvc\%ARCH%\%%B\mupen64plus.dll" pkg\ - if not exist "pkg\mupen64plus-old.dll" ( - ren "pkg\mupen64plus.dll" mupen64plus-old.dll - dir pkg\mupen64plus-old.dll - ) else dir pkg\mupen64plus.dll - ) + set PATH=%CD%\.github\workflows\scripts;%PATH% + set TOOLSET=${{ matrix.toolset }} + call ci_msvc_build.cmd ${{ matrix.arch }} + ci_msvc_build.cmd ${{ matrix.arch }} newdyn - name: Backup dependencies, etc... run: | - xcopy data pkg - copy "..\mupen64plus-win32-deps\freetype-2.13.0\lib\${{ matrix.platform }}\*.dll" pkg\ - copy "..\mupen64plus-win32-deps\libpng-1.6.39\lib\${{ matrix.platform }}\*.dll" pkg\ - copy "..\mupen64plus-win32-deps\SDL2-2.26.3\lib\${{ matrix.platform }}\*.dll" pkg\ - copy "..\mupen64plus-win32-deps\SDL2_net-2.2.0\lib\${{ matrix.platform }}\*.dll" pkg\ - copy "..\mupen64plus-win32-deps\zlib-1.2.13\lib\${{ matrix.platform }}\*.dll" pkg\ + .\.github\workflows\scripts\ci_backup_msvc_deps.cmd ${{ matrix.arch }} freetype.dll libpng16.dll SDL2.dll SDL2_net.dll zlib.dll - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: mupen64plus-core-msvc-${{ matrix.platform }}-g${{ env.G_REV }} + name: mupen64plus-core-msvc-${{ matrix.arch }}-g${{ env.G_REV }} path: pkg/* Nightly-build: @@ -225,9 +148,9 @@ jobs: if: github.ref_name == 'master' needs: [Linux, MSYS2, MSVC] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: binaries - name: Get some tools @@ -236,49 +159,7 @@ jobs: sudo apt-get -y install hashdeep - name: Creating new artifacts and update nightly-build run: | - mkdir pkg - cd binaries - for BIN in *; do - cd "${BIN}" - if [[ "${BIN:17:4}" == "msys" ]]; then - echo ":: Creating ${BIN}.zip" - zip -r "../../pkg/${BIN}.zip" * - elif [[ "${BIN:17:4}" == "msvc" ]]; then - echo ":: Creating ${BIN}.zip" - zip -r "../../pkg/${BIN}.zip" * - else - echo ":: Recovering ${BIN}.tar.gz" - mv *.tar.gz ../../pkg/ - fi - cd .. - done - cd ../pkg - echo "" - for BIN in *; do - ls -gG ${BIN} - tigerdeep -lz ${BIN} >> ../${BIN:0:16}.tiger.txt - sha256sum ${BIN} >> ../${BIN:0:16}.sha256.txt - sha512sum ${BIN} >> ../${BIN:0:16}.sha512.txt - b2sum ${BIN} >> ../${BIN:0:16}.blake2.txt - done - mv ../*.tiger.txt . - mv ../*.sha*.txt . - mv ../*.blake2.txt . - echo "" - echo "TIGER:" - cat *.tiger.txt - echo "" - echo "SHA256:" - cat *.sha256.txt - echo "" - echo "SHA512:" - cat *.sha512.txt - echo "" - echo "BLAKE2:" - cat *.blake2.txt - echo "" - git tag -f nightly-build - git push -f origin nightly-build + ./.github/workflows/scripts/ci_nightly_artifacts.sh - name: Nightly-build uses: ncipollo/release-action@v1 with: diff --git a/mupen64plus-core/.github/workflows/schedule.yml b/mupen64plus-core/.github/workflows/schedule.yml new file mode 100644 index 0000000..6ccfbb4 --- /dev/null +++ b/mupen64plus-core/.github/workflows/schedule.yml @@ -0,0 +1,166 @@ +name: Core + +on: + schedule: + - cron: '55 14 21 * *' + +jobs: + + Linux: + strategy: + fail-fast: false + matrix: + include: + - cc: GCC + arch: x64 + - cc: GCC + arch: x86 + - cc: Clang + arch: x64 + - cc: Clang + arch: x86 + name: Linux / ${{ matrix.cc }} / ${{ matrix.arch }} + runs-on: ubuntu-22.04 + if: github.repository == 'mupen64plus/mupen64plus-core' + steps: + - uses: actions/checkout@v4 + - name: Get build dependencies and arrange the environment + run: | + export BUILD_DEPS="libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libsdl1.2-dev libsdl2-dev libvulkan-dev zlib1g-dev" + ./.github/workflows/scripts/ci_install_ubuntu_deps.sh ${{ matrix.arch }} ${{ matrix.cc }} + - name: Build and related stuff, backup binaries + run: | + export PATH="$(pwd)/.github/workflows/scripts:${PATH}" + export BUILD_CONFIG="ACCURATE_FPU=0 NEW_DYNAREC=0 SDL_CONFIG=\"sdl-config\"" POSTFIX="-old" + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=1 NEW_DYNAREC=1 SDL_CONFIG=\"sdl-config\"" + unset POSTFIX + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=0 NEW_DYNAREC=0 SDL_CONFIG=\"sdl2-config\"" POSTFIX="-old" + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=1 NEW_DYNAREC=1 SDL_CONFIG=\"sdl2-config\"" MAKE_PKG=1 + unset POSTFIX + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + - name: Upload artifact + if: matrix.cc == 'GCC' + uses: actions/upload-artifact@v4 + with: + name: mupen64plus-core-linux-${{ matrix.arch }}-g${{ env.G_REV }} + path: pkg/*.tar.gz + + MSYS2: + strategy: + fail-fast: false + matrix: + include: + - cc: GCC + arch: x64 + cross: x86_64 + env: MINGW64 + - cc: GCC + arch: x86 + cross: i686 + env: MINGW32 + name: Windows / MSYS2 ${{ matrix.cc }} / ${{ matrix.arch }} + runs-on: windows-2022 + if: github.repository == 'mupen64plus/mupen64plus-core' + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.env }} + update: true + install: >- + git + libtool + make + mingw-w64-${{ matrix.cross }}-gcc + mingw-w64-${{ matrix.cross }}-toolchain + mingw-w64-${{ matrix.cross }}-freetype + mingw-w64-${{ matrix.cross }}-libpng + mingw-w64-${{ matrix.cross }}-nasm + mingw-w64-${{ matrix.cross }}-ntldd + mingw-w64-${{ matrix.cross }}-SDL2 + mingw-w64-${{ matrix.cross }}-vulkan-headers + mingw-w64-${{ matrix.cross }}-zlib + - name: Build and related stuff, backup binaries + run: | + export PATH="$(pwd)/.github/workflows/scripts:${PATH}" + export BUILD_CONFIG="ACCURATE_FPU=0 NEW_DYNAREC=0" POSTFIX="-old" + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + export BUILD_CONFIG="ACCURATE_FPU=1 NEW_DYNAREC=1" + unset POSTFIX + ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} + - name: Backup dependencies, etc... + run: | + ./.github/workflows/scripts/ci_backup_mingw_deps.sh ${{ matrix.env }} + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: mupen64plus-core-msys2-${{ matrix.arch }}-g${{ env.G_REV }} + path: pkg/* + + MSVC: + strategy: + fail-fast: false + matrix: + include: + - toolset: v143 + arch: x64 + vs: 2022 + - toolset: v141_xp + arch: x86 + vs: 2019 + name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.arch }} + runs-on: windows-${{ matrix.vs }} + if: github.repository == 'mupen64plus/mupen64plus-core' + defaults: + run: + shell: cmd + steps: + - uses: actions/checkout@v4 + - uses: microsoft/setup-msbuild@v2 + - name: Build and related stuff, backup binaries + run: | + set PATH=%CD%\.github\workflows\scripts;%PATH% + set TOOLSET=${{ matrix.toolset }} + call ci_msvc_build.cmd ${{ matrix.arch }} + ci_msvc_build.cmd ${{ matrix.arch }} newdyn + - name: Backup dependencies, etc... + run: | + .\.github\workflows\scripts\ci_backup_msvc_deps.cmd ${{ matrix.arch }} freetype.dll libpng16.dll SDL2.dll SDL2_net.dll zlib.dll + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: mupen64plus-core-msvc-${{ matrix.arch }}-g${{ env.G_REV }} + path: pkg/* + + Nightly-build: + runs-on: ubuntu-latest + if: github.ref_name == 'master' + needs: [Linux, MSYS2, MSVC] + steps: + - uses: actions/checkout@v4 + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: binaries + - name: Get some tools + run: | + sudo apt-get update + sudo apt-get -y install hashdeep + - name: Creating new artifacts and update nightly-build + run: | + ./.github/workflows/scripts/ci_nightly_artifacts.sh + - name: Nightly-build + uses: ncipollo/release-action@v1 + with: + prerelease: true + allowUpdates: true + removeArtifacts: true + replacesArtifacts: false + tag: nightly-build + artifacts: pkg/* diff --git a/mupen64plus-core/.github/workflows/scripts/ci_backup_mingw_deps.sh b/mupen64plus-core/.github/workflows/scripts/ci_backup_mingw_deps.sh new file mode 100755 index 0000000..fcad27e --- /dev/null +++ b/mupen64plus-core/.github/workflows/scripts/ci_backup_mingw_deps.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e +u + +if [[ ${#} -ne 1 ]]; then exit 9; fi + +export ENV_MSYS="$(echo "${1}" | sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/)" +export DEPS="$(LC_ALL=C grep "${ENV_MSYS}" "pkg/ldd.log" | sort | cut -d ' ' -f1)" + +if [[ "${DEPS}" == "" ]]; then exit 0; fi + +for LIB in ${DEPS}; do + echo ":: Copying ${LIB}" + cp "/${ENV_MSYS}/bin/${LIB}" pkg/ +done + +rm -f pkg/ldd.log + +exit 0 diff --git a/mupen64plus-core/.github/workflows/scripts/ci_backup_msvc_deps.cmd b/mupen64plus-core/.github/workflows/scripts/ci_backup_msvc_deps.cmd new file mode 100644 index 0000000..82e63f2 --- /dev/null +++ b/mupen64plus-core/.github/workflows/scripts/ci_backup_msvc_deps.cmd @@ -0,0 +1,32 @@ +@echo off +setlocal enableextensions enabledelayedexpansion +cls +if not exist "projects\msvc\" exit /b 9 + +set ARCH= +set DEPS= +if "%*" == "" exit /b 8 +for %%P in (%*) do ( + if /i "%%P" == "x86" (set ARCH=x86) else ( + if /i "%%P" == "x64" (set ARCH=x64) else ( + set "DEPS=!DEPS! %%P") ) +) + +if not defined ARCH exit /b 7 +if not defined DEPS exit /b 6 + +if exist "data\" xcopy /e data pkg +if errorlevel 1 exit /b 5 +if exist "pkg\mupen64plus.desktop" del /f /q pkg\mupen64plus.desktop + +set PKG=%CD%\pkg +cd ..\mupen64plus-win32-deps +if errorlevel 1 exit /b 4 +for %%D in (%DEPS%) do ( + for /f "tokens=*" %%T in ('dir /b /s %%D ^| findstr "%ARCH%"') do ( + if exist "%%T" copy "%%T" "%PKG%\" + if errorlevel 1 exit /b 3 + ) +) + +exit /b 0 diff --git a/mupen64plus-core/.github/workflows/scripts/ci_build.sh b/mupen64plus-core/.github/workflows/scripts/ci_build.sh new file mode 100755 index 0000000..02b1183 --- /dev/null +++ b/mupen64plus-core/.github/workflows/scripts/ci_build.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +set -e +u + +if [[ ${#} -lt 2 ]]; then exit 9; fi + +unset ARCH_ARG CC_ARG +export MULTILIB=0 +export ENV_ARGS="$(echo "${*}" | sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/)" + +for ARG in ${ENV_ARGS}; do + case "${ARG}" in + clang ) + export CC_ARG="Clang" CC="clang" CXX="clang++" + ;; + gcc ) + export CC_ARG="GCC" CC="gcc" CXX="g++" + ;; + multilib ) + export MULTILIB=1 + ;; + x64 ) + export ARCH_ARG="x64" CPU_TUNE="-march=nocona" BITS=64 + ;; + x86 ) + export ARCH_ARG="x86" CPU_TUNE="-march=pentium4" BITS=32 + ;; + esac +done + +if [[ -z ${ARCH_ARG} ]]; then exit 8; fi +if [[ -z ${CC_ARG} ]]; then exit 7; fi + +export REPO="${PWD##*/}" +if [[ "${REPO}" == "" ]]; then exit 6; fi + +export BIN_OS="$(uname -s | sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/)" +if [[ ! -z ${MSYSTEM} ]]; then export BIN_OS="msys2"; fi +export ENV_NAME="$(uname -s)" +export LDD="ldd" +export PKG_PATH="usr/local/lib/mupen64plus/" +if [[ "${REPO}" == *"core"* ]]; then + export PKG_PATH="usr/local/lib/" +elif [[ "${REPO}" == *"ui-console"* ]]; then + export PKG_PATH="usr/local/bin/" +fi + +if [[ "${ENV_NAME}" == *"Linux"* ]]; then + if [[ "${ARCH_ARG}" == "x86" ]]; then export PIC=1 PIE=1; fi + if [[ ${MULTILIB} -eq 0 ]]; then + if [[ "${CC_ARG}" == "GCC" ]]; then + if [[ "${ARCH_ARG}" == "x86" ]]; then export CC="i686-linux-gnu-gcc" CXX="i686-linux-gnu-g++"; fi + fi + fi +fi + +if [[ "${ENV_NAME}" == *"MINGW"* ]]; then + export INSTALL_OVERRIDE="PLUGINDIR=\"\" SHAREDIR=\"\" BINDIR=\"\" MANDIR=\"\" LIBDIR=\"\" APPSDIR=\"\" ICONSDIR=\"icons\" INCDIR=\"api\"" + export LDD="ntldd" + unset PKG_PATH +fi + +export G_REV="$(git rev-parse --short HEAD)" +if [[ -f "${GITHUB_ENV}" ]]; then + set +e + grep "G_REV=${G_REV}" "${GITHUB_ENV}" > /dev/null + if [[ ${?} -ne 0 ]]; then echo "G_REV=${G_REV}" >> "${GITHUB_ENV}"; fi + set -e +fi + +if [[ -z ${OPTFLAGS} ]]; then export OPTFLAGS="-O3 -flto ${CPU_TUNE}"; fi + +echo "" +${CC} --version +echo "" + +make CC="${CC}" CXX="${CXX}" BITS="${BITS}" ${BUILD_CONFIG} -C projects/unix clean +echo "" +make CC="${CC}" CXX="${CXX}" BITS="${BITS}" ${BUILD_CONFIG} -C projects/unix all -j4 +echo "" + +if [[ ! -d pkg ]]; then + mkdir pkg + chmod -R 755 pkg +fi +pushd projects/unix > /dev/null +export ARTIFACT="$(find *mupen64plus* -type f 2> /dev/null | head -n 1)" +popd > /dev/null + +echo "" +make CC="${CC}" CXX="${CXX}" BITS="${BITS}" ${BUILD_CONFIG} -C projects/unix install ${INSTALL_OVERRIDE} DESTDIR="$(pwd)/pkg/" +echo "" + +if [[ -z ${ARTIFACT} ]]; then + exit 5 +else + cd pkg + ls -gG "${PKG_PATH}${ARTIFACT}" + echo "" + ${LDD} "${PKG_PATH}${ARTIFACT}" > ldd.log + cat ldd.log + echo "" + if [[ "${MAKE_PKG}" == "1" ]]; then tar --owner=0 --group=0 --mode='og-w' -czf "${REPO}-${BIN_OS}-${ARCH_ARG}-g${G_REV}.tar.gz" usr; fi +fi + +exit 0 diff --git a/mupen64plus-core/.github/workflows/scripts/ci_get_libglew_i386.sh b/mupen64plus-core/.github/workflows/scripts/ci_get_libglew_i386.sh new file mode 100755 index 0000000..50bd736 --- /dev/null +++ b/mupen64plus-core/.github/workflows/scripts/ci_get_libglew_i386.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e +u + +# NOTE: There is no native "libglew-dev:i386" in Ubuntu 22.04, we will use Debian ones... + +export GLEWVER="$(apt list libglew-dev | grep "amd64" | cut -d ' ' -f2)" +export PKGS="$(apt list libglew* | grep "${GLEWVER}" | cut -d '/' -f1)" +export DEBSOURCE="http://http.us.debian.org/debian/pool/main/g/glew/" +export PKGVER_LS="$(curl -sS ${DEBSOURCE} | grep "${GLEWVER}" | grep "amd64" | cut -d '_' -f2 | sort)" +if [[ "${PKGVER_LS}" != "" ]]; then + for VER in ${PKGVER_LS}; do export PKGVER="${VER}"; done + cd /tmp + for PKG in ${PKGS}; do + for ARCH in amd64 i386; do curl -L -O "${DEBSOURCE}${PKG}_${PKGVER}_${ARCH}.deb"; done + done + sudo dpkg -i libglew*${PKGVER}*.deb +else + exit 9 +fi + +sudo ldconfig + +exit 0 diff --git a/mupen64plus-core/.github/workflows/scripts/ci_install_ubuntu_deps.sh b/mupen64plus-core/.github/workflows/scripts/ci_install_ubuntu_deps.sh new file mode 100755 index 0000000..ca480ff --- /dev/null +++ b/mupen64plus-core/.github/workflows/scripts/ci_install_ubuntu_deps.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +set -e +u + +if [[ ${#} -lt 2 ]]; then exit 9; fi + +unset ARCH_DEP CC_DEP +export BUILD_DEPS_I386="crossbuild-essential-i386 libc6-i386" +export HOTFIX_I386="libatomic1:i386 libgcc-s1:i386 libstdc++6:i386 ${HOTFIX_I386}" +export ENV_ARGS="$(echo "${*}" | sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/)" + +for ARG in ${ENV_ARGS}; do + case "${ARG}" in + clang ) + export CC_DEP="clang" + ;; + gcc ) + export CC_DEP="g++ gcc" + ;; + multilib ) + export BUILD_DEPS_I386="g++-multilib gcc-multilib libc6-dev-i386" + ;; + x64 ) + export ARCH_DEP="x64" + ;; + x86 ) + export ARCH_DEP="x86" + ;; + esac +done + +if [[ -z ${ARCH_DEP} ]]; then exit 8; fi +if [[ -z ${CC_DEP} ]]; then exit 7; fi + +if [[ "${ARCH_DEP}" == "x86" ]]; then sudo dpkg --add-architecture i386; fi +sudo apt-get update +sudo apt-get -y install build-essential git nasm pkg-config ${CC_DEP} ${BUILD_DEPS} +if [[ "${ARCH_DEP}" == "x86" ]]; then + if [[ "${BUILD_DEPS}" != "" ]]; then + for DEP in ${BUILD_DEPS}; do + if [[ "${DEP}" != "libglew-dev" ]]; then export BUILD_DEPS_I386="${BUILD_DEPS_I386} ${DEP}:i386"; fi + done + fi + sudo apt-get --reinstall -y install ${BUILD_DEPS_I386} ${HOTFIX_I386} +fi +sudo ldconfig + +exit 0 diff --git a/mupen64plus-core/.github/workflows/scripts/ci_msvc_build.cmd b/mupen64plus-core/.github/workflows/scripts/ci_msvc_build.cmd new file mode 100644 index 0000000..2752b89 --- /dev/null +++ b/mupen64plus-core/.github/workflows/scripts/ci_msvc_build.cmd @@ -0,0 +1,55 @@ +@echo off +setlocal enableextensions disabledelayedexpansion +cls +if not exist "projects\msvc\" exit /b 9 + +set ARCH= +set CONF=Release +if "%*" == "" exit /b 8 +for %%P in (%*) do ( + if /i "%%P" == "x86" set ARCH=Win32 + if /i "%%P" == "x64" set ARCH=x64 + if /i "%%P" == "newdyn" set CONF=New_Dynarec_Release +) + +if not defined ARCH exit /b 7 + +set ARTIFACT= +set FPROJ= +if not defined EXT set EXT=dll +if not defined TOOLSET set TOOLSET=v143 +for /f "tokens=1" %%R in ('git rev-parse --short HEAD') do set G_REV=%%R +if exist "%GITHUB_ENV%" ( + type "%GITHUB_ENV%" | findstr "G_REV=%G_REV%" >nul 2>&1 + if errorlevel 1 echo G_REV=%G_REV%>> "%GITHUB_ENV%" +) + +echo. +msbuild --version +echo. + +if not exist "..\mupen64plus-win32-deps\" git clone --depth 1 https://github.com/mupen64plus/mupen64plus-win32-deps.git ..\mupen64plus-win32-deps + +pushd projects\msvc\ +for /f "tokens=*" %%F in ('dir /b *.vcxproj') do set FPROJ=%%F +popd +if not defined FPROJ exit /b 6 + +echo. +msbuild "projects\msvc\%FPROJ%" /p:Configuration=%CONF%;Platform=%ARCH%;PlatformToolset=%TOOLSET% /t:Rebuild +if errorlevel 1 exit /b 5 +echo. + +if exist "projects\msvc\%ARCH%\Release\mupen64plus.dll" ren "projects\msvc\%ARCH%\Release\mupen64plus.dll" mupen64plus-old.dll + +pushd projects\msvc\%ARCH%\%CONF%\ +for /f "tokens=*" %%S in ('dir /b mupen64plus*%EXT%') do set ARTIFACT=%%S +popd +if not defined ARTIFACT exit /b 4 + +md pkg 2>nul +copy "projects\msvc\%ARCH%\%CONF%\%ARTIFACT%" pkg\ +if errorlevel 1 exit /b 3 +dir "pkg\%ARTIFACT%" + +exit /b 0 diff --git a/mupen64plus-core/.github/workflows/scripts/ci_nightly_artifacts.sh b/mupen64plus-core/.github/workflows/scripts/ci_nightly_artifacts.sh new file mode 100755 index 0000000..0966234 --- /dev/null +++ b/mupen64plus-core/.github/workflows/scripts/ci_nightly_artifacts.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -e +u + +export REPO="${PWD##*/}" +if [[ "${REPO}" == "" ]]; then exit 9; fi + +rm -fr pkg +mkdir pkg +cd binaries +for BIN in *; do + cd "${BIN}" + case "${BIN}" in + *msvc* | *msys2* ) + echo ":: Creating ${BIN}.zip" + zip -r "../../pkg/${BIN}.zip" * + ;; + * ) + echo ":: Recovering ${BIN}.tar.gz" + mv *.tar.gz ../../pkg/ + ;; + esac + cd .. +done +cd ../pkg +echo "" +for ZIP in *; do + ls -gG ${ZIP} + tigerdeep -lz ${ZIP} >> ../${REPO}.tiger.txt + sha256sum ${ZIP} >> ../${REPO}.sha256.txt + sha512sum ${ZIP} >> ../${REPO}.sha512.txt + b2sum ${ZIP} >> ../${REPO}.blake2.txt +done +mv ../${REPO}.*.txt . + +echo "" +echo "TIGER:" +cat *.tiger.txt +echo "" +echo "SHA256:" +cat *.sha256.txt +echo "" +echo "SHA512:" +cat *.sha512.txt +echo "" +echo "BLAKE2:" +cat *.blake2.txt +echo "" + +if [[ -f "${GITHUB_ENV}" ]]; then + git tag -f nightly-build + git push -f origin nightly-build +fi + +exit 0 diff --git a/mupen64plus-core/projects/unix/Makefile b/mupen64plus-core/projects/unix/Makefile index 334b334..fcfe8c8 100755 --- a/mupen64plus-core/projects/unix/Makefile +++ b/mupen64plus-core/projects/unix/Makefile @@ -796,7 +796,7 @@ targets: @echo " VULKAN=0 == Disable vulkan support for the default video extension implementation" @echo " POSTFIX=name == String added to the name of the the build (default: '')" @echo " Install Options:" - @echo " PREFIX=path == install/uninstall prefix (default: /usr/local/)" + @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)" @echo " SHAREDIR=path == path to install shared data files (default: PREFIX/share/mupen64plus)" @echo " LIBDIR=path == path to install core library (default: PREFIX/lib)" @echo " INCDIR=path == path to install core header files (default: PREFIX/include/mupen64plus)" @@ -833,7 +833,7 @@ uninstall: $(RM) "$(DESTDIR)$(SHAREDIR)/mupencheat.txt" clean: - $(RM) -r $(TARGET) $(SONAME) _obj $(OBJDIR) $(SRCDIR)/asm_defines/asm_defines_* + $(RM) -r *mupen64plus*.* $(TARGET) $(SONAME) _obj $(OBJDIR) $(SRCDIR)/asm_defines/asm_defines_*.h # build dependency files CFLAGS += -MD -MP diff --git a/mupen64plus-core/src/api/frontend.c b/mupen64plus-core/src/api/frontend.c index 60c7c28..1d1e3fc 100644 --- a/mupen64plus-core/src/api/frontend.c +++ b/mupen64plus-core/src/api/frontend.c @@ -181,7 +181,7 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P if (g_EmulatorRunning || l_DiskOpen || l_ROMOpen) return M64ERR_INVALID_STATE; // ROM buffer size must be divisible by 4 to avoid out-of-bounds read in swap_copy_rom (v64/n64 formats) - if (ParamPtr == NULL || ParamInt < 4096 || ParamInt > CART_ROM_MAX_SIZE || ParamInt % 4 != 0) + if (ParamPtr == NULL || ParamInt < 4096 || ParamInt > CART_ROM_MAX_SIZE) return M64ERR_INPUT_ASSERT; rval = open_rom((const unsigned char *) ParamPtr, ParamInt); if (rval == M64ERR_SUCCESS) diff --git a/mupen64plus-core/src/main/rom.c b/mupen64plus-core/src/main/rom.c index 844c172..be8a74e 100644 --- a/mupen64plus-core/src/main/rom.c +++ b/mupen64plus-core/src/main/rom.c @@ -76,12 +76,12 @@ static const uint8_t Z64_SIGNATURE[4] = { 0x80, 0x37, 0x12, 0x40 }; static const uint8_t V64_SIGNATURE[4] = { 0x37, 0x80, 0x40, 0x12 }; static const uint8_t N64_SIGNATURE[4] = { 0x40, 0x12, 0x37, 0x80 }; -/* Tests if a file is a valid N64 rom by checking the first 4 bytes. */ -static int is_valid_rom(const unsigned char *buffer) +/* Tests if a file is a valid N64 rom by checking the first 4 bytes and size */ +static int is_valid_rom(const unsigned char *buffer, unsigned int size) { - if (memcmp(buffer, Z64_SIGNATURE, sizeof(Z64_SIGNATURE)) == 0 - || memcmp(buffer, V64_SIGNATURE, sizeof(V64_SIGNATURE)) == 0 - || memcmp(buffer, N64_SIGNATURE, sizeof(N64_SIGNATURE)) == 0) + if ((memcmp(buffer, Z64_SIGNATURE, sizeof(Z64_SIGNATURE)) == 0) + || (memcmp(buffer, V64_SIGNATURE, sizeof(V64_SIGNATURE)) == 0 && size % 2 == 0) + || (memcmp(buffer, N64_SIGNATURE, sizeof(N64_SIGNATURE)) == 0 && size % 4 == 0)) return 1; else return 0; @@ -162,7 +162,7 @@ m64p_error open_rom(const unsigned char* romimage, unsigned int size) int i; /* check input requirements */ - if (romimage == NULL || !is_valid_rom(romimage)) + if (romimage == NULL || !is_valid_rom(romimage, size)) { DebugMessage(M64MSG_ERROR, "open_rom(): not a valid ROM image"); return M64ERR_INPUT_INVALID;