mupen64plus-core/tools/gen_asm_script.cmd
2020-03-31 10:16:06 +02:00

42 lines
1.9 KiB
Batchfile

@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