diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..390d9ff --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.uasset filter=lfs diff=lfs merge=lfs -text +*.umap filter=lfs diff=lfs merge=lfs -text diff --git a/Docs/Install.md b/Docs/Install.md index 33dd046..9c2153a 100644 --- a/Docs/Install.md +++ b/Docs/Install.md @@ -2,6 +2,7 @@ ## Prerequisites - Make sure your machine satisfies the prerequisites required by Carla: [Windows](https://carla.readthedocs.io/en/0.9.13/build_windows), [Linux](https://carla.readthedocs.io/en/0.9.13/build_linux), [Mac*](https://github.com/GustavoSilvera/carla/blob/m1/Docs/build_mac.md) - **IMPORTANT**: If on **Windows** you will **need** [`Make-3.81`](https://gnuwin32.sourceforge.net/packages/make.htm) as per the [Carla documentation](https://carla.readthedocs.io/en/latest/build_windows/#system-requirements) +- **IMPORTANT**: We highly recommend using **Python 3.7** for building the PythonAPI. Newer Python versions (3.8+) can cause issues when compiling Boost 1.72.0. See [Install_Ubuntu.md](Install_Ubuntu.md) for instructions on using pyenv to manage Python versions. - If you have previously installed Carla in your PYTHONPATH, you'll need to remove any prior PythonAPI installations - For instance, if you [installed carla via pip](https://pypi.org/project/carla/), you'll **need to uninstall** it to proceed. ```bash @@ -9,36 +10,67 @@ ``` ## Getting started -- You should first make sure DReyeVR is downloaded: - ```bash - git clone https://github.com/HARPLab/DReyeVR --depth 1 - ``` -- You'll first need to install [Unreal Engine 4.26 (CARLA fork)](https://github.com/CarlaUnreal/UnrealEngine) from source + +The installation must follow this specific order: + +### Step 1: Install Unreal Engine +Install [Unreal Engine 4.26 (CARLA fork)](https://github.com/CarlaUnreal/UnrealEngine) from source: ```bash git clone https://github.com/CarlaUnreal/UnrealEngine # set this location to your $UE4_ROOT environment variable ``` - **IMPORTANT** on DReyeVR for Carla 0.9.13 you'll need to revert the UE4 repository to a supported version (for DReyeVR). This is to optimize the DX11 rendering performance which in our testing has been the optimal render backend for VR. + **IMPORTANT** on DReyeVR for Carla 0.9.13 you'll need to revert the UE4 repository to a supported version (for DReyeVR). This is to optimize the DX11 rendering performance which in our testing has been the optimal render backend for VR. ```bash # in $UE4_ROOT git checkout d40ec35474e8793b4eea60dba6c4f051186e458e # or git reset --hard d40ec35474e8793b4eea60dba6c4f051186e458e ``` - - **IMPORTANT:** if the `git clone` link does not work for you, you probably need to [join the Epic Games Organization](https://www.unrealengine.com/en-US/ue4-on-github) to get access to UnrealEngine and all of its forks. + - **IMPORTANT:** if the `git clone` link does not work for you, you probably need to [join the Epic Games Organization](https://www.unrealengine.com/en-US/ue4-on-github) to get access to UnrealEngine and all of its forks. - UE4 build instructions for your system can be found here: [Windows](https://carla.readthedocs.io/en/0.9.13/build_windows/#unreal-engine), [Linux](https://carla.readthedocs.io/en/0.9.13/build_linux/#unreal-engine), [Mac*](https://github.com/GustavoSilvera/carla/blob/m1/Docs/build_mac.md#unreal-engine-fork ) - In order to successfully run Setup.sh, you will need to download and replace the Commit.gitdeps.xml file within /Engine/Build. See updated XML file at [Commit.gitdeps.xml](https://github.com/HARPLab/UnrealEngine/blob/DReyeVR-0.9.13/Engine/Build/Commit.gitdeps.xml) -- You'll then need to clone and build a [vanilla Carla 0.9.13](https://carla.readthedocs.io/en/0.9.13/#building-carla) +### Step 2: Clone both repositories +Clone the CARLA 0.9.13 repository and the DReyeVR repository: ```bash git clone https://github.com/carla-simulator/carla -b 0.9.13 --depth 1 + git clone https://github.com/carla-simulator/DReyeVR.git --depth 1 ``` - - Use [Building on Linux](https://carla.readthedocs.io/en/0.9.13/build_linux/) for all versions up to Ubuntu 18.04 or [Building on Windows](https://carla.readthedocs.io/en/0.9.13/build_windows/) to follow their instructions on building CARLA 0.9.13. Use [our Ubuntu 20.04 CARLA installation guide](Install_Ubuntu.md) for Ubuntu 20.04. -- (Optional) Similarly, you can install a vanilla [Carla Scenario Runner v0.9.13 ](https://github.com/carla-simulator/scenario_runner/tree/v0.9.13) project to integrate DReyeVR+Carla with Scenario Runner. + - Use [Building on Linux](https://carla.readthedocs.io/en/0.9.13/build_linux/) for all versions up to Ubuntu 18.04 or [Building on Windows](https://carla.readthedocs.io/en/0.9.13/build_windows/) to follow their instructions on building CARLA 0.9.13. Use [our Ubuntu 20.04+ CARLA installation guide](Install_Ubuntu.md) for Ubuntu 20.04 and newer. +- (Optional) Similarly, you can install a vanilla [Carla Scenario Runner v0.9.13 ](https://github.com/carla-simulator/scenario_runner/tree/v0.9.13) project to integrate DReyeVR+Carla with Scenario Runner. ```bash - git clone https://github.com/carla-simulator/scenario-runner -b v0.9.13 --depth 1 + git clone https://github.com/carla-simulator/scenario_runner -b v0.9.13 --depth 1 + ``` + +### Step 3: Download Carla assets +Navigate to the CARLA directory and download the assets: + ```bash + cd carla + ./Update.sh # Linux/Mac + Update.bat # Windows + ``` + **IMPORTANT:** The `Update.sh`/`Update.bat` script downloads assets from Carla's servers. Update the `CONTENT_LINK` variable in the script to use Backblaze B2: + - Update.sh → `https://carla-assets.s3.us-east-005.backblazeb2.com/${CONTENT_ID}.tar.gz` + - Update.bat → `https://carla-assets.s3.us-east-005.backblazeb2.com/%CONTENT_ID%.tar.gz` + +### Step 4: Install DReyeVR +The DReyeVR repository includes all the necessary files and build script fixes. Navigate to DReyeVR and run the installer: + ```bash + cd ../DReyeVR + make install CARLA=../carla + + # Verify the installation + make check CARLA=../carla + ``` + +### Step 5: Build Carla with DReyeVR +Navigate back to the Carla directory and build: + ```bash + cd ../carla + make PythonAPI # Build the PythonAPI (includes LibCarla) + make launch # Launch the editor ``` (*=The Mac operating system is no longer officially supported by Carla but our development team has made it possible to build both UE4, Carla, and DReyeVR on new Mac machines with Apple Silicon (arm64) hardware. ) @@ -48,7 +80,7 @@ # DReyeVR installation command summary
-**NOTE** You'll need a terminal on Linux/Mac. On Windows you'll be fine with the same x64 Native Tools CMD prompt that you used to build Carla. +**NOTE** You'll need a terminal on Linux/Mac. On Windows you'll be fine with the same x64 Native Tools CMD prompt that you used to build Carla. Show command lines to install and build DReyeVR ```bash @@ -58,7 +90,7 @@ mkdir CarlaDReyeVR && cd CarlaDReyeVR # doing everything in this "CarlaDReyeVR" ########### install OUR UnrealEngine fork ########### ##################################################### # Rather than https://github.com/CarlaUnreal/UnrealEngine UE4, you SHOULD clone https://github.com/HARPLab/UnrealEngine -# but otherwise all instructions remain the same. +# but otherwise all instructions remain the same. # Linux: https://carla.readthedocs.io/en/0.9.13/build_linux/#unreal-engine # Windows: https://carla.readthedocs.io/en/0.9.13/build_windows/#unreal-engine @@ -78,7 +110,7 @@ make PythonAPI && make launch # to build vanilla Carla ############## install DReyeVR plugins ############## ##################################################### # (optional) install SRanipal (eye tracking) -mv /PATH/TO/SRANIPALPLUGIN/SDK/03_Unreal/Plugins/SRanipal Unreal/CarlaUE4/Plugins/ +mv /PATH/TO/SRANIPALPLUGIN/SDK/03_Unreal/Plugins/SRanipal Unreal/CarlaUE4/Plugins/ # (optional) install LogitechWheelPlugin (steering wheel) git clone https://github.com/HARPLab/LogitechWheelPlugin @@ -131,7 +163,7 @@ bool UseLogitechPlugin = true; ... ///////////////////////////////////////////////////////////// ``` -- NOTE: you only need to install the SRanipal plugin if `UseSRanipalPlugin` is enabled, and similarly you only need to install the Logitech plugin if `UseLogitechPlugin` is enabled. +- NOTE: you only need to install the SRanipal plugin if `UseSRanipalPlugin` is enabled, and similarly you only need to install the Logitech plugin if `UseLogitechPlugin` is enabled. # Installing DReyeVR Plugins @@ -144,20 +176,20 @@ Before installing `DReyeVR`, we'll also need to install the dependencies: ## SteamVR ### **Download Steam and SteamVR** - - You'll need to use [SteamVR](https://store.steampowered.com/app/250820/SteamVR/) for the VR rendering environment, so you should first download the [Steam client application](https://store.steampowered.com/about/). - - From within the steam client, you can browse in store->search "[SteamVR](https://store.steampowered.com/app/250820/SteamVR/)" and download the free-to-install system utility. + - You'll need to use [SteamVR](https://store.steampowered.com/app/250820/SteamVR/) for the VR rendering environment, so you should first download the [Steam client application](https://store.steampowered.com/about/). + - From within the steam client, you can browse in store->search "[SteamVR](https://store.steampowered.com/app/250820/SteamVR/)" and download the free-to-install system utility. - You should be able to launch SteamVR from the client and in the small pop-up window reach both settings and "show VR view" - Make sure to calibrate the VR system to your setup and preferences! - - Additionally we recommend disabling the "Motion Smoothing" effect within SteamVR Settings to avoid nasty distortion artifacts during rendering. + - Additionally we recommend disabling the "Motion Smoothing" effect within SteamVR Settings to avoid nasty distortion artifacts during rendering. - SteamVR-settings *** ## HTC Eye Tracker Plugin ### **Download `SRanipal`** 0. *What is SRanipal?* - - We are using [HTC's SRanipal plugin](https://developer.vive.com/resources/vive-sense/sdk/vive-eye-tracking-sdk-sranipal/) as the means to communicate between Unreal Engine 4 and the Vive's Eye Tracker. + - We are using [HTC's SRanipal plugin](https://developer.vive.com/resources/vive-sense/sdk/vive-eye-tracking-sdk-sranipal/) as the means to communicate between Unreal Engine 4 and the Vive's Eye Tracker. - To learn more about SRanipal and for **first-time-setup**, see this [guide on foveated rendering using SRanipal](https://forum.vive.com/topic/7434-getting-started-with-vrs-foveated-rendering-using-htc-vive-pro-eye-unreal-engine/) by HTC developer MariosBikos_HTC 1. You'll need a (free-to-create) [Vive developer account](https://hub.vive.com/sso/login) to download the following: - a) [`VIVE_SRanipalInstaller_1.3.2.0.msi`](https://hub.vive.com/en-US/download/VIVE_SRanipalInstaller_1.3.2.0.msi) -- executable to install Tobii firmware @@ -187,13 +219,13 @@ Before installing `DReyeVR`, we'll also need to install the dependencies: # assumes CARLA_ROOT is defined, else just use your Carla path cp -r Plugins/SRanipal $CARLA_ROOT/Unreal/CarlaUE4/Plugins/ ``` - - It is recommended to re-calibrate the SRanipal eye tracker plugin for every new participant in an experiment. You can do this by entering SteamVR home, and clicking the small icon in the bottom menu bar to calibrate eye tracker to the headset wearer. + - It is recommended to re-calibrate the SRanipal eye tracker plugin for every new participant in an experiment. You can do this by entering SteamVR home, and clicking the small icon in the bottom menu bar to calibrate eye tracker to the headset wearer. - ![Calibration](Figures/Install/steamvr-home.jpg) - You can find more information by checking out this [guide on foveated rendering using SRanipal](https://forum.vive.com/topic/7434-getting-started-with-vrs-foveated-rendering-using-htc-vive-pro-eye-unreal-engine/) by HTC developer MariosBikos_HTC *** ## Logitech Wheel Plugin ### **Installing Logitech Wheel Plugin** - - This is only for those who have a Logitech steering wheel/pedals driving setup. This hardware is not required to experience the VR experience (you can simply use keyboard/mouse) but greatly adds to the immersion and allows for granular analog controls. + - This is only for those who have a Logitech steering wheel/pedals driving setup. This hardware is not required to experience the VR experience (you can simply use keyboard/mouse) but greatly adds to the immersion and allows for granular analog controls. - For reference, we used this [Logitech G923 Racing Wheel & Pedals](https://www.logitechg.com/en-us/products/driving/driving-force-racing-wheel.html). - We'll be using this [LogitechWheelPlugin](https://github.com/HARPLab/LogitechWheelPlugin) to interact with UE4 and map hardware inputs to actions. - Clone the repo and move the requisite folder to the Carla plugins folder @@ -225,9 +257,9 @@ Before installing `DReyeVR`, we'll also need to install the dependencies: ├── Content ├── Resources ├── Source - └── SRanipal.uplugin + └── SRanipal.uplugin ``` - - If you still have questions or issues, feel free to post an issue on our [Issues](https://github.com/HARPLab/DReyeVR/issues) page and we'll try our best to help you out. + - If you still have questions or issues, feel free to post an issue on our [Issues](https://github.com/HARPLab/DReyeVR/issues) page and we'll try our best to help you out.

@@ -236,8 +268,8 @@ Before installing `DReyeVR`, we'll also need to install the dependencies: - **IMPORTANT** The installation requires that `make`, `python` and `git` are available on your shell. -- You only need to install to a `CARLA` directory, ScenarioRunner is optional. - - If you don't provide the `make` variables `CARLA=...` or `SR=...` the installation wizard will automatically detect your install destination by looking at the environment variables `CARLA_ROOT` and `SCENARIO_RUNNER_ROOT` required by Carla. +- You only need to install to a `CARLA` directory, ScenarioRunner is optional. + - If you don't provide the `make` variables `CARLA=...` or `SR=...` the installation wizard will automatically detect your install destination by looking at the environment variables `CARLA_ROOT` and `SCENARIO_RUNNER_ROOT` required by Carla. ```bash # the CARLA= and SR= variables are optional @@ -331,15 +363,15 @@ make check CARLA=../carla >>> from scenario_runner import ScenarioRunner ``` With all these imports passing (no error/warning messages), you're good to go! - +
-Now you can finally build the PythonAPI to this isolated conda environment. +Now you can finally build the PythonAPI to this isolated conda environment. ```bash conda activate carla13 (carla13) make PythonAPI # builds LibCarla and PythonAPI to your (conda) python environment ``` - - NOTE: You'll need to run `conda activate carla13` every time you open a new terminal if you want to build DReyeVR since the shell needs to know which python environment to use. Luckily this minor inconvenience saves us from the significant headaches that arise when dealing with multiple `python` projects, Carla installations, and versions, etc. + - NOTE: You'll need to run `conda activate carla13` every time you open a new terminal if you want to build DReyeVR since the shell needs to know which python environment to use. Luckily this minor inconvenience saves us from the significant headaches that arise when dealing with multiple `python` projects, Carla installations, and versions, etc. ## Sanity Check: @@ -465,7 +497,7 @@ CarlaUE4.exe -vr ``` **NOTE:** To greatly boost the framerates without losing much visual fidelity you can run with the additional argument `-quality-level=Low` which we modified from vanilla Carla to preserve the same rendering distance. -**NOTE 2** You also don't necessarily NEED to run DReyeVR in VR. If you omit the `-vr` flag then you will be greeted with a flat-screen Carla game with the same features available for DReyeVR, just not in VR. +**NOTE 2** You also don't necessarily NEED to run DReyeVR in VR. If you omit the `-vr` flag then you will be greeted with a flat-screen Carla game with the same features available for DReyeVR, just not in VR.
diff --git a/Docs/Install_Ubuntu.md b/Docs/Install_Ubuntu.md index 5dc7d73..454e64c 100644 --- a/Docs/Install_Ubuntu.md +++ b/Docs/Install_Ubuntu.md @@ -1,120 +1,71 @@ -# Installing Carla on Ubuntu 20.04 -This guide is for installing Carla 0.9.13 (along with Unreal Engine 4.26) build on Ubuntu 20.04.5 (Focal Fosca). It is largely based on [this tutorial](https://carla.readthedocs.io/en/latest/build_linux/) by Carla, and can be thought of as a shorter updated of it specifically for Ubuntu 20.04 and DReyeVR. Check out the original tutorial tutorial for more detailed explanations of some the commands. Commands themselves, however, slightly differ from the original version. - -## Part One: Prerequisites -- **Ubuntu 20.04** -- **130 GB disk space.** Carla will take around 31 GB and Unreal Engine will take around 91 GB so have about 130 GB free to account for both of these plus additional minor software installations. -- **An adequate GPU**. CARLA aims for realistic simulations, so the server needs at least a 6 GB GPU although 8 GB is recommended. A dedicated GPU is highly recommended for machine learning. -- **Two TCP ports and good internet connection.** 2000 and 2001 by default. Make sure that these ports are not blocked by firewalls or any other applications. +# Installing Carla on Ubuntu 20.04+ +This guide covers the Ubuntu-specific requirements for installing Carla 0.9.13 with DReyeVR. For the general installation steps, see [Install.md](Install.md). + +## Prerequisites +- **Ubuntu 20.04 or newer** +- **130 GB disk space.** Carla will take around 31 GB and Unreal Engine will take around 91 GB so have about 130 GB free to account for both of these plus additional minor software installations. +- **An adequate GPU.** CARLA aims for realistic simulations, so the server needs at least a 6 GB GPU although 8 GB is recommended. A dedicated GPU is highly recommended for machine learning. +- **Two TCP ports and good internet connection.** 2000 and 2001 by default. Make sure that these ports are not blocked by firewalls or any other applications. - **IMPORTANT: Proprietary drivers installed.** Please make sure that you are using the latest stable version of proprietary drivers (for instance, Nvidia). Check [this guide](https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-20-04-focal-fossa-linux) for installing and updating the Nvidia driver on Ubuntu 20.04. -## Installing software requirements -Please use the following set of commands to install the necessary software packages. -**Note**: you might want to go over each of the listed packages separately to ensure that each was installed correctly to avoid issues during the installation. Later on, the missing packages will be harder to track. -```bash -sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" -sudo apt-get install build-essential clang-8 lld-8 g++-7 cmake ninja-build libvulkan1 python-dev python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git -sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-8/bin/clang++ 180 && -sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-8/bin/clang 180 -``` +## Software requirements -#### Clang issue: -One of the issues specific to Ubuntu 20.04 installation is the **clang** compiler. The CARLA team uses clang-8 and LLVM's libc++. while clang-8 can be installed on Ubuntu 20.04, it is rather outdated and does not catch some of the existing bugs within carla. If you want to use a different version of clang and libc++, follow the instructions below: -
-how to use a different clang version -Uninstall clang-8 (installed if you executed the previous command): +### Clang compiler +The CARLA team originally uses clang-8 which is outdated and not available on Ubuntu 20.04+. We have tested successfully with **clang-14** (the default on Ubuntu 22.04) ```bash -sudo apt-get remove clang-8 lld-8 -sudo rm /usr/bin/clang /usr/bin/clang++ +sudo apt-get install build-essential clang lld g++-7 cmake ninja-build libvulkan1 python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git ``` -Install version 10: -```bash -sudo apt-get install clang-10 lld-10 -``` -Set up clang and clang++ commands: +### Python version +**IMPORTANT:** We highly recommend using **Python 3.7** for building the PythonAPI. Newer Python versions (3.8+) can cause issues when compiling Boost 1.72.0. + +You can use [pyenv](https://github.com/pyenv/pyenv) to manage Python versions: ```bash -sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-10/bin/clang++ 180 && -sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-10/bin/clang 180 +# Install pyenv (if not installed) +curl -fsSL https://pyenv.run | bash + +# Install Python 3.7.9 +pyenv install 3.7.9 + +# Set it as local version for the carla directory (run this inside the carla repo) +pyenv local 3.7.9 ``` -Create a symbolic link that would tell the system to use version 10 whenever it encounters `usr/bin/clang-8` in one of the CARLA setup or installation scripts: + +If using pyenv, you may need to create a symlink for the Python headers: ```bash -sudo ln -s /usr/bin/clang /usr/bin/clang-8 -sudo ln -s /usr/bin/clang++ /usr/bin/clang++-8 +ln -s ~/.pyenv/versions/3.7.9/include/python3.7m ~/.pyenv/versions/3.7.9/include/python3.7 ``` -
-
- ### Python dependencies -Version 20.3 or higher of **pip3** is required. To check if you have a suitable version, run the following command: +Version 20.3 or higher of **pip3** is required. To check if you have a suitable version, run: ```bash pip3 -V ``` If you need to upgrade: ```bash pip3 install --upgrade pip -``` -You might be prompted to add the directory of the newer version to PATH. If yes, do so. -You must install the following Python dependencies: +# If using pyenv, you may need to specify the full path: +~/.pyenv/versions/3.7.9/bin/python3.7 -m pip install --upgrade pip ``` -pip3 install --user -Iv setuptools==47.3.1 && -pip3 install --user distro && -pip3 install --user wheel auditwheel && + +Install the required Python dependencies: +```bash +pip3 install --user -Iv setuptools==47.3.1 +pip3 install --user distro +pip3 install --user wheel auditwheel pip3 install nose2 ``` -Some of the installation and setup scripts use the deprecated **python** command. One way to avoid the issues caused by this is with a symbolic link: -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` -If your file is named other than **python3**, substitute python 3 for your python version. -
- -### Unreal Engine -This section does not require updates or modifications. Please follow the exact steps from the corresponding section of [this tutorial](https://carla.readthedocs.io/en/latest/build_linux/). -
-## Part Two: Build CARLA -**Note**: downloading aria2 with `sudo apt-get install aria2` will speed up the following commands. +## Troubleshooting -Clone the CARLA repository: -```bash -git clone https://github.com/carla-simulator/carla -b 0.9.13 -``` -Once download is finished, from the new **carla** directory, run +### Boost compilation fails with `pyconfig.h` not found +This usually happens when Python headers are not found. If using pyenv: ```bash -Update.sh +ln -s ~/.pyenv/versions/3.7.9/include/python3.7m ~/.pyenv/versions/3.7.9/include/python3.7 ``` -Navigate to the **carla** directory. Open **./Util/BuildTools/Setup.sh** and replace `XERCESC_VERSION=3.2.3` (line 428) with `XERCESC_VERSION=3.2.4`. Next, open **./Util/BuildTools/BuildOSM2ODR.sh**, and replace all instances of `xerces-c-3.2.3` with `xerces-c-3.2.4`. - - -Follow the rest of the instructions from the [tutorial](https://carla.readthedocs.io/en/latest/build_linux/). - - -Now that you have a working CARLA 0.9.13 build, go back to the [DReyeVR installation guide](https://github.com/HARPLab/DReyeVR/blob/main/Docs/Install.md) and follow the rest of the steps to install DReyeVR on top of it. - -- **READ THIS FIRST (Linux)**: You might run into a problem when compiling Boost 1.72.0 (required by `LibCarla`). -
- - Show instructions to get Anaconda working on Linux - - - ```bash - # find anaconda install: - which python3 - ... PATH/TO/ANACONDA/envs/carla/bin/python3 # example output - - # go to carla/install dir from here - cd PATH/TO/ANACONDA/envs/carla/include +## Next Steps - # create a symlink between python3.7 -> python3.7m - ln -s python3.7m python3.7 - ``` - Install `boost_1_72_0.tar.gz` manually from https://github.com/jerry73204/carla/releases/tag/fix-boost and place file in `Build/boost_1_72_0.tar.gz` - Open `Util/BuildTools/Setup.sh` (or `Util/BuildTools/Setup.bat` on Windows) - Find the section named `Get boost` includes and comment out the `wget` lines. - Now when you `make LibCarla` again, the `boost` errors should be resolved. - - For more information see the bottom of this [SO post](https://stackoverflow.com/questions/42839382/failing-to-install-boost-in-python-pyconfig-h-not-found) -
+Once you have installed the Ubuntu requirements, follow the general installation steps in [Install.md](Install.md). diff --git a/Util/BuildTools/BuildCarlaUE4.bat b/Util/BuildTools/BuildCarlaUE4.bat new file mode 100755 index 0000000..6474f6b --- /dev/null +++ b/Util/BuildTools/BuildCarlaUE4.bat @@ -0,0 +1,200 @@ +@echo off +setlocal enabledelayedexpansion + +rem BAT script that creates the binaries for Carla (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N=-[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set BUILD_UE4_EDITOR=false +set LAUNCH_UE4_EDITOR=false +set REMOVE_INTERMEDIATE=false +set USE_CARSIM=false +set USE_CHRONO=false +set CARSIM_STATE="CarSim OFF" +set CHRONO_STATE="Chrono OFF" + +:arg-parse +echo %1 +if not "%1"=="" ( + if "%1"=="--build" ( + set BUILD_UE4_EDITOR=true + ) + if "%1"=="--launch" ( + set LAUNCH_UE4_EDITOR=true + ) + if "%1"=="--clean" ( + set REMOVE_INTERMEDIATE=true + ) + if "%1"=="--carsim" ( + set USE_CARSIM=true + ) + if "%1"=="--chrono" ( + set USE_CHRONO=true + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto arg-parse +) + +if %REMOVE_INTERMEDIATE% == false ( + if %LAUNCH_UE4_EDITOR% == false ( + if %BUILD_UE4_EDITOR% == false ( + goto help + ) + ) +) + +rem Get Unreal Engine root path +if not defined UE4_ROOT ( + set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine" + set VALUE_NAME=InstalledDirectory + for /f "usebackq tokens=1,2,*" %%A in (`reg query !KEY_NAME! /s /reg:64`) do ( + if "%%A" == "!VALUE_NAME!" ( + set UE4_ROOT=%%C + ) + ) + if not defined UE4_ROOT goto error_unreal_no_found +) +if not "%UE4_ROOT:~-1%"=="\" set UE4_ROOT=%UE4_ROOT%\ + +rem Force Visual Studio 2019 toolset to avoid C4756 errors with VS2022 toolset +set VCToolsVersion=14.29.30133 + +rem Set the visual studio solution directory +rem +set UE4_PROJECT_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\ +pushd "%UE4_PROJECT_FOLDER%" + +rem Clear binaries and intermediates generated by the build system +rem +if %REMOVE_INTERMEDIATE% == true ( + rem Remove directories + for %%G in ( + "%UE4_PROJECT_FOLDER%Binaries", + "%UE4_PROJECT_FOLDER%Build", + "%UE4_PROJECT_FOLDER%Saved", + "%UE4_PROJECT_FOLDER%Intermediate", + "%UE4_PROJECT_FOLDER%Plugins\Carla\Binaries", + "%UE4_PROJECT_FOLDER%Plugins\Carla\Intermediate", + "%UE4_PROJECT_FOLDER%.vs" + ) do ( + if exist %%G ( + echo %FILE_N% Cleaning %%G + rmdir /s/q %%G + ) + ) + + rem Remove files + for %%G in ( + "%UE4_PROJECT_FOLDER%CarlaUE4.sln" + ) do ( + if exist %%G ( + echo %FILE_N% Cleaning %%G + del %%G + ) + ) +) + +rem Build Carla Editor +rem +where python >nul 2>nul +if %errorlevel% neq 0 ( + echo %FILE_N% WARNING: Python not found in PATH, skipping CarSim config + goto skip_carsim_config +) + +if %USE_CARSIM% == true ( + call python "%ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py" -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" -e + set CARSIM_STATE="CarSim ON" +) else ( + call python "%ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py" -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" + set CARSIM_STATE="CarSim OFF" +) + +:skip_carsim_config +if %USE_CHRONO% == true ( + set CHRONO_STATE="Chrono ON" +) else ( + set CHRONO_STATE="Chrono OFF" +) +set OPTIONAL_MODULES_TEXT=%CARSIM_STATE% %CHRONO_STATE% +echo %OPTIONAL_MODULES_TEXT% > "%ROOT_PATH%Unreal/CarlaUE4/Config/OptionalModules.ini" + +if %BUILD_UE4_EDITOR% == true ( + echo %FILE_N% Building Unreal Editor... + + call "%UE4_ROOT%Engine\Build\BatchFiles\Build.bat"^ + CarlaUE4Editor^ + Win64^ + Development^ + -WaitMutex^ + -FromMsBuild^ + "%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" + if errorlevel 1 goto bad_exit + + call "%UE4_ROOT%Engine\Build\BatchFiles\Build.bat"^ + CarlaUE4^ + Win64^ + Development^ + -WaitMutex^ + -FromMsBuild^ + "%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" + if errorlevel 1 goto bad_exit +) + +rem Launch Carla Editor +rem +if %LAUNCH_UE4_EDITOR% == true ( + echo %FILE_N% Launching Unreal Editor... + call "%UE4_ROOT%\Engine\Binaries\Win64\UE4Editor.exe"^ + "%UE4_PROJECT_FOLDER%CarlaUE4.uproject" + if %errorlevel% neq 0 goto error_build +) + +goto good_exit + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo Build LibCarla. + echo "Usage: %FILE_N% [-h^|--help] [--build] [--launch] [--clean]" + goto good_exit + +:error_build + echo. + echo %FILE_N% [ERROR] There was a problem building CarlaUE4. + echo %FILE_N% Please go to "Carla\Unreal\CarlaUE4", right click on + echo %FILE_N% "CarlaUE4.uproject" and select: + echo %FILE_N% "Generate Visual Studio project files" + echo %FILE_N% Open de generated "CarlaUE4.sln" and try to manually compile it + echo %FILE_N% and check what is causing the error. + goto bad_exit + +:good_exit + endlocal + exit /b 0 + +:bad_exit + endlocal + exit /b %errorlevel% + +:error_unreal_no_found + echo. + echo %FILE_N% [ERROR] Unreal Engine not detected + goto bad_exit diff --git a/Util/BuildTools/BuildOSM2ODR.bat b/Util/BuildTools/BuildOSM2ODR.bat new file mode 100755 index 0000000..f1fb044 --- /dev/null +++ b/Util/BuildTools/BuildOSM2ODR.bat @@ -0,0 +1,148 @@ +@echo off +setlocal enabledelayedexpansion + +rem BAT script that creates the library for conversion from OSM to OpenDRIVE (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N=-[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set DOC_STRING=Build LibCarla. +set USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--build] [--clean] [--no-pull] + +set REMOVE_INTERMEDIATE=false +set BUILD_OSM2ODR=false +set GIT_PULL=true +set CURRENT_OSM2ODR_COMMIT=ee0c2b9241fef5365a6bc044ac82e6580b8ce936 +set OSM2ODR_BRANCH=carla_osm2odr +set OSM2ODR_REPO=https://github.com/carla-simulator/sumo.git + +:arg-parse +if not "%1"=="" ( + if "%1"=="--rebuild" ( + set REMOVE_INTERMEDIATE=true + set BUILD_OSM2ODR=true + ) + if "%1"=="--build" ( + set BUILD_OSM2ODR=true + ) + if "%1"=="--no-pull" ( + set GIT_PULL=false + ) + if "%1"=="--clean" ( + set REMOVE_INTERMEDIATE=true + ) + if "%1"=="-h" ( + echo %DOC_STRING% + echo %USAGE_STRING% + GOTO :eof + ) + if "%1"=="--help" ( + echo %DOC_STRING% + echo %USAGE_STRING% + GOTO :eof + ) + shift + goto :arg-parse +) + +if %REMOVE_INTERMEDIATE% == false ( + if %BUILD_OSM2ODR% == false ( + echo Nothing selected to be done. + goto :eof + ) +) + +rem ============================================================================ +rem -- Local Variables --------------------------------------------------------- +rem ============================================================================ + +rem Set the visual studio solution directory +rem +set OSM2ODR_VSPROJECT_PATH=%INSTALLATION_DIR:/=\%osm2odr-visualstudio\ +set OSM2ODR_SOURCE_PATH=%INSTALLATION_DIR:/=\%osm2odr-source +set OSM2ODR_INSTALL_PATH=%ROOT_PATH:/=\%PythonAPI\carla\dependencies\ + +if %REMOVE_INTERMEDIATE% == true ( + rem Remove directories + for %%G in ( + "%OSM2ODR_INSTALL_PATH%", + ) do ( + if exist %%G ( + echo %FILE_N% Cleaning %%G + rmdir /s/q %%G + ) + ) +) + +rem Build OSM2ODR +if %BUILD_OSM2ODR% == true ( + + if %GIT_PULL% == true ( + if not exist "%OSM2ODR_SOURCE_PATH%" git clone -b %OSM2ODR_BRANCH% %OSM2ODR_REPO% %OSM2ODR_SOURCE_PATH% + cd "%OSM2ODR_SOURCE_PATH%" + git fetch + git checkout %CURRENT_OSM2ODR_COMMIT% + ) + + if not exist "%OSM2ODR_VSPROJECT_PATH%" mkdir "%OSM2ODR_VSPROJECT_PATH%" + cd "%OSM2ODR_VSPROJECT_PATH%" + + cmake -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ + -DCMAKE_INSTALL_PREFIX="%OSM2ODR_INSTALL_PATH:\=/%"^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + -DPROJ_INCLUDE_DIR=%INSTALLATION_DIR:/=\%\proj-install\include^ + -DPROJ_LIBRARY=%INSTALLATION_DIR:/=\%\proj-install\lib\proj.lib^ + -DXercesC_INCLUDE_DIR=%INSTALLATION_DIR:/=\%\xerces-c-3.3.0-install\include^ + -DXercesC_LIBRARY=%INSTALLATION_DIR:/=\%\xerces-c-3.3.0-install\lib\xerces-c_3.lib^ + "%OSM2ODR_SOURCE_PATH%" + if %errorlevel% neq 0 goto error_cmake + + cmake --build . --config Release --target install | findstr /V "Up-to-date:" + if %errorlevel% neq 0 goto error_install +) + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + if %BUILD_OSM2ODR% == true echo %FILE_N% OSM2ODR has been successfully installed in "%OSM2ODR_INSTALL_PATH%"! + goto good_exit + +:error_cmake + echo. + echo %FILE_N% [ERROR] An error ocurred while executing the cmake. + echo [ERROR] Possible causes: + echo [ERROR] - Make sure "CMake" is installed. + echo [ERROR] - Make sure it is available on your Windows "path". + echo [ERROR] - CMake 3.9.0 or higher is required. + goto bad_exit + +:error_install + echo. + echo %FILE_N% [ERROR] An error ocurred while installing using Visual Studio 16 2019 Win64. + echo [ERROR] Possible causes: + echo [ERROR] - Make sure you have Visual Studio installed. + echo [ERROR] - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo [ERROR] For example using the "Visual Studio x64 Native Tools Command Prompt", + echo [ERROR] or the "vcvarsall.bat". + goto bad_exit + +:good_exit + endlocal + exit /b 0 + +:bad_exit + endlocal + exit /b %errorlevel% diff --git a/Util/BuildTools/BuildOSM2ODR.sh b/Util/BuildTools/BuildOSM2ODR.sh index 8eca769..32c65c8 100755 --- a/Util/BuildTools/BuildOSM2ODR.sh +++ b/Util/BuildTools/BuildOSM2ODR.sh @@ -97,8 +97,8 @@ if ${BUILD_OSM2ODR} ; then -DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_CLIENT_FOLDER} \ -DPROJ_INCLUDE_DIR=${CARLA_BUILD_FOLDER}/proj-install/include \ -DPROJ_LIBRARY=${CARLA_BUILD_FOLDER}/proj-install/lib/libproj.a \ - -DXercesC_INCLUDE_DIR=${CARLA_BUILD_FOLDER}/xerces-c-3.2.3-install/include \ - -DXercesC_LIBRARY=${CARLA_BUILD_FOLDER}/xerces-c-3.2.3-install/lib/libxerces-c.a + -DXercesC_INCLUDE_DIR=${CARLA_BUILD_FOLDER}/xerces-c-3.3.0-install/include \ + -DXercesC_LIBRARY=${CARLA_BUILD_FOLDER}/xerces-c-3.3.0-install/lib/libxerces-c.a ninja osm2odr ninja install diff --git a/Util/BuildTools/BuildPythonAPI.bat b/Util/BuildTools/BuildPythonAPI.bat old mode 100644 new mode 100755 index 4375aa4..340abdd --- a/Util/BuildTools/BuildPythonAPI.bat +++ b/Util/BuildTools/BuildPythonAPI.bat @@ -1,165 +1,163 @@ -@echo off -setlocal - -rem BAT script that creates the client python api of LibCarla (carla.org). -rem Run it through a cmd with the x64 Visual C++ Toolset enabled. - -set LOCAL_PATH=%~dp0 -set FILE_N=-[%~n0]: - -rem Print batch params (debug purpose) -echo %FILE_N% [Batch params]: %* - -rem ============================================================================ -rem -- Parse arguments --------------------------------------------------------- -rem ============================================================================ - -set DOC_STRING=Build and package CARLA Python API. -set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--clean]" - -set REMOVE_INTERMEDIATE=false -set BUILD_FOR_PYTHON2=false -set BUILD_FOR_PYTHON3=false - -:arg-parse -if not "%1"=="" ( - if "%1"=="--rebuild" ( - set REMOVE_INTERMEDIATE=true - rem We don't provide support for py2 right now - set BUILD_FOR_PYTHON2=false - set BUILD_FOR_PYTHON3=true - ) - - if "%1"=="--py2" ( - set BUILD_FOR_PYTHON2=true - ) - - if "%1"=="--py3" ( - set BUILD_FOR_PYTHON3=true - ) - - - if "%1"=="--clean" ( - set REMOVE_INTERMEDIATE=true - ) - - if "%1"=="-h" ( - echo %DOC_STRING% - echo %USAGE_STRING% - GOTO :eof - ) - - if "%1"=="--help" ( - echo %DOC_STRING% - echo %USAGE_STRING% - GOTO :eof - ) - - shift - goto :arg-parse -) - -set PYTHON_LIB_PATH=%ROOT_PATH:/=\%PythonAPI\carla\ - -if %REMOVE_INTERMEDIATE% == false ( - if %BUILD_FOR_PYTHON3% == false ( - if %BUILD_FOR_PYTHON2% == false ( - echo Nothing selected to be done. - goto :eof - ) - ) -) - -if %REMOVE_INTERMEDIATE% == true ( - rem Remove directories - for %%G in ( - "%PYTHON_LIB_PATH%build", - "%PYTHON_LIB_PATH%dist", - "%PYTHON_LIB_PATH%source\carla.egg-info" - ) do ( - if exist %%G ( - echo %FILE_N% Cleaning %%G - rmdir /s/q %%G - ) - ) - if %BUILD_FOR_PYTHON3% == false ( - if %BUILD_FOR_PYTHON2% == false ( - goto good_exit - ) - ) -) - -cd "%PYTHON_LIB_PATH%" -rem if exist "%PYTHON_LIB_PATH%dist" goto already_installed - -rem ============================================================================ -rem -- Check for py ------------------------------------------------------------ -rem ============================================================================ - -rem prefer invoking 'python' (for externally installed, eg conda) over 'py' (built in to Windows) -rem -set PYTHON_EXEC=python - -where %PYTHON_EXEC%>nul -if %errorlevel% neq 0 set PYTHON_EXEC=py -3 - -where %PYTHON_EXEC%>nul -if %errorlevel% neq 0 goto error_py - -rem Build for Python 2 -rem -if %BUILD_FOR_PYTHON2%==true ( - goto py2_not_supported -) - -rem Build for Python 3 -rem -if %BUILD_FOR_PYTHON3%==true ( - echo Building Python API for Python 3. - %PYTHON_EXEC% setup.py bdist_egg bdist_wheel - if %errorlevel% neq 0 goto error_build_wheel -) - -goto success - -rem ============================================================================ -rem -- Messages and Errors ----------------------------------------------------- -rem ============================================================================ - -:success - echo. - if %BUILD_FOR_PYTHON3%==true echo %FILE_N% Carla lib for python has been successfully installed in "%PYTHON_LIB_PATH%dist"! - goto good_exit - -:already_installed - echo. - echo %FILE_N% [ERROR] Already installed in "%PYTHON_LIB_PATH%dist" - goto good_exit - -:py2_not_supported - echo. - echo %FILE_N% [ERROR] Python 2 is not currently suported in Windows. - goto bad_exit - -:error_py - echo. - echo %FILE_N% [ERROR] An error ocurred while executing the py. - echo %FILE_N% [ERROR] Possible causes: - echo %FILE_N% [ERROR] - Make sure "py" is installed. - echo %FILE_N% [ERROR] - py = python launcher. This utility is bundled with Python installation but not installed by default. - echo %FILE_N% [ERROR] - Make sure it is available on your Windows "py". - goto bad_exit - -:error_build_wheel - echo. - echo %FILE_N% [ERROR] An error occurred while building the wheel file. - goto bad_exit - -:good_exit - endlocal - exit /b 0 - -:bad_exit - endlocal - exit /b %errorlevel% - +@echo off +setlocal + +rem BAT script that creates the client python api of LibCarla (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N=-[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set DOC_STRING=Build and package CARLA Python API. +set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--clean]" + +set REMOVE_INTERMEDIATE=false +set BUILD_FOR_PYTHON2=false +set BUILD_FOR_PYTHON3=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="--rebuild" ( + set REMOVE_INTERMEDIATE=true + rem We don't provide support for py2 right now + set BUILD_FOR_PYTHON2=false + set BUILD_FOR_PYTHON3=true + ) + + if "%1"=="--py2" ( + set BUILD_FOR_PYTHON2=true + ) + + if "%1"=="--py3" ( + set BUILD_FOR_PYTHON3=true + ) + + + if "%1"=="--clean" ( + set REMOVE_INTERMEDIATE=true + ) + + if "%1"=="-h" ( + echo %DOC_STRING% + echo %USAGE_STRING% + GOTO :eof + ) + + if "%1"=="--help" ( + echo %DOC_STRING% + echo %USAGE_STRING% + GOTO :eof + ) + + shift + goto :arg-parse +) + +set PYTHON_LIB_PATH=%ROOT_PATH:/=\%PythonAPI\carla\ + +if %REMOVE_INTERMEDIATE% == false ( + if %BUILD_FOR_PYTHON3% == false ( + if %BUILD_FOR_PYTHON2% == false ( + echo Nothing selected to be done. + goto :eof + ) + ) +) + +if %REMOVE_INTERMEDIATE% == true ( + rem Remove directories + for %%G in ( + "%PYTHON_LIB_PATH%build", + "%PYTHON_LIB_PATH%dist", + "%PYTHON_LIB_PATH%source\carla.egg-info" + ) do ( + if exist %%G ( + echo %FILE_N% Cleaning %%G + rmdir /s/q %%G + ) + ) + if %BUILD_FOR_PYTHON3% == false ( + if %BUILD_FOR_PYTHON2% == false ( + goto good_exit + ) + ) +) + +cd "%PYTHON_LIB_PATH%" +rem if exist "%PYTHON_LIB_PATH%dist" goto already_installed + +rem ============================================================================ +rem -- Check for py ------------------------------------------------------------ +rem ============================================================================ + +set PYTHON_EXEC=python + +where %PYTHON_EXEC%>nul +if %errorlevel% neq 0 ( + where py>nul + if %errorlevel% neq 0 goto error_py + set PYTHON_EXEC=py -3 +) + +rem Build for Python 2 +rem +if %BUILD_FOR_PYTHON2%==true ( + goto py2_not_supported +) + +rem Build for Python 3 +rem +if %BUILD_FOR_PYTHON3%==true ( + echo Building Python API for Python 3. + call %PYTHON_EXEC% setup.py bdist_egg bdist_wheel + if %errorlevel% neq 0 goto error_build_wheel +) + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo. + if %BUILD_FOR_PYTHON3%==true echo %FILE_N% Carla lib for python has been successfully installed in "%PYTHON_LIB_PATH%dist"! + goto good_exit + +:already_installed + echo. + echo %FILE_N% [ERROR] Already installed in "%PYTHON_LIB_PATH%dist" + goto good_exit + +:py2_not_supported + echo. + echo %FILE_N% [ERROR] Python 2 is not currently suported in Windows. + goto bad_exit + +:error_py + echo. + echo %FILE_N% [ERROR] An error ocurred while executing the py. + echo %FILE_N% [ERROR] Possible causes: + echo %FILE_N% [ERROR] - Make sure "py" is installed. + echo %FILE_N% [ERROR] - py = python launcher. This utility is bundled with Python installation but not installed by default. + echo %FILE_N% [ERROR] - Make sure it is available on your Windows "py". + goto bad_exit + +:error_build_wheel + echo. + echo %FILE_N% [ERROR] An error occurred while building the wheel file. + goto bad_exit + +:good_exit + endlocal + exit /b 0 + +:bad_exit + endlocal + exit /b %errorlevel% diff --git a/Util/BuildTools/Package.bat b/Util/BuildTools/Package.bat new file mode 100755 index 0000000..dabcbbe --- /dev/null +++ b/Util/BuildTools/Package.bat @@ -0,0 +1,464 @@ +@echo off +setlocal enabledelayedexpansion + +rem don't remove next two empty lines after next +set LF=^ + + +rem Bat script that compiles and exports the carla project (carla.org) +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. +rem https://wiki.unrealengine.com/How_to_package_your_game_with_commands + +set LOCAL_PATH=%~dp0 +set FILE_N=-[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================== +rem -- Parse arguments ----------------------------------------------------------- +rem ============================================================================== + +set DOC_STRING="Makes a packaged version of CARLA for distribution." +set USAGE_STRING="Usage: %FILE_N% [-h|--help] [--no-packaging] [--no-zip] [--clean] [--clean-intermediate] [--target-archive]" + +set DO_PACKAGE=true +set DO_COPY_FILES=true +set DO_TARBALL=true +set DO_CLEAN=false +set PACKAGES=Carla +set USE_CARSIM=false +set SINGLE_PACKAGE=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="--clean" ( + set DO_CLEAN=true + set DO_TARBALL=false + set DO_PACKAGE=false + set DO_COPY_FILES=false + ) + + if "%1"=="--clean-intermediate" ( + set DO_CLEAN=true + ) + + if "%1"=="--no-zip" ( + set DO_TARBALL=false + ) + + if "%1"=="--no-packaging" ( + set DO_PACKAGE=false + ) + + if "%1"=="--packages" ( + set DO_PACKAGE=false + set DO_COPY_FILES=false + set PACKAGES=%* + shift + ) + + if "%1"=="--target-archive" ( + set SINGLE_PACKAGE=true + set TARGET_ARCHIVE=%2 + shift + ) + + if "%1"=="--carsim" ( + set USE_CARSIM=true + ) + + if "%1"=="-h" ( + echo %DOC_STRING% + echo %USAGE_STRING% + GOTO :eof + ) + + if "%1"=="--help" ( + echo %DOC_STRING% + echo %USAGE_STRING% + GOTO :eof + ) + + shift + goto :arg-parse +) + +rem Get Unreal Engine root path +if not defined UE4_ROOT ( + set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine" + set VALUE_NAME=InstalledDirectory + for /f "usebackq tokens=1,2,*" %%A in (`reg query !KEY_NAME! /s /reg:64`) do ( + if "%%A" == "!VALUE_NAME!" ( + set UE4_ROOT=%%C + ) + ) + if not defined UE4_ROOT goto error_unreal_no_found +) + +rem Force Visual Studio 2019 toolset to avoid C4756 errors with VS2022 toolset +set VCToolsVersion=14.29.30133 + +rem Set packaging paths +rem +for /f %%i in ('git describe --tags --dirty --always') do set CARLA_VERSION=%%i +if not defined CARLA_VERSION goto error_carla_version + +set BUILD_FOLDER=%INSTALLATION_DIR%UE4Carla/%CARLA_VERSION%/ + +set DESTINATION_ZIP=%INSTALLATION_DIR%UE4Carla/CARLA_%CARLA_VERSION%.zip +set SOURCE=!BUILD_FOLDER!WindowsNoEditor/ + +rem ============================================================================ +rem -- Create Carla package ---------------------------------------------------- +rem ============================================================================ + +if %DO_PACKAGE%==true ( + + where python >nul 2>nul + if %errorlevel% neq 0 ( + echo %FILE_N% WARNING: Python not found in PATH, skipping CarSim config + goto skip_carsim_config_pkg + ) + + if %USE_CARSIM% == true ( + call python "%ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py" -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" -e + echo CarSim ON > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini" + ) else ( + call python "%ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py" -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" + echo CarSim OFF > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini" + ) + + :skip_carsim_config_pkg + + if not exist "!BUILD_FOLDER!" mkdir "!BUILD_FOLDER!" + + call "%UE4_ROOT%\Engine\Build\BatchFiles\Build.bat"^ + CarlaUE4Editor^ + Win64^ + Development^ + -WaitMutex^ + -FromMsBuild^ + "%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" + + if errorlevel 1 goto error_build_editor + + call "%UE4_ROOT%\Engine\Build\BatchFiles\Build.bat"^ + CarlaUE4^ + Win64^ + Shipping^ + -WaitMutex^ + -FromMsBuild^ + "%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" + + if errorlevel 1 goto error_build + + call "%UE4_ROOT%\Engine\Build\BatchFiles\RunUAT.bat"^ + BuildCookRun^ + -nocompileeditor^ + -TargetPlatform=Win64^ + -Platform=Win64^ + -installed^ + -nop4^ + -project="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"^ + -cook^ + -stage^ + -build^ + -archive^ + -archivedirectory="!BUILD_FOLDER!"^ + -package^ + -clientconfig=Shipping + + if errorlevel 1 goto error_runUAT +) + +rem ============================================================================== +rem -- Adding extra files to package --------------------------------------------- +rem ============================================================================== + +if %DO_COPY_FILES%==true ( + echo "%FILE_N% Adding extra files to package..." + + set XCOPY_FROM=%ROOT_PATH:/=\% + set XCOPY_TO=%SOURCE:/=\% + + echo f | xcopy /y "!XCOPY_FROM!LICENSE" "!XCOPY_TO!LICENSE" + echo f | xcopy /y "!XCOPY_FROM!CHANGELOG.md" "!XCOPY_TO!CHANGELOG" + echo f | xcopy /y "!XCOPY_FROM!Docs\release_readme.md" "!XCOPY_TO!README" + echo f | xcopy /y "!XCOPY_FROM!Util\Docker\Release.Dockerfile" "!XCOPY_TO!Dockerfile" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\carla\dist\*.egg" "!XCOPY_TO!PythonAPI\carla\dist\" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\carla\dist\*.whl" "!XCOPY_TO!PythonAPI\carla\dist\" + echo d | xcopy /y /s "!XCOPY_FROM!Co-Simulation" "!XCOPY_TO!Co-Simulation" + echo d | xcopy /y /s "!XCOPY_FROM!PythonAPI\carla\agents" "!XCOPY_TO!PythonAPI\carla\agents" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\carla\scene_layout.py" "!XCOPY_TO!PythonAPI\carla\" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\carla\requirements.txt" "!XCOPY_TO!PythonAPI\carla\" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\examples\*.py" "!XCOPY_TO!PythonAPI\examples\" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\examples\requirements.txt" "!XCOPY_TO!PythonAPI\examples\" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\util\*.py" "!XCOPY_TO!PythonAPI\util\" + echo d | xcopy /y /s "!XCOPY_FROM!PythonAPI\util\opendrive" "!XCOPY_TO!PythonAPI\util\opendrive" + echo f | xcopy /y "!XCOPY_FROM!PythonAPI\util\requirements.txt" "!XCOPY_TO!PythonAPI\util\" + echo f | xcopy /y "!XCOPY_FROM!Unreal\CarlaUE4\Content\Carla\HDMaps\*.pcd" "!XCOPY_TO!HDMaps\" + echo f | xcopy /y "!XCOPY_FROM!Unreal\CarlaUE4\Content\Carla\HDMaps\Readme.md" "!XCOPY_TO!HDMaps\README" + if exist "!XCOPY_FROM!Plugins" ( + echo d | xcopy /y /s "!XCOPY_FROM!Plugins" "!XCOPY_TO!Plugins" + ) +) + +rem ============================================================================== +rem -- Zip the project ----------------------------------------------------------- +rem ============================================================================== + +if %DO_PACKAGE%==true if %DO_TARBALL%==true ( + set SRC_PATH=%SOURCE:/=\% + + echo %FILE_N% Building package... + + if exist "!SRC_PATH!Manifest_NonUFSFiles_Win64.txt" del /Q "!SRC_PATH!Manifest_NonUFSFiles_Win64.txt" + if exist "!SRC_PATH!Manifest_DebugFiles_Win64.txt" del /Q "!SRC_PATH!Manifest_DebugFiles_Win64.txt" + if exist "!SRC_PATH!Manifest_UFSFiles_Win64.txt" del /Q "!SRC_PATH!Manifest_UFSFiles_Win64.txt" + if exist "!SRC_PATH!CarlaUE4/Saved" rmdir /S /Q "!SRC_PATH!CarlaUE4/Saved" + if exist "!SRC_PATH!Engine/Saved" rmdir /S /Q "!SRC_PATH!Engine/Saved" + + set DST_ZIP=%DESTINATION_ZIP:/=\% + if exist "%ProgramW6432%/7-Zip/7z.exe" ( + "%ProgramW6432%/7-Zip/7z.exe" a "!DST_ZIP!" "!SRC_PATH!" -tzip -mmt -mx5 + ) else ( + pushd "!SRC_PATH!" + rem https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-6 + powershell -command "& { Compress-Archive -Path * -CompressionLevel Fastest -DestinationPath '!DST_ZIP!' }" + popd + ) +) + +rem ============================================================================== +rem -- Remove intermediate files ------------------------------------------------- +rem ============================================================================== + +if %DO_CLEAN%==true ( + echo %FILE_N% Removing intermediate build. + rmdir /S /Q "!BUILD_FOLDER!" +) + +rem ============================================================================== +rem -- Cook other packages ------------------------------------------------------- +rem ============================================================================== + +rem Set some file locations +set CARLAUE4_ROOT_FOLDER=%ROOT_PATH%Unreal/CarlaUE4 +set PACKAGE_PATH_FILE=%CARLAUE4_ROOT_FOLDER%/Content/PackagePath.txt +set MAP_LIST_FILE=%CARLAUE4_ROOT_FOLDER%/Content/MapPaths.txt + +rem get the packages to cook from the arguments whole string +rem (to support multiple packages) +echo Parsing packages... +if not "%PACKAGES%" == "Carla" ( + set ARGUMENTS=%PACKAGES:--=!LF!% + for /f "tokens=*" %%i in ("!ARGUMENTS!") do ( + set a=%%i + if "!a:~0,9!" == "packages=" ( + set RESULT=!a:~9! + ) else ( + if "!a:~0,9!" == "packages " ( + set RESULT=!a:~9! + ) + ) + ) +) else ( + set RESULT=%PACKAGES% +) +rem through all maps to cook (parameter) +set PACKAGES=%RESULT:,=!LF!% +for /f "tokens=* delims=" %%i in ("!PACKAGES!") do ( + + set PACKAGE_NAME=%%i + + if not !PACKAGE_NAME! == Carla ( + echo Preparing environment for cooking '!PACKAGE_NAME!'. + + set BUILD_FOLDER=%INSTALLATION_DIR%UE4Carla/!PACKAGE_NAME!_%CARLA_VERSION%\ + set PACKAGE_PATH=%CARLAUE4_ROOT_FOLDER%/Content/!PACKAGE_NAME! + + if not exist "!BUILD_FOLDER!" mkdir "!BUILD_FOLDER!" + + echo Cooking package '!PACKAGE_NAME!'... + + pushd "%CARLAUE4_ROOT_FOLDER%" + + echo - prepare + REM # Prepare cooking of package + echo Prepare cooking of package: !PACKAGE_NAME! + call "%UE4_ROOT%/Engine/Binaries/Win64/UE4Editor.exe "^ + "%CARLAUE4_ROOT_FOLDER%/CarlaUE4.uproject"^ + -run=PrepareAssetsForCooking^ + -PackageName=!PACKAGE_NAME!^ + -OnlyPrepareMaps=false + + set /p PACKAGE_FILE=<%PACKAGE_PATH_FILE% + set /p MAPS_TO_COOK=<%MAP_LIST_FILE% + + echo - cook + for /f "tokens=*" %%a in (%MAP_LIST_FILE%) do ( + REM # Cook maps + echo Cooking: %%a + call "%UE4_ROOT%/Engine/Binaries/Win64/UE4Editor.exe "^ + "%CARLAUE4_ROOT_FOLDER%/CarlaUE4.uproject"^ + -run=cook^ + -map="%%a"^ + -targetplatform="WindowsNoEditor"^ + -OutputDir="!BUILD_FOLDER!"^ + -iterate^ + -cooksinglepackage^ + ) + + REM remove the props folder if exist + set PROPS_MAP_FOLDER="%PACKAGE_PATH%/Maps/PropsMap" + if exist "%PROPS_MAP_FOLDER%" ( + rmdir /S /Q "%PROPS_MAP_FOLDER%" + ) + + popd + + echo Copying files to '!PACKAGE_NAME!'... + + pushd "!BUILD_FOLDER!" + + set SUBST_PATH=!BUILD_FOLDER!CarlaUE4 + + REM Copy the package config file to package + set TARGET="!SUBST_PATH!\Content\Carla\Config\" + mkdir !TARGET:/=\! + copy "!PACKAGE_FILE:/=\!" !TARGET:/=\! + + REM Copy some files for each map to the package + REM MAPS_TO_COOK is read into an array as tokens separated by '+', we replace the '+' by a new line + REM We need the blank line after this line, don't remove it + set MAPS_TO_COOK=!MAPS_TO_COOK:+=^ + + ! + set BASE_CONTENT=%INSTALLATION_DIR:/=\%..\Unreal\CarlaUE4\Content + for /f "tokens=1 delims=+" %%a in ("!MAPS_TO_COOK!") do ( + + REM Get path and name of map + for /f %%i in ("%%a") do ( + set MAP_FOLDER=%%~pi + set MAP_NAME=%%~ni + REM Remove the '/Game' string + set MAP_FOLDER=!MAP_FOLDER:~5! + ) + + REM # copy the OpenDrive file + set SRC=!BASE_CONTENT!!MAP_FOLDER!\OpenDrive\!MAP_NAME!.xodr + set TRG=!BUILD_FOLDER!\CarlaUE4\Content\!MAP_FOLDER!\OpenDrive\ + if exist "!SRC!" ( + mkdir "!TRG!" + copy "!SRC!" "!TRG!" + ) + + REM # copy the navigation file + set SRC=!BASE_CONTENT!!MAP_FOLDER!\Nav\!MAP_NAME!.bin + set TRG=!BUILD_FOLDER!\CarlaUE4\Content\!MAP_FOLDER!\Nav\ + if exist "!SRC!" ( + mkdir "!TRG!" + copy "!SRC!" "!TRG!" + ) + + REM # copy the traffic manager map file + set SRC=!BASE_CONTENT!!MAP_FOLDER!\TM\!MAP_NAME!.bin + set TRG=!BUILD_FOLDER!\CarlaUE4\Content\!MAP_FOLDER!\TM\ + if exist "!SRC!" ( + mkdir "!TRG!" + copy "!SRC!" "!TRG!" + ) + ) + + rmdir /S /Q "!BUILD_FOLDER!\CarlaUE4\Metadata" + rmdir /S /Q "!BUILD_FOLDER!\CarlaUE4\Plugins" + REM del "!BUILD_FOLDER!\CarlaUE4\Content\!PACKAGE_NAME!/Maps/!PROPS_MAP_NAME!" + del "!BUILD_FOLDER!\CarlaUE4\AssetRegistry.bin" + + if %DO_TARBALL%==true ( + + if %SINGLE_PACKAGE%==true ( + echo Packaging '%TARGET_ARCHIVE%'... + set DESTINATION_ZIP=%INSTALLATION_DIR%UE4Carla/%TARGET_ARCHIVE%_%CARLA_VERSION%.zip + ) else ( + echo Packaging '!PACKAGE_NAME!'... + set DESTINATION_ZIP=%INSTALLATION_DIR%UE4Carla/!PACKAGE_NAME!_%CARLA_VERSION%.zip + ) + + set SOURCE=!BUILD_FOLDER:/=\!\ + set DST_ZIP=!DESTINATION_ZIP:/=\! + + pushd "!SOURCE!" + + if exist "%ProgramW6432%/7-Zip/7z.exe" ( + "%ProgramW6432%/7-Zip/7z.exe" a "!DST_ZIP!" . -tzip -mmt -mx5 + ) else ( + rem https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-6 + powershell -command "& { Compress-Archive -Update -Path * -CompressionLevel Fastest -DestinationPath '!DST_ZIP!' }" + ) + + popd + + if errorlevel 1 goto bad_exit + echo ZIP created at !DST_ZIP! + ) + + popd + + if %DO_CLEAN%==true ( + echo %FILE_N% Removing intermediate build. + rmdir /S /Q "!BUILD_FOLDER!" + ) + ) +) + +rem ============================================================================ + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo. + if %DO_PACKAGE%==true echo %FILE_N% Carla project successful exported to "%BUILD_FOLDER:/=\%"! + if %DO_TARBALL%==true echo %FILE_N% Compress carla project exported to "%DESTINATION_ZIP%"! + goto good_exit + +:error_carla_version + echo. + echo %FILE_N% [ERROR] Carla Version is not set + goto bad_exit + +:error_unreal_no_found + echo. + echo %FILE_N% [ERROR] Unreal Engine not detected + goto bad_exit + +:error_build_editor + echo. + echo %FILE_N% [ERROR] There was a problem while building the CarlaUE4Editor. + echo [ERROR] Please read the screen log for more information. + goto bad_exit + +:error_build + echo. + echo %FILE_N% [ERROR] There was a problem while building the CarlaUE4. + echo [ERROR] Please read the screen log for more information. + goto bad_exit + +:error_runUAT + echo. + echo %FILE_N% [ERROR] There was a problem while packaging Unreal project. + echo [ERROR] Please read the screen log for more information. + goto bad_exit + +:good_exit + endlocal + exit /b 0 + +:bad_exit + endlocal + exit /b 1 diff --git a/Util/BuildTools/Setup.bat b/Util/BuildTools/Setup.bat old mode 100644 new mode 100755 index cc19758..613fd22 --- a/Util/BuildTools/Setup.bat +++ b/Util/BuildTools/Setup.bat @@ -1,377 +1,377 @@ -@echo off -setlocal - -rem BAT script that downloads and generates -rem rpclib, gtest and boost libraries for CARLA (carla.org). -rem Run it through a cmd with the x64 Visual C++ Toolset enabled. - -set LOCAL_PATH=%~dp0 -set FILE_N=-[%~n0]: - -rem Print batch params (debug purpose) -echo %FILE_N% [Batch params]: %* - -rem ============================================================================ -rem -- Check for compiler ------------------------------------------------------ -rem ============================================================================ - -where cl 1>nul -if %errorlevel% neq 0 goto error_cl - -rem TODO: check for x64 and not x86 or x64_x86 - -rem ============================================================================ -rem -- Parse arguments --------------------------------------------------------- -rem ============================================================================ - -set BOOST_VERSION=1.72.0 -set INSTALLERS_DIR=%ROOT_PATH:/=\%Util\InstallersWin\ -set VERSION_FILE=%ROOT_PATH:/=\%Util\ContentVersions.txt -set CONTENT_DIR=%ROOT_PATH:/=\%Unreal\CarlaUE4\Content\Carla\ -set CARLA_DEPENDENCIES_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies\ -set CARLA_BINARIES_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\Plugins\Carla\Binaries\Win64 -set CARLA_PYTHON_DEPENDENCIES=%ROOT_PATH:/=\%PythonAPI\carla\dependencies\ -set USE_CHRONO=false - -:arg-parse -if not "%1"=="" ( - if "%1"=="-j" ( - set NUMBER_OF_ASYNC_JOBS=%2 - ) - if "%1"=="--boost-toolset" ( - set TOOLSET=%2 - ) - if "%1"=="--chrono" ( - set USE_CHRONO=true - ) - if "%1"=="-h" ( - goto help - ) - if "%1"=="--help" ( - goto help - ) - shift - goto :arg-parse -) - -rem If not defined, use Visual Studio 2019 as tool set -if "%TOOLSET%" == "" set TOOLSET=msvc-14.2 - -rem If is not set, set the number of parallel jobs to the number of CPU threads -if "%NUMBER_OF_ASYNC_JOBS%" == "" set NUMBER_OF_ASYNC_JOBS=%NUMBER_OF_PROCESSORS% - -rem ============================================================================ -rem -- Basic info and setup ---------------------------------------------------- -rem ============================================================================ - -set INSTALLATION_DIR=%INSTALLATION_DIR:/=\% - -echo %FILE_N% Asynchronous jobs: %NUMBER_OF_ASYNC_JOBS% -echo %FILE_N% Boost toolset: %TOOLSET% -echo %FILE_N% Install directory: "%INSTALLATION_DIR%" - -if not exist "%CONTENT_DIR%" ( - echo %FILE_N% Creating "%CONTENT_DIR%" folder... - mkdir "%CONTENT_DIR%" -) - -if not exist "%INSTALLATION_DIR%" ( - echo %FILE_N% Creating "%INSTALLATION_DIR%" folder... - mkdir "%INSTALLATION_DIR%" -) - -rem ============================================================================ -rem -- Download and install zlib ----------------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing zlib... -call "%INSTALLERS_DIR%install_zlib.bat"^ - --build-dir "%INSTALLATION_DIR%" - -if %errorlevel% neq 0 goto failed - -if not defined install_zlib ( - echo %FILE_N% Failed while installing zlib. - goto failed -) else ( - set ZLIB_INSTALL_DIR=%install_zlib% -) - -rem ============================================================================ -rem -- Download and install libpng --------------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing libpng... -call "%INSTALLERS_DIR%install_libpng.bat"^ - --build-dir "%INSTALLATION_DIR%"^ - --zlib-install-dir "%ZLIB_INSTALL_DIR%" - -if %errorlevel% neq 0 goto failed - -if not defined install_libpng ( - echo %FILE_N% Failed while installing libpng. - goto failed -) else ( - set LIBPNG_INSTALL_DIR=%install_libpng% -) - -rem ============================================================================ -rem -- Download and install rpclib --------------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing rpclib... -call "%INSTALLERS_DIR%install_rpclib.bat"^ - --build-dir "%INSTALLATION_DIR%" - -if %errorlevel% neq 0 goto failed - -if not defined install_rpclib ( - echo %FILE_N% Failed while installing rpclib. - goto failed -) - -rem ============================================================================ -rem -- Download and install Google Test ---------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing Google Test... -call "%INSTALLERS_DIR%install_gtest.bat"^ - --build-dir "%INSTALLATION_DIR%" - -if %errorlevel% neq 0 goto failed - -if not defined install_gtest ( - - echo %FILE_N% Failed while installing Google Test. - goto failed -) - -rem ============================================================================ -rem -- Download and install Recast & Detour ------------------------------------ -rem ============================================================================ - -echo %FILE_N% Installing "Recast & Detour"... -call "%INSTALLERS_DIR%install_recast.bat"^ - --build-dir "%INSTALLATION_DIR%" - -if %errorlevel% neq 0 goto failed - -if not defined install_recast ( - - echo %FILE_N% Failed while installing "Recast & Detour". - goto failed -) else ( - set RECAST_INSTALL_DIR=%install_recast:\=/% -) - -rem ============================================================================ -rem -- Download and install Boost ---------------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing Boost... -call "%INSTALLERS_DIR%install_boost.bat"^ - --build-dir "%INSTALLATION_DIR%"^ - --toolset %TOOLSET%^ - --version %BOOST_VERSION%^ - -j %NUMBER_OF_ASYNC_JOBS% - -if %errorlevel% neq 0 goto failed - -if not defined install_boost ( - echo %FILE_N% Failed while installing Boost. - goto failed -) - -copy /Y "%INSTALLATION_DIR%..\Util\BoostFiles\rational.hpp" "%INSTALLATION_DIR%boost-%BOOST_VERSION%-install\include\boost\rational.hpp" -copy /Y "%INSTALLATION_DIR%..\Util\BoostFiles\read.hpp" "%INSTALLATION_DIR%boost-%BOOST_VERSION%-install\include\boost\geometry\io\wkt\read.hpp" - -if not exist "%CARLA_PYTHON_DEPENDENCIES%" ( - mkdir "%CARLA_PYTHON_DEPENDENCIES%"\lib -) -rem ============================================================================ -rem -- Download and install Xercesc -------------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing Xercesc... -call "%INSTALLERS_DIR%install_xercesc.bat"^ - --build-dir "%INSTALLATION_DIR%" -copy %INSTALLATION_DIR%\xerces-c-3.2.3-install\lib\xerces-c_3.lib %CARLA_PYTHON_DEPENDENCIES%\lib - -rem ============================================================================ -rem -- Download and install Sqlite3 -------------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing Sqlite3 -call "%INSTALLERS_DIR%install_sqlite3.bat"^ - --build-dir "%INSTALLATION_DIR%" -copy %INSTALLATION_DIR%\sqlite3-install\lib\sqlite3.lib %CARLA_PYTHON_DEPENDENCIES%\lib - -rem ============================================================================ -rem -- Download and install PROJ -------------------------------------------- -rem ============================================================================ - -echo %FILE_N% Installing PROJ -call "%INSTALLERS_DIR%install_proj.bat"^ - --build-dir "%INSTALLATION_DIR%" -copy %INSTALLATION_DIR%\proj-install\lib\proj.lib %CARLA_PYTHON_DEPENDENCIES%\lib - -rem ============================================================================ -rem -- Download and install Chrono ---------------------------------------------- -rem ============================================================================ - -if %USE_CHRONO% == true ( - echo %FILE_N% Installing Chrono... - call "%INSTALLERS_DIR%install_chrono.bat"^ - --build-dir "%INSTALLATION_DIR%" - - if not exist "%CARLA_DEPENDENCIES_FOLDER%" ( - mkdir "%CARLA_DEPENDENCIES_FOLDER%" - ) - if not exist "%CARLA_DEPENDENCIES_FOLDER%include" ( - mkdir "%CARLA_DEPENDENCIES_FOLDER%include" - ) - if not exist "%CARLA_DEPENDENCIES_FOLDER%lib" ( - mkdir "%CARLA_DEPENDENCIES_FOLDER%lib" - ) - if not exist "%CARLA_DEPENDENCIES_FOLDER%dll" ( - mkdir "%CARLA_DEPENDENCIES_FOLDER%dll" - ) - echo "%INSTALLATION_DIR%chrono-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL - xcopy /Y /S /I "%INSTALLATION_DIR%chrono-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL - copy "%INSTALLATION_DIR%chrono-install\lib\*.lib" "%CARLA_DEPENDENCIES_FOLDER%lib\*.lib" > NUL - copy "%INSTALLATION_DIR%chrono-install\bin\*.dll" "%CARLA_DEPENDENCIES_FOLDER%dll\*.dll" > NUL - xcopy /Y /S /I "%INSTALLATION_DIR%eigen-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL -) - -rem ============================================================================ -rem -- Assets download URL ----------------------------------------------------- -rem ============================================================================ - -FOR /F "usebackq tokens=1,2" %%i in ("%VERSION_FILE%") do ( - set ASSETS_VERSION=%%i - set HASH=%%j -) -set URL=http://carla-assets.s3.amazonaws.com/%HASH%.tar.gz - -rem ============================================================================ -rem -- Generate CMake ---------------------------------------------------------- -rem ============================================================================ - -for /f %%i in ('git describe --tags --dirty --always') do set carla_version=%%i -set CMAKE_INSTALLATION_DIR=%INSTALLATION_DIR:\=/% - -echo %FILE_N% Creating "CMakeLists.txt.in"... - -set CMAKE_CONFIG_FILE=%INSTALLATION_DIR%CMakeLists.txt.in - - >"%CMAKE_CONFIG_FILE%" echo # Automatically generated by Setup.bat ->>"%CMAKE_CONFIG_FILE%" echo set(CARLA_VERSION %carla_version%) ->>"%CMAKE_CONFIG_FILE%" echo. ->>"%CMAKE_CONFIG_FILE%" echo set(CMAKE_CXX_STANDARD 14) ->>"%CMAKE_CONFIG_FILE%" echo set(CMAKE_CXX_STANDARD_REQUIRED ON) ->>"%CMAKE_CONFIG_FILE%" echo. ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-D_WIN32_WINNT=0x0600) ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DHAVE_SNPRINTF) ->>"%CMAKE_CONFIG_FILE%" echo STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ->>"%CMAKE_CONFIG_FILE%" echo. ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY) ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT) ->>"%CMAKE_CONFIG_FILE%" echo. ->>"%CMAKE_CONFIG_FILE%" echo set(BOOST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%boost-%BOOST_VERSION%-install/include") ->>"%CMAKE_CONFIG_FILE%" echo set(BOOST_LIB_PATH "%CMAKE_INSTALLATION_DIR%boost-%BOOST_VERSION%-install/lib") ->>"%CMAKE_CONFIG_FILE%" echo. ->>"%CMAKE_CONFIG_FILE%" echo set(RPCLIB_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/include") ->>"%CMAKE_CONFIG_FILE%" echo set(RPCLIB_LIB_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/lib") ->>"%CMAKE_CONFIG_FILE%" echo. ->>"%CMAKE_CONFIG_FILE%" echo if (CMAKE_BUILD_TYPE STREQUAL "Server") ->>"%CMAKE_CONFIG_FILE%" echo # Prevent exceptions ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY) ->>"%CMAKE_CONFIG_FILE%" echo add_compile_options(/EHsc) ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DASIO_NO_EXCEPTIONS) ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_NO_EXCEPTIONS) ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DLIBCARLA_NO_EXCEPTIONS) ->>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DPUGIXML_NO_EXCEPTIONS) ->>"%CMAKE_CONFIG_FILE%" echo # Specific libraries for server ->>"%CMAKE_CONFIG_FILE%" echo set(GTEST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/include") ->>"%CMAKE_CONFIG_FILE%" echo set(GTEST_LIB_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/lib") ->>"%CMAKE_CONFIG_FILE%" echo elseif (CMAKE_BUILD_TYPE STREQUAL "Client") ->>"%CMAKE_CONFIG_FILE%" echo # Specific libraries for client ->>"%CMAKE_CONFIG_FILE%" echo set(ZLIB_INCLUDE_PATH "%ZLIB_INSTALL_DIR:\=/%/include") ->>"%CMAKE_CONFIG_FILE%" echo set(ZLIB_LIB_PATH "%ZLIB_INSTALL_DIR:\=/%/lib") ->>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_INCLUDE_PATH "%LIBPNG_INSTALL_DIR:\=/%/include") ->>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_LIB_PATH "%LIBPNG_INSTALL_DIR:\=/%/lib") ->>"%CMAKE_CONFIG_FILE%" echo set(RECAST_INCLUDE_PATH "%RECAST_INSTALL_DIR:\=/%/include") ->>"%CMAKE_CONFIG_FILE%" echo set(RECAST_LIB_PATH "%RECAST_INSTALL_DIR:\=/%/lib") ->>"%CMAKE_CONFIG_FILE%" echo endif () - -goto success - -rem ============================================================================ -rem -- Messages and Errors ----------------------------------------------------- -rem ============================================================================ - -:success - echo %FILE_N% - echo ########### - echo # SUCCESS # - echo ########### - echo. - echo IMPORTANT! - echo. - echo All the CARLA library dependences should be installed now. - echo (You can remove all "*-src" folders in %INSTALLATION_DIR% directory) - echo. - echo You only need the ASSET PACK with all the meshes and textures. - echo. - echo This script provides the assets for CARLA %ASSETS_VERSION% - echo You can download the assets from here: - echo. - echo %URL% - echo. - echo Unzip it in the "%CONTENT_DIR%" folder. - echo If you want another version, search it in %VERSION_FILE%. - echo. - goto good_exit - -:help - echo Download and compiles all the necessary libraries to build CARLA. - echo. - echo Commands: - echo -h, --help -^> Shows this dialog. - echo -j ^ -^> N is the integer number of async jobs while compiling (default=1). - echo --boost-toolset [T] -^> Toolset corresponding to your compiler ^(default=^*^): - echo Visual Studio 2013 -^> msvc-12.0 - echo Visual Studio 2015 -^> msvc-14.0 - echo Visual Studio 2017 -^> msvc-14.1 - echo Visual Studio 2019 -^> msvc-14.2 * - goto good_exit - -:error_cl - echo. - echo %FILE_N% [ERROR] Can't find Visual Studio compiler (cl.exe). - echo [ERROR] Possible causes: - echo [ERROR] - Make sure you use x64 (not x64_x86!) - echo [ERROR] - You are not using "Visual Studio x64 Native Tools Command Prompt". - goto failed - -:failed - echo. - echo %FILE_N% - echo Ok, and error ocurred, don't panic! - echo We have different platforms where you can find some help :) - echo. - echo - Make sure you have read the documentation: - echo http://carla.readthedocs.io/en/latest/how_to_build_on_windows/ - echo. - echo - If the problem persists, you can ask on our Github's "Building on Windows" issue: - echo https://github.com/carla-simulator/carla/issues/21 - echo. - echo - Or just use our Discord channel! - echo We'll be glad to help you there :) - echo https://discord.gg/42KJdRj - endlocal - exit /b %errorlevel% - -:good_exit - endlocal - exit /b 0 +@echo off +setlocal + +rem BAT script that downloads and generates +rem rpclib, gtest and boost libraries for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N=-[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Check for compiler ------------------------------------------------------ +rem ============================================================================ + +where cl 1>nul +if %errorlevel% neq 0 goto error_cl + +rem TODO: check for x64 and not x86 or x64_x86 + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set BOOST_VERSION=1.72.0 +set INSTALLERS_DIR=%ROOT_PATH:/=\%Util\InstallersWin\ +set VERSION_FILE=%ROOT_PATH:/=\%Util\ContentVersions.txt +set CONTENT_DIR=%ROOT_PATH:/=\%Unreal\CarlaUE4\Content\Carla\ +set CARLA_DEPENDENCIES_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies\ +set CARLA_BINARIES_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\Plugins\Carla\Binaries\Win64 +set CARLA_PYTHON_DEPENDENCIES=%ROOT_PATH:/=\%PythonAPI\carla\dependencies\ +set USE_CHRONO=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="-j" ( + set NUMBER_OF_ASYNC_JOBS=%2 + ) + if "%1"=="--boost-toolset" ( + set TOOLSET=%2 + ) + if "%1"=="--chrono" ( + set USE_CHRONO=true + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not defined, use Visual Studio 2019 as tool set +if "%TOOLSET%" == "" set TOOLSET=msvc-14.2 + +rem If is not set, set the number of parallel jobs to the number of CPU threads +if "%NUMBER_OF_ASYNC_JOBS%" == "" set NUMBER_OF_ASYNC_JOBS=%NUMBER_OF_PROCESSORS% + +rem ============================================================================ +rem -- Basic info and setup ---------------------------------------------------- +rem ============================================================================ + +set INSTALLATION_DIR=%INSTALLATION_DIR:/=\% + +echo %FILE_N% Asynchronous jobs: %NUMBER_OF_ASYNC_JOBS% +echo %FILE_N% Boost toolset: %TOOLSET% +echo %FILE_N% Install directory: "%INSTALLATION_DIR%" + +if not exist "%CONTENT_DIR%" ( + echo %FILE_N% Creating "%CONTENT_DIR%" folder... + mkdir "%CONTENT_DIR%" +) + +if not exist "%INSTALLATION_DIR%" ( + echo %FILE_N% Creating "%INSTALLATION_DIR%" folder... + mkdir "%INSTALLATION_DIR%" +) + +rem ============================================================================ +rem -- Download and install zlib ----------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing zlib... +call "%INSTALLERS_DIR%install_zlib.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_zlib ( + echo %FILE_N% Failed while installing zlib. + goto failed +) else ( + set ZLIB_INSTALL_DIR=%install_zlib% +) + +rem ============================================================================ +rem -- Download and install libpng --------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing libpng... +call "%INSTALLERS_DIR%install_libpng.bat"^ + --build-dir "%INSTALLATION_DIR%"^ + --zlib-install-dir "%ZLIB_INSTALL_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_libpng ( + echo %FILE_N% Failed while installing libpng. + goto failed +) else ( + set LIBPNG_INSTALL_DIR=%install_libpng% +) + +rem ============================================================================ +rem -- Download and install rpclib --------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing rpclib... +call "%INSTALLERS_DIR%install_rpclib.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_rpclib ( + echo %FILE_N% Failed while installing rpclib. + goto failed +) + +rem ============================================================================ +rem -- Download and install Google Test ---------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Google Test... +call "%INSTALLERS_DIR%install_gtest.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_gtest ( + + echo %FILE_N% Failed while installing Google Test. + goto failed +) + +rem ============================================================================ +rem -- Download and install Recast & Detour ------------------------------------ +rem ============================================================================ + +echo %FILE_N% Installing "Recast & Detour"... +call "%INSTALLERS_DIR%install_recast.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_recast ( + + echo %FILE_N% Failed while installing "Recast & Detour". + goto failed +) else ( + set RECAST_INSTALL_DIR=%install_recast:\=/% +) + +rem ============================================================================ +rem -- Download and install Boost ---------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Boost... +call "%INSTALLERS_DIR%install_boost.bat"^ + --build-dir "%INSTALLATION_DIR%"^ + --toolset %TOOLSET%^ + --version %BOOST_VERSION%^ + -j %NUMBER_OF_ASYNC_JOBS% + +if %errorlevel% neq 0 goto failed + +if not defined install_boost ( + echo %FILE_N% Failed while installing Boost. + goto failed +) + +copy /Y "%INSTALLATION_DIR%..\Util\BoostFiles\rational.hpp" "%INSTALLATION_DIR%boost-%BOOST_VERSION%-install\include\boost\rational.hpp" +copy /Y "%INSTALLATION_DIR%..\Util\BoostFiles\read.hpp" "%INSTALLATION_DIR%boost-%BOOST_VERSION%-install\include\boost\geometry\io\wkt\read.hpp" + +if not exist "%CARLA_PYTHON_DEPENDENCIES%" ( + mkdir "%CARLA_PYTHON_DEPENDENCIES%"\lib +) +rem ============================================================================ +rem -- Download and install Xercesc -------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Xercesc... +call "%INSTALLERS_DIR%install_xercesc.bat"^ + --build-dir "%INSTALLATION_DIR%" +copy %INSTALLATION_DIR%\xerces-c-3.3.0-install\lib\xerces-c_3.lib %CARLA_PYTHON_DEPENDENCIES%\lib + +rem ============================================================================ +rem -- Download and install Sqlite3 -------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Sqlite3 +call "%INSTALLERS_DIR%install_sqlite3.bat"^ + --build-dir "%INSTALLATION_DIR%" +copy %INSTALLATION_DIR%\sqlite3-install\lib\sqlite3.lib %CARLA_PYTHON_DEPENDENCIES%\lib + +rem ============================================================================ +rem -- Download and install PROJ -------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing PROJ +call "%INSTALLERS_DIR%install_proj.bat"^ + --build-dir "%INSTALLATION_DIR%" +copy %INSTALLATION_DIR%\proj-install\lib\proj.lib %CARLA_PYTHON_DEPENDENCIES%\lib + +rem ============================================================================ +rem -- Download and install Chrono ---------------------------------------------- +rem ============================================================================ + +if %USE_CHRONO% == true ( + echo %FILE_N% Installing Chrono... + call "%INSTALLERS_DIR%install_chrono.bat"^ + --build-dir "%INSTALLATION_DIR%" + + if not exist "%CARLA_DEPENDENCIES_FOLDER%" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%" + ) + if not exist "%CARLA_DEPENDENCIES_FOLDER%include" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%include" + ) + if not exist "%CARLA_DEPENDENCIES_FOLDER%lib" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%lib" + ) + if not exist "%CARLA_DEPENDENCIES_FOLDER%dll" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%dll" + ) + echo "%INSTALLATION_DIR%chrono-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL + xcopy /Y /S /I "%INSTALLATION_DIR%chrono-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL + copy "%INSTALLATION_DIR%chrono-install\lib\*.lib" "%CARLA_DEPENDENCIES_FOLDER%lib\*.lib" > NUL + copy "%INSTALLATION_DIR%chrono-install\bin\*.dll" "%CARLA_DEPENDENCIES_FOLDER%dll\*.dll" > NUL + xcopy /Y /S /I "%INSTALLATION_DIR%eigen-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL +) + +rem ============================================================================ +rem -- Assets download URL ----------------------------------------------------- +rem ============================================================================ + +FOR /F "usebackq tokens=1,2" %%i in ("%VERSION_FILE%") do ( + set ASSETS_VERSION=%%i + set HASH=%%j +) +set URL=http://carla-assets.s3.amazonaws.com/%HASH%.tar.gz + +rem ============================================================================ +rem -- Generate CMake ---------------------------------------------------------- +rem ============================================================================ + +for /f %%i in ('git describe --tags --dirty --always') do set carla_version=%%i +set CMAKE_INSTALLATION_DIR=%INSTALLATION_DIR:\=/% + +echo %FILE_N% Creating "CMakeLists.txt.in"... + +set CMAKE_CONFIG_FILE=%INSTALLATION_DIR%CMakeLists.txt.in + + >"%CMAKE_CONFIG_FILE%" echo # Automatically generated by Setup.bat +>>"%CMAKE_CONFIG_FILE%" echo set(CARLA_VERSION %carla_version%) +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo set(CMAKE_CXX_STANDARD 14) +>>"%CMAKE_CONFIG_FILE%" echo set(CMAKE_CXX_STANDARD_REQUIRED ON) +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-D_WIN32_WINNT=0x0600) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DHAVE_SNPRINTF) +>>"%CMAKE_CONFIG_FILE%" echo STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT) +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo set(BOOST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%boost-%BOOST_VERSION%-install/include") +>>"%CMAKE_CONFIG_FILE%" echo set(BOOST_LIB_PATH "%CMAKE_INSTALLATION_DIR%boost-%BOOST_VERSION%-install/lib") +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo set(RPCLIB_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/include") +>>"%CMAKE_CONFIG_FILE%" echo set(RPCLIB_LIB_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/lib") +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo if (CMAKE_BUILD_TYPE STREQUAL "Server") +>>"%CMAKE_CONFIG_FILE%" echo # Prevent exceptions +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY) +>>"%CMAKE_CONFIG_FILE%" echo add_compile_options(/EHsc) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DASIO_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DLIBCARLA_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DPUGIXML_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo # Specific libraries for server +>>"%CMAKE_CONFIG_FILE%" echo set(GTEST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/include") +>>"%CMAKE_CONFIG_FILE%" echo set(GTEST_LIB_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/lib") +>>"%CMAKE_CONFIG_FILE%" echo elseif (CMAKE_BUILD_TYPE STREQUAL "Client") +>>"%CMAKE_CONFIG_FILE%" echo # Specific libraries for client +>>"%CMAKE_CONFIG_FILE%" echo set(ZLIB_INCLUDE_PATH "%ZLIB_INSTALL_DIR:\=/%/include") +>>"%CMAKE_CONFIG_FILE%" echo set(ZLIB_LIB_PATH "%ZLIB_INSTALL_DIR:\=/%/lib") +>>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_INCLUDE_PATH "%LIBPNG_INSTALL_DIR:\=/%/include") +>>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_LIB_PATH "%LIBPNG_INSTALL_DIR:\=/%/lib") +>>"%CMAKE_CONFIG_FILE%" echo set(RECAST_INCLUDE_PATH "%RECAST_INSTALL_DIR:\=/%/include") +>>"%CMAKE_CONFIG_FILE%" echo set(RECAST_LIB_PATH "%RECAST_INSTALL_DIR:\=/%/lib") +>>"%CMAKE_CONFIG_FILE%" echo endif () + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo %FILE_N% + echo ########### + echo # SUCCESS # + echo ########### + echo. + echo IMPORTANT! + echo. + echo All the CARLA library dependences should be installed now. + echo (You can remove all "*-src" folders in %INSTALLATION_DIR% directory) + echo. + echo You only need the ASSET PACK with all the meshes and textures. + echo. + echo This script provides the assets for CARLA %ASSETS_VERSION% + echo You can download the assets from here: + echo. + echo %URL% + echo. + echo Unzip it in the "%CONTENT_DIR%" folder. + echo If you want another version, search it in %VERSION_FILE%. + echo. + goto good_exit + +:help + echo Download and compiles all the necessary libraries to build CARLA. + echo. + echo Commands: + echo -h, --help -^> Shows this dialog. + echo -j ^ -^> N is the integer number of async jobs while compiling (default=1). + echo --boost-toolset [T] -^> Toolset corresponding to your compiler ^(default=^*^): + echo Visual Studio 2013 -^> msvc-12.0 + echo Visual Studio 2015 -^> msvc-14.0 + echo Visual Studio 2017 -^> msvc-14.1 + echo Visual Studio 2019 -^> msvc-14.2 * + goto good_exit + +:error_cl + echo. + echo %FILE_N% [ERROR] Can't find Visual Studio compiler (cl.exe). + echo [ERROR] Possible causes: + echo [ERROR] - Make sure you use x64 (not x64_x86!) + echo [ERROR] - You are not using "Visual Studio x64 Native Tools Command Prompt". + goto failed + +:failed + echo. + echo %FILE_N% + echo Ok, and error ocurred, don't panic! + echo We have different platforms where you can find some help :) + echo. + echo - Make sure you have read the documentation: + echo http://carla.readthedocs.io/en/latest/how_to_build_on_windows/ + echo. + echo - If the problem persists, you can ask on our Github's "Building on Windows" issue: + echo https://github.com/carla-simulator/carla/issues/21 + echo. + echo - Or just use our Discord channel! + echo We'll be glad to help you there :) + echo https://discord.gg/42KJdRj + endlocal + exit /b %errorlevel% + +:good_exit + endlocal + exit /b 0 diff --git a/Util/BuildTools/Setup.sh b/Util/BuildTools/Setup.sh index 0467453..f5effa9 100755 --- a/Util/BuildTools/Setup.sh +++ b/Util/BuildTools/Setup.sh @@ -130,7 +130,7 @@ for PY_VERSION in ${PY_VERSION_LIST[@]} ; do BOOST_PACKAGE_BASENAME=boost_${BOOST_VERSION//./_} log "Retrieving boost." - wget "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_PACKAGE_BASENAME}.tar.gz" || true + wget "https://archives.boost.io/release/${BOOST_VERSION}/source/${BOOST_PACKAGE_BASENAME}.tar.gz" || true # try to use the backup boost we have in Jenkins if [[ ! -f "${BOOST_PACKAGE_BASENAME}.tar.gz" ]] ; then log "Using boost backup" @@ -393,7 +393,7 @@ unset RECAST_BASENAME # ============================================================================== LIBPNG_VERSION=1.6.37 -LIBPNG_REPO=https://sourceforge.net/projects/libpng/files/libpng16/${LIBPNG_VERSION}/libpng-${LIBPNG_VERSION}.tar.xz +LIBPNG_REPO=https://sourceforge.net/projects/libpng/files/libpng16/older-releases/${LIBPNG_VERSION}/libpng-${LIBPNG_VERSION}.tar.xz LIBPNG_BASENAME=libpng-${LIBPNG_VERSION} LIBPNG_INSTALL=${LIBPNG_BASENAME}-install @@ -422,10 +422,10 @@ else fi # ============================================================================== -# -- Get and compile libxerces 3.2.3 ------------------------------ +# -- Get and compile libxerces 3.3.0 ------------------------------ # ============================================================================== -XERCESC_VERSION=3.2.3 +XERCESC_VERSION=3.3.0 XERCESC_BASENAME=xerces-c-${XERCESC_VERSION} XERCESC_TEMP_FOLDER=${XERCESC_BASENAME} diff --git a/Util/InstallersWin/install_boost.bat b/Util/InstallersWin/install_boost.bat new file mode 100755 index 0000000..c27d6cd --- /dev/null +++ b/Util/InstallersWin/install_boost.bat @@ -0,0 +1,230 @@ +@echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem boost build for CARLA (carla.org). + +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +:arg-parse +if not "%1"=="" ( + if "%1"=="-j" ( + set NUMBER_OF_ASYNC_JOBS=%~2 + shift + ) + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + if "%1"=="--toolset" ( + set TOOLSET=%~2 + shift + ) + if "%1"=="--version" ( + set BOOST_VERSION=%~2 + shift + ) + if "%1"=="-v" ( + set BOOST_VERSION=%~2 + shift + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +if "%BOOST_VERSION%" == "" ( + echo %FILE_N% You must specify a boost version using [-v^|--version] + goto bad_exit +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +rem If not defined, use Visual Studio 2019 as tool set +if "%TOOLSET%" == "" set TOOLSET=msvc-14.2 + +rem If is not set, set the number of parallel jobs to the number of CPU threads +if "%NUMBER_OF_ASYNC_JOBS%" == "" set NUMBER_OF_ASYNC_JOBS=%NUMBER_OF_PROCESSORS% + +rem ============================================================================ +rem -- Local Variables --------------------------------------------------------- +rem ============================================================================ + +set BOOST_BASENAME=boost-%BOOST_VERSION% + +set BOOST_TEMP_FOLDER=boost_%BOOST_VERSION:.=_% +set BOOST_TEMP_FILE=%BOOST_TEMP_FOLDER%.zip +set BOOST_TEMP_FILE_DIR=%BUILD_DIR%%BOOST_TEMP_FILE% + +set BOOST_REPO=https://archives.boost.io/release/%BOOST_VERSION%/source/%BOOST_TEMP_FILE% +set BOOST_SRC_DIR=%BUILD_DIR%%BOOST_BASENAME%-source\ +set BOOST_INSTALL_DIR=%BUILD_DIR%%BOOST_BASENAME%-install\ +set BOOST_LIB_DIR=%BOOST_INSTALL_DIR%lib\ + +rem ============================================================================ +rem -- Get Boost --------------------------------------------------------------- +rem ============================================================================ + +if exist "%BOOST_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%BOOST_SRC_DIR%" ( + if not exist "%BOOST_TEMP_FILE_DIR%" ( + echo %FILE_N% Retrieving boost. + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%BOOST_REPO%', '%BOOST_TEMP_FILE_DIR%')" + ) + if not exist "%BOOST_TEMP_FILE_DIR%" ( + echo %FILE_N% Using Boost backup + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/%BOOST_TEMP_FILE%', '%BOOST_TEMP_FILE_DIR%')" + ) + if %errorlevel% neq 0 goto error_download + echo %FILE_N% Extracting boost from "%BOOST_TEMP_FILE%", this can take a while... + if exist "%ProgramW6432%/7-Zip/7z.exe" ( + "%ProgramW6432%/7-Zip/7z.exe" x "%BOOST_TEMP_FILE_DIR%" -o"%BUILD_DIR%" -y + ) else ( + powershell -Command "Expand-Archive '%BOOST_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%' -Force" + ) + echo %FILE_N% Removing "%BOOST_TEMP_FILE%" + del "%BOOST_TEMP_FILE_DIR%" + rename "%BUILD_DIR%%BOOST_TEMP_FOLDER%" "%BOOST_BASENAME%-source" +) else ( + echo %FILE_N% Not downloading boost because already exists the folder "%BOOST_SRC_DIR%". +) + +cd "%BOOST_SRC_DIR:~0,-1%" +if not exist "b2.exe" ( + echo %FILE_N% Generating build... + call bootstrap.bat vc141 +) + +if %errorlevel% neq 0 goto error_bootstrap + +rem Create user-config.jam to tell Boost where Python is +echo %FILE_N% Detecting Python for Boost.Python... +for /f "delims=" %%i in ('where python 2^>nul') do ( + set PYTHON_PATH=%%i + goto :found_python +) +echo %FILE_N% [WARNING] Python not found in PATH, boost_python will not be built! +goto :skip_python_config + +:found_python +echo %FILE_N% Found Python (shim or exe): %PYTHON_PATH% +rem Get the REAL Python executable path (not the shim) +for /f "delims=" %%p in ('python -c "import sys; print(sys.executable)"') do set PYTHON_REAL_PATH=%%p +echo %FILE_N% Real Python executable: %PYTHON_REAL_PATH% +rem Get Python version (e.g., "Python 3.7.9" -> "3.7") +for /f "tokens=2 delims= " %%a in ('python --version 2^>^&1') do set FULL_PY_VER=%%a +for /f "tokens=1,2 delims=." %%a in ("%FULL_PY_VER%") do set PYTHON_VERSION=%%a.%%b +rem Get Python include and libs directories +for /f "delims=" %%d in ('python -c "import sys; print(sys.prefix)"') do set PYTHON_PREFIX=%%d +set PYTHON_REAL_PATH_FWD=%PYTHON_REAL_PATH:\=/% +set PYTHON_INCLUDE=%PYTHON_PREFIX%\include +set PYTHON_LIBS=%PYTHON_PREFIX%\libs +set PYTHON_INCLUDE_FWD=%PYTHON_INCLUDE:\=/% +set PYTHON_LIBS_FWD=%PYTHON_LIBS:\=/% +echo using python : %PYTHON_VERSION% : "%PYTHON_REAL_PATH_FWD%" : "%PYTHON_INCLUDE_FWD%" : "%PYTHON_LIBS_FWD%" ; > user-config.jam +echo %FILE_N% Created user-config.jam for Python %PYTHON_VERSION% +type user-config.jam + +:skip_python_config + +rem This fix some kind of issue installing headers of boost < 1.67, not installing correctly +rem echo %FILE_N% Packing headers... +rem b2 headers link=static + +echo %FILE_N% Building... +b2 -j%NUMBER_OF_ASYNC_JOBS%^ + headers^ + --user-config=user-config.jam^ + --layout=versioned^ + --build-dir=.\build^ + --with-system^ + --with-filesystem^ + --with-python^ + --with-date_time^ + architecture=x86^ + address-model=64^ + toolset=%TOOLSET%^ + variant=release^ + link=static^ + runtime-link=shared^ + threading=multi^ + --prefix="%BOOST_INSTALL_DIR:~0,-1%"^ + --libdir="%BOOST_LIB_DIR:~0,-1%"^ + --includedir="%BOOST_INSTALL_DIR:~0,-1%"^ + install +if %errorlevel% neq 0 goto error_install + +for /d %%i in ("%BOOST_INSTALL_DIR%boost*") do rename "%%i" include +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo %FILE_N% Download and install a boost version. + echo "Usage: %FILE_N% [-h^|--help] [-v^|--version] [--toolset] [--build-dir] [-j]" + goto eof + +:success + echo. + echo %FILE_N% Boost has been successfully installed in "%BOOST_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A Boost installation already exists. + echo %FILE_N% Delete "%BOOST_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_download + echo. + echo %FILE_N% [GIT ERROR] An error ocurred while downloading boost. + echo %FILE_N% [GIT ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%BOOST_REPO%" + echo %FILE_N% [GIT ERROR] Workaround: + echo %FILE_N% - Download the source code of boost "%BOOST_VERSION%" and + echo %FILE_N% extract the content of "%BOOST_TEMP_FOLDER%" in + echo %FILE_N% "%BOOST_SRC_DIR%" + goto bad_exit + +:error_bootstrap + echo. + echo %FILE_N% [BOOTSTRAP ERROR] An error ocurred while executing "bootstrap.bat". + goto bad_exit + +:error_install + echo. + echo %FILE_N% [B2 ERROR] An error ocurred while installing using "b2.exe". + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + endlocal + rem A return value used for checking for errors + set install_boost=done + exit /b 0 + +:bad_exit + if exist "%BOOST_INSTALL_DIR%" rd /s /q "%BOOST_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_chrono.bat b/Util/InstallersWin/install_chrono.bat new file mode 100755 index 0000000..7ac21fa --- /dev/null +++ b/Util/InstallersWin/install_chrono.bat @@ -0,0 +1,195 @@ +REM @echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem x64 xerces-c build for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +rem ============================================================================ +rem -- Get Eigen (Chrono dependency) ------------------------------------------- +rem ============================================================================ + +set EIGEN_VERSION=3.3.7 +set EIGEN_REPO=https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip +set EIGEN_BASENAME=eigen-%EIGEN_VERSION% + +set EIGEN_SRC_DIR=%BUILD_DIR%%EIGEN_BASENAME% +set EIGEN_INSTALL_DIR=%BUILD_DIR%eigen-install +set EIGEN_INCLUDE=%EIGEN_INSTALL_DIR%\include +set EIGEN_TEMP_FILE=eigen-%EIGEN_VERSION%.zip +set EIGEN_TEMP_FILE_DIR=%BUILD_DIR%eigen-%EIGEN_VERSION%.zip + +if not exist "%EIGEN_INSTALL_DIR%" ( + if not exist "%EIGEN_TEMP_FILE_DIR%" ( + echo %FILE_N% Retrieving %EIGEN_TEMP_FILE_DIR%. + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%EIGEN_REPO%', '%EIGEN_TEMP_FILE_DIR%')" + ) + if %errorlevel% neq 0 goto error_download_eigen + rem Extract the downloaded library + echo %FILE_N% Extracting eigen from "%EIGEN_TEMP_FILE%". + powershell -Command "Expand-Archive '%EIGEN_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'" + if %errorlevel% neq 0 goto error_extracting + echo %EIGEN_SRC_DIR% + + if not exist "%EIGEN_INSTALL_DIR%" ( + mkdir %EIGEN_INSTALL_DIR% + mkdir %EIGEN_INCLUDE% + mkdir %EIGEN_INCLUDE%\unsupported + ) + move "%EIGEN_SRC_DIR%\Eigen" "%EIGEN_INCLUDE%\" + move "%EIGEN_SRC_DIR%\unsupported\Eigen" "%EIGEN_INCLUDE%\unsupported\" + + del %EIGEN_TEMP_FILE_DIR% + echo here1 +) + +rem ============================================================================ +rem -- Get Chrono ------------------------------------------- +rem ============================================================================ + +set CHRONO_VERSION=6.0.0 +@REM set CHRONO_VERSION=develop +set CHRONO_REPO=https://github.com/projectchrono/chrono.git +set CHRONO_BASENAME=chrono + +set CHRONO_SRC_DIR=%BUILD_DIR%%CHRONO_BASENAME%-src +set CHRONO_INSTALL_DIR=%BUILD_DIR%chrono-install +set CHRONO_BUILD_DIR=%CHRONO_SRC_DIR%\build + +if not exist %CHRONO_INSTALL_DIR% ( + echo %FILE_N% Retrieving Chrono. + call git clone --depth 1 --branch %CHRONO_VERSION% %CHRONO_REPO% %CHRONO_SRC_DIR% + + mkdir %CHRONO_BUILD_DIR% + mkdir %CHRONO_INSTALL_DIR% + + cd "%CHRONO_BUILD_DIR%" + + echo %FILE_N% Compiling Chrono. + cmake -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_BUILD_TYPE=Release^ + -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ + -DEIGEN3_INCLUDE_DIR="%EIGEN_INCLUDE%"^ + -DCMAKE_INSTALL_PREFIX="%CHRONO_INSTALL_DIR%"^ + -DENABLE_MODULE_VEHICLE=ON^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + %CHRONO_SRC_DIR% + + echo %FILE_N% Building... + cmake --build . --config Release --target install + +) + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo %FILE_N% Download and install a the Chrono library. + echo "Usage: %FILE_N% [-h^|--help] [--build-dir] [--zlib-install-dir]" + goto eof + +:success + echo. + echo %FILE_N% Chrono has been successfully installed in "%EIGEN_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A xerces installation already exists. + echo %FILE_N% Delete "%EIGEN_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_download_eigen + echo. + echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading xerces. + echo %FILE_N% [DOWNLOAD ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%EIGEN_REPO%" + echo %FILE_N% [DOWNLOAD ERROR] Workaround: + echo %FILE_N% - Download the xerces's source code and + echo %FILE_N% extract the content in + echo %FILE_N% "%EIGEN_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_download_chrono + echo. + echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading xerces. + echo %FILE_N% [DOWNLOAD ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%XERCESC_REPO%" + echo %FILE_N% [DOWNLOAD ERROR] Workaround: + echo %FILE_N% - Download the xerces's source code and + echo %FILE_N% extract the content in + echo %FILE_N% "%EIGEN_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_extracting + echo. + echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. + echo %FILE_N% [EXTRACTING ERROR] Workaround: + echo %FILE_N% - Download the xerces's source code and + echo %FILE_N% extract the content manually in + echo %FILE_N% "%EIGEN_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_compiling + echo. + echo %FILE_N% [COMPILING ERROR] An error ocurred while compiling with cl.exe. + echo %FILE_N% Possible causes: + echo %FILE_N% - Make sure you have Visual Studio installed. + echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo %FILE_N% For example, using the "Visual Studio x64 Native Tools Command Prompt", + echo %FILE_N% or the "vcvarsall.bat". + goto bad_exit + +:error_generating_lib + echo. + echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + rem A return value used for checking for errors + endlocal & set install_chrono=%CHRONO_INSTALL_DIR% + exit /b 0 + +:bad_exit + if exist "%EIGEN_INSTALL_DIR%" rd /s /q "%EIGEN_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_gtest.bat b/Util/InstallersWin/install_gtest.bat new file mode 100755 index 0000000..c938890 --- /dev/null +++ b/Util/InstallersWin/install_gtest.bat @@ -0,0 +1,138 @@ +@echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem Google Test build for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set DEL_SRC=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + + if "%1"=="--delete-src" ( + set DEL_SRC=true + ) + + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +set GT_VERSION=release-1.8.1 +set GT_SRC=gtest-src +set GT_SRC_DIR=%BUILD_DIR%%GT_SRC%\ +set GT_INSTALL=gtest-install +set GT_INSTALL_DIR=%BUILD_DIR%%GT_INSTALL%\ +set GT_BUILD_DIR=%GT_SRC_DIR%build\ + +if exist "%GT_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%GT_SRC_DIR%" ( + echo %FILE_N% Cloning Google Test - version "%GT_VERSION%"... + + call git clone --depth=1 -b "%GT_VERSION%" https://github.com/google/googletest.git "%GT_SRC_DIR:~0,-1%" + if %errorlevel% neq 0 goto error_git +) else ( + echo %FILE_N% Not cloning Google Test because already exists a folder called "%GT_SRC%". +) + +if not exist "%GT_BUILD_DIR%" ( + echo %FILE_N% Creating "%GT_BUILD_DIR%" + mkdir "%GT_BUILD_DIR%" +) + +cd "%GT_BUILD_DIR%" +echo %FILE_N% Generating build... + +cmake .. -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_BUILD_TYPE=Release^ + -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ + -DCMAKE_INSTALL_PREFIX="%GT_INSTALL_DIR:\=/%"^ + -DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + "%GT_SRC_DIR:\=/%" +if %errorlevel% neq 0 goto error_cmake + +echo %FILE_N% Building... +cmake --build . --config Release --target install + +if errorlevel neq 0 goto error_install + +rem Remove the downloaded Google Test source because is no more needed +if %DEL_SRC% == true ( + rd /s /q "%GT_SRC_DIR%" +) + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo. + echo %FILE_N% Google Test has been successfully installed in "%GT_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A Google Test installation already exists. + echo %FILE_N% Delete "%GT_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_git + echo. + echo %FILE_N% [GIT ERROR] An error ocurred while executing the git. + echo %FILE_N% [GIT ERROR] Possible causes: + echo %FILE_N% - Make sure "git" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + goto bad_exit + +:error_cmake + echo. + echo %FILE_N% [CMAKE ERROR] An error ocurred while executing the cmake. + echo %FILE_N% [CMAKE ERROR] Possible causes: + echo %FILE_N% - Make sure "CMake" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + goto bad_exit + +:error_install + echo. + echo %FILE_N% [Visual Studio 16 2019 Win64 ERROR] An error ocurred while installing using Visual Studio 16 2019 Win64. + echo %FILE_N% [Visual Studio 16 2019 Win64 ERROR] Possible causes: + echo %FILE_N% - Make sure you have Visual Studio installed. + echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo %FILE_N% For example using the "Visual Studio x64 Native Tools Command Prompt", + echo %FILE_N% or the "vcvarsall.bat". + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + endlocal + set install_gtest=done + exit /b 0 + +:bad_exit + if exist "%GT_INSTALL_DIR%" rd /s /q "%GT_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_proj.bat b/Util/InstallersWin/install_proj.bat new file mode 100755 index 0000000..f642fe7 --- /dev/null +++ b/Util/InstallersWin/install_proj.bat @@ -0,0 +1,162 @@ +REM @echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem x64 xerces-c build for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +rem ============================================================================ +rem -- Local Variables --------------------------------------------------------- +rem ============================================================================ + +set PROJ_BASE_NAME=proj-7.2.1 +set PROJ_ZIP=%PROJ_BASE_NAME%.tar.gz +set PROJ_ZIP_DIR=%BUILD_DIR%%PROJ_ZIP% +set PROJ_REPO=https://download.osgeo.org/proj/%PROJ_ZIP% + +set SQLITE_INSTALL_DIR=%BUILD_DIR%sqlite3-install +set SQLITE_INCLUDE_DIR=%SQLITE_INSTALL_DIR%\include +set SQLITE_BIN=%SQLITE_INSTALL_DIR%\bin\sqlite.exe +set SQLITE_LIB=%SQLITE_INSTALL_DIR%\lib\sqlite3.lib + +set PROJ_SRC_DIR=%BUILD_DIR%proj-src +set PROJ_BUILD_DIR=%PROJ_SRC_DIR%\build +set PROJ_INSTALL_DIR=%BUILD_DIR%proj-install + +set PROJ_INCLUDE_DIR=%PROJ_INSTALL_DIR%\include +set PROJ_BIN_DIR=%PROJ_INSTALL_DIR%\bin +set PROJ_LIB_DIR=%PROJ_INSTALL_DIR%\lib + +if exist "%PROJ_INSTALL_DIR%" ( + goto already_build +) + +echo %FILE_N% Retrieving %PROJ_BASE_NAME%. +powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%PROJ_REPO%', '%PROJ_ZIP_DIR%')" +if %errorlevel% neq 0 goto error_download + +cd %BUILD_DIR% +echo %FILE_N% Extracting PROJ from "%PROJ_ZIP%". +call tar -xzf %PROJ_ZIP% +move %BUILD_DIR%%PROJ_BASE_NAME% %PROJ_SRC_DIR% + +mkdir %PROJ_BUILD_DIR% +cd %PROJ_BUILD_DIR% + +cmake .. -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ + -DCMAKE_CXX_FLAGS="/MD /MP"^ + -DSQLITE3_INCLUDE_DIR=%SQLITE_INCLUDE_DIR% -DSQLITE3_LIBRARY=%SQLITE_LIB%^ + -DEXE_SQLITE3=%SQLITE_BIN%^ + -DENABLE_TIFF=OFF -DENABLE_CURL=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_PROJSYNC=OFF^ + -DCMAKE_BUILD_TYPE=Release -DBUILD_PROJINFO=OFF^ + -DBUILD_CCT=OFF -DBUILD_CS2CS=OFF -DBUILD_GEOD=OFF -DBUILD_GIE=OFF^ + -DBUILD_PROJ=OFF -DBUILD_TESTING=OFF^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + -DCMAKE_INSTALL_PREFIX=%PROJ_INSTALL_DIR% +if %errorlevel% neq 0 goto error_cmake + +cmake --build . --config Release --target install + +del %PROJ_ZIP_DIR% + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo %FILE_N% Download and install a PROJ. + echo "Usage: %FILE_N% [-h^|--help] [--build-dir] [--zlib-install-dir]" + goto eof + +:success + echo. + echo %FILE_N% PROJ has been successfully installed in "%PROJ_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A PROJ installation already exists. + echo %FILE_N% Delete "%PROJ_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_download + echo. + echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading PROJ. + echo %FILE_N% [DOWNLOAD ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%PROJ_REPO%" + echo %FILE_N% [DOWNLOAD ERROR] Workaround: + echo %FILE_N% - Download the PROJ's source code and + echo %FILE_N% extract the content in + echo %FILE_N% "%PROJ_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_extracting + echo. + echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. + echo %FILE_N% [EXTRACTING ERROR] Workaround: + echo %FILE_N% - Download the PROJ's source code and + echo %FILE_N% extract the content manually in + echo %FILE_N% "%PROJ_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_compiling + echo. + echo %FILE_N% [COMPILING ERROR] An error ocurred while compiling with cl.exe. + echo %FILE_N% Possible causes: + echo %FILE_N% - Make sure you have Visual Studio installed. + echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo %FILE_N% For example, using the "Visual Studio x64 Native Tools Command Prompt", + echo %FILE_N% or the "vcvarsall.bat". + goto bad_exit + +:error_generating_lib + echo. + echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + rem A return value used for checking for errors + endlocal & set install_proj=%PROJ_INSTALL_DIR% + exit /b 0 + +:bad_exit + if exist "%PROJ_INSTALL_DIR%" rd /s /q "%PROJ_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_recast.bat b/Util/InstallersWin/install_recast.bat new file mode 100755 index 0000000..16a9489 --- /dev/null +++ b/Util/InstallersWin/install_recast.bat @@ -0,0 +1,144 @@ +@echo off +setlocal + +rem BAT script that downloads and installs Recast & Detour library +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set DEL_SRC=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + + if "%1"=="--delete-src" ( + set DEL_SRC=true + ) + + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +set RECAST_HASH=0b13b0 +set RECAST_COMMIT=0b13b0d288ac96fdc5347ee38299511c6e9400db +set RECAST_SRC=recast-%RECAST_HASH%-src +set RECAST_SRC_DIR=%BUILD_DIR%%RECAST_SRC%\ +set RECAST_INSTALL=recast-%RECAST_HASH%-install +set RECAST_INSTALL_DIR=%BUILD_DIR%%RECAST_INSTALL%\ +set RECAST_BUILD_DIR=%RECAST_SRC_DIR%build\ +set RECAST_BASENAME=%RECAST_SRC% + +if exist "%RECAST_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%RECAST_SRC_DIR%" ( + echo %FILE_N% Cloning "Recast & Detour" + + call git clone https://github.com/carla-simulator/recastnavigation.git "%RECAST_SRC_DIR:~0,-1%" + cd "%RECAST_SRC_DIR%" + call git reset --hard %RECAST_COMMIT% + cd .. + if %errorlevel% neq 0 goto error_git +) else ( + echo %FILE_N% Not cloning "Recast & Detour" because already exists a folder called "%RECAST_SRC%". +) + +if not exist "%RECAST_BUILD_DIR%" ( + echo %FILE_N% Creating "%RECAST_BUILD_DIR%" + mkdir "%RECAST_BUILD_DIR%" +) + +cd "%RECAST_BUILD_DIR%" +echo %FILE_N% Generating build... + +cmake .. -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_BUILD_TYPE=Release^ + -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ + -DCMAKE_INSTALL_PREFIX="%RECAST_INSTALL_DIR:\=/%"^ + -DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + "%RECAST_SRC_DIR:\=/%" +if %errorlevel% neq 0 goto error_cmake + +echo %FILE_N% Building... +cmake --build . --config Release --target install + +if errorlevel neq 0 goto error_install + +rem Remove the downloaded Recast & Detour source because is no more needed +if %DEL_SRC% == true ( + rd /s /q "%RECAST_SRC_DIR%" +) + +md "%RECAST_INSTALL_DIR%include\recast" +move "%RECAST_INSTALL_DIR%include\*.h" "%RECAST_INSTALL_DIR%include\recast" + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo. + echo %FILE_N% "Recast & Detour" has been successfully installed in "%RECAST_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A "Recast & Detour" installation already exists. + echo %FILE_N% Delete "%RECAST_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_git + echo. + echo %FILE_N% [GIT ERROR] An error ocurred while executing the git. + echo %FILE_N% [GIT ERROR] Possible causes: + echo %FILE_N% - Make sure "git" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + goto bad_exit + +:error_cmake + echo. + echo %FILE_N% [CMAKE ERROR] An error ocurred while executing the cmake. + echo %FILE_N% [CMAKE ERROR] Possible causes: + echo %FILE_N% - Make sure "CMake" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + goto bad_exit + +:error_install + echo. + echo %FILE_N% [Visual Studio 16 2019 Win64 ERROR] An error ocurred while installing using Visual Studio 16 2019 Win64. + echo %FILE_N% [Visual Studio 16 2019 Win64 ERROR] Possible causes: + echo %FILE_N% - Make sure you have Visual Studio installed. + echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo %FILE_N% For example using the "Visual Studio x64 Native Tools Command Prompt", + echo %FILE_N% or the "vcvarsall.bat". + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + endlocal & set install_recast=%RECAST_INSTALL_DIR% + exit /b 0 + +:bad_exit + if exist "%RECAST_INSTALL_DIR%" rd /s /q "%RECAST_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_rpclib.bat b/Util/InstallersWin/install_rpclib.bat new file mode 100755 index 0000000..d2b7444 --- /dev/null +++ b/Util/InstallersWin/install_rpclib.bat @@ -0,0 +1,141 @@ +@echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem rpclib build for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set DEL_SRC=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + + if "%1"=="--delete-src" ( + set DEL_SRC=true + ) + + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +set RPC_VERSION=v2.2.1_c5 +set RPC_SRC=rpclib-src +set RPC_SRC_DIR=%BUILD_DIR%%RPC_SRC%\ +set RPC_INSTALL=rpclib-install +set RPC_INSTALL_DIR=%BUILD_DIR%%RPC_INSTALL%\ +set RPC_BUILD_DIR=%RPC_SRC_DIR%build\ + +set PUSHD_RPC=%RPC_SRC_DIR% + +if exist "%RPC_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%RPC_SRC_DIR%" ( + echo %FILE_N% Cloning rpclib - version "%RPC_VERSION%"... + + echo git clone -b "%RPC_VERSION%" https://github.com/carla-simulator/rpclib.git "%RPC_SRC_DIR:~0,-1%" + call git clone -b "%RPC_VERSION%" https://github.com/carla-simulator/rpclib.git "%RPC_SRC_DIR:~0,-1%" + if %errorlevel% neq 0 goto error_git +) else ( + echo %FILE_N% Not cloning rpclib because already exists a folder called "%RPC_SRC%". +) + +if not exist "%RPC_BUILD_DIR%" ( + echo %FILE_N% Creating "%RPC_BUILD_DIR%" + mkdir "%RPC_BUILD_DIR%" +) + +cd "%RPC_BUILD_DIR%" +echo %FILE_N% Generating build... + +cmake .. -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_BUILD_TYPE=Release^ + -DRPCLIB_BUILD_EXAMPLES=OFF^ + -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ + -DCMAKE_INSTALL_PREFIX="%RPC_INSTALL_DIR:\=/%"^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + "%RPC_SRC_DIR:\=/%" +if %errorlevel% neq 0 goto error_cmake + +echo %FILE_N% Building... +cmake --build . --config Release --target install + +if %errorlevel% neq 0 goto error_install + +rem Remove the downloaded rpclib source because is no more needed +if %DEL_SRC% == true ( + rd /s /q "%RPC_SRC_DIR%" +) + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo. + echo %FILE_N% rpclib has been successfully installed in "%RPC_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A rpclib installation already exists. + echo %FILE_N% Delete "%RPC_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_git + echo. + echo %FILE_N% [GIT ERROR] An error ocurred while executing the git. + echo %FILE_N% [GIT ERROR] Possible causes: + echo %FILE_N% - Make sure "git" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + goto bad_exit + +:error_cmake + echo. + echo %FILE_N% [CMAKE ERROR] An error ocurred while executing the cmake. + echo %FILE_N% [CMAKE ERROR] Possible causes: + echo %FILE_N% - Make sure "CMake" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + echo %FILE_N% - CMake 3.9.0 or higher is required. + goto bad_exit + +:error_install + echo. + echo %FILE_N% [Visual Studio 16 2019 Win64 ERROR] An error ocurred while installing using Visual Studio 16 2019 Win64. + echo %FILE_N% [Visual Studio 16 2019 Win64 ERROR] Possible causes: + echo %FILE_N% - Make sure you have Visual Studio installed. + echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo %FILE_N% For example using the "Visual Studio x64 Native Tools Command Prompt", + echo %FILE_N% or the "vcvarsall.bat". + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + endlocal & set install_rpclib=done + exit /b 0 + +:bad_exit + if exist "%RPC_INSTALL_DIR%" rd /s /q "%RPC_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_xercesc.bat b/Util/InstallersWin/install_xercesc.bat old mode 100644 new mode 100755 index fb5cd51..6eb01e5 --- a/Util/InstallersWin/install_xercesc.bat +++ b/Util/InstallersWin/install_xercesc.bat @@ -1,196 +1,197 @@ -REM @echo off -setlocal - -rem BAT script that downloads and installs a ready to use -rem x64 xerces-c build for CARLA (carla.org). -rem Run it through a cmd with the x64 Visual C++ Toolset enabled. - -set LOCAL_PATH=%~dp0 -set FILE_N= -[%~n0]: - -rem Print batch params (debug purpose) -echo %FILE_N% [Batch params]: %* - -rem ============================================================================ -rem -- Parse arguments --------------------------------------------------------- -rem ============================================================================ - -:arg-parse -if not "%1"=="" ( - if "%1"=="--build-dir" ( - set BUILD_DIR=%~dpn2 - shift - ) - if "%1"=="-h" ( - goto help - ) - if "%1"=="--help" ( - goto help - ) - shift - goto :arg-parse -) - -rem If not set set the build dir to the current dir -if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 -if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ - -rem ============================================================================ -rem -- Local Variables --------------------------------------------------------- -rem ============================================================================ - -set XERCESC_BASENAME=xerces-c -set XERCESC_VERSION=3.2.3 - -rem xerces-c-x.x.x -set XERCESC_TEMP_FOLDER=%XERCESC_BASENAME%-%XERCESC_VERSION% -rem ../xerces-c-x.x.x -set XERCESC_TEMP_FOLDER_DIR=%BUILD_DIR%%XERCESC_TEMP_FOLDER% -rem xerces-c-x.x.x-src.zip -set XERCESC_TEMP_FILE=%XERCESC_TEMP_FOLDER%-src.zip -rem ../xerces-c-x.x.x-src.zip -set XERCESC_TEMP_FILE_DIR=%BUILD_DIR%%XERCESC_TEMP_FILE% - -set XERCESC_REPO=https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-%XERCESC_VERSION%.zip - -rem ../xerces-c-x.x.x-source/ -set XERCESC_SRC_DIR=%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-source\ -rem ../xerces-c-x.x.x-install/ -set XERCESC_INSTALL_DIR=%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-install\ - -rem ============================================================================ -rem -- Get xerces -------------------------------------------------------------- -rem ============================================================================ - -if exist "%XERCESC_INSTALL_DIR%" ( - goto already_build -) - -if not exist "%XERCESC_SRC_DIR%" ( - if not exist "%XERCESC_TEMP_FILE_DIR%" ( - echo %FILE_N% Retrieving %XERCESC_BASENAME%. - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%XERCESC_REPO%', '%XERCESC_TEMP_FILE_DIR%')" - ) - if not exist "%XERCESC_TEMP_FILE_DIR%" ( - echo %FILE_N% Using %XERCESC_BASENAME% from backup. - goto error_download - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/xerces-c-%XERCESC_VERSION%-src.zip', '%XERCESC_TEMP_FILE_DIR%')" - ) - if %errorlevel% neq 0 goto error_download - rem Extract the downloaded library - echo %FILE_N% Extracting xerces from "%XERCESC_TEMP_FILE%". - powershell -Command "Expand-Archive '%XERCESC_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'" - if %errorlevel% neq 0 goto error_extracting - - rem Remove unnecessary files and folders - echo %FILE_N% Removing "%XERCESC_TEMP_FILE%" - del "%XERCESC_TEMP_FILE_DIR%" - echo %FILE_N% Removing dir "%BUILD_DIR%manifest" - rmdir /s/q "%BUILD_DIR%manifest" - - echo %FILE_N% Renaming dir %XERCESC_TEMP_FOLDER_DIR% to %XERCESC_BASENAME%-%XERCESC_VERSION%-source - rename "%XERCESC_TEMP_FOLDER_DIR%" "%XERCESC_BASENAME%-%XERCESC_VERSION%-source" -) else ( - echo %FILE_N% Not downloading xerces because already exists the folder "%XERCESC_SRC_DIR%". -) - -rem ============================================================================ -rem -- Compile xerces ---------------------------------------------------------- -rem ============================================================================ - -if not exist "%XERCESC_SRC_DIR%build" ( - echo %FILE_N% Creating "%XERCESC_SRC_DIR%build" - mkdir "%XERCESC_SRC_DIR%build" -) - -cd "%XERCESC_SRC_DIR%build" - -if not exist "%XERCESC_INSTALL_DIR%lib" ( - echo %FILE_N% Creating "%XERCESC_INSTALL_DIR%lib" - mkdir "%XERCESC_INSTALL_DIR%lib" -) - -if not exist "%XERCESC_INSTALL_DIR%include" ( - echo %FILE_N% Creating "%XERCESC_INSTALL_DIR%include" - mkdir "%XERCESC_INSTALL_DIR%include" -) - -cmake .. -G "Visual Studio 16 2019" -A x64^ - -DCMAKE_INSTALL_PREFIX="%XERCESC_INSTALL_DIR:\=/%"^ - -DBUILD_SHARED_LIBS=OFF^ - -Dtranscoder=windows^ - "%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-source" -if %errorlevel% neq 0 goto error_cmake - -cmake --build . --config Release --target install - -goto success - -rem ============================================================================ -rem -- Messages and Errors ----------------------------------------------------- -rem ============================================================================ - -:help - echo %FILE_N% Download and install a xerces. - echo "Usage: %FILE_N% [-h^|--help] [--build-dir] [--zlib-install-dir]" - goto eof - -:success - echo. - echo %FILE_N% xerces has been successfully installed in "%XERCESC_INSTALL_DIR%"! - goto good_exit - -:already_build - echo %FILE_N% A xerces installation already exists. - echo %FILE_N% Delete "%XERCESC_INSTALL_DIR%" if you want to force a rebuild. - goto good_exit - -:error_download - echo. - echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading xerces. - echo %FILE_N% [DOWNLOAD ERROR] Possible causes: - echo %FILE_N% - Make sure that the following url is valid: - echo %FILE_N% "%XERCESC_REPO%" - echo %FILE_N% [DOWNLOAD ERROR] Workaround: - echo %FILE_N% - Download the xerces's source code and - echo %FILE_N% extract the content in - echo %FILE_N% "%XERCESC_SRC_DIR%" - echo %FILE_N% And re-run the setup script. - goto bad_exit - -:error_extracting - echo. - echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. - echo %FILE_N% [EXTRACTING ERROR] Workaround: - echo %FILE_N% - Download the xerces's source code and - echo %FILE_N% extract the content manually in - echo %FILE_N% "%XERCESC_SRC_DIR%" - echo %FILE_N% And re-run the setup script. - goto bad_exit - -:error_compiling - echo. - echo %FILE_N% [COMPILING ERROR] An error ocurred while compiling with cl.exe. - echo %FILE_N% Possible causes: - echo %FILE_N% - Make sure you have Visual Studio installed. - echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. - echo %FILE_N% For example, using the "Visual Studio x64 Native Tools Command Prompt", - echo %FILE_N% or the "vcvarsall.bat". - goto bad_exit - -:error_generating_lib - echo. - echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. - goto bad_exit - -:good_exit - echo %FILE_N% Exiting... - rem A return value used for checking for errors - endlocal & set install_xerces=%XERCESC_INSTALL_DIR% - exit /b 0 - -:bad_exit - if exist "%XERCESC_INSTALL_DIR%" rd /s /q "%XERCESC_INSTALL_DIR%" - echo %FILE_N% Exiting with error... - endlocal - exit /b %errorlevel% +REM @echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem x64 xerces-c build for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +rem ============================================================================ +rem -- Local Variables --------------------------------------------------------- +rem ============================================================================ + +set XERCESC_BASENAME=xerces-c +set XERCESC_VERSION=3.3.0 + +rem xerces-c-x.x.x +set XERCESC_TEMP_FOLDER=%XERCESC_BASENAME%-%XERCESC_VERSION% +rem ../xerces-c-x.x.x +set XERCESC_TEMP_FOLDER_DIR=%BUILD_DIR%%XERCESC_TEMP_FOLDER% +rem xerces-c-x.x.x-src.zip +set XERCESC_TEMP_FILE=%XERCESC_TEMP_FOLDER%-src.zip +rem ../xerces-c-x.x.x-src.zip +set XERCESC_TEMP_FILE_DIR=%BUILD_DIR%%XERCESC_TEMP_FILE% + +set XERCESC_REPO=https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-%XERCESC_VERSION%.zip + +rem ../xerces-c-x.x.x-source/ +set XERCESC_SRC_DIR=%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-source\ +rem ../xerces-c-x.x.x-install/ +set XERCESC_INSTALL_DIR=%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-install\ + +rem ============================================================================ +rem -- Get xerces -------------------------------------------------------------- +rem ============================================================================ + +if exist "%XERCESC_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%XERCESC_SRC_DIR%" ( + if not exist "%XERCESC_TEMP_FILE_DIR%" ( + echo %FILE_N% Retrieving %XERCESC_BASENAME%. + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%XERCESC_REPO%', '%XERCESC_TEMP_FILE_DIR%')" + ) + if not exist "%XERCESC_TEMP_FILE_DIR%" ( + echo %FILE_N% Using %XERCESC_BASENAME% from backup. + goto error_download + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/xerces-c-%XERCESC_VERSION%-src.zip', '%XERCESC_TEMP_FILE_DIR%')" + ) + if %errorlevel% neq 0 goto error_download + rem Extract the downloaded library + echo %FILE_N% Extracting xerces from "%XERCESC_TEMP_FILE%". + powershell -Command "Expand-Archive '%XERCESC_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'" + if %errorlevel% neq 0 goto error_extracting + + rem Remove unnecessary files and folders + echo %FILE_N% Removing "%XERCESC_TEMP_FILE%" + del "%XERCESC_TEMP_FILE_DIR%" + echo %FILE_N% Removing dir "%BUILD_DIR%manifest" + rmdir /s/q "%BUILD_DIR%manifest" + + echo %FILE_N% Renaming dir %XERCESC_TEMP_FOLDER_DIR% to %XERCESC_BASENAME%-%XERCESC_VERSION%-source + rename "%XERCESC_TEMP_FOLDER_DIR%" "%XERCESC_BASENAME%-%XERCESC_VERSION%-source" +) else ( + echo %FILE_N% Not downloading xerces because already exists the folder "%XERCESC_SRC_DIR%". +) + +rem ============================================================================ +rem -- Compile xerces ---------------------------------------------------------- +rem ============================================================================ + +if not exist "%XERCESC_SRC_DIR%build" ( + echo %FILE_N% Creating "%XERCESC_SRC_DIR%build" + mkdir "%XERCESC_SRC_DIR%build" +) + +cd "%XERCESC_SRC_DIR%build" + +if not exist "%XERCESC_INSTALL_DIR%lib" ( + echo %FILE_N% Creating "%XERCESC_INSTALL_DIR%lib" + mkdir "%XERCESC_INSTALL_DIR%lib" +) + +if not exist "%XERCESC_INSTALL_DIR%include" ( + echo %FILE_N% Creating "%XERCESC_INSTALL_DIR%include" + mkdir "%XERCESC_INSTALL_DIR%include" +) + +cmake .. -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_INSTALL_PREFIX="%XERCESC_INSTALL_DIR:\=/%"^ + -DBUILD_SHARED_LIBS=OFF^ + -Dtranscoder=windows^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + "%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-source" +if %errorlevel% neq 0 goto error_cmake + +cmake --build . --config Release --target install + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo %FILE_N% Download and install a xerces. + echo "Usage: %FILE_N% [-h^|--help] [--build-dir] [--zlib-install-dir]" + goto eof + +:success + echo. + echo %FILE_N% xerces has been successfully installed in "%XERCESC_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A xerces installation already exists. + echo %FILE_N% Delete "%XERCESC_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_download + echo. + echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading xerces. + echo %FILE_N% [DOWNLOAD ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%XERCESC_REPO%" + echo %FILE_N% [DOWNLOAD ERROR] Workaround: + echo %FILE_N% - Download the xerces's source code and + echo %FILE_N% extract the content in + echo %FILE_N% "%XERCESC_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_extracting + echo. + echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. + echo %FILE_N% [EXTRACTING ERROR] Workaround: + echo %FILE_N% - Download the xerces's source code and + echo %FILE_N% extract the content manually in + echo %FILE_N% "%XERCESC_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_compiling + echo. + echo %FILE_N% [COMPILING ERROR] An error ocurred while compiling with cl.exe. + echo %FILE_N% Possible causes: + echo %FILE_N% - Make sure you have Visual Studio installed. + echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo %FILE_N% For example, using the "Visual Studio x64 Native Tools Command Prompt", + echo %FILE_N% or the "vcvarsall.bat". + goto bad_exit + +:error_generating_lib + echo. + echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + rem A return value used for checking for errors + endlocal & set install_xerces=%XERCESC_INSTALL_DIR% + exit /b 0 + +:bad_exit + if exist "%XERCESC_INSTALL_DIR%" rd /s /q "%XERCESC_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_zlib.bat b/Util/InstallersWin/install_zlib.bat old mode 100644 new mode 100755 index 1e4adbc..4d242a9 --- a/Util/InstallersWin/install_zlib.bat +++ b/Util/InstallersWin/install_zlib.bat @@ -1,178 +1,179 @@ -@echo off -setlocal - -rem BAT script that downloads and installs a ready to use -rem x64 zlib build for CARLA (carla.org). -rem Run it through a cmd with the x64 Visual C++ Toolset enabled. - -set MAKEFLAGS= -set LOCAL_PATH=%~dp0 -set FILE_N= -[%~n0]: - -rem Print batch params (debug purpose) -echo %FILE_N% [Batch params]: %* - -rem ============================================================================ -rem -- Parse arguments --------------------------------------------------------- -rem ============================================================================ - -:arg-parse -if not "%1"=="" ( - if "%1"=="--build-dir" ( - set BUILD_DIR=%~dpn2 - shift - ) - if "%1"=="--toolset" ( - set TOOLSET=%~2 - shift - ) - if "%1"=="-h" ( - goto help - ) - if "%1"=="--help" ( - goto help - ) - shift - goto :arg-parse -) - -rem If not set set the build dir to the current dir -if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 -if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ - -rem If not defined, use Visual Studio 2019 as tool set -if "%TOOLSET%" == "" set TOOLSET="" - -rem ============================================================================ -rem -- Local Variables --------------------------------------------------------- -rem ============================================================================ - -set ZLIB_BASENAME=zlib -set ZLIB_VERSION=1.2.11 - -set ZLIB_TEMP_FOLDER=%ZLIB_BASENAME%-%ZLIB_VERSION% -set ZLIB_TEMP_FILE=%ZLIB_TEMP_FOLDER%.zip -set ZLIB_TEMP_FILE_DIR=%BUILD_DIR%%ZLIB_TEMP_FILE% - -set ZLIB_REPO=https://github.com/madler/zlib/archive/refs/tags/v%ZLIB_VERSION%.zip - -set ZLIB_SRC_DIR=%BUILD_DIR%%ZLIB_BASENAME%-source\ -set ZLIB_INSTALL_DIR=%BUILD_DIR%%ZLIB_BASENAME%-install\ - -rem ============================================================================ -rem -- Get zlib --------------------------------------------------------------- -rem ============================================================================ - -if exist "%ZLIB_INSTALL_DIR%" ( - goto already_build -) - -if not exist "%ZLIB_SRC_DIR%" ( - if not exist "%ZLIB_TEMP_FILE_DIR%" ( - echo %FILE_N% Retrieving %ZLIB_BASENAME%. - powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%ZLIB_REPO%', '%ZLIB_TEMP_FILE_DIR%')" - if %errorlevel% neq 0 goto error_download - ) - rem Extract the downloaded library - echo %FILE_N% Extracting zlib from "%ZLIB_TEMP_FILE%". - powershell -Command "Expand-Archive '%ZLIB_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'" - if %errorlevel% neq 0 goto error_extracting - - rem Remove the no longer needed downloaded file - echo %FILE_N% Removing "%ZLIB_TEMP_FILE%" - del "%ZLIB_TEMP_FILE_DIR%" - rename "%BUILD_DIR%%ZLIB_TEMP_FOLDER%" "%ZLIB_BASENAME%-source" -) else ( - echo %FILE_N% Not downloading zlib because already exists the folder "%ZLIB_SRC_DIR%". -) - -if not exist "%ZLIB_SRC_DIR%build" ( - echo %FILE_N% Creating "%ZLIB_SRC_DIR%build" - mkdir "%ZLIB_SRC_DIR%build" -) - -cd "%ZLIB_SRC_DIR%build" - -rem -DCMAKE_BUILD_TYPE=Release^ -rem -DCMAKE_CONFIGURATION_TYPES=Release^ -cmake -G "NMake Makefiles"^ - -DCMAKE_INSTALL_PREFIX="%ZLIB_INSTALL_DIR:\=/%"^ - -DCMAKE_BUILD_TYPE=Release^ - "%ZLIB_SRC_DIR%" -if %errorlevel% neq 0 goto error_cmake - -rem https://stackoverflow.com/questions/601970/how-do-i-utilise-all-the-cores-for-nmake -set CL=/MP - -nmake install -if %errorlevel% neq 0 goto error_install - -goto success - -rem ============================================================================ -rem -- Messages and Errors ----------------------------------------------------- -rem ============================================================================ - -:help - echo %FILE_N% Download and install a zlib. - echo "Usage: %FILE_N% [-h^|--help] [--toolset] [--build-dir]" - goto eof - -:success - echo. - echo %FILE_N% zlib has been successfully installed in "%ZLIB_INSTALL_DIR%"! - goto good_exit - -:already_build - echo %FILE_N% A zlib installation already exists. - echo %FILE_N% Delete "%ZLIB_INSTALL_DIR%" if you want to force a rebuild. - goto good_exit - -:error_download - echo. - echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading zlib. - echo %FILE_N% [DOWNLOAD ERROR] Possible causes: - echo %FILE_N% - Make sure that the following url is valid: - echo %FILE_N% "%ZLIB_REPO%" - echo %FILE_N% [DOWNLOAD ERROR] Workaround: - echo %FILE_N% - Download the zlib's source code and - echo %FILE_N% extract the content in - echo %FILE_N% "%ZLIB_SRC_DIR%" - echo %FILE_N% And re-run the setup script. - goto bad_exit - -:error_extracting - echo. - echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. - echo %FILE_N% [EXTRACTING ERROR] Workaround: - echo %FILE_N% - Download the libpng's source code and - echo %FILE_N% extract the content manually in - echo %FILE_N% "%ZLIB_SRC_DIR%" - echo %FILE_N% And re-run the setup script. - goto bad_exit - -:error_cmake - echo. - echo %FILE_N% [CMAKE ERROR] An error ocurred while executing cmake command. - echo %FILE_N% [CMAKE ERROR] Possible causes: - echo %FILE_N% - Make sure "CMake" is installed. - echo %FILE_N% - Make sure it is available on your Windows "path". - echo %FILE_N% - Make sure you have cmake 3.12.4 or higher installed. - goto bad_exit - -:error_install - echo. - echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. - goto bad_exit - -:good_exit - echo %FILE_N% Exiting... - rem A return value used for checking for errors - endlocal & set install_zlib=%ZLIB_INSTALL_DIR% - exit /b 0 - -:bad_exit - if exist "%ZLIB_INSTALL_DIR%" rd /s /q "%ZLIB_INSTALL_DIR%" - echo %FILE_N% Exiting with error... - endlocal - exit /b %errorlevel% +@echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem x64 zlib build for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set MAKEFLAGS= +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + if "%1"=="--toolset" ( + set TOOLSET=%~2 + shift + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +rem If not defined, use Visual Studio 2019 as tool set +if "%TOOLSET%" == "" set TOOLSET="" + +rem ============================================================================ +rem -- Local Variables --------------------------------------------------------- +rem ============================================================================ + +set ZLIB_BASENAME=zlib +set ZLIB_VERSION=1.2.11 + +set ZLIB_TEMP_FOLDER=%ZLIB_BASENAME%-%ZLIB_VERSION% +set ZLIB_TEMP_FILE=%ZLIB_TEMP_FOLDER%.zip +set ZLIB_TEMP_FILE_DIR=%BUILD_DIR%%ZLIB_TEMP_FILE% + +set ZLIB_REPO=https://github.com/madler/zlib/archive/refs/tags/v%ZLIB_VERSION%.zip + +set ZLIB_SRC_DIR=%BUILD_DIR%%ZLIB_BASENAME%-source\ +set ZLIB_INSTALL_DIR=%BUILD_DIR%%ZLIB_BASENAME%-install\ + +rem ============================================================================ +rem -- Get zlib --------------------------------------------------------------- +rem ============================================================================ + +if exist "%ZLIB_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%ZLIB_SRC_DIR%" ( + if not exist "%ZLIB_TEMP_FILE_DIR%" ( + echo %FILE_N% Retrieving %ZLIB_BASENAME%. + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%ZLIB_REPO%', '%ZLIB_TEMP_FILE_DIR%')" + if %errorlevel% neq 0 goto error_download + ) + rem Extract the downloaded library + echo %FILE_N% Extracting zlib from "%ZLIB_TEMP_FILE%". + powershell -Command "Expand-Archive '%ZLIB_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'" + if %errorlevel% neq 0 goto error_extracting + + rem Remove the no longer needed downloaded file + echo %FILE_N% Removing "%ZLIB_TEMP_FILE%" + del "%ZLIB_TEMP_FILE_DIR%" + rename "%BUILD_DIR%%ZLIB_TEMP_FOLDER%" "%ZLIB_BASENAME%-source" +) else ( + echo %FILE_N% Not downloading zlib because already exists the folder "%ZLIB_SRC_DIR%". +) + +if not exist "%ZLIB_SRC_DIR%build" ( + echo %FILE_N% Creating "%ZLIB_SRC_DIR%build" + mkdir "%ZLIB_SRC_DIR%build" +) + +cd "%ZLIB_SRC_DIR%build" + +rem -DCMAKE_BUILD_TYPE=Release^ +rem -DCMAKE_CONFIGURATION_TYPES=Release^ +cmake -G "NMake Makefiles"^ + -DCMAKE_INSTALL_PREFIX="%ZLIB_INSTALL_DIR:\=/%"^ + -DCMAKE_BUILD_TYPE=Release^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5^ + "%ZLIB_SRC_DIR:~0,-1%" +if %errorlevel% neq 0 goto error_cmake + +rem https://stackoverflow.com/questions/601970/how-do-i-utilise-all-the-cores-for-nmake +set CL=/MP + +nmake install +if %errorlevel% neq 0 goto error_install + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo %FILE_N% Download and install a zlib. + echo "Usage: %FILE_N% [-h^|--help] [--toolset] [--build-dir]" + goto eof + +:success + echo. + echo %FILE_N% zlib has been successfully installed in "%ZLIB_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A zlib installation already exists. + echo %FILE_N% Delete "%ZLIB_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_download + echo. + echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading zlib. + echo %FILE_N% [DOWNLOAD ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%ZLIB_REPO%" + echo %FILE_N% [DOWNLOAD ERROR] Workaround: + echo %FILE_N% - Download the zlib's source code and + echo %FILE_N% extract the content in + echo %FILE_N% "%ZLIB_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_extracting + echo. + echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. + echo %FILE_N% [EXTRACTING ERROR] Workaround: + echo %FILE_N% - Download the libpng's source code and + echo %FILE_N% extract the content manually in + echo %FILE_N% "%ZLIB_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_cmake + echo. + echo %FILE_N% [CMAKE ERROR] An error ocurred while executing cmake command. + echo %FILE_N% [CMAKE ERROR] Possible causes: + echo %FILE_N% - Make sure "CMake" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + echo %FILE_N% - Make sure you have cmake 3.12.4 or higher installed. + goto bad_exit + +:error_install + echo. + echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + rem A return value used for checking for errors + endlocal & set install_zlib=%ZLIB_INSTALL_DIR% + exit /b 0 + +:bad_exit + if exist "%ZLIB_INSTALL_DIR%" rd /s /q "%ZLIB_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel%