Skip to content

Commit 902108b

Browse files
Sync CarlaSetup.sh and CarlaSetup.bat. (#8565)
* Move CarlaSetup.bat prerequisite install step into separate script. * Sync setup script structure and command line options + multiple fixes. * Update ninja version. * Minor changes. * Update logs. * Minor fix.
1 parent 41d6125 commit 902108b

File tree

5 files changed

+182
-121
lines changed

5 files changed

+182
-121
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Build/
77
Install/
88
Doxygen/
99
Dist/
10+
Temp/
1011
out/
1112

1213
CMakeSettings.json

CarlaSetup.bat

+87-96
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,107 @@
1-
SETLOCAL EnableDelayedExpansion
2-
3-
echo Starting Content Download...
4-
if not exist "Unreal\CarlaUnreal\Content" mkdir Unreal\CarlaUnreal\Content
5-
start cmd /c git -C Unreal/CarlaUnreal/Content clone -b ue5-dev https://bitbucket.org/carla-simulator/carla-content.git Carla
6-
7-
8-
echo Installing Visual Studio 2022...
9-
curl -L -O https://aka.ms/vs/17/release/vs_community.exe || exit /b
10-
rem See: https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community?view=vs-2022&preserve-view=true
11-
vs_Community.exe --add ^
12-
Microsoft.VisualStudio.Workload.NativeDesktop ^
13-
Microsoft.VisualStudio.Workload.NativeGame ^
14-
Microsoft.VisualStudio.Workload.ManagedDesktop ^
15-
Microsoft.VisualStudio.Component.Windows10SDK.18362 ^
16-
Microsoft.VisualStudio.Component.VC.CMake.Project ^
17-
Microsoft.Net.ComponentGroup.4.8.1.DeveloperTools ^
18-
Microsoft.VisualStudio.Component.VC.Llvm.Clang ^
19-
Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset ^
20-
Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang ^
21-
Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64 ^
22-
--removeProductLang Es-es ^
23-
--addProductLang En-us ^
24-
--installWhileDownloading ^
25-
--passive ^
26-
--wait
27-
del vs_community.exe
28-
echo Visual Studion 2022 Installed!!!
1+
@echo off
2+
setlocal EnableDelayedExpansion
3+
4+
set SKIP_PREREQUISITES=false
5+
set LAUNCH=false
6+
set INTERACTIVE=false
7+
8+
if not "%*"=="" (
9+
for %%x in ("%*") do (
10+
if "%%~x"=="--interactive" (
11+
set INTERACTIVE=true
12+
) else if "%%~x"=="-i" (
13+
set INTERACTIVE=true
14+
) else if "%%~x"=="--skip-prerequisites" (
15+
set SKIP_PREREQUISITES=true
16+
) else if "%%~x"=="-p" (
17+
set SKIP_PREREQUISITES=true
18+
) else if "%%~x"=="--launch" (
19+
set LAUNCH=true
20+
) else if "%%~x"=="-l" (
21+
set LAUNCH=true
22+
) else (
23+
echo Unknown argument "%%~x"
24+
)
25+
)
26+
)
2927

28+
rem -- PREREQUISITES INSTALL STEP --
3029

31-
ninja --version 2>NUL
32-
if errorlevel 1 (
33-
echo Found Ninja - FAIL
34-
echo Installing Ninja 1.11.1...
35-
echo Installing Ninja...
36-
curl -L -o %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win.zip https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip || exit /b
37-
powershell -command "Expand-Archive $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\ninja-win.zip $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\ninja-win" || exit /b
38-
move %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win\ninja.exe %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja.exe || exit /b
39-
rmdir /s /q %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win
40-
del /f %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win.zip
41-
echo Ninja Installed!!!
30+
if %SKIP_PREREQUISITES%==false (
31+
echo Installing prerequisites...
32+
call Util/SetupUtils/InstallPrerequisites.bat || exit /b
4233
) else (
43-
echo Found Ninja - OK
44-
ninja --version
34+
echo Skipping prerequisites install step.
4535
)
4636

47-
48-
python --version 2>NUL
49-
if errorlevel 1 (
50-
echo Found Python - FAIL
51-
echo Installing Python 3.8.10...
52-
curl -L -O https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe || exit /b
53-
python-3.8.10-amd64.exe /passive PrependPath=1 || exit /b
54-
del python-3.8.10-amd64.exe
55-
set "PATH=%LocalAppData%\Programs\Python\Python38\Scripts\;%LocalAppData%\Programs\Python\Python38\;%PATH%"
56-
echo Python 3.8.10 installed!!!
37+
rem -- CLONE CONTENT --
38+
if exist "%cd%\Unreal\CarlaUnreal\Content" (
39+
echo Found CARLA content.
5740
) else (
58-
echo Found Python - OK
59-
python --version
41+
echo Could not find CARLA content. Downloading...
42+
mkdir %cd%\Unreal\CarlaUnreal\Content
43+
git ^
44+
-C %cd%\Unreal\CarlaUnreal\Content ^
45+
clone ^
46+
-b ue5-dev ^
47+
https://bitbucket.org/carla-simulator/carla-content.git ^
48+
Carla ^
49+
|| exit /b
6050
)
6151

52+
rem Activate VS terminal development environment:
53+
if exist "%PROGRAMFILES%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" (
54+
echo Activating "x64 Native Tools Command Prompt" terminal environment.
55+
call "%PROGRAMFILES%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" || exit /b
56+
) else (
57+
echo Could not find vcvarsall.bat, aborting setup...
58+
exit 1
59+
)
6260

63-
echo Installing Python Packages...
64-
python -m pip install --upgrade pip || exit /b
65-
python -m pip install -r requirements.txt || exit /b
66-
echo Python Packages Installed...
67-
68-
69-
echo Switching to x64 Native Tools Command Prompt for VS 2022 command line...
70-
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
71-
72-
61+
rem -- DOWNLOAD + BUILD UNREAL ENGINE --
7362
if exist "%CARLA_UNREAL_ENGINE_PATH%" (
74-
echo Found UnrealEngine5 %CARLA_UNREAL_ENGINE_PATH% - OK
63+
echo Found Unreal Engine 5 at "%CARLA_UNREAL_ENGINE_PATH%".
7564
) else if exist ..\UnrealEngine5_carla (
76-
echo Found UnrealEngine5 ..\UnrealEngine5_carla - OK
77-
pushd ..
78-
pushd UnrealEngine5_carla
79-
set CARLA_UNREAL_ENGINE_PATH=!cd!
80-
setx CARLA_UNREAL_ENGINE_PATH !cd!
81-
popd
82-
popd
65+
echo Found CARLA Unreal Engine at %cd%/UnrealEngine5_carla. Assuming already built...
8366
) else (
84-
echo Found UnrealEngine5 $CARLA_UNREAL_ENGINE_PATH - FAIL
67+
echo Could not find CARLA Unreal Engine, downloading...
8568
pushd ..
86-
echo Cloning CARLA Unreal Engine 5...
87-
git clone -b ue5-dev-carla https://github.com/CarlaUnreal/UnrealEngine.git UnrealEngine5_carla || exit /b
69+
git clone ^
70+
-b ue5-dev-carla ^
71+
https://github.com/CarlaUnreal/UnrealEngine.git ^
72+
UnrealEngine5_carla || exit /b
8873
pushd UnrealEngine5_carla
8974
set CARLA_UNREAL_ENGINE_PATH=!cd!
9075
setx CARLA_UNREAL_ENGINE_PATH !cd!
76+
echo Running Unreal Engine pre-build steps...
77+
call Setup.bat || exit /b
78+
call GenerateProjectFiles.bat || exit /b
79+
echo Building Unreal Engine 5...
80+
msbuild ^
81+
Engine\Intermediate\ProjectFiles\UE5.vcxproj ^
82+
/property:Configuration="Development_Editor" ^
83+
/property:Platform="x64" || exit /b
9184
popd
9285
popd
9386
)
94-
pushd ..
95-
pushd %CARLA_UNREAL_ENGINE_PATH%
96-
echo Setup CARLA Unreal Engine 5...
97-
call Setup.bat || exit /b
98-
echo GenerateProjectFiles CARLA Unreal Engine 5...
99-
call GenerateProjectFiles.bat || exit /b
100-
echo Opening Visual Studio 2022...
101-
msbuild Engine\Intermediate\ProjectFiles\UE5.vcxproj /property:Configuration="Development_Editor" /property:Platform="x64" || exit /b
102-
popd
103-
popd
104-
105-
echo Configuring CARLA...
106-
call cmake -G Ninja -S . -B Build -DCMAKE_BUILD_TYPE=Release -DBUILD_CARLA_UNREAL=ON -DCARLA_UNREAL_ENGINE_PATH=%CARLA_UNREAL_ENGINE_PATH% || exit /b
107-
108-
echo Buiding CARLA...
109-
call cmake --build Build || exit /b
11087

111-
echo Installing PythonAPI...
112-
cmake --build Build --target carla-python-api-install
113-
114-
echo Build Succesfull :)
115-
echo Launching Unreal Editor with CARLA...
116-
call cmake --build Build --target launch || exit /b
88+
rem -- BUILD CARLA --
89+
echo Configuring the CARLA CMake project...
90+
cmake ^
91+
-G Ninja ^
92+
-S . ^
93+
-B Build ^
94+
-DCMAKE_BUILD_TYPE=Release ^
95+
-DCARLA_UNREAL_ENGINE_PATH=%CARLA_UNREAL_ENGINE_PATH% || exit /b
96+
echo Building CARLA...
97+
cmake --build Build || exit /b
98+
echo Installing Python API...
99+
cmake --build Build --target carla-python-api-install || exit /b
100+
echo CARLA Python API build+install succeeded.
101+
102+
rem -- POST-BUILD STEPS --
103+
104+
if %LAUNCH%==true (
105+
echo Launching Carla Unreal Editor...
106+
cmake --build Build --target launch || exit /b
107+
)

CarlaSetup.sh

+29-15
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,33 @@ else
5656
echo "Found git credentials."
5757
fi
5858

59+
# -- PREREQUISITES INSTALL STEP --
5960
if [ $skip_prerequisites -eq 0 ]; then
6061
echo "Installing prerequisites..."
6162
sudo -E bash -x Util/SetupUtils/InstallPrerequisites.sh
6263
else
6364
echo "Skipping prerequisites install step."
6465
fi
6566

67+
# -- CLONE CONTENT --
68+
if [ -d $cd/Unreal/CarlaUnreal/Content ]; then
69+
echo "Found CARLA content."
70+
else
71+
echo "Could not find CARLA content. Downloading..."
72+
mkdir -p $cd/Unreal/CarlaUnreal/Content
73+
git \
74+
-C $cd/Unreal/CarlaUnreal/Content \
75+
clone \
76+
-b ue5-dev \
77+
https://bitbucket.org/carla-simulator/carla-content.git \
78+
Carla
79+
fi
80+
81+
# -- DOWNLOAD + BUILD UNREAL ENGINE --
6682
if [ ! -z $CARLA_UNREAL_ENGINE_PATH ] && [ -d $CARLA_UNREAL_ENGINE_PATH ]; then
6783
echo "Found CARLA Unreal Engine at $CARLA_UNREAL_ENGINE_PATH"
6884
elif [ -d ../UnrealEngine5_carla ]; then
69-
pushd ..
70-
pushd UnrealEngine5_carla
71-
echo "Found CARLA Unreal Engine at ../UnrealEngine5_carla"
72-
export CARLA_UNREAL_ENGINE_PATH=$PWD
73-
echo -e '\n#CARLA UnrealEngine5\nexport CARLA_UNREAL_ENGINE_PATH='$CARLA_UNREAL_ENGINE_PATH >> ~/.bashrc
74-
popd
75-
popd
85+
echo "Found CARLA Unreal Engine at $cd/UnrealEngine5_carla. Assuming already built..."
7686
else
7787
echo "Could not find CARLA Unreal Engine, downloading..."
7888
pushd ..
@@ -89,27 +99,31 @@ else
8999
pushd UnrealEngine5_carla
90100
echo -e '\n#CARLA UnrealEngine5\nexport CARLA_UNREAL_ENGINE_PATH='$PWD >> ~/.bashrc
91101
export CARLA_UNREAL_ENGINE_PATH=$PWD
102+
echo "Running Unreal Engine pre-build steps..."
103+
bash -x Setup.sh
104+
bash -x GenerateProjectFiles.sh
105+
echo "Building Unreal Engine 5..."
106+
make
92107
popd
93108
popd
94-
echo "Installed CARLA Unreal Engine..."
95109
fi
96110

97-
echo "Configuring CARLA..."
111+
# -- BUILD CARLA --
112+
echo "Configuring the CARLA CMake project..."
98113
cmake -G Ninja -S . -B Build \
99114
--toolchain=$PWD/CMake/LinuxToolchain.cmake \
100115
-DLAUNCH_ARGS="-prefernvidia" \
101116
-DCMAKE_BUILD_TYPE=Release \
102117
-DENABLE_ROS2=ON \
103-
-DBUILD_CARLA_UNREAL=ON \
104118
-DCARLA_UNREAL_ENGINE_PATH=$CARLA_UNREAL_ENGINE_PATH
105119
echo "Building CARLA..."
106120
cmake --build Build
107-
echo "Building + installing Python API..."
121+
echo "Installing Python API..."
108122
cmake --build Build --target carla-python-api-install
109-
echo "Waiting for Content to finish downloading..."
110-
wait #Waitting for content
111-
echo "Installation and build successful."
123+
echo "CARLA Python API build+install succeeded."
124+
125+
# -- POST-BUILD STEPS --
112126
if [ $launch -eq 1 ]; then
113127
echo "Launching Carla - Unreal Editor..."
114128
cmake --build Build --target launch
115-
fi
129+
fi
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@echo off
2+
3+
set NINJA_VERSION=1.12.1
4+
set PYTHON_VERSION=3.8.10
5+
rem https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community?view=vs-2022&preserve-view=true
6+
set VISUAL_STUDIO_COMPONENTS=^
7+
Microsoft.VisualStudio.Workload.NativeDesktop ^
8+
Microsoft.VisualStudio.Workload.NativeGame ^
9+
Microsoft.VisualStudio.Workload.ManagedDesktop ^
10+
Microsoft.VisualStudio.Component.Windows10SDK.22621 ^
11+
Microsoft.VisualStudio.Component.VC.CMake.Project ^
12+
Microsoft.Net.Component.4.8.SDK ^
13+
Microsoft.Net.ComponentGroup.4.8.1.DeveloperTools ^
14+
Microsoft.VisualStudio.Component.VC.Llvm.Clang ^
15+
Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset ^
16+
Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang ^
17+
Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64
18+
19+
rem -- INSTALL VISUAL STUDIO --
20+
if not exist %cd%\Temp (
21+
mkdir %cd%\Temp
22+
)
23+
pushd Temp
24+
curl -L -O https://aka.ms/vs/17/release/vs_community.exe || exit /b
25+
popd Temp
26+
%cd%\Temp\vs_community.exe --add %VISUAL_STUDIO_COMPONENTS% --installWhileDownloading --passive --wait || exit /b
27+
del %cd%\Temp\vs_community.exe
28+
rmdir %cd%\Temp
29+
30+
rem -- INSTALL NINJA --
31+
ninja --version 2>NUL
32+
if errorlevel 1 (
33+
echo Could not find Ninja. Downloading...
34+
curl -L -o %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win.zip https://github.com/ninja-build/ninja/releases/download/v%NINJA_VERSION%/ninja-win.zip || exit /b
35+
powershell -command "Expand-Archive $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\ninja-win.zip $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\ninja-win" || exit /b
36+
move %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win\ninja.exe %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja.exe || exit /b
37+
rmdir /s /q %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win
38+
del /f %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\ninja-win.zip
39+
echo Installed Ninja %NINJA_VERSION%.
40+
) else (
41+
echo Found Ninja.
42+
)
43+
44+
rem -- INSTALL PYTHON --
45+
python --version 2>NUL
46+
if errorlevel 1 (
47+
echo Could not find Python. Downloading...
48+
echo Installing Python %PYTHON_VERSION%...
49+
curl -L -O https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHON_VERSION%-amd64.exe || exit /b
50+
python-%PYTHON_VERSION%-amd64.exe /passive PrependPath=1 || exit /b
51+
del python-%PYTHON_VERSION%-amd64.exe
52+
set "PATH=%LocalAppData%\Programs\Python\Python38\Scripts\;%LocalAppData%\Programs\Python\Python38\;%PATH%"
53+
echo Python %PYTHON_VERSION% installed!!!
54+
) else (
55+
echo Found Python.
56+
)
57+
58+
rem -- INSTALL PYTHON PACKAGES --
59+
python -m pip install --upgrade pip || exit /b
60+
python -m pip install -r requirements.txt || exit /b

Util/SetupUtils/InstallPrerequisites.sh

+5-10
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ if [ "$EUID" -ne 0 ]; then
1111
exit 1
1212
fi
1313

14+
# -- INSTALL APT PACKAGES --
1415
echo "Installing Ubuntu Packages..."
15-
if ! command -v retry &> /dev/null
16-
then
17-
apt update
18-
apt-get install retry
19-
fi
20-
retry --until=success --times=12 --delay=300 -- apt-get update
21-
retry --until=success --times=12 --delay=300 -- apt-get -y install \
16+
apt-get update
17+
apt-get -y install \
2218
build-essential \
2319
g++-12 \
2420
gcc-12 \
@@ -40,13 +36,12 @@ retry --until=success --times=12 --delay=300 -- apt-get -y install \
4036
git \
4137
git-lfs
4238

39+
# -- INSTALL PYTHON PACKAGES --
4340
echo "Installing Python Packages..."
4441
pip3 install --upgrade pip
4542
pip3 install -r requirements.txt
4643

47-
echo "Cloning CARLA Content asynchronously... (see progress in ContentClone.log)"
48-
mkdir -p Unreal/CarlaUnreal/Content
49-
git -C Unreal/CarlaUnreal/Content clone -b ue5-dev https://bitbucket.org/carla-simulator/carla-content.git Carla &> ContentClone.log&
44+
# -- INSTALL CMAKE --
5045

5146
check_cmake_version() {
5247
CMAKE_VERSION="$($2 --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"

0 commit comments

Comments
 (0)