Improve glue code generation

This commit is contained in:
Jj0YzL5nvJ 2020-03-31 00:24:35 -07:00 committed by Dorian Fevrier
parent 4222bc20f6
commit de4d743b35
4 changed files with 58 additions and 15 deletions

1
.gitattributes vendored
View file

@ -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

View file

@ -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

View file

@ -943,7 +943,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -961,7 +961,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "__x86_64__" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='New_Dynarec_Debug|Win32'">
@ -979,7 +979,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x86_New_Dynarec_Debug|Win32'">
@ -997,7 +997,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ARM_New_Dynarec_Debug|Win32'">
@ -1015,7 +1015,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='New_Dynarec_Debug|x64'">
@ -1033,7 +1033,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ARM64_New_Dynarec_Debug|x64'">
@ -1051,7 +1051,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x64_New_Dynarec_Debug|x64'">
@ -1069,7 +1069,7 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -1090,7 +1090,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -1111,7 +1111,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "__x86_64__" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='New_Dynarec_Release|Win32'">
@ -1132,7 +1132,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "NEW_DYNAREC=1" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "NEW_DYNAREC=1"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='New_Dynarec_Release|x64'">
@ -1153,10 +1153,10 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
<PreBuildEvent>
<Command>del ..\..\src\asm_defines\asm_defines_* &amp; cl /c /Fo$(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2" /I ..\..\src ..\..\src\asm_defines\asm_defines.c &amp; "..\..\..\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</Command>
<Command>..\..\tools\gen_asm_script.cmd $(IntDir) /D "__x86_64__" /D "NEW_DYNAREC=2"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

42
tools/gen_asm_script.cmd Normal file
View file

@ -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