diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a15fb46c223..f235c9c46fe 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,4 +1,5 @@ { + "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "ghcr.io/julialang/devcontainer-features/julia:1": { "channel": "1.7" @@ -11,5 +12,5 @@ "gpu": "optional" }, "privileged": true, - "onCreateCommand": "julia -e 'using Pkg; Pkg.precompile();'" + "onCreateCommand": "julia -e 'using Pkg; Pkg.precompile();'", } diff --git a/O/OpenSourceRoutingMachine/build_tarballs.jl b/O/OpenSourceRoutingMachine/build_tarballs.jl new file mode 100644 index 00000000000..93608c251c3 --- /dev/null +++ b/O/OpenSourceRoutingMachine/build_tarballs.jl @@ -0,0 +1,157 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder, Pkg + +name = "OpenSourceRoutingMachine" +version = v"5.28.0" # UNTAGGED / ASK FOR NEW RELEASE TAG + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/Project-OSRM/osrm-backend.git", "c59ad69d6a081fb0c8fca9fe7bf798d4150ea8d2"), + DirectorySource("./bundled"), + # OSRM requires C++20, which needs a newer SDK + ArchiveSource("https://github.com/realjf/MacOSX-SDKs/releases/download/v0.0.1/MacOSX12.3.sdk.tar.xz", + "a511c1cf1ebfe6fe3b8ec005374b9c05e89ac28b3d4eb468873f59800c02b030"), +] + +sdk_update_script = raw""" +if [[ "${target}" == *-apple-darwin* ]]; then + # Install a newer SDK which supports C++20 + pushd $WORKSPACE/srcdir/MacOSX12.*.sdk + rm -rf /opt/${target}/${target}/sys-root/System + rm -rf /opt/${target}/${target}/sys-root/usr/* + cp -ra usr/* "/opt/${target}/${target}/sys-root/usr/." + cp -ra System "/opt/${target}/${target}/sys-root/." + popd + export MACOSX_DEPLOYMENT_TARGET=12.3 +fi +""" + +# Bash recipe for building across all platforms +script = sdk_update_script * raw""" +cd $WORKSPACE/srcdir/osrm-backend + +# Use boost patch, drop once https://github.com/Project-OSRM/osrm-backend/pull/7073 is merged +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/boost_1_87.patch" + +# Patch CMakeLists.txt +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/cmake_fixes.patch" + +if [[ ${target} == *mingw* ]]; then + atomic_patch -p1 "${WORKSPACE}/srcdir/patches/mingw.patch" + + # oneTBB requires at least Windows Vista/Server 2008: + # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsemaphoreexa + export CXXFLAGS="-D_WIN32_WINNT=0x0600" +fi + +CFLAGS="-Wno-array-bounds -Wno-error=suggest-override -Wno-error=deprecated-declarations -Wno-error=stringop-overflow -Wno-error=uninitialized -Wno-error=array-bounds" +mkdir build && cd build + +export AR=$HOSTAR + +CMAKE_FLAGS=() +CMAKE_FLAGS+=(-DCMAKE_INSTALL_PREFIX=${prefix}) +CMAKE_FLAGS+=(-DCMAKE_BUILD_TYPE=Release) +CMAKE_FLAGS+=(-DBUILD_SHARED_LIBS=ON) +CMAKE_FLAGS+=(-DENABLE_CCACHE=OFF) +CMAKE_FLAGS+=(-Wno-dev) +CMAKE_FLAGS+=(-DENABLE_MASON=OFF) +CMAKE_FLAGS+=(-DZLIB_INCLUDE_DIRS=${includedir}) +CMAKE_FLAGS+=(-DCMAKE_AR=$HOSTAR) +CMAKE_FLAGS+=(-DZLIB_LIBRARY=${libdir}/libz.${dlext}) +CMAKE_FLAGS+=(-DENABLE_LTO=OFF) + +cmake_cxx_flags="-Wno-array-bounds -Wno-error=suggest-override -Wno-error=deprecated-declarations -Wno-error=stringop-overflow -Wno-error=uninitialized -Wno-error=array-bounds" + +if [[ ${target} == *mingw* ]]; then + CMAKE_FLAGS+=(-DLUA_INCLUDE_DIR=${includedir}) + CMAKE_FLAGS+=(-DLUA_LIBRARIES=${libdir}/liblua.${dlext}) + CMAKE_FLAGS+=(-D__TBB_USE_FENV=0) + CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN%.*}_clang.cmake) + + cmake_cxx_flags="-U__STRICT_ANSI__ -Wno-error=-W#warnings ${cmake_cxx_flags}" +else + CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN}) +fi + +CMAKE_FLAGS+=(-DCMAKE_CXX_FLAGS="${cmake_cxx_flags}") + +cmake .. ${CMAKE_FLAGS[@]} +cmake --build . -j${nproc} +cmake --build . -j${nproc} --target install + +cp osrm-* ${bindir} +cp libosrm* ${libdir} + +cp ../profiles/*.lua ${prefix} +cp ../profiles/lib/*.lua ${prefix}/lib + +install_license ../LICENSE.TXT +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +# 32 bit platforms are not supported +# oneTBB_jll isn't available for Windows i686 on Yggdrasil (version 2021.5.0) +# oneTBB_jll isn't available for armv6l, armv7l +# musl builds with lots of TBB errors like 'undefined reference to `getcontext'' +platforms = supported_platforms(; exclude=p -> Sys.iswindows(p) || (nbits(p) == 32)) +platforms = expand_cxxstring_abis(platforms) + +# The products that we will ensure are always built +products = Product[ + ExecutableProduct("osrm-routed", :osrm_routed) + ExecutableProduct("osrm-partition", :osrm_partition) + ExecutableProduct("osrm-components", :osrm_components) + ExecutableProduct("osrm-contract", :osrm_contract) + ExecutableProduct("osrm-customize", :osrm_customize) + ExecutableProduct("osrm-datastore", :osrm_datastore) + ExecutableProduct("osrm-extract", :osrm_extract) + # We are not dlopening because the build images use Julia 1.7, which can't dlopen SOs built + # with GCC 12, which is required for OSRM. However, Julia 1.8+ can dlopen them (tested), + # and that is what our compat entry says, so the dlopen failure can safely be ignored. + LibraryProduct("libosrm", :libosrm, dont_dlopen=true) + FileProduct("bicycle.lua", :bicycle) + FileProduct("debug_way.lua", :debug_way) + FileProduct("test.lua", :test) + FileProduct("car.lua", :car) + FileProduct("rasterbot.lua", :rasterbot) + FileProduct("testbot.lua", :testbot) + FileProduct("debug_example.lua", :debug_example) + FileProduct("foot.lua", :foot) + FileProduct("rasterbotinterp.lua", :rasterbotinterp) + FileProduct("turnbot.lua", :turnbot) + FileProduct("lib/access.lua", :lib_access) + FileProduct("lib/maxspeed.lua", :lib_maxspeed) + FileProduct("lib/profile_debugger.lua", :lib_profile_debugger) + FileProduct("lib/set.lua", :lib_set) + FileProduct("lib/utils.lua", :lib_utils) + FileProduct("lib/destination.lua", :lib_destination) + FileProduct("lib/measure.lua", :lib_measure) + FileProduct("lib/relations.lua", :lib_relations) + FileProduct("lib/tags.lua", :lib_tags) + FileProduct("lib/way_handlers.lua", :lib_way_handlers) + FileProduct("lib/guidance.lua", :lib_guidance) + FileProduct("lib/pprint.lua", :lib_pprint) + FileProduct("lib/sequence.lua", :lib_sequence) + FileProduct("lib/traffic_signal.lua", :lib_traffic_signal) +] + +# Dependencies that must be installed before this package can be built +dependencies = [ + Dependency("Bzip2_jll"; compat="1.0.9") + Dependency("boost_jll"; compat="=1.87.0") # Earlier versions of boost seem uncompatible with C++20 deprecations + Dependency("Expat_jll"; compat="2.6.5") + Dependency("XML2_jll") + Dependency("oneTBB_jll"; compat="2022.0.0") + Dependency("Lua_jll"; compat="~5.4.3") + Dependency("Zlib_jll") + Dependency("Fmt_jll") + HostBuildDependency("Lua_jll") + # Dependency("libosmium_jll") + Dependency("CompilerSupportLibraries_jll"; platforms=filter(!Sys.isbsd, platforms)) +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.8", preferred_gcc_version=v"13", clang_use_lld=false) diff --git a/O/OpenSourceRoutingMachine/bundled/patches/boost_1_87.patch b/O/OpenSourceRoutingMachine/bundled/patches/boost_1_87.patch new file mode 100644 index 00000000000..87699e39ed9 --- /dev/null +++ b/O/OpenSourceRoutingMachine/bundled/patches/boost_1_87.patch @@ -0,0 +1,16 @@ +# Source: https://github.com/Project-OSRM/osrm-backend/pull/7073 +diff --git a/include/server/server.hpp b/include/server/server.hpp +index 34b8982e6..02b0dda05 100644 +--- a/include/server/server.hpp ++++ b/include/server/server.hpp +@@ -53,8 +53,7 @@ class Server + const auto port_string = std::to_string(port); + + boost::asio::ip::tcp::resolver resolver(io_context); +- boost::asio::ip::tcp::resolver::query query(address, port_string); +- boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query); ++ boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(address, port_string).begin(); + + acceptor.open(endpoint.protocol()); + #ifdef SO_REUSEPORT + diff --git a/O/OpenSourceRoutingMachine/bundled/patches/cmake_fixes.patch b/O/OpenSourceRoutingMachine/bundled/patches/cmake_fixes.patch new file mode 100644 index 00000000000..a8854339be8 --- /dev/null +++ b/O/OpenSourceRoutingMachine/bundled/patches/cmake_fixes.patch @@ -0,0 +1,171 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a8388b7db..ffdf31d6d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -147,7 +147,7 @@ configure_file( + ) + file(GLOB UtilGlob src/util/*.cpp src/util/*/*.cpp) + file(GLOB ExtractorGlob src/extractor/*.cpp src/extractor/*/*.cpp) +-file(GLOB GuidanceGlob src/guidance/*.cpp src/extractor/intersection/*.cpp) ++file(GLOB GuidanceGlob src/guidance/*.cpp) + file(GLOB PartitionerGlob src/partitioner/*.cpp) + file(GLOB CustomizerGlob src/customize/*.cpp) + file(GLOB ContractorGlob src/contractor/*.cpp) +@@ -155,7 +155,7 @@ file(GLOB UpdaterGlob src/updater/*.cpp) + file(GLOB StorageGlob src/storage/*.cpp) + file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp) + file(GLOB EngineGlob src/engine/*.cpp src/engine/**/*.cpp) +-file(GLOB ErrorcodesGlob src/osrm/errorcodes.cpp) ++file(GLOB OSRMGlob src/osrm/*.cpp) + + add_library(UTIL OBJECT ${UtilGlob}) + add_library(EXTRACTOR OBJECT ${ExtractorGlob}) +@@ -179,14 +179,20 @@ add_executable(osrm-partition src/tools/partition.cpp) + add_executable(osrm-customize src/tools/customize.cpp) + add_executable(osrm-contract src/tools/contract.cpp) + add_executable(osrm-datastore src/tools/store.cpp $ $) +-add_library(osrm src/osrm/osrm.cpp $ $ $ $) +-add_library(osrm_contract src/osrm/contractor.cpp $ $) +-add_library(osrm_extract src/osrm/extractor.cpp $ $ $) +-add_library(osrm_guidance $ $) +-add_library(osrm_partition src/osrm/partitioner.cpp $ $ $) +-add_library(osrm_customize src/osrm/customizer.cpp $ $ $) +-add_library(osrm_update $ $ $) +-add_library(osrm_store $ $ $) ++add_library(osrm ++ ${OSRMGlob} ++ $ ++ $ ++ $ ++ $ ++ $ ++ $ ++ $ ++ $ ++ $ ++ $ ++ ) ++ + + # Explicitly set the build type to Release if no other type is specified + # on the command line. Without this, cmake defaults to an unoptimized, +@@ -478,86 +484,29 @@ set(BOOST_ENGINE_LIBRARIES + ${BOOST_BASE_LIBRARIES}) + + # Binaries +-target_link_libraries(osrm-datastore osrm_store ${Boost_PROGRAM_OPTIONS_LIBRARY}) +-target_link_libraries(osrm-extract osrm_extract ${Boost_PROGRAM_OPTIONS_LIBRARY}) +-target_link_libraries(osrm-partition osrm_partition ${Boost_PROGRAM_OPTIONS_LIBRARY}) +-target_link_libraries(osrm-customize osrm_customize ${Boost_PROGRAM_OPTIONS_LIBRARY}) +-target_link_libraries(osrm-contract osrm_contract ${Boost_PROGRAM_OPTIONS_LIBRARY}) ++target_link_libraries(osrm-datastore osrm ${Boost_PROGRAM_OPTIONS_LIBRARY}) ++target_link_libraries(osrm-extract osrm ${Boost_PROGRAM_OPTIONS_LIBRARY}) ++target_link_libraries(osrm-partition osrm ${Boost_PROGRAM_OPTIONS_LIBRARY}) ++target_link_libraries(osrm-customize osrm ${Boost_PROGRAM_OPTIONS_LIBRARY}) ++target_link_libraries(osrm-contract osrm ${Boost_PROGRAM_OPTIONS_LIBRARY}) + if (BUILD_ROUTED) + target_link_libraries(osrm-routed osrm ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OPTIONAL_SOCKET_LIBS} ${ZLIB_LIBRARY}) + endif() + +-set(EXTRACTOR_LIBRARIES +- ${BZIP2_LIBRARIES} +- ${BOOST_BASE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${EXPAT_LIBRARIES} +- ${LUA_LIBRARIES} +- ${OSMIUM_LIBRARIES} +- ${TBB_LIBRARIES} +- ${ZLIB_LIBRARY} +- ${MAYBE_COVERAGE_LIBRARIES}) +-set(GUIDANCE_LIBRARIES +- ${BOOST_BASE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${LUA_LIBRARIES} +- ${TBB_LIBRARIES} +- ${MAYBE_COVERAGE_LIBRARIES}) +-set(PARTITIONER_LIBRARIES +- ${BOOST_ENGINE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${TBB_LIBRARIES} +- ${MAYBE_RT_LIBRARY} +- ${MAYBE_COVERAGE_LIBRARIES} +- ${ZLIB_LIBRARY}) +-set(CUSTOMIZER_LIBRARIES +- ${BOOST_ENGINE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${TBB_LIBRARIES} +- ${MAYBE_RT_LIBRARY} +- ${MAYBE_COVERAGE_LIBRARIES}) +-set(UPDATER_LIBRARIES +- ${BOOST_BASE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${TBB_LIBRARIES} +- ${MAYBE_RT_LIBRARY} +- ${MAYBE_COVERAGE_LIBRARIES} +- ${ZLIB_LIBRARY}) +-set(CONTRACTOR_LIBRARIES +- ${BOOST_BASE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${LUA_LIBRARIES} +- ${TBB_LIBRARIES} +- ${MAYBE_RT_LIBRARY} +- ${MAYBE_COVERAGE_LIBRARIES}) +-set(ENGINE_LIBRARIES +- ${BOOST_ENGINE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${TBB_LIBRARIES} +- ${MAYBE_RT_LIBRARY} +- ${MAYBE_COVERAGE_LIBRARIES} +- ${ZLIB_LIBRARY}) +-set(STORAGE_LIBRARIES +- ${BOOST_BASE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${TBB_LIBRARIES} +- ${MAYBE_RT_LIBRARY} +- ${MAYBE_COVERAGE_LIBRARIES}) +-set(UTIL_LIBRARIES +- ${BOOST_BASE_LIBRARIES} +- ${CMAKE_THREAD_LIBS_INIT} +- ${TBB_LIBRARIES} +- ${MAYBE_COVERAGE_LIBRARIES} +- ${ZLIB_LIBRARY}) +- + # Libraries +-target_link_libraries(osrm ${ENGINE_LIBRARIES}) +-target_link_libraries(osrm_update ${UPDATER_LIBRARIES}) +-target_link_libraries(osrm_contract ${CONTRACTOR_LIBRARIES} osrm_update osrm_store) +-target_link_libraries(osrm_extract osrm_guidance ${EXTRACTOR_LIBRARIES}) +-target_link_libraries(osrm_partition ${PARTITIONER_LIBRARIES}) +-target_link_libraries(osrm_customize ${CUSTOMIZER_LIBRARIES} osrm_update osrm_store) +-target_link_libraries(osrm_store ${STORAGE_LIBRARIES}) ++target_link_libraries(osrm ++ ${BZIP2_LIBRARIES} ++ ${Boost_REGEX_LIBRARY} ++ ${BOOST_BASE_LIBRARIES} ++ ${BOOST_ENGINE_LIBRARIES} ++ ${CMAKE_THREAD_LIBS_INIT} ++ ${EXPAT_LIBRARIES} ++ ${LUA_LIBRARIES} ++ ${OSMIUM_LIBRARIES} ++ ${TBB_LIBRARIES} ++ ${MAYBE_RT_LIBRARY} ++ ${ZLIB_LIBRARY} ++ ${MAYBE_COVERAGE_LIBRARIES}) + + # BUILD_COMPONENTS + add_executable(osrm-components src/tools/components.cpp $ $) +@@ -622,14 +571,6 @@ if (BUILD_ROUTED) + install(TARGETS osrm-routed DESTINATION bin) + endif() + install(TARGETS osrm DESTINATION lib) +-install(TARGETS osrm_extract DESTINATION lib) +-install(TARGETS osrm_partition DESTINATION lib) +-install(TARGETS osrm_customize DESTINATION lib) +-install(TARGETS osrm_update DESTINATION lib) +-install(TARGETS osrm_contract DESTINATION lib) +-install(TARGETS osrm_store DESTINATION lib) +-install(TARGETS osrm_guidance DESTINATION lib) +- + + # Install profiles and support library to /usr/local/share/osrm/profiles by default + set(DefaultProfilesDir profiles) diff --git a/O/OpenSourceRoutingMachine/bundled/patches/mingw.patch b/O/OpenSourceRoutingMachine/bundled/patches/mingw.patch new file mode 100644 index 00000000000..7657893d842 --- /dev/null +++ b/O/OpenSourceRoutingMachine/bundled/patches/mingw.patch @@ -0,0 +1,52 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1876d6b85..40eb80443 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -250,12 +250,24 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set(COLOR_FLAG "") + endif() + # using GCC +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${COLOR_FLAG} -fPIC -ftemplate-depth=1024") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${COLOR_FLAG} -fPIC -ftemplate-depth=1024 -Wno-array-bounds") + + if(WIN32) # using mingw + add_dependency_defines(-DWIN32) + set(OPTIONAL_SOCKET_LIBS ws2_32 wsock32) + endif() ++ ++ if (MINGW) ++ set(MINGW_FLAGS "-U__STRICT_ANSI__") ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MINGW_FLAGS}") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MINGW_FLAGS}") ++ set(OSRM_CXXFLAGS "${OSRM_CXXFLAGS} ${MINGW_FLAGS}") ++ add_dependency_defines(-U__STRICT_ANSI__) ++ add_compile_definitions(-U__STRICT_ANSI__) ++ add_compile_definitions(-D_WIN32_WINNT=0x0600) ++ endif() ++ ++ + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + # using Intel C++ + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-intel -wd10237 -Wall -ipo -fPIC") +@@ -266,7 +278,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_dependency_defines(-DBOOST_LIB_DIAGNOSTIC) + add_dependency_defines(-D_CRT_SECURE_NO_WARNINGS) + add_dependency_defines(-DNOMINMAX) # avoid min and max macros that can break compilation +- add_dependency_defines(-D_WIN32_WINNT=0x0501) ++ add_dependency_defines(-D_WIN32_WINNT=0x0600) + add_dependency_defines(-DXML_STATIC) + find_library(ws2_32_LIBRARY_PATH ws2_32) + target_link_libraries(osrm-extract wsock32 ws2_32) +diff --git a/include/util/isatty.hpp b/include/util/isatty.hpp +index 05fbd5aaf..a449356e8 100644 +--- a/include/util/isatty.hpp ++++ b/include/util/isatty.hpp +@@ -5,7 +5,7 @@ + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + #include + #else +-#ifdef WIN32 ++#if defined(__MINGW32__) || defined(__CYGWIN__) + #include + #define isatty _isatty + #define fileno _fileno