From f6676ca8e953cfffccf0a0e7213b165f050dbd8e Mon Sep 17 00:00:00 2001 From: Axel1092 Date: Tue, 28 Jul 2020 11:29:06 +0200 Subject: [PATCH] Cleaned up build files. --- Util/BuildTools/BuildOSM2ODR.bat | 105 ++++++++++++++++++++++++++++--- Util/BuildTools/BuildOSM2ODR.sh | 99 +++++++++++++++++++++++------ Util/BuildTools/Linux.mk | 8 ++- Util/BuildTools/Vars.mk | 3 + Util/BuildTools/Windows.mk | 4 +- Util/OSM2ODR/src/CMakeLists.txt | 20 ------ 6 files changed, 188 insertions(+), 51 deletions(-) diff --git a/Util/BuildTools/BuildOSM2ODR.bat b/Util/BuildTools/BuildOSM2ODR.bat index f5f22e0e1..fe8ae5f77 100644 --- a/Util/BuildTools/BuildOSM2ODR.bat +++ b/Util/BuildTools/BuildOSM2ODR.bat @@ -14,6 +14,44 @@ rem ============================================================================ rem -- Parse arguments --------------------------------------------------------- rem ============================================================================ +set DOC_STRING=Build LibCarla. +set USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--build] [--clean] + +set REMOVE_INTERMEDIATE=false +set BUILD_OSM2ODR=false + +: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"=="--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 --------------------------------------------------------- @@ -24,19 +62,66 @@ rem set OSM2ODR_VSPROJECT_PATH=%INSTALLATION_DIR:/=\%osm2odr-visualstudio\ set OSM2ODR_INSTALL_PATH=%ROOT_PATH:/=\%PythonAPI\carla\dependencies\ -if "%1"=="--rebuild" ( - rmdir "%OSM2ODR_VSPROJECT_PATH%" /s /q +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 + ) + ) ) - if not exist "%OSM2ODR_VSPROJECT_PATH%" mkdir "%OSM2ODR_VSPROJECT_PATH%" cd "%OSM2ODR_VSPROJECT_PATH%" -cmake -G "Visual Studio 15 2017 Win64"^ - -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ - -DCMAKE_INSTALL_PREFIX="%OSM2ODR_INSTALL_PATH:\=/%"^ - "%ROOT_PATH%\Util\OSM2ODR" -cmake --build . --config Release --target install | findstr /V "Up-to-date:" +rem Build OSM2ODR +if %BUILD_OSM2ODR% == true ( + cmake -G "Visual Studio 15 2017 Win64"^ + -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^ + -DCMAKE_INSTALL_PREFIX="%OSM2ODR_INSTALL_PATH:\=/%"^ + "%ROOT_PATH%\Util\OSM2ODR" + if %errorlevel% neq 0 goto error_cmake -endlocal -exit /b 0 \ No newline at end of file + 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 15 2017 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 cf599d18b..078c00e1a 100755 --- a/Util/BuildTools/BuildOSM2ODR.sh +++ b/Util/BuildTools/BuildOSM2ODR.sh @@ -2,26 +2,89 @@ source $(dirname "$0")/Environment.sh -# define clang compiler -export CC=/usr/bin/clang-8 -export CXX=/usr/bin/clang++-8 +function get_source_code_checksum { + local EXCLUDE='*__pycache__*' + find "${OSM2ODR_ROOT_FOLDER}"/* \! -path "${EXCLUDE}" -print0 | sha1sum | awk '{print $1}' +} -OSM2ODR_BASE_DIR=${CARLA_ROOT_FOLDER}/Util/OSM2ODR -OSM2ODR_BUILD_DIR=${CARLA_ROOT_FOLDER}/Build/osm2odr-build -OSM2ODR_BIN_DIR=${OSM2ODR_BASE_DIR}/bin -[ ! -d ${OSM2ODR_BUILD_DIR} ] && mkdir ${OSM2ODR_BUILD_DIR} +DOC_STRING="Build OSM2ODR." -cd ${OSM2ODR_BUILD_DIR} +USAGE_STRING=$(cat <<- END +Usage: $0 [-h|--help] -case $1 in - --rebuild) - rm -r * || true - ;; -esac +commands -cmake ${OSM2ODR_BASE_DIR} \ - -G "Eclipse CDT4 - Ninja" \ - -DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_CLIENT_FOLDER} + [--clean] Clean intermediate files. + [--rebuild] Clean and rebuild both configurations. +END +) -ninja osm2odr -ninja install +REMOVE_INTERMEDIATE=false +BUILD_OSM2ODR=false + +OPTS=`getopt -o h --long help,rebuild,build,clean -n 'parse-options' -- "$@"` + +if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi + +eval set -- "$OPTS" + +while true; do + case $1 in + --rebuild ) + REMOVE_INTERMEDIATE=true; + BUILD_OSM2ODR=true; + shift ;; + --build ) + BUILD_OSM2ODR=true; + shift ;; + --clean ) + REMOVE_INTERMEDIATE=true; + shift ;; + -h | --help ) + echo "$DOC_STRING" + echo "$USAGE_STRING" + exit 1 + ;; + * ) + break ;; + esac +done + +if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_OSM2ODR}; }; then + fatal_error "Nothing selected to be done." +fi + +# ============================================================================== +# -- Clean intermediate files -------------------------------------------------- +# ============================================================================== + +if ${REMOVE_INTERMEDIATE} ; then + + log "Cleaning intermediate files and folders." + + rm -Rf ${OSM2ODR_BUILD_FOLDER}* + +fi + +# ============================================================================== +# -- Build library ------------------------------------------------------------- +# ============================================================================== + +if ${BUILD_OSM2ODR} ; then + + [ ! -d ${OSM2ODR_BUILD_FOLDER} ] && mkdir ${OSM2ODR_BUILD_FOLDER} + cd ${OSM2ODR_BUILD_FOLDER} + # define clang compiler + export CC=/usr/bin/clang-8 + export CXX=/usr/bin/clang++-8 + + cmake ${OSM2ODR_ROOT_FOLDER} \ + -G "Eclipse CDT4 - Ninja" \ + -DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_CLIENT_FOLDER} + + ninja osm2odr + ninja install + +fi + +log "Success!" diff --git a/Util/BuildTools/Linux.mk b/Util/BuildTools/Linux.mk index a30c71dde..781aa848f 100644 --- a/Util/BuildTools/Linux.mk +++ b/Util/BuildTools/Linux.mk @@ -28,15 +28,19 @@ clean.PythonAPI: @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --clean clean.CarlaUE4Editor: @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --clean -clean: clean.CarlaUE4Editor clean.PythonAPI clean.LibCarla +clean.osm2odr: + @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.sh --clean +clean: clean.CarlaUE4Editor clean.PythonAPI clean.LibCarla clean.osm2odr rebuild: setup @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --rebuild + @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.sh --rebuild @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --rebuild @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --rebuild hard-clean: @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --hard-clean + @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.sh --clean @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --clean @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --clean @echo "To force recompiling dependencies run: rm -Rf ${CARLA_BUILD_FOLDER}" @@ -151,4 +155,4 @@ build.utils: PythonAPI @${CARLA_BUILD_TOOLS_FOLDER}/BuildUtilsDocker.sh osm2odr: - @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.sh $(ARGS) \ No newline at end of file + @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.sh --build \ No newline at end of file diff --git a/Util/BuildTools/Vars.mk b/Util/BuildTools/Vars.mk index ead230c9d..2a5563496 100644 --- a/Util/BuildTools/Vars.mk +++ b/Util/BuildTools/Vars.mk @@ -19,6 +19,9 @@ LIBCARLA_BUILD_CLIENT_FOLDER=${CARLA_BUILD_FOLDER}/libcarla-client-build LIBCARLA_INSTALL_SERVER_FOLDER=${CARLAUE4_PLUGIN_ROOT_FOLDER}/CarlaDependencies LIBCARLA_INSTALL_CLIENT_FOLDER=${CARLA_PYTHONAPI_SOURCE_FOLDER}/dependencies +OSM2ODR_ROOT_FOLDER=${CURDIR}/Util/OSM2ODR +OSM2ODR_BUILD_FOLDER=${CARLA_BUILD_FOLDER}/libosm2dr-build + CARLAUE4_PLUGIN_DEPS_FOLDER=${CARLAUE4_PLUGIN_ROOT_FOLDER}/CarlaDependencies LIBSTDCPP_TOOLCHAIN_FILE=${CARLA_BUILD_FOLDER}/LibStdCppToolChain.cmake diff --git a/Util/BuildTools/Windows.mk b/Util/BuildTools/Windows.mk index 93493307b..d02b5a847 100644 --- a/Util/BuildTools/Windows.mk +++ b/Util/BuildTools/Windows.mk @@ -42,10 +42,12 @@ clean: @"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --clean @"${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat" --clean @"${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat" --clean + @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.bat --clean rebuild: setup @"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --clean @"${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat" --rebuild + @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.bat --rebuild @"${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat" --rebuild check: PythonAPI @@ -79,4 +81,4 @@ deploy: @"${CARLA_BUILD_TOOLS_FOLDER}/Deploy.bat" $(ARGS) osm2odr: - @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.bat $(ARGS) \ No newline at end of file + @${CARLA_BUILD_TOOLS_FOLDER}/BuildOSM2ODR.bat --build \ No newline at end of file diff --git a/Util/OSM2ODR/src/CMakeLists.txt b/Util/OSM2ODR/src/CMakeLists.txt index c972b5f1d..e39165378 100644 --- a/Util/OSM2ODR/src/CMakeLists.txt +++ b/Util/OSM2ODR/src/CMakeLists.txt @@ -1,24 +1,4 @@ -set(netconvertlibs - netwrite netimport netbuild foreign_eulerspiral ${GDAL_LIBRARY} netimport_vissim netimport_vissim_typeloader netimport_vissim_tempstructs ${commonlibs}) - -#add_subdirectory(foreign) -#add_subdirectory(netbuild) -#add_subdirectory(netimport) -#add_subdirectory(netwrite) -#add_subdirectory(utils) - -#add_executable(netconvert netconvert_main.cpp) -#set_target_properties(netconvert PROPERTIES OUTPUT_NAME netconvert${BINARY_SUFFIX}) -#set_target_properties(netconvert PROPERTIES OUTPUT_NAME_DEBUG netconvert${BINARY_SUFFIX}D) -#target_link_libraries(netconvert ${netconvertlibs}) -#add_dependencies(netconvert generate-version-h) - -#install(TARGETS netconvert RUNTIME DESTINATION bin) - set(osm2odr_sources "OSM2ODR.cpp") -#add_library(osm2odr STATIC ${osm2odr_sources}) -#target_link_libraries(osm2odr ${netconvertlibs}) -#install(TARGETS osm2odr ARCHIVE DESTINATION lib) configure_file(config.h.cmake config.h)