Bước này tạo ra 2 file batch-script để build data tự động. Các file này nằm trong thư mục FifteenPuzzle, cùng cấp với các thư mục source, data ...
File này chứa các thông tin cần thiết về cấu hình, cấu trúc, và đặt biệt là đường dẫn đến các thư mục cần thiết. Các thư mục này có thể khác nhau khi build cho từng máy, và người dùng chỉ cần sửa đổi thông tin cấu hình cho phù hợp từng máy trước khi build
config.bat
@echo offREM =======================================REM == USER DEFINED ==REM =======================================set JDK=C:\jdk1.6.0_10\binREM =======================================REM == DO NOT MODIFY THE FOLLOWING ==REM =======================================set CUR_DIR=%CD%set ROOT_DIR=%~dp0set TOOLPACK=%ROOT_DIR%\external\gametutor\tools\ToolPack.jarset SOURCE_DIR=%ROOT_DIR%\source\set DATA_DIR=%ROOT_DIR%\data\Trong file này, tham số duy nhất cần hiệu chỉnh khi build trên máy khác là đường dẫn JDK
Ta tiến hành qua các công đoạn sau
@echo offclscd %ROOT_DIR%if not exist "config.bat" (echo ERROR: config.bat not found
goto END
)call config.bat:CHECKINGecho ::Checkingif not exist %JDK% ( echo ERROR: JDK [%JDK%] not foundgoto END
)if not exist %DATA_DIR% ( echo ERROR: JDK [%DATA_DIR%] not foundgoto END
)if not exist %SOURCE_DIR% ( echo ERROR: JDK [%DATA_DIR%] not foundgoto END
)if not exist %TOOLPACK% ( echo ERROR: JDK [%TOOLPACK%] not foundgoto END
):BEGINcd %DATA_DIR%if exist #build (rd /s /q #build)if exist #temp (rd /s /q #temp):CLONE_RESecho ========CLONE RESOURCE========dir /B/S *.* > #raw_files.txtmd #tempmd #buildfor /F %%i in (#raw_files.txt) do ( copy %%i #temp>nul)copy %TOOLPACK% #temp>nulcd .\#tempSET TOOLPACK_JAR=%TOOLPACK%for /F "tokens=2 delims==" %%i in ('set TOOLPACK_JAR') do ( set TOOLPACK_JAR=%%~nxi):CONVERT_IMAGEecho ========CONVERT IMAGE TO TGA========dir /B/S *.jpg, *.png, *.bmp > #raw_files.txtfor /F %%i in (#raw_files.txt) do ( %JDK%\java -jar -Xmx512M %TOOLPACK_JAR% tga %%i %%~ni.tga):BUILD_TEXTecho ========BUILD TEXT========%JDK%\java -jar -Xmx512M %TOOLPACK_JAR% le text.xlscopy /y .\*.ff ..\#build>nulcopy /y .\*.lang ..\#build>nulcopy /y .\*.h %SOURCE_DIR%>nul:COPY_RESecho ========COPY RESOURCE========dir /B/S *.wav, *.ogg, *.spr, *.tga > #raw_files.txtfor /F %%i in (#raw_files.txt) do ( copy /y %%i ..\#build\%%~nxi>nul):ENDecho ========DONE========cd %CUR_DIR%if exist %DATA_DIR%\#temp (rd /s /q %DATA_DIR%\#temp)if exist %DATA_DIR%\#raw_files.txt (del %DATA_DIR%\#raw_files.txt>nul)Tổng hợp các quá trình trên, ta có file makedata.bat
makedata.bat
@echo off cls cd %ROOT_DIR% if not exist "config.bat" ( echo ERROR: config.bat not found goto END ) call config.bat :CHECKING echo ::Checking if not exist %JDK% ( echo ERROR: JDK [%JDK%] not found goto END ) if not exist %DATA_DIR% ( echo ERROR: JDK [%DATA_DIR%] not found goto END ) if not exist %SOURCE_DIR% ( echo ERROR: JDK [%DATA_DIR%] not found goto END ) if not exist %TOOLPACK% ( echo ERROR: JDK [%TOOLPACK%] not found goto END ) :BEGIN cd %DATA_DIR% if exist #build (rd /s /q #build) if exist #temp (rd /s /q #temp) :CLONE_RES echo ========CLONE RESOURCE======== dir /B/S *.* > #raw_files.txt md #temp md #build for /F %%i in (#raw_files.txt) do ( copy %%i #temp>nul ) copy %TOOLPACK% #temp>nul cd .\#temp SET TOOLPACK_JAR=%TOOLPACK% for /F "tokens=2 delims==" %%i in ('set TOOLPACK_JAR') do ( set TOOLPACK_JAR=%%~nxi ) :CONVERT_IMAGE echo ========CONVERT IMAGE TO TGA======== dir /B/S *.jpg, *.png, *.bmp > #raw_files.txt for /F %%i in (#raw_files.txt) do ( %JDK%\java -jar -Xmx512M %TOOLPACK_JAR% tga %%i %%~ni.tga ) :BUILD_TEXT echo ========BUILD TEXT======== %JDK%\java -jar -Xmx512M %TOOLPACK_JAR% le text.xls copy /y .\*.ff ..\#build>nul copy /y .\*.lang ..\#build>nul copy /y .\*.h %SOURCE_DIR%>nul :COPY_RES echo ========COPY RESOURCE======== dir /B/S *.wav, *.ogg, *.spr, *.tga > #raw_files.txt for /F %%i in (#raw_files.txt) do ( copy /y %%i ..\#build\%%~nxi>nul ) :END echo ========DONE======== cd %CUR_DIR% if exist %DATA_DIR%\#temp (rd /s /q %DATA_DIR%\#temp) if exist %DATA_DIR%\#raw_files.txt (del %DATA_DIR%\#raw_files.txt>nul)
Kết quả sau khi thực thi makedata.bat (ví dụ minh họa)
Để có thể run được game với thư mục data là #build, ta cần thiết lập đường dẫn Working Directory cho project game là $(SolutionDir)..\..\data\#build