@echo off
setlocal enabledelayedexpansion

set SOLUTION_NAME=%1
set PROJECT_NAME=%2
set TARGET_PATH=%3
set DEST=%~f4

set CURRENT_DIR=%~dp0
set PROJECT_SRC_DIR=%CURRENT_DIR:~0,-1%\..\src\%PROJECT_NAME%
for %%f in ("%PROJECT_SRC_DIR%") do ( set PROJECT_SRC_DIR=%%~ff )
echo %PROJECT_SRC_DIR%
echo %TARGET_PATH%
:: Deploy dll
::------------------------------------
echo ## Deploy dll

set DEST_DIR=%DEST%\shaders

if not exist "!DEST_DIR!" (
    mkdir !DEST_DIR!
)

for %%f in ("%TARGET_PATH%") do (
    set FILENAME=%%~ff
)

copy !FILENAME! !DEST_DIR! /Y/B > nul

echo ##   Deploy !FILENAME! to !DEST_DIR!

:: Deploy mtd
::------------------------------------
echo ## Deploy mtd
for /R %PROJECT_SRC_DIR% %%a in (*.mtd) do (

    set DEST_DIR=%DEST%\shaders
    
    if not exist "!DEST_DIR!" (
        mkdir !DEST_DIR!
    )
    
    copy %%a !DEST_DIR! /Y/B > nul
    
    for %%f in ("%%a") do (
        set FILENAME=%%~ff
    )
    
    echo ##   Deploy !FILENAME! to !DEST_DIR!
)

:: Deploy templete
::------------------------------------
echo ## Deploy template
for /R %PROJECT_SRC_DIR% %%a in (*.py) do (

    set DEST_DIR=%DEST%\templates
    
    if not exist "!DEST_DIR!" (
        mkdir !DEST_DIR!
    )
    
    copy %%a !DEST_DIR! /Y/B > nul
    
    for %%f in ("%%a") do (
        set FILENAME=%%~ff
    )
    
    echo ##   Deploy !FILENAME! to !DEST_DIR!
)
echo ## Deploy Finish
endlocal