From de4d743b35af4a2519473e9c4db62218bcade9e1 Mon Sep 17 00:00:00 2001 From: Jj0YzL5nvJ Date: Tue, 31 Mar 2020 00:24:35 -0700 Subject: [PATCH] Improve glue code generation --- .gitattributes | 1 + appveyor.yml | 4 +-- projects/msvc/mupen64plus-core.vcxproj | 26 ++++++++-------- tools/gen_asm_script.cmd | 42 ++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 tools/gen_asm_script.cmd diff --git a/.gitattributes b/.gitattributes index f0537714..c5000eb8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -26,6 +26,7 @@ RELEASE text *.ver text # windows specific text files +*.cmd text eol=crlf *.sln text eol=crlf *.vcproj text eol=crlf *.vcxproj text eol=crlf diff --git a/appveyor.yml b/appveyor.yml index 1a62c0fa..3c6530e2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ before_build: - git clone --depth 1 https://github.com/mupen64plus/mupen64plus-win32-deps.git ..\mupen64plus-win32-deps build_script: - - msbuild projects/msvc/mupen64plus-core.vcxproj /p:Configuration=%configuration%;Platform=%platform% + - msbuild projects\msvc\mupen64plus-core.vcxproj /p:Configuration=%configuration%;Platform=%platform% after_build: - ps: $env:rev1 = git describe --tags @@ -21,7 +21,7 @@ after_build: - if "%rev3%" NEQ "Release" set rev3=NewDynarec - set filepkg=mupen64plus-core_v%rev1%_%rev2%-%rev3% - cd projects\msvc\%platform%\%configuration% - - 7z a -t7z ..\..\..\..\build\%filepkg%.7z mupen64plus.dll + - 7z a -t7z ..\..\..\..\build\%filepkg%.7z *.dll artifacts: - path: build\$(filepkg).7z diff --git a/projects/msvc/mupen64plus-core.vcxproj b/projects/msvc/mupen64plus-core.vcxproj index c4cf0055..1df907b5 100644 --- a/projects/msvc/mupen64plus-core.vcxproj +++ b/projects/msvc/mupen64plus-core.vcxproj @@ -943,7 +943,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) @@ -961,7 +961,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "__x86_64__" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" @@ -979,7 +979,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1" @@ -997,7 +997,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1" @@ -1015,7 +1015,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1" @@ -1033,7 +1033,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" @@ -1051,7 +1051,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" @@ -1069,7 +1069,7 @@ Windows - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" @@ -1090,7 +1090,7 @@ true - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) @@ -1111,7 +1111,7 @@ true - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "__x86_64__" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" @@ -1132,7 +1132,7 @@ true - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1" @@ -1153,10 +1153,10 @@ true - del ..\..\src\asm_defines\asm_defines_* & cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c & "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk $(IntDir)asm_defines.obj + ..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" - + \ No newline at end of file diff --git a/tools/gen_asm_script.cmd b/tools/gen_asm_script.cmd new file mode 100644 index 00000000..6f32aaf4 --- /dev/null +++ b/tools/gen_asm_script.cmd @@ -0,0 +1,42 @@ +@echo off +:: +:: To correctly handle the undefined GAS_ARG2TOINF +setlocal enableextensions disabledelayedexpansion +:: +:: Validation of the parameters sent by VS to use them as variables, if an invalid parameter is sent (syntax conflict), this script will fail without error code +for /f "tokens=1*" %%A in ('echo %*') do set GAS_ARG1=%%A& set GAS_ARG2TOINF=%%B +:: +:: Lite version of Anti-PEBCAK/Layer_8/Wetware implementation +:: * Makes GAS_PATH more "static"... +:: * Ensures that "Item A" and "Item B" exist, and sends "corresponding" error if not +:: * The sole purpose of this piece of code is to make the script fail outside VS +:: +set GAS_PATH=..\..\src\asm_defines\ +if not exist mupen64plus-core.vcxproj exit /b 202 +if not exist "%GAS_PATH%asm_defines.c" exit /b 303 +:: +:: Legacy code adaptation for this script: +:: * Delete the "glue code" libraries previously generated by gawk and/or this script +:: * CL's stuff/witchcraft, if all goes well it will generate "Item C" +:: +del %GAS_PATH%asm_defines_* +cl /c /Fo%GAS_ARG1% %GAS_ARG2TOINF% /I ..\..\src %GAS_PATH%asm_defines.c +:: +:: If "Item C" does not exist, send error +if not exist "%GAS_ARG1%asm_defines.obj" exit /b 404 +:: +:: Legacy code adaptation for gawk, currently disabled +REM "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk %GAS_ARG1%asm_defines.obj +:: +:: Simplified adaptation of 'gen_asm_defines.awk': +:: * Display 'asm_defines.obj' as a list +:: * Look for the '@ASM_DEFINE' pattern +:: * Take element '$2' and '$3' on that line +:: * Print '#define "$2" ("$3")' to asm_defines_gas.h +:: * Print '%define "$2" ("$3")' to asm_defines_nasm.h +:: +for /f "tokens=2,3" %%J in ('type %GAS_ARG1%asm_defines.obj ^| find "@ASM_DEFINE"') do ( +echo #define %%J ^(%%K^)>>%GAS_PATH%asm_defines_gas.h +echo %%define %%J ^(%%K^)>>%GAS_PATH%asm_defines_nasm.h +) +exit /b 0 \ No newline at end of file