Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- FIXED: Work around compilation error due to a false-positive of array-bounds check in sol2 [#7317](https://github.com/Project-OSRM/osrm-backend/pull/7317)
- FIXED: Fix compilation with gcc >14 in release with LTO. [#7268](https://github.com/Project-OSRM/osrm-backend/issues/7268)
- Misc:
- ADDED: `--list-inputs` option to all OSRM tools to list required/optional input file extensions for deployment scripts [#2865](https://github.com/Project-OSRM/osrm-backend/issues/2865)
- ADDED: `--max-header-size` to override the (automatically) configured maximum header size for osrm-routed [#7336](https://github.com/Project-OSRM/osrm-backend/pull/7336)
- CHANGED: Use boost::beast instead of own HTTP code for osrm-routed [#7328](https://github.com/Project-OSRM/osrm-backend/pull/7328)
- ADDED: `SHM_LOCK_DIR` environment variable for shared memory lock file directory [#7312](https://github.com/Project-OSRM/osrm-backend/pull/7312)
Expand Down
18 changes: 18 additions & 0 deletions docs/routed.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## Command Line Options

### --list-inputs

Lists all required and optional input file extensions that the tool expects.
Useful for deployment scripts that need to know which files to copy.

Example:
```
$ osrm-routed --list-inputs
required .osrm.datasource_names
required .osrm.ebg_nodes
required .osrm.edges
...
optional .osrm.hsgr
optional .osrm.cells
```

## Environment Variables

### SHM_LOCK_DIR
Expand Down
17 changes: 17 additions & 0 deletions include/storage/io_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ struct IOConfig

std::filesystem::path base_path;

// Print all required and optional input files to the output stream
void ListInputFiles(std::ostream &out) const
{
for (const auto &file : required_input_files)
{
// Skip empty string (represents OSM input for extractor)
if (!file.empty())
{
out << "required " << file.string() << "\n";
}
}
for (const auto &file : optional_input_files)
{
out << "optional " << file.string() << "\n";
}
}

protected:
// Infer the base path from the path of the .osrm file
void UseDefaultOutputNames(const std::filesystem::path &base)
Expand Down
13 changes: 12 additions & 1 deletion src/tools/contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ return_code parseArguments(int argc,
{
// declare a group of options that will be allowed only on command line
boost::program_options::options_description generic_options("Options");
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
generic_options.add_options()
("version,v", "Show version")
("help,h", "Show this help message")
("list-inputs", "List required and optional input file extensions")(
"verbosity,l",
boost::program_options::value<std::string>(&verbosity)->default_value("INFO"),
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str());
Expand Down Expand Up @@ -120,6 +123,14 @@ return_code parseArguments(int argc,
return return_code::exit;
}

if (option_variables.count("list-inputs"))
{
contractor::ContractorConfig config;
config.ListInputFiles(std::cout);
config.updater_config.ListInputFiles(std::cout);
return return_code::exit;
}

boost::program_options::notify(option_variables);

if (!option_variables.count("input"))
Expand Down
13 changes: 12 additions & 1 deletion src/tools/customize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ return_code parseArguments(int argc,
{
// declare a group of options that will be allowed only on command line
boost::program_options::options_description generic_options("Options");
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
generic_options.add_options()
("version,v", "Show version")
("help,h", "Show this help message")
("list-inputs", "List required and optional input file extensions")(
"verbosity,l",
boost::program_options::value<std::string>(&verbosity)->default_value("INFO"),
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str());
Expand Down Expand Up @@ -120,6 +123,14 @@ return_code parseArguments(int argc,
return return_code::exit;
}

if (option_variables.count("list-inputs"))
{
customizer::CustomizationConfig config;
config.ListInputFiles(std::cout);
config.updater_config.ListInputFiles(std::cout);
return return_code::exit;
}

boost::program_options::notify(option_variables);

if (!option_variables.count("input"))
Expand Down
12 changes: 11 additions & 1 deletion src/tools/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ return_code parseArguments(int argc,
{
// declare a group of options that will be a llowed only on command line
boost::program_options::options_description generic_options("Options");
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
generic_options.add_options()
("version,v", "Show version")
("help,h", "Show this help message")
("list-inputs", "List required and optional input file extensions")(
"verbosity,l",
boost::program_options::value<std::string>(&verbosity)->default_value("INFO"),
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str());
Expand Down Expand Up @@ -134,6 +137,13 @@ return_code parseArguments(int argc,
return return_code::exit;
}

if (option_variables.count("list-inputs"))
{
extractor::ExtractorConfig config;
config.ListInputFiles(std::cout);
return return_code::exit;
}

boost::program_options::notify(option_variables);

if (!option_variables.count("input"))
Expand Down
12 changes: 11 additions & 1 deletion src/tools/partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ return_code parseArguments(int argc,
{
// declare a group of options that will be allowed only on command line
boost::program_options::options_description generic_options("Options");
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
generic_options.add_options()
("version,v", "Show version")
("help,h", "Show this help message")
("list-inputs", "List required and optional input file extensions")(
"verbosity,l",
boost::program_options::value<std::string>(&verbosity)->default_value("INFO"),
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str());
Expand Down Expand Up @@ -163,6 +166,13 @@ return_code parseArguments(int argc,
return return_code::exit;
}

if (option_variables.count("list-inputs"))
{
partitioner::PartitionerConfig config;
config.ListInputFiles(std::cout);
return return_code::exit;
}

boost::program_options::notify(option_variables);

if (!option_variables.count("input"))
Expand Down
8 changes: 8 additions & 0 deletions src/tools/routed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ inline unsigned generateServerProgramOptions(const int argc,
generic_options.add_options() //
("version,v", "Show version") //
("help,h", "Show this help message") //
("list-inputs", "List required and optional input file extensions") //
("verbosity,l",
#ifdef NDEBUG
boost::program_options::value<std::string>(&config.verbosity)->default_value("INFO"),
Expand Down Expand Up @@ -241,6 +242,13 @@ inline unsigned generateServerProgramOptions(const int argc,
return INIT_OK_DO_NOT_START_ENGINE;
}

if (option_variables.count("list-inputs"))
{
storage::StorageConfig storage_config;
storage_config.ListInputFiles(std::cout);
return INIT_OK_DO_NOT_START_ENGINE;
}

boost::program_options::notify(option_variables);

if (max_header_size == 0)
Expand Down
8 changes: 8 additions & 0 deletions src/tools/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ bool generateDataStoreOptions(const int argc,
generic_options.add_options() //
("version,v", "Show version") //
("help,h", "Show this help message") //
("list-inputs", "List required and optional input file extensions") //
("verbosity,l",
boost::program_options::value<std::string>(&verbosity)->default_value("INFO"),
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str()) //
Expand Down Expand Up @@ -208,6 +209,13 @@ bool generateDataStoreOptions(const int argc,
return false;
}

if (option_variables.count("list-inputs"))
{
storage::StorageConfig config;
config.ListInputFiles(std::cout);
return false;
}

if (option_variables.count("remove-locks"))
{
removeLocks();
Expand Down
104 changes: 104 additions & 0 deletions unit_tests/storage/io_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#include "storage/io_config.hpp"

#include <boost/test/unit_test.hpp>

#include <sstream>

BOOST_AUTO_TEST_SUITE(io_config)

using namespace osrm;
using namespace osrm::storage;

// Test helper class to access IOConfig functionality
struct TestConfig : IOConfig
{
TestConfig(std::vector<std::filesystem::path> required,
std::vector<std::filesystem::path> optional)
: IOConfig(std::move(required), std::move(optional), {})
{
}
};

BOOST_AUTO_TEST_CASE(list_input_files_format)
{
TestConfig config({".osrm.ebg", ".osrm.edges"}, {".osrm.hsgr", ".osrm.cells"});

std::ostringstream output;
config.ListInputFiles(output);

std::string result = output.str();

// Check that required files are listed with "required" prefix
BOOST_CHECK(result.find("required .osrm.ebg") != std::string::npos);
BOOST_CHECK(result.find("required .osrm.edges") != std::string::npos);

// Check that optional files are listed with "optional" prefix
BOOST_CHECK(result.find("optional .osrm.hsgr") != std::string::npos);
BOOST_CHECK(result.find("optional .osrm.cells") != std::string::npos);

// Check that each line ends with newline
BOOST_CHECK(result.find("required .osrm.ebg\n") != std::string::npos);
BOOST_CHECK(result.find("optional .osrm.hsgr\n") != std::string::npos);
}

BOOST_AUTO_TEST_CASE(list_input_files_empty_string_skipped)
{
// ExtractorConfig has an empty string as the first required input
// (representing the OSM input file)
TestConfig config({"", ".osrm.ebg"}, {".osrm.hsgr"});

std::ostringstream output;
config.ListInputFiles(output);

std::string result = output.str();

// Empty string should not appear in output
BOOST_CHECK(result.find("required \n") == std::string::npos);

// Other entries should still be present
BOOST_CHECK(result.find("required .osrm.ebg") != std::string::npos);
BOOST_CHECK(result.find("optional .osrm.hsgr") != std::string::npos);
}

BOOST_AUTO_TEST_CASE(list_input_files_empty_lists)
{
TestConfig config({}, {});

std::ostringstream output;
config.ListInputFiles(output);

std::string result = output.str();

// Output should be empty when there are no input files
BOOST_CHECK(result.empty());
}

BOOST_AUTO_TEST_CASE(list_input_files_required_only)
{
TestConfig config({".osrm.ebg", ".osrm.edges"}, {});

std::ostringstream output;
config.ListInputFiles(output);

std::string result = output.str();

BOOST_CHECK(result.find("required .osrm.ebg") != std::string::npos);
BOOST_CHECK(result.find("required .osrm.edges") != std::string::npos);
BOOST_CHECK(result.find("optional") == std::string::npos);
}

BOOST_AUTO_TEST_CASE(list_input_files_optional_only)
{
TestConfig config({}, {".osrm.hsgr", ".osrm.cells"});

std::ostringstream output;
config.ListInputFiles(output);

std::string result = output.str();

BOOST_CHECK(result.find("required") == std::string::npos);
BOOST_CHECK(result.find("optional .osrm.hsgr") != std::string::npos);
BOOST_CHECK(result.find("optional .osrm.cells") != std::string::npos);
}

BOOST_AUTO_TEST_SUITE_END()
Loading