Skip to content

Commit

Permalink
General: updated our different developer scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Oct 16, 2019
2 parents 2a6aad9 + 49f03f2 commit 18fb385
Show file tree
Hide file tree
Showing 25 changed files with 117 additions and 78 deletions.
4 changes: 3 additions & 1 deletion clean
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

scripts/genericclean
appDir="$(cd "$(dirname "$0")"; pwd)"

${appDir}/scripts/genericclean
4 changes: 3 additions & 1 deletion clean.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@ECHO OFF

CALL scripts\genericclean
SET AppDir=%~dp0

CALL "%AppDir%scripts\genericclean"
4 changes: 3 additions & 1 deletion cleanall
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

scripts/genericclean all
appDir="$(cd "$(dirname "$0")"; pwd)"

${appDir}/scripts/genericclean all
4 changes: 3 additions & 1 deletion cleanall.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@ECHO OFF

CALL scripts\genericclean all
SET AppDir=%~dp0

CALL "%AppDir%scripts\genericclean" all
4 changes: 3 additions & 1 deletion distrib/linux/application.sh.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

bin/${CMAKE_PROJECT_NAME} $*
appDir="$(cd "$(dirname "$0")"; pwd)"

${appDir}/bin/@CMAKE_PROJECT_NAME@ $*
4 changes: 3 additions & 1 deletion distrib/macos/application.sh.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

${CMAKE_PROJECT_NAME}.app/Contents/MacOS/${CMAKE_PROJECT_NAME} $*
appDir="$(cd "$(dirname "$0")"; pwd)"

${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/MacOS/@CMAKE_PROJECT_NAME@ $*
4 changes: 3 additions & 1 deletion distrib/windows/application.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

TITLE Running the ${CMAKE_PROJECT_NAME} environment...

bin\${CMAKE_PROJECT_NAME} %*
SET AppBase=%~dp0bin\${CMAKE_PROJECT_NAME}

"%AppBase%" %*
6 changes: 4 additions & 2 deletions distrib/windows/application.vbs.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ For Each arg in WScript.Arguments
args = args&" "&arg
Next

cmd = "bin\${CMAKE_PROJECT_NAME}.exe"&args
Set shell = CreateObject("WScript.Shell")

CreateObject("WScript.Shell").Run cmd, 1, False
cmd = """"&Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName)-Len(Wscript.ScriptName))&"bin\${CMAKE_PROJECT_NAME}.exe"&args&""""

shell.Run cmd, 1, False
6 changes: 4 additions & 2 deletions format
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/sh

if [ -d "src" ]; then
appDir="$(cd "$(dirname "$0")"; pwd)"

if [ -d "${appDir}/src" ]; then
echo "\033[44;37;1mFormatting OpenCOR...\033[0m"

if [ "`hash clang-format 2>&1`" = "" ]; then
for i in `find src -name "*.cpp" -o -name "*.h" | sort | egrep -v "(3rdparty|\/ext\/|\/qzip)"`; do
for i in `find ${appDir}/src -name "*.cpp" -o -name "*.h" | sort | egrep -v "(3rdparty|\/ext\/|\/qzip)"`; do
echo "Formatting $i..."

clang-format -i -style=file $i
Expand Down
9 changes: 5 additions & 4 deletions format.bat
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
@ECHO OFF

SET CurrentPath=%CD%
SET AppDir=%~dp0
SET OrigDir=%CD%

IF EXIST %CurrentPath%\src (
IF EXIST "%AppDir%src" (
TITLE Formatting OpenCOR...

FOR %%X IN (clang-format.exe) DO (
SET ClangFormatFound=%%~$PATH:X
)

IF DEFINED ClangFormatFound (
CD %CurrentPath%\src
CD "%AppDir%src"

FOR /R %%I IN (*.cpp *.h) DO (
ECHO.%%I | FINDSTR /V "3rdparty \ext\ \qzip">NUL && (
Expand All @@ -20,7 +21,7 @@ IF EXIST %CurrentPath%\src (
)
)

CD %CurrentPath%
CD "%OrigDir%"
) ELSE (
ECHO Clang-Format is not installed.
)
Expand Down
4 changes: 3 additions & 1 deletion make
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

scripts/genericmake Release $*
appDir="$(cd "$(dirname "$0")"; pwd)"

${appDir}/scripts/genericmake Release $*
4 changes: 3 additions & 1 deletion make.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@ECHO OFF

CALL scripts\genericmake Release %*
SET AppDir=%~dp0

CALL "%AppDir%scripts\genericmake" Release %*
4 changes: 3 additions & 1 deletion maketests
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

scripts/genericmake Tests $*
appDir="$(cd "$(dirname "$0")"; pwd)"

${appDir}/scripts/genericmake Tests $*
4 changes: 3 additions & 1 deletion maketests.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@ECHO OFF

CALL scripts\genericmake Tests %*
SET AppDir=%~dp0

CALL "%AppDir%scripts\genericmake" Tests %*
12 changes: 8 additions & 4 deletions package
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

./clean
./make $*
appDir="$(cd "$(dirname "$0")"; pwd)"

${appDir}/clean
${appDir}/make $*

exitCode=$?

Expand All @@ -11,7 +13,9 @@ fi

echo "\033[44;37;1mPackaging OpenCOR...\033[0m"

cd build
origDir=`pwd`

cd ${appDir}/build

if [ "`uname -s`" = "Linux" ]; then
cpack
Expand All @@ -25,7 +29,7 @@ fi

exitCode=$?

cd ..
cd $origDir

if [ $exitCode -eq 0 ]; then
echo "\033[42;37;1mAll done!\033[0m"
Expand Down
12 changes: 8 additions & 4 deletions package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

SETLOCAL ENABLEDELAYEDEXPANSION

CALL clean
CALL make %*
SET AppDir=%~dp0

CALL "%AppDir%clean"
CALL "%AppDir%make" %*

SET ExitCode=!ERRORLEVEL!

IF !ExitCode! EQU 0 (
TITLE Packaging OpenCOR...

CD build
SET OrigDir=%CD%

CD "%AppDir%build"

cpack

SET ExitCode=!ERRORLEVEL!

CD ..
CD "%OrigDir%"
)

EXIT /B !ExitCode!
20 changes: 9 additions & 11 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

echo "\033[44;37;1mRunning OpenCOR...\033[0m"

WMsg="OpenCOR must first be built before being run."
appDir="$(cd "$(dirname "$0")"; pwd)"

if [ "`uname -s`" = "Linux" ]; then
if [ -f build/bin/OpenCOR ]; then
build/bin/OpenCOR "$@"
else
echo $WMsg
fi
appExe=${appDir}/build/bin/OpenCOR
else
if [ -d build/OpenCOR.app ]; then
build/OpenCOR.app/Contents/MacOS/OpenCOR "$@"
else
echo $WMsg
fi
appExe=${appDir}/build/OpenCOR.app/Contents/MacOS/OpenCOR
fi

if [ -f ${appExe} ]; then
${appExe} "$@"
else
echo "OpenCOR must first be built before being run."
fi

echo "\033[42;37;1mAll done!\033[0m"
7 changes: 4 additions & 3 deletions run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

TITLE Running OpenCOR...

SET AppBase=%~dp0build\bin\OpenCOR
SET NeedInformation=

IF NOT EXIST build\bin\OpenCOR.com SET NeedInformation=Yes
IF NOT EXIST build\bin\OpenCOR.exe SET NeedInformation=Yes
IF NOT EXIST "%AppBase%.com" SET NeedInformation=Yes
IF NOT EXIST "%AppBase%.exe" SET NeedInformation=Yes

IF DEFINED NeedInformation (
ECHO OpenCOR must first be built before being run.
) ELSE (
build\bin\OpenCOR %*
"%AppBase%" %*
)
6 changes: 4 additions & 2 deletions run.vbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
If CreateObject("Scripting.FileSystemObject").FileExists("build\bin\OpenCOR.exe") Then
appExe = Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName)-Len(Wscript.ScriptName))&"build\bin\OpenCOR.exe"

If CreateObject("Scripting.FileSystemObject").FileExists(""""&appExe&"""") Then
args = ""

For Each arg in WScript.Arguments
args = args&" "&arg
Next

cmd = "build\bin\OpenCOR.exe"&args
cmd = """"&appExe&args&""""

CreateObject("WScript.Shell").Run cmd, 1, False
Else
Expand Down
20 changes: 9 additions & 11 deletions runtests
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

echo "\033[44;37;1mRunning OpenCOR's tests...\033[0m"

WMsg="OpenCOR's tests must first be built before being run."
appDir="$(cd "$(dirname "$0")"; pwd)"

if [ "`uname -s`" = "Linux" ]; then
if [ -f build/bin/runtests ]; then
build/bin/runtests
else
echo $WMsg
fi
OPENCOR_TESTS_EXE=${appDir}/build/bin/runtests
else
if [ -f build/OpenCOR.app/Contents/MacOS/runtests ]; then
build/OpenCOR.app/Contents/MacOS/runtests
else
echo $WMsg
fi
OPENCOR_TESTS_EXE=${appDir}/build/OpenCOR.app/Contents/MacOS/runtests
fi

if [ -f ${OPENCOR_TESTS_EXE} ]; then
${OPENCOR_TESTS_EXE} "$@"
else
echo "OpenCOR's tests must first be built before being run."
fi

echo "\033[42;37;1mAll done!\033[0m"
8 changes: 3 additions & 5 deletions runtests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

TITLE Running OpenCOR's tests...

SET NeedInformation=
SET appTestsExe=%~dp0build\bin\runtests.exe

IF NOT EXIST build\bin\runtests.exe SET NeedInformation=Yes

IF DEFINED NeedInformation (
IF NOT EXIST %appTestsExe% (
ECHO OpenCOR's tests must first be built before being run.
) ELSE (
build\bin\runtests
"%appTestsExe%"
)
6 changes: 4 additions & 2 deletions scripts/genericclean
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ else
echo "\033[44;37;1mCleaning OpenCOR...\033[0m"
fi

rm -fr build/.clang-tidy build/.ninja* build/* > /dev/null 2>&1
appDir="$(cd "$(dirname "$0")"; pwd)"/..

rm -fr ${appDir}/build/.clang-tidy ${appDir}/build/.ninja* ${appDir}/build/* > /dev/null 2>&1

if [ "$1" = "all" ]; then
rm -fr ext/* > /dev/null 2>&1
rm -fr ${appDir}/ext/* > /dev/null 2>&1
fi

echo "\033[42;37;1mAll done!\033[0m"
13 changes: 7 additions & 6 deletions scripts/genericclean.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ IF "%1" == "all" (
TITLE Cleaning OpenCOR...
)

SET CurrentPath=%CD%
SET AppDir=%~dp0..\
SET OrigDir=%CD%

IF EXIST %CurrentPath%\build (
CD %CurrentPath%\build
IF EXIST "%AppDir%build" (
CD "%AppDir%build"

FOR %%I IN (*.*) DO ATTRIB -R "%%I"
FOR /D %%I IN (*.*) DO RMDIR /S /Q "%%I"
FOR %%I IN (*.*) DO IF NOT "%%I" == ".gitignore" DEL /Q "%%I"
)

IF "%1" == "all" (
IF EXIST %CurrentPath%\ext (
CD %CurrentPath%\ext
IF EXIST "%AppDir%ext" (
CD "%AppDir%ext"

FOR /D %%I IN (*.*) DO RMDIR /S /Q "%%I"
FOR %%I IN (*.*) DO IF NOT "%%I" == ".gitignore" DEL /Q "%%I"
)
)

CD %CurrentPath%
CD "%OrigDir%"
16 changes: 9 additions & 7 deletions scripts/genericmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh

if [ -d "build" ]; then
appDir="$(cd "$(dirname "$0")"; pwd)"/..

if [ -d "${appDir}/build" ]; then
cmakeBuildType=$1

if [ "$cmakeBuildType" = "Release" ]; then
Expand All @@ -20,22 +22,22 @@ if [ -d "build" ]; then
cmakeGenerator="Unix Makefiles"
fi

if [ "$cmakeBuildType" = "Release" ]; then
titleTests=""
else
if [ "$cmakeBuildType" = "Debug" ]; then
titleTests=" and its tests"
fi

echo "\033[44;37;1mMaking OpenCOR$titleTests (using $generator)...\033[0m"

cd build
origDir=`pwd`

cd ${appDir}/build

cmake -G "$cmakeGenerator" -DCMAKE_BUILD_TYPE=$cmakeBuildType -DENABLE_TESTS=$enableTests ..

exitCode=$?

if [ $exitCode -ne 0 ]; then
cd ..
cd $origDir

exit $exitCode
fi
Expand All @@ -50,7 +52,7 @@ if [ -d "build" ]; then

exitCode=$?

cd ..
cd $origDir

if [ $exitCode -eq 0 ]; then
echo "\033[42;37;1mAll done!\033[0m"
Expand Down

0 comments on commit 18fb385

Please sign in to comment.