use vbscript to create projects for qnx and bada platform

This commit is contained in:
dumganhar 2012-01-10 11:39:58 +08:00
parent 69d91dc6e1
commit cff46c1064
3 changed files with 140 additions and 117 deletions

View File

@ -1,97 +0,0 @@
@echo off
:: This script is used to create an bada project.
:: Don't change it until you know what you do.
setlocal
setlocal enabledelayedexpansion
set COCOS2DX_ROOT=%cd%
set /p PROJECT_NAME=please input project name:
if /i %PROJECT_NAME%==tests (
echo can't not use "tests" as a project name, because it is used for cocos2dx tests project.
goto END
)
if /i %PROJECT_NAME%==HelloWorld (
echo can't not use "HelloWorld" as a project name, because it is used for cocos2dx HelloWorld project.
goto END
)
if not exist %PROJECT_NAME% md %PROJECT_NAME%
cd %PROJECT_NAME%
set PROJECT_ROOT=%COCOS2DX_ROOT%\%PROJECT_NAME%
echo project root = %PROJECT_ROOT%
if not exist bada (
md Resource
md bada\sdk1.0\Icons
md bada\sdk1.0\Res
md bada\sdk2.0\Icons
md bada\sdk2.0\Res
md bada\src
) else (
echo "bada project exist!"
goto END
)
xcopy /y /s %COCOS2DX_ROOT%\HelloWorld\Resource\*.* Resource
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk1.0\Icons bada\sdk1.0\Icons
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk1.0\.badaprj bada\sdk1.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk1.0\.cproject bada\sdk1.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk1.0\.project bada\sdk1.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk1.0\application.xml bada\sdk1.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk1.0\manifest.xml bada\sdk1.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\src bada\src
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk2.0\Icons bada\sdk2.0\Icons
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk2.0\.badaprj bada\sdk2.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk2.0\.cproject bada\sdk2.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk2.0\.project bada\sdk2.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk2.0\application.xml bada\sdk2.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\sdk2.0\manifest.xml bada\sdk2.0
copy /y %COCOS2DX_ROOT%\HelloWorld\bada\src bada\src
if not exist Classes (
md Classes
xcopy /y /s %COCOS2DX_ROOT%\HelloWorld\Classes\*.* Classes
) else (
echo "Classes folder exist, it will not be override!"
)
:: rename HelloWorldEntry.cpp
move bada\src\HelloWorldEntry.cpp bada\src\%PROJECT_NAME%Entry.cpp
cd bada\sdk1.0
call :replace .cproject
call :replace .project
call :replace application.xml
cd ..\..\bada\sdk2.0
call :replace .cproject
call :replace .project
call :replace application.xml
echo Congratulations, %PROJECT_NAME% project have been created, please import the project from BadaIDE.
:END
endlocal
pause
exit
:replace
for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%1"') do (
if "%%b"=="" (
echo\>>tmp.txt
) else (
set "var=%%b"
set "var=!var:HelloWorld=%PROJECT_NAME%!"
echo !var!>>tmp.txt
)
)
move tmp.txt %1

81
create_bada_project.vbs Normal file
View File

@ -0,0 +1,81 @@
set fso = Wscript.CreateObject("Scripting.FileSystemObject")
dim szPrompt, msgRet
szPrompt = "Prompt"
function ReplaceFileContent(fileName, oldStr, newStr)
set f = fso.opentextfile(fileName)
s = replace(f.readall, oldStr, newStr)
f.close
set r = fso.opentextfile(fileName, 2, true)
r.write s
end function
function CopyFolder(srcFolder, desFolder)
if (fso.FolderExists(desFolder)) then
'msgbox("none:"+srcFolder+":"+desFolder)
'If the desFolder exist, do nothing.
else
CopyFolder = fso.CopyFolder(srcFolder, desFolder)
end if
end function
function ConfigureProject()
dim szProjectName
szProjectName = Inputbox("Please Input Project Name:", szPrompt)
if szProjectName = "" then
Wscript.quit
end if
if (0 = strcomp(szProjectName, "HelloWorld", 1) or 0 = strcomp(szProjectName, "tests", 1)) then
msgRet = msgbox("Can not create a project named with "+szProjectName+", Please input again!", 1, szPrompt)
if (msgRet = 1) then
call ConfigureProject
end if
Wscript.quit
end if
if (fso.FolderExists(szProjectName)) then
else
fso.CreateFolder(szProjectName)
end if
dim badaFolder
badaFolder = szProjectName + "\bada"
if (fso.FolderExists(badaFolder)) then
msgRet = msgbox("The '"+szProjectName+"' project exists, can't override! Please input again!", 1, szPrompt)
if (msgRet = 1) then
call ConfigureProject
end if
Wcript.quit
end if
dim szSrcClass, szSrcBada, szSrcResource
dim szDesClass, szDesBada, szDesResource
szSrcClass = "HelloWorld\Classes"
szSrcBada = "HelloWorld\bada"
szSrcResource = "HelloWorld\Resource"
szDesClass = szProjectName+"\Classes"
szDesBada = szProjectName+"\bada"
szDesResource = szProjectName+"\Resource"
call CopyFolder(szSrcClass, szDesClass)
call CopyFolder(szSrcBada, szDesBada)
call CopyFolder(szSrcResource, szDesResource)
dim i
for i=1 to 2
call ReplaceFileContent(szProjectName+"\bada\sdk"+cstr(i)+".0\application.xml", "HelloWorld", szProjectName)
call ReplaceFileContent(szProjectName+"\bada\sdk"+cstr(i)+".0\.project", "HelloWorld", szProjectName)
call ReplaceFileContent(szProjectName+"\bada\sdk"+cstr(i)+".0\.cproject", "HelloWorld", szProjectName)
next
call msgbox("Congratulations, the '"+szProjectName+"' project have been created successfully, please input the project from Bada IDE!", 0, szPrompt)
end function
call ConfigureProject
Wscript.quit

View File

@ -1,5 +1,8 @@
set fso = Wscript.CreateObject("Scripting.FileSystemObject")
dim szPrompt, msgRet
szPrompt = "Prompt"
function ReplaceFileContent(fileName, oldStr, newStr)
set f = fso.opentextfile(fileName)
s = replace(f.readall, oldStr, newStr)
@ -8,32 +11,68 @@ function ReplaceFileContent(fileName, oldStr, newStr)
r.write s
end function
dim szProjectName
szProjectName = Inputbox("Please Input Project Name:", "Prompt")
function CopyFolder(srcFolder, desFolder)
if (fso.FolderExists(desFolder)) then
'msgbox("none:"+srcFolder+":"+desFolder)
'If the desFolder exist, do nothing.
else
CopyFolder = fso.CopyFolder(srcFolder, desFolder)
end if
end function
if (fso.FolderExists(szProjectName)) then
else
fso.CreateFolder(szProjectName)
end if
function ConfigureProject()
dim szProjectName
szProjectName = Inputbox("Please Input Project Name:", szPrompt)
dim qnxFolder
qnxFolder = szProjectName + "\qnx"
if (fso.FolderExists(qnxFolder)) then
msgbox("the project exists, can't override!")
Wscript.quit
else
fso.CreateFolder(qnxFolder)
end if
if szProjectName = "" then
Wscript.quit
end if
ret = fso.CopyFolder("HelloWorld\Classes", szProjectName+"\Classes")
ret = fso.CopyFolder("HelloWorld\qnx", szProjectName+"\qnx")
ret = fso.CopyFolder("HelloWorld\Resource", szProjectName+"\Resource")
if (0 = strcomp(szProjectName, "HelloWorld", 1) or 0 = strcomp(szProjectName, "tests", 1)) then
msgRet = msgbox("Can not create a project named with "+szProjectName+", Please input again!", 1, szPrompt)
if (msgRet = 1) then
call ConfigureProject
end if
Wscript.quit
end if
if (fso.FolderExists(szProjectName)) then
else
fso.CreateFolder(szProjectName)
end if
call ReplaceFileContent(szProjectName+"\qnx\bar-descriptor.xml", "HelloWorld", szProjectName)
call ReplaceFileContent(szProjectName+"\qnx\.project", "HelloWorld", szProjectName)
call ReplaceFileContent(szProjectName+"\qnx\.cproject", "HelloWorld", szProjectName)
dim qnxFolder
qnxFolder = szProjectName + "\qnx"
if (fso.FolderExists(qnxFolder)) then
msgRet = msgbox("The '"+szProjectName+"' project exists, can't override! Please input again!", 1, szPrompt)
if (msgRet = 1) then
call ConfigureProject
end if
Wcript.quit
end if
dim szSrcClass, szSrcQnx, szSrcResource
dim szDesClass, szDesQnx, szDesResource
szSrcClass = "HelloWorld\Classes"
szSrcQnx = "HelloWorld\qnx"
szSrcResource = "HelloWorld\Resource"
szDesClass = szProjectName+"\Classes"
szDesQnx = szProjectName+"\qnx"
szDesResource = szProjectName+"\Resource"
call CopyFolder(szSrcClass, szDesClass)
call CopyFolder(szSrcQnx, szDesQnx)
call CopyFolder(szSrcResource, szDesResource)
call ReplaceFileContent(szProjectName+"\qnx\bar-descriptor.xml", "HelloWorld", szProjectName)
call ReplaceFileContent(szProjectName+"\qnx\.project", "HelloWorld", szProjectName)
call ReplaceFileContent(szProjectName+"\qnx\.cproject", "HelloWorld", szProjectName)
call msgbox("Congratulations, the '"+szProjectName+"' project have been created successfully, please input the project from QNX IDE!", 0, szPrompt)
end function
call ConfigureProject
Wscript.quit