updates linux scripts

master
Joey Pollack 1 year ago
parent 55db1098b8
commit f2954aa6c1

@ -1,17 +1,32 @@
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
REM This script expects to be run from the parent directory
REM ex. scripts/build.bat
REM Sets the escape char. see for info:
REM https://stackoverflow.com/questions/55891318/how-to-echo-with-different-colors-in-the-windows-command-line-inside-a-for-loop
for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
IF not exist build/ (
echo This script needs to be run from the directory above build/
goto END
echo This script needs to be run from the directory above build/
goto END
)
cmake --build build/ --target all
SET BUILD_ERRORLEVEL=!ERRORLEVEL!
IF NOT "!BUILD_ERRORLEVEL!"=="0" (
echo %ESC%[91mBUILD FAILED!%ESC%[0m %BUILD_ERRORLEVEL%
EXIT /B !BUILD_ERRORLEVEL!
)
IF "%~1" == "r" (
cmake --build build/ --target ALL_BUILD --config Release
) ELSE (
cmake --build build/ --target ALL_BUILD --config Debug
IF not exist build/bin/shaders (
mkdir build/bin/shaders
)
REM TODO: Run any extra tasks here
echo %ESC%[92mBUILD SUCCEEDED!%ESC%[0m
:END
ENDLOCAL

@ -0,0 +1,16 @@
#! /bin/sh
# This script expects to be run from the parent directory
# ex. scripts/build.sh
#Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
echo building project...
cmake --build build/
if [ $? -eq 0 ]; then
echo "${GREEN}BUILD SUCCESSFUL${NC}"
else
echo "${RED}BUILD FAILED${NC}"
fi

@ -0,0 +1,4 @@
rm -r build
mkdir build

@ -1,7 +1,44 @@
@echo off
REM This script expects to be run from the parent directory
REM ex. scripts/cmconfig.bat
@echo off
REM ex. scripts/config.bat
REM script options (like -c and -r) must come before any cmake options (EXAMPLE_BASIC, NO_DIAG, etc)
set options=
set build_type=
IF "%1"=="" goto command
goto loop
:command
IF "%build_type%"=="" (
set build_type=-DCMAKE_BUILD_TYPE=Debug
echo Build mode is Debug
)
echo using options %options%
:: cmake -Wno-dev %build_type% %options% -B build/ -S . -G "Visual Studio 17 2022" -A x64
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -Wno-dev -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang %build_type% %options% -B build/ -S . -G Ninja
goto exit
:loop
IF "%1"=="-c" (
call scripts\clean.bat
goto loop_condition
)
IF "%1"=="-r" (
echo Build mode is release
set build_type=-DCMAKE_BUILD_TYPE=Release
goto loop_condition
)
set options=%options%-D%1=ON
:loop_condition
shift
IF "%1"=="" goto command
goto loop
cmake -Wno-dev -B build/ -S . -G "Visual Studio 17 2022" -A x64
:exit

@ -0,0 +1,39 @@
#!/bin/sh
# This script expects to be run from the parent directory
# ex. scripts/config.sh
#Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
options=
build_type=-DCMAKE_BUILD_TYPE=Debug
until [ "$1" = "" ]
do
if [ "$1" = "-r" ]
then
build_type=-DCMAKE_BUILD_TYPE=Release
elif [ "$1" = "-c" ]
then
rm -r build
mkdir build
else
options="$options -D$1=ON"
fi
shift
done
echo using options: $options
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang $build_type -Wno-dev $options -S . -B build/
if [ $? -eq 0 ]; then
echo "${GREEN}cmake config successful!${NC}"
else
echo "${RED}cmake config failed. Cleaning partial config.${NC}"
fi

@ -623,10 +623,54 @@ int main(int argc, char** argv)
std::cout << "\nGenerating config script file: " << config_file.string().c_str();
ofs << "#! /bin/sh";
ofs << "\n# This script expects to be run from the parent directory";
ofs << "\n# ex. scripts/cmconfig.sh";
ofs << "\n\ncmake -S . -B build/";
ofs << "#!/bin/sh\n";
ofs << "# This script expects to be run from the parent directory\n";
ofs << "# ex. scripts/config.sh\n";
ofs << "\n";
ofs << "#Colors\n";
ofs << "RED='\033[0;31m'\n";
ofs << "GREEN='\033[0;32m'\n";
ofs << "NC='\033[0m'\n";
ofs << "\n";
ofs << "options=\n";
ofs << "build_type=-DCMAKE_BUILD_TYPE=Debug\n";
ofs << "\n";
ofs << "until [ \"$1\" = \"\" ]\n";
ofs << "do\n";
ofs << "\n";
ofs << " if [ \"$1\" = \"-r\" ]\n";
ofs << " then\n";
ofs << " build_type=-DCMAKE_BUILD_TYPE=Release\n";
ofs << "\n";
ofs << " elif [ \"$1\" = \"-c\" ]\n";
ofs << " then\n";
ofs << " rm -r build\n";
ofs << " mkdir build\n";
ofs << " else\n";
ofs << " options=\"$options -D$1=ON\"\n";
ofs << " fi\n";
ofs << "\n";
ofs << " shift\n";
ofs << "done\n";
ofs << " echo using options: $options\n";
ofs << " cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang $build_type -Wno-dev $options -S . -B build/\n";
ofs << "\n";
ofs << " if [ $? -eq 0 ]; then\n";
ofs << " echo \"${GREEN}cmake config successful!${NC}\"\n";
ofs << " else\n";
ofs << " echo \"${RED}cmake config failed. Cleaning partial config.${NC}\"\n";
ofs << " fi\n";
ofs << "\n";
ofs.close();
ofs.clear();
@ -641,10 +685,24 @@ int main(int argc, char** argv)
std::cout << "\nGenerating build script file: " << build_file.string().c_str();
ofs << "#! /bin/sh";
ofs << "\n# This script expects to be run from the parent directory";
ofs << "\n# ex. scripts/build.sh";
ofs << "\n\ncmake -C build/";
ofs << "#! /bin/sh\n";
ofs << "# This script expects to be run from the parent directory\n";
ofs << "# ex. scripts/build.sh\n";
ofs << "\n";
ofs << "#Colors\n";
ofs << "RED='\033[0;31m'\n";
ofs << "GREEN='\033[0;32m'\n";
ofs << "NC='\033[0m'\n";
ofs << "\n";
ofs << "echo building project...\n";
ofs << "cmake --build build/\n";
ofs << "if [ $? -eq 0 ]; then\n";
ofs << " echo \"${GREEN}BUILD SUCCESSFUL${NC}\"\n";
ofs << "else\n";
ofs << " echo \"${RED}BUILD FAILED${NC}\"\n";
ofs << "fi\n";
ofs.close();
ofs.clear();
}

@ -9,6 +9,7 @@
* Code should work on windows and *nix
******************************************************************************/
#include "CmdArgParser.h"
#include "StringManip.h"

Loading…
Cancel
Save