Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d6c27762c | |||
| 2596a9354f | |||
| 8ae9abaa63 | |||
| d3638ace59 | |||
| c2f877eb9d | |||
| 825132eec7 | |||
| 7436835244 | |||
| eb15e5bde4 | |||
| 51c7421ebc | |||
| bc56a1f8e6 | |||
| 4f36d2dce1 | |||
| 772f9ccc21 | |||
| 85eb7a9383 | |||
| 9457f36f49 | |||
| 37f5780472 | |||
| d985459696 | |||
| edffbae777 | |||
| 77477a86dd | |||
| eba856af17 | |||
| c9b8462754 | |||
| a7956f65ca | |||
| 38bd6b547d | |||
| 926a6c1849 | |||
| aa1b47c596 | |||
| 9003881a77 | |||
| f1ad997a4b | |||
| 20708b0ff8 | |||
| 995eaec555 | |||
| beaaa597d4 | |||
| 96e90ce321 | |||
| 7f7aa3dc2c | |||
| 9fff420a1a | |||
| b04f3200b1 | |||
| 5cf37a0c7c | |||
| 59cbb08c0e | |||
| 9b88056062 | |||
| 3808617142 | |||
| 32dffeb54d | |||
| 3f14453f5b | |||
| 3ba8001807 | |||
| 6960bd42c5 | |||
| 699ac31383 | |||
| 797db7a097 | |||
| 63c9d599f9 | |||
| 6faa5f45e8 | |||
| 86d4db97ca | |||
| 844685102d | |||
| 97bd968b2a | |||
| 80eb71ded5 |
+1
-1
@@ -46,9 +46,9 @@ Thumbs.db
|
||||
/example/build/
|
||||
/test/data/monaco.osrm*
|
||||
/test/data/ch
|
||||
/test/data/corech
|
||||
/test/data/mld
|
||||
/cmake/postinst
|
||||
/target
|
||||
|
||||
# Eclipse related files #
|
||||
#########################
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
- NodeJS:
|
||||
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
|
||||
- Misc:
|
||||
- CHANGED: Use thread_local instead of boost::thread_specific_ptr. [#6991](https://github.com/Project-OSRM/osrm-backend/pull/6991)
|
||||
- CHANGED: Bump flatbuffers to v24.3.25 version. [#6988](https://github.com/Project-OSRM/osrm-backend/pull/6988)
|
||||
- CHANGED: Add .reserve(...) to assembleGeometry function. [#6983](https://github.com/Project-OSRM/osrm-backend/pull/6983)
|
||||
- CHANGED: Get rid of boost::optional leftovers. [#6977](https://github.com/Project-OSRM/osrm-backend/pull/6977)
|
||||
- CHANGED: Use Link Time Optimisation whenever possible. [#6967](https://github.com/Project-OSRM/osrm-backend/pull/6967)
|
||||
|
||||
@@ -133,6 +133,7 @@ endif()
|
||||
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
||||
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/generated/include/)
|
||||
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sol2/include)
|
||||
|
||||
set(BOOST_COMPONENTS date_time iostreams program_options thread unit_test_framework)
|
||||
|
||||
Generated
+2582
File diff suppressed because it is too large
Load Diff
+37
@@ -0,0 +1,37 @@
|
||||
[package]
|
||||
name = "osrm-backend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cheap-ruler = "0.4.0"
|
||||
chksum-md5 = "0.0.0"
|
||||
clap = "4.5.7"
|
||||
colored = "2.1.0"
|
||||
cucumber = { version = "0.21.1", features = ["tracing"] }
|
||||
flatbuffers = "24.3.25"
|
||||
futures = "0.3.30"
|
||||
geo-types = "0.7.13"
|
||||
help = "0.0.0"
|
||||
log = "0.4.21"
|
||||
reqwest = {version = "0.12.5", features = ["blocking"] }
|
||||
serde = { version = "1.0.203", features = ["serde_derive"] }
|
||||
serde_json = "1.0.118"
|
||||
xml-builder = "0.5.2"
|
||||
|
||||
[[test]]
|
||||
name = "cucumber"
|
||||
harness = false
|
||||
|
||||
[profile.bench]
|
||||
debug = true
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
||||
[build-dependencies]
|
||||
flatc-rust = "0.2.0"
|
||||
reqwest = {version = "0.12.5", features = ["blocking"] }
|
||||
serde = { version = "1.0.203", features = ["serde_derive"] }
|
||||
toml = "0.8.14"
|
||||
zip-extract = "0.1.3"
|
||||
@@ -0,0 +1,117 @@
|
||||
use std::env;
|
||||
use std::fmt::Display;
|
||||
use std::io::Cursor;
|
||||
use std::path::PathBuf;
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
macro_rules! build_println {
|
||||
($($tokens: tt)*) => {
|
||||
println!("cargo:warning=\r\x1b[32;1m {}", format!($($tokens)*))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum OS {
|
||||
Mac,
|
||||
MacIntel,
|
||||
Linux,
|
||||
Windows,
|
||||
}
|
||||
|
||||
impl Display for OS {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum DependencyValue {
|
||||
String(String),
|
||||
Object {
|
||||
version: String,
|
||||
features: Vec<String>,
|
||||
},
|
||||
}
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct CargoToml {
|
||||
dependencies: HashMap<String, DependencyValue>,
|
||||
}
|
||||
|
||||
let cargo_toml_raw = include_str!("Cargo.toml");
|
||||
let cargo_toml: CargoToml = toml::from_str(cargo_toml_raw).unwrap();
|
||||
|
||||
let version = match cargo_toml
|
||||
.dependencies
|
||||
.get("flatbuffers")
|
||||
.expect("Must have dependency flatbuffers")
|
||||
{
|
||||
DependencyValue::String(s) => s,
|
||||
DependencyValue::Object {
|
||||
version,
|
||||
features: _,
|
||||
} => version,
|
||||
};
|
||||
|
||||
let executable_path = match env::consts::OS {
|
||||
"windows" => "target/flatc.exe",
|
||||
_ => "target/flatc",
|
||||
};
|
||||
|
||||
if let Some((platform, compiler)) = match env::consts::OS {
|
||||
"linux" if env::consts::ARCH == "x86_64" => Some((OS::Linux, ".clang++-15")),
|
||||
"macos" if env::consts::ARCH == "x86_64" => Some((OS::MacIntel, "")),
|
||||
"macos" if env::consts::ARCH == "aarch64" => Some((OS::Mac, "")),
|
||||
"windows" if env::consts::ARCH == "x86_64" => Some((OS::Windows, "")),
|
||||
_ => None,
|
||||
} {
|
||||
let url = format!("https://github.com/google/flatbuffers/releases/download/v{version}/{platform}.flatc.binary{compiler}.zip");
|
||||
|
||||
if !Path::new(executable_path).exists() {
|
||||
build_println!("Downloading flatc executable from {url}");
|
||||
let response = match reqwest::blocking::get(url) {
|
||||
Ok(response) => response,
|
||||
Err(e) => panic!("network error during build: {e}"),
|
||||
};
|
||||
let archive = match response.bytes() {
|
||||
Ok(archive) => archive,
|
||||
Err(e) => panic!("could not retrieve byte stream during build: {e}"),
|
||||
};
|
||||
let target_dir = PathBuf::from("target");
|
||||
zip_extract::extract(Cursor::new(archive), &target_dir, true)
|
||||
.expect("flatc cannot be unpacked")
|
||||
} else {
|
||||
build_println!("cached flatc executable found, not downloading");
|
||||
}
|
||||
} else {
|
||||
build_println!("unsupported platform: {} {}. 'flatc' binary supporting version {} of the library needs to be in system path", env::consts::OS, env::consts::ARCH, version);
|
||||
}
|
||||
|
||||
let (flatc, location) = match Path::new(executable_path).exists() {
|
||||
true => (flatc_rust::Flatc::from_path(executable_path), "downloaded"),
|
||||
false => (flatc_rust::Flatc::from_env_path(), "locally installed"),
|
||||
};
|
||||
assert!(flatc.check().is_ok());
|
||||
let version = &flatc.version().unwrap();
|
||||
build_println!(
|
||||
"Using {location} flatc v{} to compile schema files ({executable_path})",
|
||||
version.version()
|
||||
);
|
||||
flatc
|
||||
.run(flatc_rust::Args {
|
||||
extra: &["--gen-all"],
|
||||
inputs: &[
|
||||
Path::new("generated/include/engine/api/flatbuffers/position.fbs"),
|
||||
Path::new("generated/include/engine/api/flatbuffers/waypoint.fbs"),
|
||||
Path::new("generated/include/engine/api/flatbuffers/route.fbs"),
|
||||
Path::new("generated/include/engine/api/flatbuffers/table.fbs"),
|
||||
Path::new("generated/include/engine/api/flatbuffers/fbresult.fbs"),
|
||||
],
|
||||
out_dir: Path::new("target/flatbuffers/"),
|
||||
..Default::default()
|
||||
})
|
||||
.expect("flatc failed generating files");
|
||||
}
|
||||
+1
-1
@@ -200,7 +200,7 @@ curl 'http://router.project-osrm.org/nearest/v1/driving/13.388860,52.517037?numb
|
||||
Finds the fastest route between coordinates in the supplied order.
|
||||
|
||||
```endpoint
|
||||
GET /route/v1/{profile}/{coordinates}?alternatives={true|false|number}&steps={true|false}&geometries={polyline|polyline6|geojson}&overview={full|simplified|false}&annotations={true|false}
|
||||
GET /route/v1/{profile}/{coordinates}?alternatives={true|false|number}&steps={true|false}&geometries={polyline|polyline6|geojson}&overview={full|simplified|false}&annotations={true|false}&continue_straight={default|true|false}
|
||||
```
|
||||
|
||||
In addition to the [general options](#general-options) the following options are supported for this service:
|
||||
|
||||
@@ -60,5 +60,5 @@ Feature: Car - Handle driving
|
||||
When I route I should get
|
||||
| from | to | route | modes | speed | turns |
|
||||
| a | g | abc,cde,efg,efg | driving,driving,driving,driving | 7 km/h | depart,new name right,new name left,arrive |
|
||||
| c | e | cde,cde | driving,driving | 2 km/h | depart,arrive |
|
||||
| e | c | cde,cde | driving,driving | 2 km/h | depart,arrive |
|
||||
| c | e | cde,cde | driving,driving | 2.4 km/h | depart,arrive |
|
||||
| e | c | cde,cde | driving,driving | 2.4 km/h | depart,arrive |
|
||||
|
||||
@@ -113,12 +113,12 @@ Feature: Car - Destination only, no passing through
|
||||
Scenario: Car - Routing around a way that becomes destination only
|
||||
Given the node map
|
||||
"""
|
||||
a---c---b
|
||||
+ \
|
||||
+ |
|
||||
d |
|
||||
1 |
|
||||
\___e
|
||||
a---c---b
|
||||
+ \
|
||||
+ |
|
||||
d |
|
||||
1 |
|
||||
\___e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
@@ -136,12 +136,12 @@ Feature: Car - Destination only, no passing through
|
||||
Scenario: Car - Routing through a parking lot tagged access=destination,service
|
||||
Given the node map
|
||||
"""
|
||||
a----c++++b+++g------h---i
|
||||
| + + + /
|
||||
| + + + /
|
||||
| + + + /
|
||||
| d++++e+f /
|
||||
z--------------y
|
||||
a----c++++b+++g------h---i
|
||||
| + + + /
|
||||
| + + + /
|
||||
| + + + /
|
||||
| d++++e+f /
|
||||
z--------------y
|
||||
"""
|
||||
|
||||
And the ways
|
||||
@@ -165,12 +165,12 @@ Feature: Car - Destination only, no passing through
|
||||
Given a grid size of 20 meters
|
||||
Given the node map
|
||||
"""
|
||||
a---c---b
|
||||
:
|
||||
x
|
||||
:
|
||||
d
|
||||
\__e
|
||||
a---c---b
|
||||
:
|
||||
x
|
||||
:
|
||||
d
|
||||
\__e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
|
||||
@@ -1061,7 +1061,7 @@ Feature: Collapse
|
||||
# i
|
||||
# """
|
||||
|
||||
And the node locations
|
||||
Given the node locations
|
||||
| node | lat | lon | #id |
|
||||
| a | -33.9644254 | 151.1378673 | 33226063 |
|
||||
| b | -33.9644373 | 151.1377172 | 1072787030 |
|
||||
|
||||
@@ -9,7 +9,7 @@ Feature: Basic Roundabout
|
||||
"""
|
||||
|
||||
Scenario: Roundabout exit counting for left sided driving
|
||||
And a grid size of 10 meters
|
||||
Given a grid size of 10 meters
|
||||
And the node map
|
||||
"""
|
||||
a
|
||||
@@ -33,7 +33,7 @@ Feature: Basic Roundabout
|
||||
| a,h | ab,gh,gh | depart,roundabout turn right exit-3,arrive |
|
||||
|
||||
Scenario: Mixed Entry and Exit
|
||||
And a grid size of 10 meters
|
||||
Given a grid size of 10 meters
|
||||
And the node map
|
||||
"""
|
||||
c a
|
||||
|
||||
@@ -46,7 +46,7 @@ class OSRMBaseLoader{
|
||||
let retry = (err) => {
|
||||
if (err) {
|
||||
if (retryCount < this.scope.OSRM_CONNECTION_RETRIES) {
|
||||
const timeoutMs = 10 * Math.pow(this.scope.OSRM_CONNECTION_EXP_BACKOFF_COEF, retryCount);
|
||||
const timeoutMs = 10 * Math.pow(1.1, retryCount);
|
||||
retryCount++;
|
||||
setTimeout(() => { tryConnect(this.scope.OSRM_IP, this.scope.OSRM_PORT, retry); }, timeoutMs);
|
||||
} else {
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
@prepare @options @help
|
||||
Feature: osrm-contract command line options: help
|
||||
|
||||
Scenario: osrm-contract - Help should be shown when no options are passed
|
||||
When I try to run "osrm-contract"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-contract(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--core"
|
||||
And stdout should contain "--segment-speed-file"
|
||||
And it should exit with an error
|
||||
|
||||
Scenario: osrm-contract - Help, short
|
||||
When I run "osrm-contract -h"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-contract(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--core"
|
||||
And stdout should contain "--segment-speed-file"
|
||||
And it should exit successfully
|
||||
|
||||
Scenario: osrm-contract - Help, long
|
||||
When I run "osrm-contract --help"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-contract(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--core"
|
||||
And stdout should contain "--segment-speed-file"
|
||||
And it should exit successfully
|
||||
@@ -1,38 +0,0 @@
|
||||
@contract @options @help
|
||||
Feature: osrm-customize command line options: help
|
||||
|
||||
Scenario: osrm-customize - Help should be shown when no options are passed
|
||||
When I try to run "osrm-customize"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-customize(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And it should exit with an error
|
||||
|
||||
Scenario: osrm-customize - Help, short
|
||||
When I run "osrm-customize -h"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-customize(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And it should exit successfully
|
||||
|
||||
Scenario: osrm-customize - Help, long
|
||||
When I run "osrm-customize --help"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-customize(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And it should exit successfully
|
||||
@@ -33,10 +33,6 @@ Feature: osrm-datastore command line options
|
||||
When I try to run "osrm-datastore {processed_file} --dataset-name cucumber/only_metric_test --only-metric"
|
||||
Then it should exit successfully
|
||||
|
||||
Scenario: osrm-datastore - Displaying help should work
|
||||
When I try to run "osrm-datastore {processed_file} --help"
|
||||
Then it should exit successfully
|
||||
|
||||
Scenario: osrm-datastore - Errors on invalid path
|
||||
When I try to run "osrm-datastore invalid_path.osrm"
|
||||
Then stderr should contain "[error] Config contains invalid file paths."
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
@extract @options @help
|
||||
Feature: osrm-extract command line options: help
|
||||
|
||||
Background:
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: osrm-extract - Help should be shown when no options are passed
|
||||
When I run "osrm-extract"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-extract(.exe)? <input.osm/.osm.bz2/.osm.pbf> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--profile"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--small-component-size"
|
||||
And it should exit successfully
|
||||
|
||||
Scenario: osrm-extract - Help, short
|
||||
When I run "osrm-extract -h"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-extract(.exe)? <input.osm/.osm.bz2/.osm.pbf> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--profile"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--small-component-size"
|
||||
And it should exit successfully
|
||||
|
||||
Scenario: osrm-extract - Help, long
|
||||
When I run "osrm-extract --help"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-extract(.exe)? <input.osm/.osm.bz2/.osm.pbf> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--profile"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--small-component-size"
|
||||
And it should exit successfully
|
||||
@@ -1,53 +0,0 @@
|
||||
@partition @options @help
|
||||
Feature: osrm-partition command line options: help
|
||||
|
||||
Scenario: osrm-partition - Help should be shown when no options are passed
|
||||
When I try to run "osrm-partition"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-partition(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--balance"
|
||||
And stdout should contain "--boundary"
|
||||
And stdout should contain "--optimizing-cuts"
|
||||
And stdout should contain "--small-component-size"
|
||||
And stdout should contain "--max-cell-sizes"
|
||||
And it should exit with an error
|
||||
|
||||
Scenario: osrm-partition - Help, short
|
||||
When I run "osrm-partition -h"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-partition(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--balance"
|
||||
And stdout should contain "--boundary"
|
||||
And stdout should contain "--optimizing-cuts"
|
||||
And stdout should contain "--small-component-size"
|
||||
And stdout should contain "--max-cell-sizes"
|
||||
And it should exit successfully
|
||||
|
||||
Scenario: osrm-partition - Help, long
|
||||
When I run "osrm-partition --help"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-partition(.exe)? <input.osrm> \[options\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--balance"
|
||||
And stdout should contain "--boundary"
|
||||
And stdout should contain "--optimizing-cuts"
|
||||
And stdout should contain "--small-component-size"
|
||||
And stdout should contain "--max-cell-sizes"
|
||||
And it should exit successfully
|
||||
@@ -1,71 +0,0 @@
|
||||
@routed @options @help
|
||||
Feature: osrm-routed command line options: help
|
||||
|
||||
Background:
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: osrm-routed - Help should be shown when no options are passed
|
||||
When I run "osrm-routed"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-routed(.exe)? <base.osrm> \[<options>\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "--trial"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--ip"
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--shared-memory"
|
||||
And stdout should contain "--max-viaroute-size"
|
||||
And stdout should contain "--max-trip-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-matching-size"
|
||||
And stdout should contain "--default-radius"
|
||||
And stdout should contain "--keepalive-timeout"
|
||||
And it should exit successfully
|
||||
|
||||
Scenario: osrm-routed - Help, short
|
||||
When I run "osrm-routed -h"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-routed(.exe)? <base.osrm> \[<options>\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "--trial"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--ip"
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--shared-memory"
|
||||
And stdout should contain "--max-viaroute-size"
|
||||
And stdout should contain "--max-trip-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-matching-size"
|
||||
And stdout should contain "--default-radius"
|
||||
And stdout should contain "--keepalive-timeout"
|
||||
And it should exit successfully
|
||||
|
||||
Scenario: osrm-routed - Help, long
|
||||
When I run "osrm-routed --help"
|
||||
Then stderr should be empty
|
||||
And stdout should contain /osrm-routed(.exe)? <base.osrm> \[<options>\]:/
|
||||
And stdout should contain "Options:"
|
||||
And stdout should contain "--version"
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--verbosity"
|
||||
And stdout should contain "--trial"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--ip"
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--shared-memory"
|
||||
And stdout should contain "--max-trip-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-matching-size"
|
||||
And stdout should contain "--default-radius"
|
||||
And stdout should contain "--keepalive-timeout"
|
||||
And it should exit successfully
|
||||
@@ -75,7 +75,7 @@ Feature: Avoid weird loops caused by rounding errors
|
||||
|
||||
@412 @via
|
||||
Scenario: Avoid weird loops 3
|
||||
And the node map
|
||||
Given the node map
|
||||
"""
|
||||
a
|
||||
b e
|
||||
|
||||
@@ -136,22 +136,6 @@ Feature: Basic Map Matching
|
||||
| trace | matchings |
|
||||
| abcbd | abbd |
|
||||
|
||||
Scenario: Testbot - Map matching with core factor
|
||||
Given the contract extra arguments "--core 0.8"
|
||||
Given the node map
|
||||
"""
|
||||
a b c d
|
||||
e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | oneway |
|
||||
| abcd | no |
|
||||
|
||||
When I match I should get
|
||||
| trace | timestamps | matchings |
|
||||
| abcd | 0 1 2 3 | abcd |
|
||||
|
||||
Scenario: Testbot - Map matching with small distortion
|
||||
Given the node map
|
||||
"""
|
||||
|
||||
@@ -401,12 +401,12 @@ Feature: Snapping at intersections
|
||||
Given the extract extra arguments "--small-component-size=4"
|
||||
|
||||
And the ways
|
||||
| nodes | oneway |
|
||||
| ab | no |
|
||||
| bc | no |
|
||||
| cd | no |
|
||||
| fed | no |
|
||||
| bg | yes | # small SCC
|
||||
| nodes | oneway | # comment |
|
||||
| ab | no | |
|
||||
| bc | no | |
|
||||
| cd | no | |
|
||||
| fed | no | |
|
||||
| bg | yes | small SCC |
|
||||
|
||||
And the relations
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
@@ -437,14 +437,14 @@ Feature: Snapping at intersections
|
||||
Given the extract extra arguments "--small-component-size=4"
|
||||
|
||||
And the ways
|
||||
| nodes | oneway |
|
||||
| ab | no |
|
||||
| bc | no |
|
||||
| cd | no |
|
||||
| fed | no |
|
||||
| ghi | no |
|
||||
| jkl | no |
|
||||
| bm | yes | # small SCC
|
||||
| nodes | oneway | # comment |
|
||||
| ab | no | |
|
||||
| bc | no | |
|
||||
| cd | no | |
|
||||
| fed | no | |
|
||||
| ghi | no | |
|
||||
| jkl | no | |
|
||||
| bm | yes | small SCC |
|
||||
|
||||
And the relations
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
|
||||
@@ -65,32 +65,6 @@ Feature: Via points
|
||||
| waypoints | route | turns |
|
||||
| 1,2,3 | cd,ac,ab,bd,cd | depart,new name right,new name right,new name right,arrive |
|
||||
|
||||
Scenario: Simple via point with core factor
|
||||
Given the contract extra arguments "--core 0.8"
|
||||
Given the node map
|
||||
"""
|
||||
a b c d
|
||||
e f g
|
||||
h i
|
||||
j
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| abcd |
|
||||
| efg |
|
||||
| hi |
|
||||
| be |
|
||||
| cfh |
|
||||
| dgij |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route |
|
||||
| a,b,c | abcd,abcd,abcd,abcd |
|
||||
| c,b,a | abcd,abcd,abcd,abcd |
|
||||
| a,d,j | abcd,abcd,dgij,dgij |
|
||||
| j,d,a | dgij,dgij,abcd,abcd |
|
||||
|
||||
Scenario: Via point at a dead end
|
||||
Given the node map
|
||||
"""
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ table FBResult {
|
||||
data_version: string;
|
||||
waypoints: [Waypoint]; //Used as 'sources' waypoints for a 'Table' service
|
||||
routes: [RouteObject];
|
||||
table: Table;
|
||||
table: TableResult;
|
||||
}
|
||||
|
||||
root_type FBResult;
|
||||
@@ -0,0 +1,249 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_FBRESULT_OSRM_ENGINE_API_FBRESULT_H_
|
||||
#define FLATBUFFERS_GENERATED_FBRESULT_OSRM_ENGINE_API_FBRESULT_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 25,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
#include "route_generated.h"
|
||||
#include "table_generated.h"
|
||||
|
||||
namespace osrm {
|
||||
namespace engine {
|
||||
namespace api {
|
||||
namespace fbresult {
|
||||
|
||||
struct Error;
|
||||
struct ErrorBuilder;
|
||||
|
||||
struct FBResult;
|
||||
struct FBResultBuilder;
|
||||
|
||||
struct Error FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef ErrorBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_CODE = 4,
|
||||
VT_MESSAGE = 6
|
||||
};
|
||||
const ::flatbuffers::String *code() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_CODE);
|
||||
}
|
||||
const ::flatbuffers::String *message() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_MESSAGE);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_CODE) &&
|
||||
verifier.VerifyString(code()) &&
|
||||
VerifyOffset(verifier, VT_MESSAGE) &&
|
||||
verifier.VerifyString(message()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct ErrorBuilder {
|
||||
typedef Error Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_code(::flatbuffers::Offset<::flatbuffers::String> code) {
|
||||
fbb_.AddOffset(Error::VT_CODE, code);
|
||||
}
|
||||
void add_message(::flatbuffers::Offset<::flatbuffers::String> message) {
|
||||
fbb_.AddOffset(Error::VT_MESSAGE, message);
|
||||
}
|
||||
explicit ErrorBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Error> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Error>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Error> CreateError(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::String> code = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> message = 0) {
|
||||
ErrorBuilder builder_(_fbb);
|
||||
builder_.add_message(message);
|
||||
builder_.add_code(code);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<Error> CreateErrorDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *code = nullptr,
|
||||
const char *message = nullptr) {
|
||||
auto code__ = code ? _fbb.CreateString(code) : 0;
|
||||
auto message__ = message ? _fbb.CreateString(message) : 0;
|
||||
return osrm::engine::api::fbresult::CreateError(
|
||||
_fbb,
|
||||
code__,
|
||||
message__);
|
||||
}
|
||||
|
||||
struct FBResult FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef FBResultBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_ERROR = 4,
|
||||
VT_CODE = 6,
|
||||
VT_DATA_VERSION = 8,
|
||||
VT_WAYPOINTS = 10,
|
||||
VT_ROUTES = 12,
|
||||
VT_TABLE = 14
|
||||
};
|
||||
bool error() const {
|
||||
return GetField<uint8_t>(VT_ERROR, 0) != 0;
|
||||
}
|
||||
const osrm::engine::api::fbresult::Error *code() const {
|
||||
return GetPointer<const osrm::engine::api::fbresult::Error *>(VT_CODE);
|
||||
}
|
||||
const ::flatbuffers::String *data_version() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_DATA_VERSION);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>> *waypoints() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>> *>(VT_WAYPOINTS);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::RouteObject>> *routes() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::RouteObject>> *>(VT_ROUTES);
|
||||
}
|
||||
const osrm::engine::api::fbresult::TableResult *table() const {
|
||||
return GetPointer<const osrm::engine::api::fbresult::TableResult *>(VT_TABLE);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_ERROR, 1) &&
|
||||
VerifyOffset(verifier, VT_CODE) &&
|
||||
verifier.VerifyTable(code()) &&
|
||||
VerifyOffset(verifier, VT_DATA_VERSION) &&
|
||||
verifier.VerifyString(data_version()) &&
|
||||
VerifyOffset(verifier, VT_WAYPOINTS) &&
|
||||
verifier.VerifyVector(waypoints()) &&
|
||||
verifier.VerifyVectorOfTables(waypoints()) &&
|
||||
VerifyOffset(verifier, VT_ROUTES) &&
|
||||
verifier.VerifyVector(routes()) &&
|
||||
verifier.VerifyVectorOfTables(routes()) &&
|
||||
VerifyOffset(verifier, VT_TABLE) &&
|
||||
verifier.VerifyTable(table()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBResultBuilder {
|
||||
typedef FBResult Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_error(bool error) {
|
||||
fbb_.AddElement<uint8_t>(FBResult::VT_ERROR, static_cast<uint8_t>(error), 0);
|
||||
}
|
||||
void add_code(::flatbuffers::Offset<osrm::engine::api::fbresult::Error> code) {
|
||||
fbb_.AddOffset(FBResult::VT_CODE, code);
|
||||
}
|
||||
void add_data_version(::flatbuffers::Offset<::flatbuffers::String> data_version) {
|
||||
fbb_.AddOffset(FBResult::VT_DATA_VERSION, data_version);
|
||||
}
|
||||
void add_waypoints(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>>> waypoints) {
|
||||
fbb_.AddOffset(FBResult::VT_WAYPOINTS, waypoints);
|
||||
}
|
||||
void add_routes(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::RouteObject>>> routes) {
|
||||
fbb_.AddOffset(FBResult::VT_ROUTES, routes);
|
||||
}
|
||||
void add_table(::flatbuffers::Offset<osrm::engine::api::fbresult::TableResult> table) {
|
||||
fbb_.AddOffset(FBResult::VT_TABLE, table);
|
||||
}
|
||||
explicit FBResultBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<FBResult> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<FBResult>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<FBResult> CreateFBResult(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
bool error = false,
|
||||
::flatbuffers::Offset<osrm::engine::api::fbresult::Error> code = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> data_version = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>>> waypoints = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::RouteObject>>> routes = 0,
|
||||
::flatbuffers::Offset<osrm::engine::api::fbresult::TableResult> table = 0) {
|
||||
FBResultBuilder builder_(_fbb);
|
||||
builder_.add_table(table);
|
||||
builder_.add_routes(routes);
|
||||
builder_.add_waypoints(waypoints);
|
||||
builder_.add_data_version(data_version);
|
||||
builder_.add_code(code);
|
||||
builder_.add_error(error);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<FBResult> CreateFBResultDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
bool error = false,
|
||||
::flatbuffers::Offset<osrm::engine::api::fbresult::Error> code = 0,
|
||||
const char *data_version = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>> *waypoints = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<osrm::engine::api::fbresult::RouteObject>> *routes = nullptr,
|
||||
::flatbuffers::Offset<osrm::engine::api::fbresult::TableResult> table = 0) {
|
||||
auto data_version__ = data_version ? _fbb.CreateString(data_version) : 0;
|
||||
auto waypoints__ = waypoints ? _fbb.CreateVector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>>(*waypoints) : 0;
|
||||
auto routes__ = routes ? _fbb.CreateVector<::flatbuffers::Offset<osrm::engine::api::fbresult::RouteObject>>(*routes) : 0;
|
||||
return osrm::engine::api::fbresult::CreateFBResult(
|
||||
_fbb,
|
||||
error,
|
||||
code,
|
||||
data_version__,
|
||||
waypoints__,
|
||||
routes__,
|
||||
table);
|
||||
}
|
||||
|
||||
inline const osrm::engine::api::fbresult::FBResult *GetFBResult(const void *buf) {
|
||||
return ::flatbuffers::GetRoot<osrm::engine::api::fbresult::FBResult>(buf);
|
||||
}
|
||||
|
||||
inline const osrm::engine::api::fbresult::FBResult *GetSizePrefixedFBResult(const void *buf) {
|
||||
return ::flatbuffers::GetSizePrefixedRoot<osrm::engine::api::fbresult::FBResult>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyFBResultBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<osrm::engine::api::fbresult::FBResult>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedFBResultBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<osrm::engine::api::fbresult::FBResult>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishFBResultBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<osrm::engine::api::fbresult::FBResult> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedFBResultBuffer(
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<osrm::engine::api::fbresult::FBResult> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
} // namespace fbresult
|
||||
} // namespace api
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_FBRESULT_OSRM_ENGINE_API_FBRESULT_H_
|
||||
@@ -0,0 +1,51 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_POSITION_OSRM_ENGINE_API_FBRESULT_H_
|
||||
#define FLATBUFFERS_GENERATED_POSITION_OSRM_ENGINE_API_FBRESULT_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 25,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace osrm {
|
||||
namespace engine {
|
||||
namespace api {
|
||||
namespace fbresult {
|
||||
|
||||
struct Position;
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Position FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
float longitude_;
|
||||
float latitude_;
|
||||
|
||||
public:
|
||||
Position()
|
||||
: longitude_(0),
|
||||
latitude_(0) {
|
||||
}
|
||||
Position(float _longitude, float _latitude)
|
||||
: longitude_(::flatbuffers::EndianScalar(_longitude)),
|
||||
latitude_(::flatbuffers::EndianScalar(_latitude)) {
|
||||
}
|
||||
float longitude() const {
|
||||
return ::flatbuffers::EndianScalar(longitude_);
|
||||
}
|
||||
float latitude() const {
|
||||
return ::flatbuffers::EndianScalar(latitude_);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Position, 8);
|
||||
|
||||
} // namespace fbresult
|
||||
} // namespace api
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_POSITION_OSRM_ENGINE_API_FBRESULT_H_
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,7 +1,7 @@
|
||||
include "waypoint.fbs";
|
||||
namespace osrm.engine.api.fbresult;
|
||||
|
||||
table Table {
|
||||
table TableResult {
|
||||
durations: [float];
|
||||
rows: ushort;
|
||||
cols: ushort;
|
||||
@@ -0,0 +1,149 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_TABLE_OSRM_ENGINE_API_FBRESULT_H_
|
||||
#define FLATBUFFERS_GENERATED_TABLE_OSRM_ENGINE_API_FBRESULT_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 25,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
#include "waypoint_generated.h"
|
||||
|
||||
namespace osrm {
|
||||
namespace engine {
|
||||
namespace api {
|
||||
namespace fbresult {
|
||||
|
||||
struct TableResult;
|
||||
struct TableResultBuilder;
|
||||
|
||||
struct TableResult FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef TableResultBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_DURATIONS = 4,
|
||||
VT_ROWS = 6,
|
||||
VT_COLS = 8,
|
||||
VT_DISTANCES = 10,
|
||||
VT_DESTINATIONS = 12,
|
||||
VT_FALLBACK_SPEED_CELLS = 14
|
||||
};
|
||||
const ::flatbuffers::Vector<float> *durations() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<float> *>(VT_DURATIONS);
|
||||
}
|
||||
uint16_t rows() const {
|
||||
return GetField<uint16_t>(VT_ROWS, 0);
|
||||
}
|
||||
uint16_t cols() const {
|
||||
return GetField<uint16_t>(VT_COLS, 0);
|
||||
}
|
||||
const ::flatbuffers::Vector<float> *distances() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<float> *>(VT_DISTANCES);
|
||||
}
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>> *destinations() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>> *>(VT_DESTINATIONS);
|
||||
}
|
||||
const ::flatbuffers::Vector<uint32_t> *fallback_speed_cells() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint32_t> *>(VT_FALLBACK_SPEED_CELLS);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_DURATIONS) &&
|
||||
verifier.VerifyVector(durations()) &&
|
||||
VerifyField<uint16_t>(verifier, VT_ROWS, 2) &&
|
||||
VerifyField<uint16_t>(verifier, VT_COLS, 2) &&
|
||||
VerifyOffset(verifier, VT_DISTANCES) &&
|
||||
verifier.VerifyVector(distances()) &&
|
||||
VerifyOffset(verifier, VT_DESTINATIONS) &&
|
||||
verifier.VerifyVector(destinations()) &&
|
||||
verifier.VerifyVectorOfTables(destinations()) &&
|
||||
VerifyOffset(verifier, VT_FALLBACK_SPEED_CELLS) &&
|
||||
verifier.VerifyVector(fallback_speed_cells()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TableResultBuilder {
|
||||
typedef TableResult Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_durations(::flatbuffers::Offset<::flatbuffers::Vector<float>> durations) {
|
||||
fbb_.AddOffset(TableResult::VT_DURATIONS, durations);
|
||||
}
|
||||
void add_rows(uint16_t rows) {
|
||||
fbb_.AddElement<uint16_t>(TableResult::VT_ROWS, rows, 0);
|
||||
}
|
||||
void add_cols(uint16_t cols) {
|
||||
fbb_.AddElement<uint16_t>(TableResult::VT_COLS, cols, 0);
|
||||
}
|
||||
void add_distances(::flatbuffers::Offset<::flatbuffers::Vector<float>> distances) {
|
||||
fbb_.AddOffset(TableResult::VT_DISTANCES, distances);
|
||||
}
|
||||
void add_destinations(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>>> destinations) {
|
||||
fbb_.AddOffset(TableResult::VT_DESTINATIONS, destinations);
|
||||
}
|
||||
void add_fallback_speed_cells(::flatbuffers::Offset<::flatbuffers::Vector<uint32_t>> fallback_speed_cells) {
|
||||
fbb_.AddOffset(TableResult::VT_FALLBACK_SPEED_CELLS, fallback_speed_cells);
|
||||
}
|
||||
explicit TableResultBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<TableResult> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<TableResult>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<TableResult> CreateTableResult(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<float>> durations = 0,
|
||||
uint16_t rows = 0,
|
||||
uint16_t cols = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<float>> distances = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>>> destinations = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<uint32_t>> fallback_speed_cells = 0) {
|
||||
TableResultBuilder builder_(_fbb);
|
||||
builder_.add_fallback_speed_cells(fallback_speed_cells);
|
||||
builder_.add_destinations(destinations);
|
||||
builder_.add_distances(distances);
|
||||
builder_.add_durations(durations);
|
||||
builder_.add_cols(cols);
|
||||
builder_.add_rows(rows);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<TableResult> CreateTableResultDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const std::vector<float> *durations = nullptr,
|
||||
uint16_t rows = 0,
|
||||
uint16_t cols = 0,
|
||||
const std::vector<float> *distances = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>> *destinations = nullptr,
|
||||
const std::vector<uint32_t> *fallback_speed_cells = nullptr) {
|
||||
auto durations__ = durations ? _fbb.CreateVector<float>(*durations) : 0;
|
||||
auto distances__ = distances ? _fbb.CreateVector<float>(*distances) : 0;
|
||||
auto destinations__ = destinations ? _fbb.CreateVector<::flatbuffers::Offset<osrm::engine::api::fbresult::Waypoint>>(*destinations) : 0;
|
||||
auto fallback_speed_cells__ = fallback_speed_cells ? _fbb.CreateVector<uint32_t>(*fallback_speed_cells) : 0;
|
||||
return osrm::engine::api::fbresult::CreateTableResult(
|
||||
_fbb,
|
||||
durations__,
|
||||
rows,
|
||||
cols,
|
||||
distances__,
|
||||
destinations__,
|
||||
fallback_speed_cells__);
|
||||
}
|
||||
|
||||
} // namespace fbresult
|
||||
} // namespace api
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_TABLE_OSRM_ENGINE_API_FBRESULT_H_
|
||||
@@ -0,0 +1,205 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_WAYPOINT_OSRM_ENGINE_API_FBRESULT_H_
|
||||
#define FLATBUFFERS_GENERATED_WAYPOINT_OSRM_ENGINE_API_FBRESULT_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 24 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 25,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
#include "position_generated.h"
|
||||
|
||||
namespace osrm {
|
||||
namespace engine {
|
||||
namespace api {
|
||||
namespace fbresult {
|
||||
|
||||
struct Uint64Pair;
|
||||
|
||||
struct Waypoint;
|
||||
struct WaypointBuilder;
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Uint64Pair FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
uint64_t first_;
|
||||
uint64_t second_;
|
||||
|
||||
public:
|
||||
Uint64Pair()
|
||||
: first_(0),
|
||||
second_(0) {
|
||||
}
|
||||
Uint64Pair(uint64_t _first, uint64_t _second)
|
||||
: first_(::flatbuffers::EndianScalar(_first)),
|
||||
second_(::flatbuffers::EndianScalar(_second)) {
|
||||
}
|
||||
uint64_t first() const {
|
||||
return ::flatbuffers::EndianScalar(first_);
|
||||
}
|
||||
uint64_t second() const {
|
||||
return ::flatbuffers::EndianScalar(second_);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Uint64Pair, 16);
|
||||
|
||||
struct Waypoint FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef WaypointBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_HINT = 4,
|
||||
VT_DISTANCE = 6,
|
||||
VT_NAME = 8,
|
||||
VT_LOCATION = 10,
|
||||
VT_NODES = 12,
|
||||
VT_MATCHINGS_INDEX = 14,
|
||||
VT_WAYPOINT_INDEX = 16,
|
||||
VT_ALTERNATIVES_COUNT = 18,
|
||||
VT_TRIPS_INDEX = 20
|
||||
};
|
||||
const ::flatbuffers::String *hint() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_HINT);
|
||||
}
|
||||
float distance() const {
|
||||
return GetField<float>(VT_DISTANCE, 0.0f);
|
||||
}
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
const osrm::engine::api::fbresult::Position *location() const {
|
||||
return GetStruct<const osrm::engine::api::fbresult::Position *>(VT_LOCATION);
|
||||
}
|
||||
const osrm::engine::api::fbresult::Uint64Pair *nodes() const {
|
||||
return GetStruct<const osrm::engine::api::fbresult::Uint64Pair *>(VT_NODES);
|
||||
}
|
||||
uint32_t matchings_index() const {
|
||||
return GetField<uint32_t>(VT_MATCHINGS_INDEX, 0);
|
||||
}
|
||||
uint32_t waypoint_index() const {
|
||||
return GetField<uint32_t>(VT_WAYPOINT_INDEX, 0);
|
||||
}
|
||||
uint32_t alternatives_count() const {
|
||||
return GetField<uint32_t>(VT_ALTERNATIVES_COUNT, 0);
|
||||
}
|
||||
uint32_t trips_index() const {
|
||||
return GetField<uint32_t>(VT_TRIPS_INDEX, 0);
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_HINT) &&
|
||||
verifier.VerifyString(hint()) &&
|
||||
VerifyField<float>(verifier, VT_DISTANCE, 4) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyField<osrm::engine::api::fbresult::Position>(verifier, VT_LOCATION, 4) &&
|
||||
VerifyField<osrm::engine::api::fbresult::Uint64Pair>(verifier, VT_NODES, 8) &&
|
||||
VerifyField<uint32_t>(verifier, VT_MATCHINGS_INDEX, 4) &&
|
||||
VerifyField<uint32_t>(verifier, VT_WAYPOINT_INDEX, 4) &&
|
||||
VerifyField<uint32_t>(verifier, VT_ALTERNATIVES_COUNT, 4) &&
|
||||
VerifyField<uint32_t>(verifier, VT_TRIPS_INDEX, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct WaypointBuilder {
|
||||
typedef Waypoint Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_hint(::flatbuffers::Offset<::flatbuffers::String> hint) {
|
||||
fbb_.AddOffset(Waypoint::VT_HINT, hint);
|
||||
}
|
||||
void add_distance(float distance) {
|
||||
fbb_.AddElement<float>(Waypoint::VT_DISTANCE, distance, 0.0f);
|
||||
}
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Waypoint::VT_NAME, name);
|
||||
}
|
||||
void add_location(const osrm::engine::api::fbresult::Position *location) {
|
||||
fbb_.AddStruct(Waypoint::VT_LOCATION, location);
|
||||
}
|
||||
void add_nodes(const osrm::engine::api::fbresult::Uint64Pair *nodes) {
|
||||
fbb_.AddStruct(Waypoint::VT_NODES, nodes);
|
||||
}
|
||||
void add_matchings_index(uint32_t matchings_index) {
|
||||
fbb_.AddElement<uint32_t>(Waypoint::VT_MATCHINGS_INDEX, matchings_index, 0);
|
||||
}
|
||||
void add_waypoint_index(uint32_t waypoint_index) {
|
||||
fbb_.AddElement<uint32_t>(Waypoint::VT_WAYPOINT_INDEX, waypoint_index, 0);
|
||||
}
|
||||
void add_alternatives_count(uint32_t alternatives_count) {
|
||||
fbb_.AddElement<uint32_t>(Waypoint::VT_ALTERNATIVES_COUNT, alternatives_count, 0);
|
||||
}
|
||||
void add_trips_index(uint32_t trips_index) {
|
||||
fbb_.AddElement<uint32_t>(Waypoint::VT_TRIPS_INDEX, trips_index, 0);
|
||||
}
|
||||
explicit WaypointBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Waypoint> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Waypoint>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Waypoint> CreateWaypoint(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::String> hint = 0,
|
||||
float distance = 0.0f,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
const osrm::engine::api::fbresult::Position *location = nullptr,
|
||||
const osrm::engine::api::fbresult::Uint64Pair *nodes = nullptr,
|
||||
uint32_t matchings_index = 0,
|
||||
uint32_t waypoint_index = 0,
|
||||
uint32_t alternatives_count = 0,
|
||||
uint32_t trips_index = 0) {
|
||||
WaypointBuilder builder_(_fbb);
|
||||
builder_.add_trips_index(trips_index);
|
||||
builder_.add_alternatives_count(alternatives_count);
|
||||
builder_.add_waypoint_index(waypoint_index);
|
||||
builder_.add_matchings_index(matchings_index);
|
||||
builder_.add_nodes(nodes);
|
||||
builder_.add_location(location);
|
||||
builder_.add_name(name);
|
||||
builder_.add_distance(distance);
|
||||
builder_.add_hint(hint);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline ::flatbuffers::Offset<Waypoint> CreateWaypointDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *hint = nullptr,
|
||||
float distance = 0.0f,
|
||||
const char *name = nullptr,
|
||||
const osrm::engine::api::fbresult::Position *location = nullptr,
|
||||
const osrm::engine::api::fbresult::Uint64Pair *nodes = nullptr,
|
||||
uint32_t matchings_index = 0,
|
||||
uint32_t waypoint_index = 0,
|
||||
uint32_t alternatives_count = 0,
|
||||
uint32_t trips_index = 0) {
|
||||
auto hint__ = hint ? _fbb.CreateString(hint) : 0;
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
return osrm::engine::api::fbresult::CreateWaypoint(
|
||||
_fbb,
|
||||
hint__,
|
||||
distance,
|
||||
name__,
|
||||
location,
|
||||
nodes,
|
||||
matchings_index,
|
||||
waypoint_index,
|
||||
alternatives_count,
|
||||
trips_index);
|
||||
}
|
||||
|
||||
} // namespace fbresult
|
||||
} // namespace api
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_WAYPOINT_OSRM_ENGINE_API_FBRESULT_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -137,7 +137,7 @@ class TableAPI final : public BaseAPI
|
||||
speed_cells = MakeEstimatesTable(fb_result, fallback_speed_cells);
|
||||
}
|
||||
|
||||
fbresult::TableBuilder table(fb_result);
|
||||
fbresult::TableResultBuilder table(fb_result);
|
||||
table.add_destinations(destinations);
|
||||
table.add_rows(number_of_sources);
|
||||
table.add_cols(number_of_destinations);
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "util/query_heap.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/thread/tss.hpp>
|
||||
|
||||
namespace osrm::engine
|
||||
{
|
||||
|
||||
@@ -45,19 +43,19 @@ template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
|
||||
ManyToManyHeapData,
|
||||
util::UnorderedMapStorage<NodeID, int>>;
|
||||
|
||||
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
|
||||
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
|
||||
|
||||
using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>;
|
||||
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
|
||||
|
||||
static SearchEngineHeapPtr forward_heap_1;
|
||||
static SearchEngineHeapPtr reverse_heap_1;
|
||||
static SearchEngineHeapPtr forward_heap_2;
|
||||
static SearchEngineHeapPtr reverse_heap_2;
|
||||
static SearchEngineHeapPtr forward_heap_3;
|
||||
static SearchEngineHeapPtr reverse_heap_3;
|
||||
static ManyToManyHeapPtr many_to_many_heap;
|
||||
static SearchEngineHeapPtr map_matching_forward_heap_1;
|
||||
static SearchEngineHeapPtr map_matching_reverse_heap_1;
|
||||
static thread_local SearchEngineHeapPtr forward_heap_1;
|
||||
static thread_local SearchEngineHeapPtr reverse_heap_1;
|
||||
static thread_local SearchEngineHeapPtr forward_heap_2;
|
||||
static thread_local SearchEngineHeapPtr reverse_heap_2;
|
||||
static thread_local SearchEngineHeapPtr forward_heap_3;
|
||||
static thread_local SearchEngineHeapPtr reverse_heap_3;
|
||||
static thread_local ManyToManyHeapPtr many_to_many_heap;
|
||||
static thread_local SearchEngineHeapPtr map_matching_forward_heap_1;
|
||||
static thread_local SearchEngineHeapPtr map_matching_reverse_heap_1;
|
||||
|
||||
void InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes);
|
||||
|
||||
@@ -127,16 +125,16 @@ template <> struct SearchEngineData<routing_algorithms::mld::Algorithm>
|
||||
MapMatchingMultiLayerDijkstraHeapData,
|
||||
util::TwoLevelStorage<NodeID, int>>;
|
||||
|
||||
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
|
||||
using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>;
|
||||
using MapMatchingHeapPtr = boost::thread_specific_ptr<MapMatchingQueryHeap>;
|
||||
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
|
||||
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
|
||||
using MapMatchingHeapPtr = std::unique_ptr<MapMatchingQueryHeap>;
|
||||
|
||||
static SearchEngineHeapPtr forward_heap_1;
|
||||
static SearchEngineHeapPtr reverse_heap_1;
|
||||
static MapMatchingHeapPtr map_matching_forward_heap_1;
|
||||
static MapMatchingHeapPtr map_matching_reverse_heap_1;
|
||||
static thread_local SearchEngineHeapPtr forward_heap_1;
|
||||
static thread_local SearchEngineHeapPtr reverse_heap_1;
|
||||
static thread_local MapMatchingHeapPtr map_matching_forward_heap_1;
|
||||
static thread_local MapMatchingHeapPtr map_matching_reverse_heap_1;
|
||||
|
||||
static ManyToManyHeapPtr many_to_many_heap;
|
||||
static thread_local ManyToManyHeapPtr many_to_many_heap;
|
||||
|
||||
void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes,
|
||||
unsigned number_of_boundary_nodes);
|
||||
@@ -148,4 +146,4 @@ template <> struct SearchEngineData<routing_algorithms::mld::Algorithm>
|
||||
};
|
||||
} // namespace osrm::engine
|
||||
|
||||
#endif // SEARCH_ENGINE_DATA_HPP
|
||||
#endif // SEARCH_ENGINE_DATA_HPP
|
||||
@@ -15,48 +15,6 @@
|
||||
namespace osrm::util
|
||||
{
|
||||
|
||||
template <typename NodeID, typename Key> class GenerationArrayStorage
|
||||
{
|
||||
using GenerationCounter = std::uint16_t;
|
||||
|
||||
public:
|
||||
explicit GenerationArrayStorage(std::size_t size)
|
||||
: positions(size, 0), generation(1), generations(size, 0)
|
||||
{
|
||||
}
|
||||
|
||||
Key &operator[](NodeID node)
|
||||
{
|
||||
generation[node] = generation;
|
||||
return positions[node];
|
||||
}
|
||||
|
||||
Key peek_index(const NodeID node) const
|
||||
{
|
||||
if (generations[node] < generation)
|
||||
{
|
||||
return std::numeric_limits<Key>::max();
|
||||
}
|
||||
return positions[node];
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
generation++;
|
||||
// if generation overflows we end up at 0 again and need to clear the vector
|
||||
if (generation == 0)
|
||||
{
|
||||
generation = 1;
|
||||
std::fill(generations.begin(), generations.end(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GenerationCounter generation;
|
||||
std::vector<GenerationCounter> generations;
|
||||
std::vector<Key> positions;
|
||||
};
|
||||
|
||||
template <typename NodeID, typename Key> class ArrayStorage
|
||||
{
|
||||
public:
|
||||
@@ -72,29 +30,6 @@ template <typename NodeID, typename Key> class ArrayStorage
|
||||
std::vector<Key> positions;
|
||||
};
|
||||
|
||||
template <typename NodeID, typename Key> class MapStorage
|
||||
{
|
||||
public:
|
||||
explicit MapStorage(std::size_t) {}
|
||||
|
||||
Key &operator[](NodeID node) { return nodes[node]; }
|
||||
|
||||
void Clear() { nodes.clear(); }
|
||||
|
||||
Key peek_index(const NodeID node) const
|
||||
{
|
||||
const auto iter = nodes.find(node);
|
||||
if (nodes.end() != iter)
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
return std::numeric_limits<Key>::max();
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<NodeID, Key> nodes;
|
||||
};
|
||||
|
||||
template <typename NodeID, typename Key> class UnorderedMapStorage
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -59,7 +59,6 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
|
||||
SET test_region=monaco
|
||||
SET test_region_ch=ch\monaco
|
||||
SET test_region_corech=corech\monaco
|
||||
SET test_region_mld=mld\monaco
|
||||
SET test_osm=%test_region%.osm.pbf
|
||||
COPY %PROJECT_DIR%\test\data\%test_region%.osm.pbf %test_osm%
|
||||
@@ -69,18 +68,13 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
MKDIR ch
|
||||
XCOPY %test_region%.osrm.* ch\
|
||||
XCOPY %test_region%.osrm ch\
|
||||
MKDIR corech
|
||||
XCOPY %test_region%.osrm.* corech\
|
||||
XCOPY %test_region%.osrm corech\
|
||||
MKDIR mld
|
||||
XCOPY %test_region%.osrm.* mld\
|
||||
XCOPY %test_region%.osrm mld\
|
||||
%CONFIGURATION%\osrm-contract.exe %test_region_ch%.osrm
|
||||
%CONFIGURATION%\osrm-contract.exe --core 0.8 %test_region_corech%.osrm
|
||||
%CONFIGURATION%\osrm-partition.exe %test_region_mld%.osrm
|
||||
%CONFIGURATION%\osrm-customize.exe %test_region_mld%.osrm
|
||||
XCOPY /Y ch\*.* ..\test\data\ch\
|
||||
XCOPY /Y corech\*.* ..\test\data\corech\
|
||||
XCOPY /Y mld\*.* ..\test\data\mld\
|
||||
unit_tests\%CONFIGURATION%\library-tests.exe
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
|
||||
@@ -30,6 +30,9 @@ VTZERO_TAG=v1.1.0
|
||||
FMT_PATH="fmtlib/fmt"
|
||||
FMT_TAG=v10.2.1
|
||||
|
||||
FLATBUFFERS_PATH="google/flatbuffers"
|
||||
FLATBUFFERS_TAG=v24.3.25
|
||||
|
||||
function update_subtree () {
|
||||
name=$(echo "$1" | tr '[:lower:]' '[:upper:]')
|
||||
path=$(tmpvar=${name}_PATH && echo ${!tmpvar})
|
||||
@@ -53,6 +56,6 @@ function update_subtree () {
|
||||
}
|
||||
|
||||
## Update dependencies
|
||||
for dep in osmium sol rapidjson microtar protozero vtzero fmt; do
|
||||
for dep in osmium sol rapidjson microtar protozero vtzero fmt flatbuffers; do
|
||||
update_subtree $dep
|
||||
done
|
||||
|
||||
@@ -5,16 +5,18 @@ namespace osrm::engine
|
||||
|
||||
// CH heaps
|
||||
using CH = routing_algorithms::ch::Algorithm;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::forward_heap_1;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::reverse_heap_1;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::forward_heap_2;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::reverse_heap_2;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::forward_heap_3;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::reverse_heap_3;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::map_matching_forward_heap_1;
|
||||
SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::map_matching_reverse_heap_1;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::forward_heap_1;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::reverse_heap_1;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::forward_heap_2;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::reverse_heap_2;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::forward_heap_3;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr SearchEngineData<CH>::reverse_heap_3;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr
|
||||
SearchEngineData<CH>::map_matching_forward_heap_1;
|
||||
thread_local SearchEngineData<CH>::SearchEngineHeapPtr
|
||||
SearchEngineData<CH>::map_matching_reverse_heap_1;
|
||||
|
||||
SearchEngineData<CH>::ManyToManyHeapPtr SearchEngineData<CH>::many_to_many_heap;
|
||||
thread_local SearchEngineData<CH>::ManyToManyHeapPtr SearchEngineData<CH>::many_to_many_heap;
|
||||
|
||||
void SearchEngineData<CH>::InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes)
|
||||
{
|
||||
@@ -114,11 +116,13 @@ void SearchEngineData<CH>::InitializeOrClearManyToManyThreadLocalStorage(unsigne
|
||||
|
||||
// MLD
|
||||
using MLD = routing_algorithms::mld::Algorithm;
|
||||
SearchEngineData<MLD>::SearchEngineHeapPtr SearchEngineData<MLD>::forward_heap_1;
|
||||
SearchEngineData<MLD>::SearchEngineHeapPtr SearchEngineData<MLD>::reverse_heap_1;
|
||||
SearchEngineData<MLD>::MapMatchingHeapPtr SearchEngineData<MLD>::map_matching_forward_heap_1;
|
||||
SearchEngineData<MLD>::MapMatchingHeapPtr SearchEngineData<MLD>::map_matching_reverse_heap_1;
|
||||
SearchEngineData<MLD>::ManyToManyHeapPtr SearchEngineData<MLD>::many_to_many_heap;
|
||||
thread_local SearchEngineData<MLD>::SearchEngineHeapPtr SearchEngineData<MLD>::forward_heap_1;
|
||||
thread_local SearchEngineData<MLD>::SearchEngineHeapPtr SearchEngineData<MLD>::reverse_heap_1;
|
||||
thread_local SearchEngineData<MLD>::MapMatchingHeapPtr
|
||||
SearchEngineData<MLD>::map_matching_forward_heap_1;
|
||||
thread_local SearchEngineData<MLD>::MapMatchingHeapPtr
|
||||
SearchEngineData<MLD>::map_matching_reverse_heap_1;
|
||||
thread_local SearchEngineData<MLD>::ManyToManyHeapPtr SearchEngineData<MLD>::many_to_many_heap;
|
||||
|
||||
void SearchEngineData<MLD>::InitializeOrClearMapMatchingThreadLocalStorage(
|
||||
unsigned number_of_nodes, unsigned number_of_boundary_nodes)
|
||||
@@ -178,4 +182,4 @@ void SearchEngineData<MLD>::InitializeOrClearManyToManyThreadLocalStorage(
|
||||
many_to_many_heap.reset(new ManyToManyQueryHeap(number_of_nodes, number_of_boundary_nodes));
|
||||
}
|
||||
}
|
||||
} // namespace osrm::engine
|
||||
} // namespace osrm::engine
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace osrm::server::service
|
||||
{
|
||||
@@ -30,11 +31,11 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters)
|
||||
return help;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
engine::Status NearestService::RunQuery(std::size_t prefix_length,
|
||||
std::string &query,
|
||||
osrm::engine::api::ResultT &result)
|
||||
{
|
||||
std::cout << "running query: " << query << "\n";
|
||||
result = util::json::Object();
|
||||
auto &json_result = std::get<util::json::Object>(result);
|
||||
|
||||
|
||||
+5
-14
@@ -46,25 +46,16 @@ return_code parseArguments(int argc,
|
||||
boost::program_options::value<unsigned int>(&contractor_config.requested_num_threads)
|
||||
->default_value(std::thread::hardware_concurrency()),
|
||||
"Number of threads to use")(
|
||||
"core,k",
|
||||
boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0),
|
||||
"DEPRECATED: Will always be 1.0. Percentage of the graph (in vertices) to contract "
|
||||
"[0..1].")("segment-speed-file",
|
||||
boost::program_options::value<std::vector<std::string>>(
|
||||
&contractor_config.updater_config.segment_speed_lookup_paths)
|
||||
->composing(),
|
||||
"Lookup files containing nodeA, nodeB, speed data to adjust edge weights")(
|
||||
"segment-speed-file",
|
||||
boost::program_options::value<std::vector<std::string>>(
|
||||
&contractor_config.updater_config.segment_speed_lookup_paths)
|
||||
->composing(),
|
||||
"Lookup files containing nodeA, nodeB, speed data to adjust edge weights")(
|
||||
"turn-penalty-file",
|
||||
boost::program_options::value<std::vector<std::string>>(
|
||||
&contractor_config.updater_config.turn_penalty_lookup_paths)
|
||||
->composing(),
|
||||
"Lookup files containing from_, to_, via_nodes, and turn penalties to adjust turn weights")(
|
||||
"level-cache,o",
|
||||
boost::program_options::bool_switch(&contractor_config.use_cached_priority)
|
||||
->default_value(false),
|
||||
"DEPRECATED: Will always be false. Use .level file to retain the contraction level for "
|
||||
"each "
|
||||
"node from the last run.")(
|
||||
"edge-weight-updates-over-factor",
|
||||
boost::program_options::value<double>(
|
||||
&contractor_config.updater_config.log_edge_updates_factor)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(clap::ValueEnum, Clone, Default, Debug)]
|
||||
pub enum LoadMethod {
|
||||
Mmap,
|
||||
#[default]
|
||||
Datastore,
|
||||
Directly,
|
||||
}
|
||||
impl Display for LoadMethod {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let result = match self {
|
||||
LoadMethod::Mmap => "mmap",
|
||||
LoadMethod::Datastore => "datastore",
|
||||
LoadMethod::Directly => "directly",
|
||||
};
|
||||
write!(f, "{result}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(clap::ValueEnum, Clone, Default, Debug)]
|
||||
pub enum RoutingAlgorithm {
|
||||
#[default]
|
||||
Ch,
|
||||
Mld,
|
||||
}
|
||||
|
||||
impl Display for RoutingAlgorithm {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let result = match self {
|
||||
RoutingAlgorithm::Ch => "ch",
|
||||
RoutingAlgorithm::Mld => "mld",
|
||||
};
|
||||
write!(f, "{result}")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move to external file
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
// underlying memory storage
|
||||
#[arg(short, default_value_t = LoadMethod::Datastore)]
|
||||
memory: LoadMethod,
|
||||
|
||||
// Number of times to greet
|
||||
#[arg(short, default_value_t = RoutingAlgorithm::Ch)]
|
||||
p: RoutingAlgorithm,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Offset {
|
||||
Absolute(f64),
|
||||
Percentage(f64),
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use crate::extract_number_and_offset;
|
||||
|
||||
// #[test]
|
||||
// fn extract_number_and_offset() {
|
||||
// let (value, result) = extract_number_and_offset("m", "300 +- 1m");
|
||||
// assert_eq!(value, 300.);
|
||||
// assert_eq!(offset, 1);
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,101 @@
|
||||
use colored::Colorize;
|
||||
use cucumber::{cli, event, parser, Event};
|
||||
use std::{
|
||||
io::{self, Write},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct DotWriter {
|
||||
scenarios_started: usize,
|
||||
scenarios_failed: usize,
|
||||
scenarios_finished: usize,
|
||||
features_started: usize,
|
||||
features_finished: usize,
|
||||
step_started: usize,
|
||||
step_failed: usize,
|
||||
step_passed: usize,
|
||||
step_skipped: usize,
|
||||
start_time: Option<Instant>,
|
||||
}
|
||||
|
||||
impl<W: 'static> cucumber::Writer<W> for DotWriter {
|
||||
type Cli = cli::Empty; // we provide no CLI options
|
||||
|
||||
async fn handle_event(&mut self, ev: parser::Result<Event<event::Cucumber<W>>>, _: &Self::Cli) {
|
||||
let green_dot = ".".green();
|
||||
let cyan_dash = "-".cyan();
|
||||
let red_cross = "X".red();
|
||||
match ev {
|
||||
Ok(Event { value, .. }) => match value {
|
||||
event::Cucumber::Feature(_feature, ev) => match ev {
|
||||
event::Feature::Started => {
|
||||
self.features_started += 1;
|
||||
print!("{green_dot}")
|
||||
}
|
||||
event::Feature::Scenario(_scenario, ev) => match ev.event {
|
||||
event::Scenario::Started => {
|
||||
self.scenarios_started += 1;
|
||||
print!("{green_dot}")
|
||||
}
|
||||
event::Scenario::Step(_step, ev) => match ev {
|
||||
event::Step::Started => {
|
||||
self.step_started += 1;
|
||||
print!("{green_dot}")
|
||||
}
|
||||
event::Step::Passed(..) => {
|
||||
self.step_passed += 1;
|
||||
print!("{green_dot}")
|
||||
}
|
||||
event::Step::Skipped => {
|
||||
self.step_skipped += 1;
|
||||
print!("{cyan_dash}")
|
||||
}
|
||||
event::Step::Failed(_, _, _, _err) => {
|
||||
self.step_failed += 1;
|
||||
print!("{red_cross}")
|
||||
}
|
||||
},
|
||||
event::Scenario::Hook(_, _) => {}
|
||||
event::Scenario::Background(_, _) => {}
|
||||
event::Scenario::Log(_) => {}
|
||||
event::Scenario::Finished => {
|
||||
self.scenarios_finished += 1;
|
||||
}
|
||||
},
|
||||
event::Feature::Rule(_, _) => {}
|
||||
event::Feature::Finished => {
|
||||
self.features_finished += 1;
|
||||
}
|
||||
},
|
||||
event::Cucumber::Finished => {
|
||||
println!();
|
||||
let f = format!("{} failed", self.scenarios_failed).red();
|
||||
let p = format!("{} passed", self.scenarios_finished).green();
|
||||
println!("{} scenarios ({f}, {p})", self.scenarios_started);
|
||||
let f = format!("{} failed", self.step_failed).red();
|
||||
let s = format!("{} skipped", self.step_skipped).cyan();
|
||||
let p = format!("{} passed", self.step_passed).green();
|
||||
println!("{} steps ({f}, {s}, {p})", self.step_started);
|
||||
|
||||
let elapsed = Instant::now() - self.start_time.unwrap();
|
||||
let minutes = elapsed.as_secs() / 60;
|
||||
let seconds = (elapsed.as_millis() % 60_000) as f64 / 1000.;
|
||||
println!("{}m{}s", minutes, seconds);
|
||||
}
|
||||
event::Cucumber::ParsingFinished {
|
||||
features: _,
|
||||
rules: _,
|
||||
scenarios: _,
|
||||
steps: _,
|
||||
parser_errors: _,
|
||||
} => {}
|
||||
event::Cucumber::Started => {
|
||||
self.start_time = Some(Instant::now());
|
||||
}
|
||||
},
|
||||
Err(e) => println!("Error: {e}"),
|
||||
}
|
||||
let _ = io::stdout().flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
use super::comparison::Offset;
|
||||
|
||||
pub fn approx_equal(a: f64, b: f64, dp: u8) -> bool {
|
||||
let p = 10f64.powi(-(dp as i32));
|
||||
(a - b).abs() < p
|
||||
}
|
||||
|
||||
fn aprox_equal_within_percentage_range(actual: f64, expectation: f64, percentage: f64) -> bool {
|
||||
assert!(percentage.is_sign_positive() && percentage <= 100.);
|
||||
let factor = 0.01 * percentage as f64;
|
||||
actual >= expectation - (factor * expectation) && actual <= expectation + (factor * expectation)
|
||||
}
|
||||
|
||||
fn approx_equal_within_offset_range(actual: f64, expectation: f64, offset: f64) -> bool {
|
||||
assert!(offset >= 0., "offset must be positive");
|
||||
actual >= expectation - offset && actual <= expectation + offset
|
||||
}
|
||||
|
||||
pub fn approximate_within_range(actual: f64, expectation: f64, offset: &Offset) -> bool {
|
||||
match offset {
|
||||
Offset::Absolute(a) => approx_equal_within_offset_range(actual, expectation, *a),
|
||||
Offset::Percentage(p) => aprox_equal_within_percentage_range(actual, expectation, *p),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
use std::{
|
||||
fs::{self, File},
|
||||
io::Read,
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use log::debug;
|
||||
|
||||
pub fn get_file_as_byte_vec(path: &PathBuf) -> Vec<u8> {
|
||||
debug!("opening {path:?}");
|
||||
let mut f = File::open(path).expect("no file found");
|
||||
let metadata = fs::metadata(path).expect("unable to read metadata");
|
||||
let mut buffer = vec![0; metadata.len() as usize];
|
||||
match f.read(&mut buffer) {
|
||||
Ok(l) => assert_eq!(metadata.len() as usize, l, "data was not completely read"),
|
||||
Err(e) => panic!("Error: {e}"),
|
||||
}
|
||||
|
||||
buffer
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
use std::{env, fs, path::PathBuf};
|
||||
|
||||
use log::debug;
|
||||
|
||||
use crate::common::{
|
||||
file_util::get_file_as_byte_vec, lexicographic_file_walker::LexicographicFileWalker,
|
||||
};
|
||||
|
||||
pub fn md5_of_osrm_executables() -> chksum_md5::MD5 {
|
||||
// create OSRM digest before any tests are executed since cucumber-rs doesn't have @beforeAll
|
||||
let exe_path = env::current_exe().expect("failed to get current exe path");
|
||||
let path = exe_path
|
||||
.ancestors()
|
||||
.find(|p| p.ends_with("target"))
|
||||
.expect("compiled cucumber test executable resides in a directory tree with the root name 'target'")
|
||||
.parent().unwrap();
|
||||
// TODO: Remove after migration to Rust build dir
|
||||
let build_path = path.join("build");
|
||||
// TODO: Remove after migration to Rust build dir
|
||||
let mut dependencies = Vec::new();
|
||||
|
||||
// FIXME: the following iterator gymnastics port the exact order and behavior of the JavaScript implementation
|
||||
let names = [
|
||||
"osrm-extract",
|
||||
"osrm-contract",
|
||||
"osrm-customize",
|
||||
"osrm-partition",
|
||||
"osrm_extract",
|
||||
"osrm_contract",
|
||||
"osrm_customize",
|
||||
"osrm_partition",
|
||||
];
|
||||
|
||||
let files: Vec<PathBuf> = fs::read_dir(build_path)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|dir_entry| dir_entry.path())
|
||||
.collect();
|
||||
|
||||
let iter = names.iter().map(|name| {
|
||||
files
|
||||
.iter()
|
||||
.find(|path_buf| {
|
||||
path_buf
|
||||
.file_stem()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.contains(name)
|
||||
})
|
||||
.cloned()
|
||||
.expect("file exists and is usable")
|
||||
});
|
||||
|
||||
dependencies.extend(iter);
|
||||
|
||||
let profiles_path = path.join("profiles");
|
||||
debug!("{profiles_path:?}");
|
||||
|
||||
dependencies.extend(
|
||||
LexicographicFileWalker::new(&profiles_path)
|
||||
.filter(|pb| !pb.to_str().unwrap().contains("examples"))
|
||||
.filter(|pathbuf| match pathbuf.extension() {
|
||||
Some(ext) => ext.to_str().unwrap() == "lua",
|
||||
None => false,
|
||||
}),
|
||||
);
|
||||
let mut md5 = chksum_md5::new();
|
||||
debug!("md5: {}", md5.digest().to_hex_lowercase());
|
||||
|
||||
for path_buf in dependencies {
|
||||
let data = get_file_as_byte_vec(&path_buf);
|
||||
if data.is_empty() {
|
||||
continue;
|
||||
}
|
||||
md5.update(data);
|
||||
// debug!("md5: {}", md5.digest().to_hex_lowercase());
|
||||
}
|
||||
md5
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// struct to keep state agent, profile, host, etc
|
||||
// functions to make nearest, route, etc calls
|
||||
// fn nearest(arg1, ... argn) -> NearestResponse
|
||||
|
||||
// use std::{path::Path, time::Duration};
|
||||
|
||||
// use ureq::{Agent, AgentBuilder};
|
||||
|
||||
// pub struct HttpRequest {
|
||||
// agent: Agent,
|
||||
// }
|
||||
|
||||
// impl HttpRequest {
|
||||
// // pub fn fetch_to_file(url: &str, output: &Path) -> Result<()> {}
|
||||
|
||||
// pub fn new() -> Self {
|
||||
// let agent = AgentBuilder::new()
|
||||
// .timeout_read(Duration::from_secs(5))
|
||||
// .timeout_write(Duration::from_secs(5))
|
||||
// .build();
|
||||
|
||||
// Self { agent }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,55 @@
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
// TODO: port into toolbox-rs
|
||||
pub struct LexicographicFileWalker {
|
||||
dirs: VecDeque<PathBuf>,
|
||||
files: VecDeque<PathBuf>,
|
||||
}
|
||||
|
||||
impl LexicographicFileWalker {
|
||||
pub fn new(path: &Path) -> Self {
|
||||
let mut dirs = VecDeque::new();
|
||||
|
||||
if path.is_dir() {
|
||||
dirs.push_back(path.to_path_buf());
|
||||
}
|
||||
|
||||
Self {
|
||||
dirs,
|
||||
files: VecDeque::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for LexicographicFileWalker {
|
||||
type Item = PathBuf;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.dirs.is_empty() && self.files.is_empty() {
|
||||
return None;
|
||||
}
|
||||
while self.files.is_empty() && !self.dirs.is_empty() {
|
||||
assert!(!self.dirs.is_empty());
|
||||
let current_dir = self.dirs.pop_front().unwrap();
|
||||
let mut temp_dirs = Vec::new();
|
||||
|
||||
for entry in fs::read_dir(current_dir).unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
if path.is_dir() {
|
||||
temp_dirs.push(path.clone());
|
||||
} else {
|
||||
self.files.push_back(path.clone());
|
||||
}
|
||||
}
|
||||
self.files.make_contiguous().sort();
|
||||
temp_dirs.sort();
|
||||
self.dirs.extend(temp_dirs.into_iter());
|
||||
}
|
||||
self.files.pop_front()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
use std::{
|
||||
io::{BufRead, BufReader},
|
||||
process::{Child, Command, Stdio},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct LocalTask {
|
||||
ready: bool,
|
||||
command: String,
|
||||
arguments: Vec<String>,
|
||||
child: Option<Child>,
|
||||
}
|
||||
|
||||
impl LocalTask {
|
||||
pub fn new(command: String) -> Self {
|
||||
Self {
|
||||
ready: false,
|
||||
command: command,
|
||||
arguments: Vec::new(),
|
||||
child: None,
|
||||
}
|
||||
}
|
||||
pub fn is_ready(&self) -> bool {
|
||||
// TODO: also check that process is running
|
||||
self.ready
|
||||
}
|
||||
pub fn arg(mut self, argument: &str) -> Self {
|
||||
self.arguments.push(argument.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn spawn_wait_till_ready(&mut self, ready_token: &str) {
|
||||
let mut command = &mut Command::new(&self.command);
|
||||
for argument in &self.arguments {
|
||||
command = command.arg(argument);
|
||||
}
|
||||
|
||||
match command.stdout(Stdio::piped()).spawn() {
|
||||
Ok(o) => self.child = Some(o),
|
||||
Err(e) => panic!("cannot spawn task: {e}"),
|
||||
}
|
||||
|
||||
if self.child.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(output) = &mut self.child.as_mut().unwrap().stdout {
|
||||
// implement with a timeout
|
||||
let mut reader = BufReader::new(output);
|
||||
let mut line = String::new();
|
||||
while let Ok(_count) = reader.read_line(&mut line) {
|
||||
// println!("count: {count} ->{line}");
|
||||
if line.contains(ready_token) {
|
||||
self.ready = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// impl Drop for LocalTask {
|
||||
// fn drop(&mut self) {
|
||||
// if let Err(e) = self.child.as_mut().expect("can't access child").kill() {
|
||||
// panic!("shutdown failed: {e}");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,8 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize)]
|
||||
pub struct Location {
|
||||
// Note: The order is important since we derive Deserialize
|
||||
pub longitude: f64,
|
||||
pub latitude: f64,
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#![allow(clippy::derivable_impls, clippy::all)]
|
||||
extern crate flatbuffers;
|
||||
|
||||
pub mod cli_arguments;
|
||||
pub mod comparison;
|
||||
pub mod dot_writer;
|
||||
pub mod f64_utils;
|
||||
pub mod file_util;
|
||||
pub mod hash_util;
|
||||
pub mod http_request;
|
||||
pub mod lexicographic_file_walker;
|
||||
pub mod local_task;
|
||||
pub mod location;
|
||||
pub mod nearest_response;
|
||||
pub mod osm;
|
||||
pub mod osm_db;
|
||||
pub mod osrm_error;
|
||||
pub mod osrm_world;
|
||||
pub mod route_response;
|
||||
pub mod scenario_id;
|
||||
|
||||
// flatbuffer
|
||||
#[allow(dead_code, unused_imports)]
|
||||
#[path = "../../target/flatbuffers/fbresult_generated.rs"]
|
||||
pub mod fbresult_flatbuffers;
|
||||
#[allow(dead_code, unused_imports)]
|
||||
#[path = "../../target/flatbuffers/position_generated.rs"]
|
||||
pub mod position_flatbuffers;
|
||||
#[allow(dead_code, unused_imports)]
|
||||
#[path = "../../target/flatbuffers/route_generated.rs"]
|
||||
pub mod route_flatbuffers;
|
||||
#[allow(dead_code, unused_imports)]
|
||||
#[path = "../../target/flatbuffers/table_generated.rs"]
|
||||
pub mod table_flatbuffers;
|
||||
#[allow(dead_code, unused_imports)]
|
||||
#[path = "../../target/flatbuffers/waypoint_generated.rs"]
|
||||
pub mod waypoint_flatbuffers;
|
||||
@@ -0,0 +1,88 @@
|
||||
use super::location::Location;
|
||||
use crate::common::fbresult_flatbuffers::osrm::engine::api::fbresult::FBResult;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Waypoint {
|
||||
pub hint: String,
|
||||
pub nodes: Option<Vec<u64>>,
|
||||
pub distance: f32,
|
||||
pub name: String,
|
||||
location: Location,
|
||||
}
|
||||
|
||||
impl Waypoint {
|
||||
pub fn location(&self) -> &Location {
|
||||
&self.location
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct NearestResponse {
|
||||
pub code: String,
|
||||
pub waypoints: Vec<Waypoint>,
|
||||
pub data_version: Option<String>,
|
||||
}
|
||||
|
||||
impl NearestResponse {
|
||||
// TODO: the from_* functions should be a) into_. or b) implement From<_> trait
|
||||
pub fn from_json_reader(reader: impl std::io::Read) -> Self {
|
||||
let response = match serde_json::from_reader::<_, NearestResponse>(reader) {
|
||||
Ok(response) => response,
|
||||
Err(e) => panic!("parsing error {e}"),
|
||||
};
|
||||
response
|
||||
}
|
||||
|
||||
pub fn from_flatbuffer(mut reader: impl std::io::Read) -> Self {
|
||||
let mut buffer = Vec::new();
|
||||
if let Err(e) = reader.read_to_end(&mut buffer) {
|
||||
panic!("cannot read from strem: {e}");
|
||||
};
|
||||
let decoded: Result<FBResult, flatbuffers::InvalidFlatbuffer> =
|
||||
flatbuffers::root::<FBResult>(&buffer);
|
||||
let decoded: FBResult = match decoded {
|
||||
Ok(d) => d,
|
||||
Err(e) => panic!("Error during parsing: {e} {:?}", buffer),
|
||||
};
|
||||
let code = match decoded.code() {
|
||||
Some(e) => e.message().expect("code exists but is not unwrappable"),
|
||||
None => "",
|
||||
};
|
||||
let data_version = match decoded.data_version() {
|
||||
Some(s) => s,
|
||||
None => "",
|
||||
};
|
||||
|
||||
let waypoints = decoded
|
||||
.waypoints()
|
||||
.expect("waypoints should be at least an empty list")
|
||||
.iter()
|
||||
.map(|wp| {
|
||||
let hint = wp.hint().expect("hint is missing").to_string();
|
||||
let location = wp.location().expect("waypoint must have a location");
|
||||
let location = Location {
|
||||
latitude: location.latitude() as f64,
|
||||
longitude: location.longitude() as f64,
|
||||
};
|
||||
let nodes = wp.nodes().expect("waypoint mus have nodes");
|
||||
let nodes = Some(vec![nodes.first(), nodes.second()]);
|
||||
let distance = wp.distance();
|
||||
|
||||
Waypoint {
|
||||
hint,
|
||||
nodes,
|
||||
distance,
|
||||
name: "".into(),
|
||||
location,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
code: code.into(),
|
||||
waypoints,
|
||||
data_version: Some(data_version.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use xml_builder::XMLElement;
|
||||
|
||||
use super::location::Location;
|
||||
|
||||
static OSM_USER: &str = "osrm";
|
||||
static OSM_TIMESTAMP: &str = "2000-01-01T00:00:00Z";
|
||||
static OSM_UID: &str = "1";
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct OSMNode {
|
||||
pub id: u64,
|
||||
pub location: Location,
|
||||
pub tags: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl OSMNode {
|
||||
pub fn add_tag(&mut self, key: &str, value: &str) {
|
||||
if key.is_empty() || value.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.tags.insert(key.into(), value.into());
|
||||
}
|
||||
|
||||
// pub fn set_id_(&mut self, id: u64) {
|
||||
// self.id = id;
|
||||
// }
|
||||
|
||||
// pub fn set_tags(&mut self, tags: HashMap<String, String>) {
|
||||
// self.tags = tags
|
||||
// }
|
||||
|
||||
pub fn to_xml(&self) -> XMLElement {
|
||||
let mut node = XMLElement::new("node");
|
||||
node.add_attribute("id", &self.id.to_string());
|
||||
node.add_attribute("version", "1");
|
||||
node.add_attribute("uid", OSM_UID);
|
||||
node.add_attribute("user", OSM_USER);
|
||||
node.add_attribute("timestamp", OSM_TIMESTAMP);
|
||||
node.add_attribute("lon", &format!("{:?}", self.location.longitude));
|
||||
node.add_attribute("lat", &format!("{:?}", self.location.latitude));
|
||||
|
||||
if !self.tags.is_empty() {
|
||||
for (key, value) in &self.tags {
|
||||
let mut tags = XMLElement::new("tag");
|
||||
tags.add_attribute("k", key);
|
||||
tags.add_attribute("v", value);
|
||||
node.add_child(tags).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
node
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct OSMWay {
|
||||
pub id: u64,
|
||||
pub tags: HashMap<String, String>,
|
||||
pub nodes: Vec<OSMNode>,
|
||||
pub add_locations: bool,
|
||||
}
|
||||
|
||||
impl OSMWay {
|
||||
pub fn add_node(&mut self, node: OSMNode) {
|
||||
self.nodes.push(node);
|
||||
}
|
||||
|
||||
// pub fn set_tags(&mut self, tags: HashMap<String, String>) {
|
||||
// self.tags = tags;
|
||||
// }
|
||||
|
||||
pub fn add_tag(&mut self, key: &str, value: &str) {
|
||||
if key.is_empty() || value.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.tags.insert(key.into(), value.into());
|
||||
}
|
||||
|
||||
pub fn to_xml(&self) -> XMLElement {
|
||||
let mut way = XMLElement::new("way");
|
||||
way.add_attribute("id", &self.id.to_string());
|
||||
way.add_attribute("version", "1");
|
||||
way.add_attribute("uid", OSM_UID);
|
||||
way.add_attribute("user", OSM_USER);
|
||||
way.add_attribute("timestamp", OSM_TIMESTAMP);
|
||||
|
||||
assert!(self.nodes.len() >= 2);
|
||||
|
||||
for node in &self.nodes {
|
||||
let mut nd = XMLElement::new("nd");
|
||||
nd.add_attribute("ref", &node.id.to_string());
|
||||
if self.add_locations {
|
||||
nd.add_attribute("lon", &format!("{:?}", node.location.longitude));
|
||||
nd.add_attribute("lat", &format!("{:?}", node.location.latitude));
|
||||
}
|
||||
way.add_child(nd).unwrap();
|
||||
}
|
||||
|
||||
if !self.tags.is_empty() {
|
||||
for (key, value) in &self.tags {
|
||||
let mut tags = XMLElement::new("tag");
|
||||
tags.add_attribute("k", key);
|
||||
tags.add_attribute("v", value);
|
||||
way.add_child(tags).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
way
|
||||
}
|
||||
}
|
||||
|
||||
// #[derive(Clone, Debug)]
|
||||
// struct Member {
|
||||
// id: u64,
|
||||
// member_type: String,
|
||||
// member_role: String,
|
||||
// }
|
||||
|
||||
// #[derive(Clone, Debug)]
|
||||
// struct OSMRelation {
|
||||
// id: u64,
|
||||
// osm_user: String,
|
||||
// osm_time_stamp: String,
|
||||
// osm_uid: String,
|
||||
// members: Vec<Member>,
|
||||
// tags: HashMap<String, String>,
|
||||
// }
|
||||
|
||||
// impl OSMRelation {
|
||||
// fn add_member(&mut self, member_type: String, id: u64, member_role: String) {
|
||||
// self.members.push(Member {
|
||||
// id,
|
||||
// member_type,
|
||||
// member_role,
|
||||
// });
|
||||
// }
|
||||
|
||||
// pub fn add_tag(&mut self, key: &str, value: &str) {
|
||||
// self.tags.insert(key.into(), value.into());
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,131 @@
|
||||
use super::osm::{OSMNode, OSMWay};
|
||||
use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
|
||||
|
||||
// TODO: better error handling in XML creation
|
||||
#[derive(Debug, Default)]
|
||||
pub struct OSMDb {
|
||||
nodes: Vec<(String, OSMNode)>,
|
||||
ways: Vec<OSMWay>,
|
||||
// relations: Vec<OSMRelation>,
|
||||
}
|
||||
|
||||
impl OSMDb {
|
||||
pub fn add_node(&mut self, node: OSMNode) {
|
||||
let name = node.tags.get("name").unwrap();
|
||||
// assert!(
|
||||
// name.len() == 1,
|
||||
// "name needs to be of length 1, but was \"{name}\""
|
||||
// );
|
||||
self.nodes.push((name.clone(), node));
|
||||
}
|
||||
|
||||
pub fn find_node(&self, search_name: String) -> Option<&(String, OSMNode)> {
|
||||
// TODO: this is a linear search.
|
||||
self.nodes.iter().find(|(name, _node)| search_name == *name)
|
||||
}
|
||||
|
||||
pub fn add_way(&mut self, way: OSMWay) {
|
||||
self.ways.push(way);
|
||||
}
|
||||
|
||||
// pub fn add_relation(&mut self, relation: OSMRelation) {
|
||||
// self.relations.push(relation);
|
||||
// }
|
||||
|
||||
// pub fn clear(&mut self) {
|
||||
// self.nodes.clear();
|
||||
// self.ways.clear();
|
||||
// // self.relations.clear();
|
||||
// }
|
||||
|
||||
pub fn to_xml(&self) -> String {
|
||||
let mut xml = XMLBuilder::new()
|
||||
.version(XMLVersion::XML1_0)
|
||||
.encoding("UTF-8".into())
|
||||
.build();
|
||||
|
||||
let mut osm = XMLElement::new("osm");
|
||||
osm.add_attribute("generator", "osrm-test");
|
||||
osm.add_attribute("version", "0.6");
|
||||
|
||||
for (_, node) in &self.nodes {
|
||||
osm.add_child(node.to_xml()).unwrap();
|
||||
}
|
||||
|
||||
for way in &self.ways {
|
||||
osm.add_child(way.to_xml()).unwrap();
|
||||
}
|
||||
|
||||
xml.set_root_element(osm);
|
||||
|
||||
let mut writer: Vec<u8> = Vec::new();
|
||||
xml.generate(&mut writer).unwrap();
|
||||
String::from_utf8(writer).unwrap()
|
||||
}
|
||||
|
||||
// pub fn node_len(&self) -> usize {
|
||||
// self.nodes.len()
|
||||
// }
|
||||
// pub fn way_len(&self) -> usize {
|
||||
// self.ways.len()
|
||||
// }
|
||||
// pub fn relation_len(&self) -> usize {
|
||||
// self.relations.len()
|
||||
// }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
#[test]
|
||||
fn empty_db_by_default() {
|
||||
use super::*;
|
||||
let osm_db = OSMDb::default();
|
||||
assert_eq!(0, osm_db.node_len());
|
||||
assert_eq!(0, osm_db.way_len());
|
||||
// assert_eq!(0, osm_db.relation_len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn osm_db_with_single_node() {
|
||||
use super::*;
|
||||
let mut osm_db = OSMDb::default();
|
||||
|
||||
let mut node1 = OSMNode {
|
||||
id: 123,
|
||||
location: Location {
|
||||
longitude: 8.9876,
|
||||
latitude: 50.1234,
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut node2 = OSMNode {
|
||||
id: 321,
|
||||
location: Location {
|
||||
longitude: 8.9876,
|
||||
latitude: 50.1234,
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
node1.add_tag("name", "a");
|
||||
node2.add_tag("name", "b");
|
||||
osm_db.add_node(node1.clone());
|
||||
osm_db.add_node(node2.clone());
|
||||
|
||||
let mut way = OSMWay {
|
||||
id: 890,
|
||||
..Default::default()
|
||||
};
|
||||
way.nodes.push(node1);
|
||||
way.nodes.push(node2);
|
||||
|
||||
osm_db.add_way(way);
|
||||
|
||||
let actual = osm_db.to_xml();
|
||||
let expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"osrm-test\" version=\"0.6\">\n\t<node id=\"123\" version=\"1.0\" user=\"osrm\" timestamp=\"2000-01-01T00:00:00Z\" lon=\"8.9876\" lat=\"50.1234\">\n\t\t<tag name=\"a\" />\n\t</node>\n\t<node id=\"321\" version=\"1.0\" user=\"osrm\" timestamp=\"2000-01-01T00:00:00Z\" lon=\"8.9876\" lat=\"50.1234\">\n\t\t<tag name=\"b\" />\n\t</node>\n\t<way id=\"890\" version=\"1\" uid=\"1\" user=\"osrm\" timestamp=\"2000-01-01T00:00:00Z\">\n\t\t<nd ref=\"123\" />\n\t\t<nd ref=\"321\" />\n\t</way>\n</osm>\n";
|
||||
|
||||
// println!("{actual}");
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
pub struct OSRMError {
|
||||
pub code: String,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
impl OSRMError {
|
||||
pub fn from_json_reader(reader: impl std::io::Read) -> Self {
|
||||
let response = match serde_json::from_reader::<_, Self>(reader) {
|
||||
Ok(response) => response,
|
||||
Err(e) => panic!("parsing error {e}"),
|
||||
};
|
||||
response
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
use super::{
|
||||
nearest_response::NearestResponse,
|
||||
osm::{OSMNode, OSMWay},
|
||||
osm_db::OSMDb,
|
||||
osrm_error::OSRMError,
|
||||
route_response::RouteResponse,
|
||||
};
|
||||
use crate::{common::local_task::LocalTask, Location};
|
||||
use core::panic;
|
||||
use cucumber::World;
|
||||
use log::debug;
|
||||
use reqwest::StatusCode;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs::{create_dir_all, File},
|
||||
io::Write,
|
||||
path::PathBuf,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
const DEFAULT_ORIGIN: Location = Location {
|
||||
longitude: 1.0f64,
|
||||
latitude: 1.0f64,
|
||||
};
|
||||
const DEFAULT_GRID_SIZE: f64 = 100.;
|
||||
const WAY_SPACING: f64 = 100.;
|
||||
const DEFAULT_PROFILE: &str = "bicycle";
|
||||
|
||||
#[derive(Debug, World)]
|
||||
pub struct OSRMWorld {
|
||||
pub feature_path: Option<PathBuf>,
|
||||
pub scenario_id: String,
|
||||
pub feature_digest: String,
|
||||
pub osrm_digest: String,
|
||||
pub osm_id: u64,
|
||||
pub profile: String,
|
||||
|
||||
pub known_osm_nodes: HashMap<char, Location>,
|
||||
pub known_locations: HashMap<char, Location>,
|
||||
|
||||
pub osm_db: OSMDb,
|
||||
pub extraction_parameters: Vec<String>,
|
||||
|
||||
pub request_with_flatbuffers: bool,
|
||||
pub query_options: HashMap<String, String>,
|
||||
pub request_string: Option<String>,
|
||||
|
||||
pub grid_size: f64,
|
||||
pub origin: Location,
|
||||
pub way_spacing: f64,
|
||||
|
||||
task: LocalTask,
|
||||
client: reqwest::blocking::Client,
|
||||
}
|
||||
|
||||
impl Default for OSRMWorld {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
feature_path: Default::default(),
|
||||
scenario_id: Default::default(),
|
||||
feature_digest: Default::default(),
|
||||
osrm_digest: Default::default(),
|
||||
osm_id: Default::default(),
|
||||
profile: DEFAULT_PROFILE.into(),
|
||||
known_osm_nodes: Default::default(),
|
||||
known_locations: Default::default(),
|
||||
osm_db: Default::default(),
|
||||
extraction_parameters: Default::default(),
|
||||
request_with_flatbuffers: Default::default(),
|
||||
query_options: HashMap::from([
|
||||
// default parameters // TODO: check if necessary
|
||||
("steps".into(), "true".into()),
|
||||
("alternatives".into(), "false".into()),
|
||||
// ("annotations".into(), "true".into()),
|
||||
]),
|
||||
request_string: Default::default(),
|
||||
|
||||
grid_size: DEFAULT_GRID_SIZE,
|
||||
origin: DEFAULT_ORIGIN,
|
||||
way_spacing: WAY_SPACING,
|
||||
task: LocalTask::default(),
|
||||
client: reqwest::blocking::Client::builder()
|
||||
.connect_timeout(Duration::from_secs(5))
|
||||
.no_proxy()
|
||||
.http1_only()
|
||||
.build()
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl OSRMWorld {
|
||||
pub fn feature_cache_path(&self) -> PathBuf {
|
||||
let full_path = self.feature_path.clone().unwrap();
|
||||
let path = full_path
|
||||
.ancestors()
|
||||
.find(|p| p.ends_with("features"))
|
||||
.expect(".feature files reside in a directory tree with the root name 'features'");
|
||||
|
||||
let suffix = full_path.strip_prefix(path).unwrap();
|
||||
let path = path.parent().unwrap();
|
||||
debug!("suffix: {suffix:?}");
|
||||
let cache_path = path
|
||||
.join("test")
|
||||
.join("cache")
|
||||
.join(suffix)
|
||||
.join(&self.feature_digest);
|
||||
|
||||
debug!("{cache_path:?}");
|
||||
if !cache_path.exists() {
|
||||
create_dir_all(&cache_path).expect("cache path could not be created");
|
||||
} else {
|
||||
debug!("not creating cache dir");
|
||||
}
|
||||
cache_path
|
||||
}
|
||||
|
||||
pub fn routed_path(&self) -> PathBuf {
|
||||
let full_path = self.feature_path.clone().unwrap();
|
||||
let path = full_path
|
||||
.ancestors()
|
||||
.find(|p| p.ends_with("features"))
|
||||
.expect(".feature files reside in a directory tree with the root name 'features'");
|
||||
let routed_path = path
|
||||
.parent()
|
||||
.expect("cannot get parent path")
|
||||
.join("build")
|
||||
.join("osrm-routed");
|
||||
assert!(routed_path.exists(), "osrm-routed binary not found");
|
||||
routed_path
|
||||
}
|
||||
|
||||
pub fn set_scenario_specific_paths_and_digests(&mut self, path: Option<PathBuf>) {
|
||||
self.feature_path.clone_from(&path);
|
||||
|
||||
let file = File::open(path.clone().unwrap())
|
||||
.unwrap_or_else(|_| panic!("filesystem broken? can't open file {:?}", path));
|
||||
self.feature_digest = chksum_md5::chksum(file)
|
||||
.expect("md5 could not be computed")
|
||||
.to_hex_lowercase();
|
||||
}
|
||||
|
||||
pub fn make_osm_id(&mut self) -> u64 {
|
||||
// number implicitly starts a 1. This is in line with previous implementations
|
||||
self.osm_id += 1;
|
||||
self.osm_id
|
||||
}
|
||||
|
||||
pub fn add_osm_node(&mut self, name: char, location: Location, id: Option<u64>) {
|
||||
if self.known_osm_nodes.contains_key(&name) {
|
||||
panic!("duplicate node: {name}");
|
||||
}
|
||||
let id = match id {
|
||||
Some(id) => id,
|
||||
None => self.make_osm_id(),
|
||||
};
|
||||
let node = OSMNode {
|
||||
id,
|
||||
location,
|
||||
tags: HashMap::from([("name".to_string(), name.to_string())]),
|
||||
};
|
||||
|
||||
self.known_osm_nodes.insert(name, location);
|
||||
self.osm_db.add_node(node);
|
||||
}
|
||||
|
||||
pub fn add_osm_way(&mut self, way: OSMWay) {
|
||||
way.nodes.iter().for_each(|node| {
|
||||
self.osm_db.add_node(node.clone());
|
||||
});
|
||||
|
||||
self.osm_db.add_way(way);
|
||||
}
|
||||
|
||||
pub fn get_location(&self, name: char) -> Location {
|
||||
*match name {
|
||||
// TODO: move lookup to world
|
||||
'0'..='9' => self
|
||||
.known_locations
|
||||
.get(&name)
|
||||
.expect("test case specifies unknown location: {name}"),
|
||||
'a'..='z' => self
|
||||
.known_osm_nodes
|
||||
.get(&name)
|
||||
.expect("test case specifies unknown osm node: {name}"),
|
||||
_ => unreachable!("nodes have to be name in [0-9][a-z]"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_location(&mut self, name: char, location: Location) {
|
||||
if self.known_locations.contains_key(&name) {
|
||||
panic!("duplicate location: {name}")
|
||||
}
|
||||
self.known_locations.insert(name, location);
|
||||
}
|
||||
|
||||
pub fn write_osm_file(&self) {
|
||||
let osm_file = self
|
||||
.feature_cache_path()
|
||||
.join(self.scenario_id.clone() + ".osm");
|
||||
if !osm_file.exists() {
|
||||
debug!("writing to osm file: {osm_file:?}");
|
||||
let mut file = File::create(osm_file).expect("could not create OSM file");
|
||||
file.write_all(self.osm_db.to_xml().as_bytes())
|
||||
.expect("could not write OSM file");
|
||||
} else {
|
||||
debug!("not writing to OSM file {osm_file:?}");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_osm_file(&self) {
|
||||
let cache_path = self.artefact_cache_path();
|
||||
if cache_path.exists() {
|
||||
debug!("{cache_path:?} exists");
|
||||
} else {
|
||||
unimplemented!("{cache_path:?} does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn artefact_cache_path(&self) -> PathBuf {
|
||||
self.feature_cache_path().join(&self.osrm_digest)
|
||||
}
|
||||
|
||||
fn start_routed(&mut self) {
|
||||
if self.task.is_ready() {
|
||||
// task running already
|
||||
return;
|
||||
}
|
||||
let data_path = self
|
||||
.artefact_cache_path()
|
||||
.join(self.scenario_id.to_owned() + ".osrm");
|
||||
|
||||
self.task = LocalTask::new(self.routed_path().to_string_lossy().into())
|
||||
.arg(data_path.to_str().expect("data path unwrappable"));
|
||||
self.task
|
||||
.spawn_wait_till_ready("running and waiting for requests");
|
||||
assert!(self.task.is_ready());
|
||||
}
|
||||
|
||||
pub fn nearest(
|
||||
&mut self,
|
||||
query_location: &Location,
|
||||
) -> Result<(u16, NearestResponse), (u16, OSRMError)> {
|
||||
self.start_routed();
|
||||
|
||||
let mut url = format!(
|
||||
"http://localhost:5000/nearest/v1/{}/{:?},{:?}",
|
||||
self.profile, query_location.longitude, query_location.latitude
|
||||
);
|
||||
if self.request_with_flatbuffers {
|
||||
url += ".flatbuffers";
|
||||
}
|
||||
|
||||
let response = match self.client.get(url).send() {
|
||||
Ok(response) => response,
|
||||
Err(e) => panic!("http error: {e}"),
|
||||
};
|
||||
let status = response.status();
|
||||
let bytes = &response.bytes().unwrap()[..];
|
||||
|
||||
match status {
|
||||
StatusCode::OK => {
|
||||
let response = match self.request_with_flatbuffers {
|
||||
true => NearestResponse::from_flatbuffer(bytes),
|
||||
false => NearestResponse::from_json_reader(bytes),
|
||||
};
|
||||
return Ok((status.as_u16(), response));
|
||||
}
|
||||
_ => {
|
||||
return Err((status.as_u16(), OSRMError::from_json_reader(bytes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn route(
|
||||
&mut self,
|
||||
waypoints: &[Location],
|
||||
) -> Result<(u16, RouteResponse), (u16, OSRMError)> {
|
||||
self.start_routed();
|
||||
|
||||
let waypoint_string = waypoints
|
||||
.iter()
|
||||
.map(|location| format!("{:?},{:?}", location.longitude, location.latitude))
|
||||
.collect::<Vec<String>>()
|
||||
.join(";");
|
||||
|
||||
let url = match &self.request_string {
|
||||
None => {
|
||||
let mut url = format!(
|
||||
"http://127.0.0.1:5000/route/v1/{}/{waypoint_string}",
|
||||
self.profile,
|
||||
);
|
||||
if self.request_with_flatbuffers {
|
||||
url += ".flatbuffers";
|
||||
}
|
||||
if !self.query_options.is_empty() {
|
||||
let options = self
|
||||
.query_options
|
||||
.iter()
|
||||
.map(|(key, value)| format!("{key}={value}"))
|
||||
.collect::<Vec<String>>()
|
||||
.join("&");
|
||||
url += "?";
|
||||
url += &options;
|
||||
}
|
||||
url
|
||||
}
|
||||
Some(request_string) => {
|
||||
let temp = format!("http://127.0.0.1:5000/{}", request_string);
|
||||
temp
|
||||
}
|
||||
};
|
||||
// println!("url: {url}");
|
||||
let response = match self.client.get(url).send() {
|
||||
Ok(response) => response,
|
||||
Err(e) => panic!("http error: {e}"),
|
||||
};
|
||||
let status = &response.status();
|
||||
|
||||
match *status {
|
||||
StatusCode::OK => {
|
||||
let text = response.text().unwrap();
|
||||
let response = match self.request_with_flatbuffers {
|
||||
true => unimplemented!("RouteResponse::from_flatbuffer(body)"),
|
||||
false => RouteResponse::from_string(&text),
|
||||
};
|
||||
Ok((status.as_u16(), response))
|
||||
}
|
||||
_ => {
|
||||
let bytes = &response.bytes().unwrap()[..];
|
||||
return Err((status.as_u16(), OSRMError::from_json_reader(bytes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::{location::Location, nearest_response::Waypoint};
|
||||
|
||||
#[derive(Deserialize, Default, Debug)]
|
||||
pub struct Maneuver {
|
||||
pub bearing_after: u64,
|
||||
pub bearing_before: u64,
|
||||
pub location: Location,
|
||||
pub modifier: Option<String>, // TODO: should be an enum
|
||||
pub r#type: String, // TODO: should be an enum
|
||||
pub exit: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum Geometry {
|
||||
A(String),
|
||||
B {
|
||||
coordinates: Vec<Location>,
|
||||
r#type: String,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for Geometry {
|
||||
fn default() -> Self {
|
||||
Geometry::A("".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Deserialize)]
|
||||
pub struct Intersection {
|
||||
pub r#in: Option<u64>,
|
||||
pub out: Option<u64>,
|
||||
pub entry: Vec<bool>,
|
||||
pub bearings: Vec<u64>,
|
||||
pub location: Location,
|
||||
pub classes: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug)]
|
||||
pub struct Step {
|
||||
pub geometry: Geometry,
|
||||
pub mode: String,
|
||||
pub maneuver: Maneuver,
|
||||
pub name: String,
|
||||
pub pronunciation: Option<String>,
|
||||
pub rotary_name: Option<String>,
|
||||
pub r#ref: Option<String>,
|
||||
pub duration: f64,
|
||||
pub distance: f64,
|
||||
pub intersections: Vec<Intersection>,
|
||||
}
|
||||
|
||||
// #[derive(Deserialize, Debug)]
|
||||
// pub struct Annotation {
|
||||
// pub nodes: Option<Vec<u64>>,
|
||||
// }
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
pub struct Leg {
|
||||
pub summary: String,
|
||||
pub weight: f64,
|
||||
pub duration: f64,
|
||||
pub steps: Vec<Step>,
|
||||
pub distance: f64,
|
||||
// pub annotation: Option<Vec<Annotation>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Default)]
|
||||
pub struct Route {
|
||||
pub geometry: Geometry,
|
||||
pub weight: f64,
|
||||
pub duration: f64,
|
||||
pub legs: Vec<Leg>,
|
||||
pub weight_name: String,
|
||||
pub distance: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
pub struct RouteResponse {
|
||||
pub code: String,
|
||||
pub routes: Vec<Route>,
|
||||
pub waypoints: Option<Vec<Waypoint>>,
|
||||
pub data_version: Option<String>,
|
||||
}
|
||||
|
||||
impl RouteResponse {
|
||||
pub fn from_json_reader(reader: impl std::io::Read) -> Self {
|
||||
let response = match serde_json::from_reader::<_, Self>(reader) {
|
||||
Ok(response) => response,
|
||||
Err(e) => panic!("parsing error {e}"),
|
||||
};
|
||||
response
|
||||
}
|
||||
|
||||
pub fn from_string(input: &str) -> Self {
|
||||
// println!("{input}");
|
||||
let response = match serde_json::from_str(input) {
|
||||
Ok(response) => response,
|
||||
Err(e) => panic!("parsing error {e} => {input}"),
|
||||
};
|
||||
response
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
pub fn scenario_id(scenario: &cucumber::gherkin::Scenario) -> String {
|
||||
// ports the following logic:
|
||||
// let name = scenario.getName().toLowerCase().replace(/[/\-'=,():*#]/g, '')
|
||||
// .replace(/\s/g, '_').replace(/__/g, '_').replace(/\.\./g, '.')
|
||||
// .substring(0, 64);
|
||||
let mut s = scenario
|
||||
.name
|
||||
.to_ascii_lowercase()
|
||||
.replace(
|
||||
&['/', '\\', '-', '\'', '=', ',', '(', ')', ':', '*', '#'][..],
|
||||
"",
|
||||
)
|
||||
.chars()
|
||||
.map(|x| match x {
|
||||
' ' => '_',
|
||||
_ => x,
|
||||
})
|
||||
.collect::<String>()
|
||||
.replace('\\', "_")
|
||||
.replace("__", "_")
|
||||
.replace("..", ".");
|
||||
s.truncate(64);
|
||||
format!("{}_{}", scenario.position.line, s)
|
||||
}
|
||||
+1183
File diff suppressed because it is too large
Load Diff
@@ -1,41 +0,0 @@
|
||||
:: Copyright 2018 Google Inc. All rights reserved.
|
||||
::
|
||||
:: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
:: you may not use this file except in compliance with the License.
|
||||
:: You may obtain a copy of the License at
|
||||
::
|
||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
||||
::
|
||||
:: Unless required by applicable law or agreed to in writing, software
|
||||
:: distributed under the License is distributed on an "AS IS" BASIS,
|
||||
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
:: See the License for the specific language governing permissions and
|
||||
:: limitations under the License.
|
||||
set buildtype=Release
|
||||
if "%1"=="-b" set buildtype=%2
|
||||
|
||||
cd tests
|
||||
call generate_code.bat -b %buildtype% || goto FAIL
|
||||
|
||||
:: TODO: Release and Debug builds produce differences here for some reason.
|
||||
git checkout HEAD -- monster_test.bfbs
|
||||
git checkout HEAD -- arrays_test.bfbs
|
||||
|
||||
git -c core.autocrlf=true diff --exit-code --quiet || goto :DIFFFOUND
|
||||
goto SUCCESS
|
||||
|
||||
:DIFFFOUND
|
||||
@echo "" >&2
|
||||
@echo "ERROR: ********************************************************" >&2
|
||||
@echo "ERROR: The following differences were found after running the" >&2
|
||||
@echo "ERROR: tests/generate_code.sh script. Maybe you forgot to run" >&2
|
||||
@echo "ERROR: it after making changes in a generator or schema?" >&2
|
||||
@echo "ERROR: ********************************************************" >&2
|
||||
@echo "" >&2
|
||||
@git -c core.autocrlf=true --no-pager diff --binary
|
||||
|
||||
:FAIL
|
||||
set EXITCODE=1
|
||||
:SUCCESS
|
||||
cd ..
|
||||
EXIT /B %EXITCODE%
|
||||
+29
-9
@@ -1,18 +1,38 @@
|
||||
---
|
||||
buildifier: latest
|
||||
bazel: 6.4.0
|
||||
platforms:
|
||||
ubuntu1604:
|
||||
build_targets:
|
||||
- "..."
|
||||
test_targets:
|
||||
- "..."
|
||||
ubuntu1804:
|
||||
environment:
|
||||
CC: clang
|
||||
SWIFT_VERSION: "5.5.3"
|
||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||
shell_commands:
|
||||
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||
- "mkdir $SWIFT_HOME"
|
||||
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||
build_targets:
|
||||
- "..."
|
||||
- "//..."
|
||||
test_targets:
|
||||
- "..."
|
||||
- "//..."
|
||||
ubuntu2004:
|
||||
environment:
|
||||
CC: clang
|
||||
SWIFT_VERSION: "5.5.3"
|
||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||
shell_commands:
|
||||
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||
- "mkdir $SWIFT_HOME"
|
||||
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||
build_targets:
|
||||
- "//..."
|
||||
test_targets:
|
||||
- "//..."
|
||||
macos:
|
||||
xcode_version: "14.2"
|
||||
build_targets:
|
||||
- "..."
|
||||
- "//..."
|
||||
test_targets:
|
||||
- "..."
|
||||
- "//..."
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
# We cannot use "common" here because the "version" command doesn't support
|
||||
# --deleted_packages. We need to specify it for both build and query instead.
|
||||
build --deleted_packages=tests/ts/bazel_repository_test_dir
|
||||
query --deleted_packages=tests/ts/bazel_repository_test_dir
|
||||
Vendored
+347
@@ -0,0 +1,347 @@
|
||||
---
|
||||
FormatStyle: "file"
|
||||
WarningsAsErrors: "*"
|
||||
HeaderFilterRegex: ".*"
|
||||
Checks: "google-build-explicit-make-pair,
|
||||
google-build-namespaces,
|
||||
google-build-using-namespace,
|
||||
google-default-arguments,
|
||||
google-explicit-constructor,
|
||||
google-global-names-in-headers,
|
||||
google-objc-avoid-nsobject-new,
|
||||
google-objc-avoid-throwing-exception,
|
||||
google-objc-function-naming,
|
||||
google-objc-global-variable-declaration,
|
||||
google-readability-avoid-underscore-in-googletest-name,
|
||||
google-readability-braces-around-statements,
|
||||
google-readability-casting,
|
||||
google-readability-function-size,
|
||||
google-readability-namespace-comments,
|
||||
google-runtime-int,
|
||||
google-runtime-operator,
|
||||
google-upgrade-googletest-case,
|
||||
clang-analyzer-apiModeling.StdCLibraryFunctions,
|
||||
clang-analyzer-apiModeling.TrustNonnull,
|
||||
clang-analyzer-apiModeling.google.GTest,
|
||||
clang-analyzer-apiModeling.llvm.CastValue,
|
||||
clang-analyzer-apiModeling.llvm.ReturnValue,
|
||||
clang-analyzer-core.CallAndMessage,
|
||||
clang-analyzer-core.CallAndMessageModeling,
|
||||
clang-analyzer-core.DivideZero,
|
||||
clang-analyzer-core.DynamicTypePropagation,
|
||||
clang-analyzer-core.NonNullParamChecker,
|
||||
clang-analyzer-core.NonnilStringConstants,
|
||||
clang-analyzer-core.NullDereference,
|
||||
clang-analyzer-core.StackAddrEscapeBase,
|
||||
clang-analyzer-core.StackAddressEscape,
|
||||
clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
clang-analyzer-core.VLASize,
|
||||
clang-analyzer-core.builtin.BuiltinFunctions,
|
||||
clang-analyzer-core.builtin.NoReturnFunctions,
|
||||
clang-analyzer-core.uninitialized.ArraySubscript,
|
||||
clang-analyzer-core.uninitialized.Assign,
|
||||
clang-analyzer-core.uninitialized.Branch,
|
||||
clang-analyzer-core.uninitialized.CapturedBlockVariable,
|
||||
clang-analyzer-core.uninitialized.UndefReturn,
|
||||
clang-analyzer-cplusplus.InnerPointer,
|
||||
clang-analyzer-cplusplus.Move,
|
||||
clang-analyzer-cplusplus.NewDelete,
|
||||
clang-analyzer-cplusplus.NewDeleteLeaks,
|
||||
clang-analyzer-cplusplus.PlacementNew,
|
||||
clang-analyzer-cplusplus.PureVirtualCall,
|
||||
clang-analyzer-cplusplus.SelfAssignment,
|
||||
clang-analyzer-cplusplus.SmartPtrModeling,
|
||||
clang-analyzer-cplusplus.StringChecker,
|
||||
clang-analyzer-cplusplus.VirtualCallModeling,
|
||||
clang-analyzer-deadcode.DeadStores,
|
||||
clang-analyzer-fuchsia.HandleChecker,
|
||||
clang-analyzer-nullability.NullPassedToNonnull,
|
||||
clang-analyzer-nullability.NullReturnedFromNonnull,
|
||||
clang-analyzer-nullability.NullabilityBase,
|
||||
clang-analyzer-nullability.NullableDereferenced,
|
||||
clang-analyzer-nullability.NullablePassedToNonnull,
|
||||
clang-analyzer-nullability.NullableReturnedFromNonnull,
|
||||
clang-analyzer-optin.cplusplus.UninitializedObject,
|
||||
clang-analyzer-optin.cplusplus.VirtualCall,
|
||||
clang-analyzer-optin.mpi.MPI-Checker,
|
||||
clang-analyzer-optin.osx.OSObjectCStyleCast,
|
||||
clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
|
||||
clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,
|
||||
clang-analyzer-optin.performance.GCDAntipattern,
|
||||
clang-analyzer-optin.performance.Padding,
|
||||
clang-analyzer-optin.portability.UnixAPI,
|
||||
clang-analyzer-osx.API,
|
||||
clang-analyzer-osx.MIG,
|
||||
clang-analyzer-osx.NSOrCFErrorDerefChecker,
|
||||
clang-analyzer-osx.NumberObjectConversion,
|
||||
clang-analyzer-osx.OSObjectRetainCount,
|
||||
clang-analyzer-osx.ObjCProperty,
|
||||
clang-analyzer-osx.SecKeychainAPI,
|
||||
clang-analyzer-osx.cocoa.AtSync,
|
||||
clang-analyzer-osx.cocoa.AutoreleaseWrite,
|
||||
clang-analyzer-osx.cocoa.ClassRelease,
|
||||
clang-analyzer-osx.cocoa.Dealloc,
|
||||
clang-analyzer-osx.cocoa.IncompatibleMethodTypes,
|
||||
clang-analyzer-osx.cocoa.Loops,
|
||||
clang-analyzer-osx.cocoa.MissingSuperCall,
|
||||
clang-analyzer-osx.cocoa.NSAutoreleasePool,
|
||||
clang-analyzer-osx.cocoa.NSError,
|
||||
clang-analyzer-osx.cocoa.NilArg,
|
||||
clang-analyzer-osx.cocoa.NonNilReturnValue,
|
||||
clang-analyzer-osx.cocoa.ObjCGenerics,
|
||||
clang-analyzer-osx.cocoa.RetainCount,
|
||||
clang-analyzer-osx.cocoa.RetainCountBase,
|
||||
clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak,
|
||||
clang-analyzer-osx.cocoa.SelfInit,
|
||||
clang-analyzer-osx.cocoa.SuperDealloc,
|
||||
clang-analyzer-osx.cocoa.UnusedIvars,
|
||||
clang-analyzer-osx.cocoa.VariadicMethodTypes,
|
||||
clang-analyzer-osx.coreFoundation.CFError,
|
||||
clang-analyzer-osx.coreFoundation.CFNumber,
|
||||
clang-analyzer-osx.coreFoundation.CFRetainRelease,
|
||||
clang-analyzer-osx.coreFoundation.containers.OutOfBounds,
|
||||
clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,
|
||||
clang-analyzer-security.FloatLoopCounter,
|
||||
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
|
||||
clang-analyzer-security.insecureAPI.UncheckedReturn,
|
||||
clang-analyzer-security.insecureAPI.bcmp,
|
||||
clang-analyzer-security.insecureAPI.bcopy,
|
||||
clang-analyzer-security.insecureAPI.bzero,
|
||||
clang-analyzer-security.insecureAPI.decodeValueOfObjCType,
|
||||
clang-analyzer-security.insecureAPI.getpw,
|
||||
clang-analyzer-security.insecureAPI.gets,
|
||||
clang-analyzer-security.insecureAPI.mkstemp,
|
||||
clang-analyzer-security.insecureAPI.mktemp,
|
||||
clang-analyzer-security.insecureAPI.rand,
|
||||
clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-analyzer-security.insecureAPI.vfork,
|
||||
clang-analyzer-unix.API,
|
||||
clang-analyzer-unix.DynamicMemoryModeling,
|
||||
clang-analyzer-unix.Malloc,
|
||||
clang-analyzer-unix.MallocSizeof,
|
||||
clang-analyzer-unix.MismatchedDeallocator,
|
||||
clang-analyzer-unix.Vfork,
|
||||
clang-analyzer-unix.cstring.BadSizeArg,
|
||||
clang-analyzer-unix.cstring.CStringModeling,
|
||||
clang-analyzer-unix.cstring.NullArg,
|
||||
clang-analyzer-valist.CopyToSelf,
|
||||
clang-analyzer-valist.Uninitialized,
|
||||
clang-analyzer-valist.Unterminated,
|
||||
clang-analyzer-valist.ValistBase,
|
||||
clang-analyzer-webkit.NoUncountedMemberChecker,
|
||||
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
|
||||
clang-analyzer-webkit.UncountedLambdaCapturesChecker,
|
||||
|
||||
################################################ Optional checks ################################################
|
||||
|
||||
#google-readability-todo,
|
||||
#bugprone-argument-comment,
|
||||
#bugprone-assert-side-effect,
|
||||
#bugprone-bad-signal-to-kill-thread,
|
||||
#bugprone-bool-pointer-implicit-conversion,
|
||||
#bugprone-branch-clone,
|
||||
#bugprone-copy-constructor-init,
|
||||
#bugprone-dangling-handle,
|
||||
#bugprone-dynamic-static-initializers,
|
||||
#bugprone-easily-swappable-parameters,
|
||||
#bugprone-exception-escape,
|
||||
#bugprone-fold-init-type,
|
||||
#bugprone-forward-declaration-namespace,
|
||||
#bugprone-forwarding-reference-overload,
|
||||
#bugprone-implicit-widening-of-multiplication-result,
|
||||
#bugprone-inaccurate-erase,
|
||||
#bugprone-incorrect-roundings,
|
||||
#bugprone-infinite-loop,
|
||||
#bugprone-integer-division,
|
||||
#bugprone-lambda-function-name,
|
||||
#bugprone-macro-parentheses,
|
||||
#bugprone-macro-repeated-side-effects,
|
||||
#bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
#bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||
#bugprone-misplaced-widening-cast,
|
||||
#bugprone-move-forwarding-reference,
|
||||
#bugprone-multiple-statement-macro,
|
||||
#bugprone-narrowing-conversions,
|
||||
#bugprone-no-escape,
|
||||
#bugprone-not-null-terminated-result,
|
||||
#bugprone-parent-virtual-call,
|
||||
#bugprone-posix-return,
|
||||
#bugprone-redundant-branch-condition,
|
||||
#bugprone-reserved-identifier,
|
||||
#bugprone-signal-handler,
|
||||
#bugprone-signed-char-misuse,
|
||||
#bugprone-sizeof-container,
|
||||
#bugprone-sizeof-expression,
|
||||
#bugprone-spuriously-wake-up-functions,
|
||||
#bugprone-string-constructor,
|
||||
#bugprone-string-integer-assignment,
|
||||
#bugprone-string-literal-with-embedded-nul,
|
||||
#bugprone-stringview-nullptr,
|
||||
#bugprone-suspicious-enum-usage,
|
||||
#bugprone-suspicious-include,
|
||||
#bugprone-suspicious-memory-comparison,
|
||||
#bugprone-suspicious-memset-usage,
|
||||
#bugprone-suspicious-missing-comma,
|
||||
#bugprone-suspicious-semicolon,
|
||||
#bugprone-suspicious-string-compare,
|
||||
#bugprone-swapped-arguments,
|
||||
#bugprone-terminating-continue,
|
||||
#bugprone-throw-keyword-missing,
|
||||
#bugprone-too-small-loop-variable,
|
||||
#bugprone-undefined-memory-manipulation,
|
||||
#bugprone-undelegated-constructor,
|
||||
#bugprone-unhandled-exception-at-new,
|
||||
#bugprone-unhandled-self-assignment,
|
||||
#bugprone-unused-raii,
|
||||
#bugprone-unused-return-value,
|
||||
#bugprone-use-after-move,
|
||||
#bugprone-virtual-near-miss,
|
||||
#cppcoreguidelines-avoid-c-arrays,
|
||||
#cppcoreguidelines-avoid-goto,
|
||||
#cppcoreguidelines-avoid-magic-numbers,
|
||||
#cppcoreguidelines-avoid-non-const-global-variables,
|
||||
#cppcoreguidelines-c-copy-assignment-signature,
|
||||
#cppcoreguidelines-explicit-virtual-functions,
|
||||
#cppcoreguidelines-init-variables,
|
||||
#cppcoreguidelines-interfaces-global-init,
|
||||
#cppcoreguidelines-macro-usage,
|
||||
#cppcoreguidelines-narrowing-conversions,
|
||||
#cppcoreguidelines-no-malloc,
|
||||
#cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
#cppcoreguidelines-owning-memory,
|
||||
#cppcoreguidelines-prefer-member-initializer,
|
||||
#cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
#cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
#cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
#cppcoreguidelines-pro-type-const-cast,
|
||||
#cppcoreguidelines-pro-type-cstyle-cast,
|
||||
#cppcoreguidelines-pro-type-member-init,
|
||||
#cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
#cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
#cppcoreguidelines-pro-type-union-access,
|
||||
#cppcoreguidelines-pro-type-vararg,
|
||||
#cppcoreguidelines-slicing,
|
||||
#cppcoreguidelines-special-member-functions,
|
||||
#cppcoreguidelines-virtual-class-destructor,
|
||||
#hicpp-avoid-c-arrays,
|
||||
#hicpp-avoid-goto,
|
||||
#hicpp-braces-around-statements,
|
||||
#hicpp-deprecated-headers,
|
||||
#hicpp-exception-baseclass,
|
||||
#hicpp-explicit-conversions,
|
||||
#hicpp-function-size,
|
||||
#hicpp-invalid-access-moved,
|
||||
#hicpp-member-init,
|
||||
#hicpp-move-const-arg,
|
||||
#hicpp-multiway-paths-covered,
|
||||
#hicpp-named-parameter,
|
||||
#hicpp-new-delete-operators,
|
||||
#hicpp-no-array-decay,
|
||||
#hicpp-no-assembler,
|
||||
#hicpp-no-malloc,
|
||||
#hicpp-noexcept-move,
|
||||
#hicpp-signed-bitwise,
|
||||
#hicpp-special-member-functions,
|
||||
#hicpp-static-assert,
|
||||
#hicpp-undelegated-constructor,
|
||||
#hicpp-uppercase-literal-suffix,
|
||||
#hicpp-use-auto,
|
||||
#hicpp-use-emplace,
|
||||
#hicpp-use-equals-default,
|
||||
#hicpp-use-equals-delete,
|
||||
#hicpp-use-noexcept,
|
||||
#hicpp-use-nullptr,
|
||||
#hicpp-use-override,
|
||||
#hicpp-vararg,
|
||||
#modernize-avoid-bind,
|
||||
#modernize-avoid-c-arrays,
|
||||
#modernize-concat-nested-namespaces,
|
||||
#modernize-deprecated-headers,
|
||||
#modernize-deprecated-ios-base-aliases,
|
||||
#modernize-loop-convert,
|
||||
#modernize-make-shared,
|
||||
#modernize-make-unique,
|
||||
#modernize-pass-by-value,
|
||||
#modernize-raw-string-literal,
|
||||
#modernize-redundant-void-arg,
|
||||
#modernize-replace-auto-ptr,
|
||||
#modernize-replace-disallow-copy-and-assign-macro,
|
||||
#modernize-replace-random-shuffle,
|
||||
#modernize-return-braced-init-list,
|
||||
#modernize-shrink-to-fit,
|
||||
#modernize-unary-static-assert,
|
||||
#modernize-use-auto,
|
||||
#modernize-use-bool-literals,
|
||||
#modernize-use-default-member-init,
|
||||
#modernize-use-emplace,
|
||||
#modernize-use-equals-default,
|
||||
#modernize-use-equals-delete,
|
||||
#modernize-use-nodiscard,
|
||||
#modernize-use-noexcept,
|
||||
#modernize-use-nullptr,
|
||||
#modernize-use-override,
|
||||
#modernize-use-trailing-return-type,
|
||||
#modernize-use-transparent-functors,
|
||||
#modernize-use-uncaught-exceptions,
|
||||
#modernize-use-using,
|
||||
#performance-faster-string-find,
|
||||
#performance-for-range-copy,
|
||||
#performance-implicit-conversion-in-loop,
|
||||
#performance-inefficient-algorithm,
|
||||
#performance-inefficient-string-concatenation,
|
||||
#performance-inefficient-vector-operation,
|
||||
#performance-move-const-arg,
|
||||
#performance-move-constructor-init,
|
||||
#performance-no-automatic-move,
|
||||
#performance-no-int-to-ptr,
|
||||
#performance-noexcept-move-constructor,
|
||||
#performance-trivially-destructible,
|
||||
#performance-type-promotion-in-math-fn,
|
||||
#performance-unnecessary-copy-initialization,
|
||||
#performance-unnecessary-value-param,
|
||||
#portability-restrict-system-includes,
|
||||
#portability-simd-intrinsics,
|
||||
#readability-avoid-const-params-in-decls,
|
||||
#readability-braces-around-statements,
|
||||
#readability-const-return-type,
|
||||
#readability-container-contains,
|
||||
#readability-container-data-pointer,
|
||||
#readability-container-size-empty,
|
||||
#readability-convert-member-functions-to-static,
|
||||
#readability-delete-null-pointer,
|
||||
#readability-duplicate-include,
|
||||
#readability-else-after-return,
|
||||
#readability-function-cognitive-complexity,
|
||||
#readability-function-size,
|
||||
#readability-identifier-length,
|
||||
#readability-identifier-naming,
|
||||
#readability-implicit-bool-conversion,
|
||||
#readability-inconsistent-declaration-parameter-name,
|
||||
#readability-isolate-declaration,
|
||||
#readability-magic-numbers,
|
||||
#readability-make-member-function-const,
|
||||
#readability-misleading-indentation,
|
||||
#readability-misplaced-array-index,
|
||||
#readability-named-parameter,
|
||||
#readability-non-const-parameter,
|
||||
#readability-qualified-auto,
|
||||
#readability-redundant-access-specifiers,
|
||||
#readability-redundant-control-flow,
|
||||
#readability-redundant-declaration,
|
||||
#readability-redundant-function-ptr-dereference,
|
||||
#readability-redundant-member-init,
|
||||
#readability-redundant-preprocessor,
|
||||
#readability-redundant-smartptr-get,
|
||||
#readability-redundant-string-cstr,
|
||||
#readability-redundant-string-init,
|
||||
#readability-simplify-boolean-expr,
|
||||
#readability-simplify-subscript-expr,
|
||||
#readability-static-accessed-through-instance,
|
||||
#readability-static-definition-in-anonymous-namespace,
|
||||
#readability-string-compare,
|
||||
#readability-suspicious-call-argument,
|
||||
#readability-uniqueptr-delete-release,
|
||||
#readability-uppercase-literal-suffix,
|
||||
#readability-use-anyofallof
|
||||
"
|
||||
+1
@@ -5,3 +5,4 @@ root = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
/* eslint-env node */
|
||||
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
]
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
Thank you for submitting an issue!
|
||||
|
||||
Please make sure you include the names of the affected language(s), compiler version(s), operating system version(s), and FlatBuffers version(s) in your issue title.
|
||||
|
||||
This helps us get the correct maintainers to look at your issue. Here are examples of good titles:
|
||||
|
||||
- Crash when accessing FlatBuffer [C++, gcc 4.8, OS X, master]
|
||||
- Flatc converts a protobuf 'bytes' field to 'string' in fbs schema file [all languages, FlatBuffers 1.4]
|
||||
|
||||
Include other details as appropriate.
|
||||
|
||||
Thanks!
|
||||
@@ -1,16 +0,0 @@
|
||||
Thank you for submitting a PR!
|
||||
|
||||
Please make sure you include the names of the affected language(s) in your PR title.
|
||||
This helps us get the correct maintainers to look at your issue.
|
||||
|
||||
If you make changes to any of the code generators, be sure to run
|
||||
`cd tests && sh generate_code.sh` (or equivalent .bat) and include the generated
|
||||
code changes in the PR. This allows us to better see the effect of the PR.
|
||||
|
||||
If your PR includes C++ code, please adhere to the Google C++ Style Guide,
|
||||
and don't forget we try to support older compilers (e.g. VS2010, GCC 4.6.3),
|
||||
so only some C++11 support is available.
|
||||
|
||||
Include other details as appropriate.
|
||||
|
||||
Thanks!
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 365
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 14
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
activity for 1 year. It will be automatically closed if no further activity occurs.
|
||||
To keep it open, simply post a new comment. Maintainers will re-open on
|
||||
new activity. Thank you for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
@@ -1,6 +1,13 @@
|
||||
*_wire.txt
|
||||
*_wire.bin
|
||||
.DS_Store
|
||||
**/.build
|
||||
build
|
||||
**/Packages
|
||||
/*.xcodeproj
|
||||
**/xcuserdata/
|
||||
**/xcshareddata/
|
||||
**/.swiftpm/
|
||||
*.o
|
||||
*.o.d
|
||||
*.class
|
||||
@@ -39,12 +46,16 @@ project.properties
|
||||
proguard-project.txt
|
||||
linklint_results
|
||||
Makefile
|
||||
flatbenchmark
|
||||
flatbenchmark.exe
|
||||
flatc
|
||||
flatc.exe
|
||||
flathash
|
||||
flathash.exe
|
||||
flattests
|
||||
flattests.exe
|
||||
flattests_cpp17
|
||||
flattests_cpp17.exe
|
||||
flatsamplebinary
|
||||
flatsamplebinary.exe
|
||||
flatsampletext
|
||||
@@ -63,13 +74,11 @@ tests/monsterdata_go_wire.mon
|
||||
tests/monsterdata_javascript_wire.mon
|
||||
tests/monsterdata_lobster_wire.mon
|
||||
tests/monsterdata_rust_wire.mon
|
||||
tests/unicode_test.mon
|
||||
tests/ts/
|
||||
tests/php/
|
||||
CMakeLists.txt.user
|
||||
CMakeScripts/**
|
||||
CTestTestfile.cmake
|
||||
FlatbuffersConfigVersion.cmake
|
||||
flatbuffers-config-version.cmake
|
||||
FlatBuffers.cbp
|
||||
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
|
||||
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
|
||||
@@ -79,6 +88,7 @@ java/*.iml
|
||||
.idea
|
||||
*.iml
|
||||
target
|
||||
java/target
|
||||
**/*.pyc
|
||||
build/VS2010/FlatBuffers.sdf
|
||||
build/VS2010/FlatBuffers.opensdf
|
||||
@@ -96,7 +106,10 @@ android/build/
|
||||
samples/android/.externalNativeBuild/
|
||||
samples/android/.gradle/
|
||||
samples/android/build/
|
||||
js/flatbuffers.mjs
|
||||
js/**/*.js
|
||||
js/**/*.d.ts
|
||||
mjs/**/*.js
|
||||
mjs/**/*.d.ts
|
||||
/bazel-bin
|
||||
/bazel-flatbuffers
|
||||
/bazel-genfiles
|
||||
@@ -116,3 +129,27 @@ dart/doc/api/
|
||||
Cargo.lock
|
||||
.corpus**
|
||||
.seed**
|
||||
.crash**
|
||||
grpc/google/
|
||||
**/Package.resolved
|
||||
.clangd/**
|
||||
package-lock.json
|
||||
/*.ilk
|
||||
/*.pdb
|
||||
.clwb
|
||||
yarn-error.log
|
||||
.cache/
|
||||
/flatbuffers.lib
|
||||
.cmake/
|
||||
**/dist
|
||||
**/vendor
|
||||
**/go.sum
|
||||
flatbuffers.pc
|
||||
**/FlatBuffers.Test.Swift.xcodeproj
|
||||
**/html/**
|
||||
**/latex/**
|
||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
|
||||
cmake-build-debug/
|
||||
_deps/
|
||||
**/.gradle/**
|
||||
kotlin/**/generated
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
hoist=false
|
||||
Vendored
-221
@@ -1,221 +0,0 @@
|
||||
env:
|
||||
global:
|
||||
# Set at the root level as this is ignored when set under matrix.env.
|
||||
- GCC_VERSION="4.9"
|
||||
# Fail on first error if UBSAN or ASAN enabled for a target
|
||||
- UBSAN_OPTIONS=halt_on_error=1
|
||||
- ASAN_OPTIONS=halt_on_error=1
|
||||
# Travis machines have 2 cores
|
||||
- JOBS=2
|
||||
- MAKEFLAGS="-j 2"
|
||||
|
||||
conan-linux: &conan-linux
|
||||
os: linux
|
||||
dist: xenial
|
||||
language: python
|
||||
python: "3.7"
|
||||
services:
|
||||
- docker
|
||||
install:
|
||||
- ./conan/travis/install.sh
|
||||
script:
|
||||
- ./conan/travis/build.sh
|
||||
if: tag IS present
|
||||
|
||||
conan-linux-master: &conan-linux-master
|
||||
os: linux
|
||||
dist: xenial
|
||||
language: python
|
||||
python: "3.7"
|
||||
services:
|
||||
- docker
|
||||
install:
|
||||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/install.sh; fi'
|
||||
script:
|
||||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/build.sh; fi'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
conan-osx: &conan-osx
|
||||
os: osx
|
||||
language: generic
|
||||
install:
|
||||
- ./conan/travis/install.sh
|
||||
script:
|
||||
- ./conan/travis/build.sh
|
||||
if: tag IS present
|
||||
|
||||
matrix:
|
||||
include:
|
||||
#- language: python
|
||||
# python: "2.7"
|
||||
# install:
|
||||
# - "pip install wheel twine"
|
||||
# script:
|
||||
# - "cd python/"
|
||||
# - 'VERSION="$TRAVIS_TAG" python setup.py sdist bdist_wheel'
|
||||
# - "cd ../"
|
||||
# deploy:
|
||||
# # Checkpointed release builds.
|
||||
# - provider: script
|
||||
# script: .travis/deploy-python.sh
|
||||
# skip_cleanup: true
|
||||
# on:
|
||||
# tags: true
|
||||
# # all_branches must be set with tags: true. See below post:
|
||||
# # https://stackoverflow.com/a/27775257/1076585
|
||||
# all_branches: true
|
||||
# # Produce a new build for the cutting edge when master changes.
|
||||
# - provider: script
|
||||
# script: .travis/deploy-python.sh
|
||||
# skip_cleanup: true
|
||||
# on:
|
||||
# branch: master
|
||||
- language: cpp
|
||||
os:
|
||||
- linux
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- docker-ce
|
||||
script:
|
||||
- bash .travis/build-and-run-docker-test-containers.sh
|
||||
|
||||
- language: cpp
|
||||
os:
|
||||
- linux
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BUILD_TYPE=Debug
|
||||
- BUILD_TYPE=Release
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
||||
|
||||
script:
|
||||
- bash .travis/check-sources.sh
|
||||
- bash grpc/build_grpc.sh
|
||||
- cmake .
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
||||
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
||||
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
||||
-DFLATBUFFERS_CODE_SANITIZE=ON
|
||||
- cmake --build . -- -j${JOBS}
|
||||
- LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
||||
- bash .travis/check-generate-code.sh
|
||||
|
||||
- language: cpp
|
||||
os: osx
|
||||
osx_image: xcode9.3
|
||||
env:
|
||||
matrix:
|
||||
- BUILD_TYPE=Debug
|
||||
- BUILD_TYPE=Release
|
||||
|
||||
script:
|
||||
- bash grpc/build_grpc.sh
|
||||
- cmake .
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
||||
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
||||
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
||||
-DFLATBUFFERS_CODE_SANITIZE=ON
|
||||
- cmake --build . -- -j${JOBS}
|
||||
- DYLD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
||||
- bash .travis/check-generate-code.sh
|
||||
|
||||
- <<: *conan-linux-master
|
||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=conanio/clang39
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode7.3
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=7.3
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode8.3
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=8.1
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode9
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.0
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode9.4
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.1
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode10.2
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||
|
||||
- language: android
|
||||
sudo: true
|
||||
dist: trusty
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- build-tools-25.0.2
|
||||
- android-25
|
||||
- extra-android-m2repository
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
before_install:
|
||||
# Output something every 10 minutes or Travis kills the job
|
||||
- while sleep 540; do echo "=====[ $SECONDS seconds still running ]====="; done &
|
||||
# Install the r17c version of the NDK that still so that we can continue to test with gnustl
|
||||
# and stlport.
|
||||
- export ANDROID_NDK_HOME=$HOME/android-ndk
|
||||
- NDK_ZIP=$ANDROID_NDK_HOME/ndk.zip
|
||||
- mkdir -p $ANDROID_NDK_HOME
|
||||
- curl -o $NDK_ZIP https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip
|
||||
- unzip -q -d $ANDROID_NDK_HOME $NDK_ZIP
|
||||
- rm $NDK_ZIP
|
||||
- mv $ANDROID_NDK_HOME/android-ndk-*/* $ANDROID_NDK_HOME
|
||||
- rmdir $ANDROID_NDK_HOME/android-ndk-*
|
||||
- export CMAKE=$(which cmake)
|
||||
# libc required for prebuilt llvm toolchain the NDK r17c.
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq libc6; fi
|
||||
# Setup environment for Linux build which is required to build the sample.
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
||||
script:
|
||||
- failed=0; for build_gradle in $(git ls-files | grep build.gradle); do ( cd "$(dirname "${build_gradle}")" && ./gradlew build ) || failed=1; done; exit $((failed))
|
||||
# Kill the sleep loop
|
||||
- kill %1
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
set -e
|
||||
|
||||
# build flatc on debian once to speed up the test loop below
|
||||
docker build -t build_flatc_debian_stretch -f tests/docker/Dockerfile.testing.build_flatc_debian_stretch .
|
||||
BUILD_CONTAINER_ID=$(docker create --read-only build_flatc_debian_stretch)
|
||||
docker cp ${BUILD_CONTAINER_ID}:/code/flatc flatc_debian_stretch
|
||||
|
||||
for f in $(ls tests/docker/languages | sort)
|
||||
do
|
||||
# docker pull sometimes fails for unknown reasons, probably travisci-related. this retries the pull we need a few times.
|
||||
REQUIRED_BASE_IMAGE=$(cat tests/docker/languages/${f} | head -n 1 | awk ' { print $2 } ')
|
||||
|
||||
set +e
|
||||
n=0
|
||||
until [ $n -ge 5 ]
|
||||
do
|
||||
docker pull $REQUIRED_BASE_IMAGE && break
|
||||
n=$[$n+1]
|
||||
sleep 1
|
||||
done
|
||||
set -e
|
||||
|
||||
docker build -t $(echo ${f} | cut -f 3- -d .) -f tests/docker/languages/${f} .
|
||||
echo "TEST OK: ${f}"
|
||||
done
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
set -e
|
||||
|
||||
cd tests
|
||||
./generate_code.sh
|
||||
cd ..
|
||||
|
||||
# TODO: Linux and macos builds produce differences here for some reason.
|
||||
git checkout HEAD -- tests/monster_test.bfbs
|
||||
git checkout HEAD -- tests/arrays_test.bfbs
|
||||
|
||||
if ! git diff --quiet; then
|
||||
echo >&2
|
||||
echo "ERROR: ********************************************************" >&2
|
||||
echo "ERROR: The following differences were found after running the" >&2
|
||||
echo "ERROR: tests/generate_code.sh script. Maybe you forgot to run" >&2
|
||||
echo "ERROR: it after making changes in a generator or schema?" >&2
|
||||
echo "ERROR: ********************************************************" >&2
|
||||
echo >&2
|
||||
git diff --binary --exit-code
|
||||
fi
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
set -e
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
scan_dir="$1"
|
||||
else
|
||||
scan_dir="$( pwd )"
|
||||
fi
|
||||
|
||||
py_checker="$0.py"
|
||||
|
||||
echo "scan root directory = '$scan_dir'"
|
||||
python3 --version
|
||||
# Scan recursively and search all *.cpp and *.h files using regex patterns.
|
||||
# Assume that script running from a root of Flatbuffers working dir.
|
||||
python3 $py_checker "ascii" "$scan_dir/include" "\.h$"
|
||||
python3 $py_checker "ascii" "$scan_dir/src" "\.cpp$"
|
||||
python3 $py_checker "ascii" "$scan_dir/tests" "\.h$"
|
||||
python3 $py_checker "utf-8" "$scan_dir/tests" "\.cpp$"
|
||||
@@ -1,35 +0,0 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
def check_encoding(encoding, scan_dir, regex_pattern):
|
||||
fname = None
|
||||
try:
|
||||
assert encoding in ['ascii', 'utf-8'], "unexpected encoding"
|
||||
cmp = re.compile(regex_pattern)
|
||||
for root, dirs, files in os.walk(scan_dir):
|
||||
fname = root
|
||||
cmp_list = [f for f in files if cmp.search(f) is not None]
|
||||
for f in cmp_list:
|
||||
fname = os.path.join(root, f)
|
||||
with open(fname, mode='rb') as test_file:
|
||||
btext = test_file.read()
|
||||
# check encoding
|
||||
btext.decode(encoding=encoding, errors="strict")
|
||||
if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
|
||||
raise ValueError("unexpected BOM in file")
|
||||
# check LF line endings
|
||||
LF = btext.count(b'\n')
|
||||
CR = btext.count(b'\r')
|
||||
if CR!=0:
|
||||
raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR))
|
||||
except Exception as err:
|
||||
print("ERROR with [{}]: {}".format(fname, err))
|
||||
return -1
|
||||
else:
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
# python check-sources.sh.py 'ascii' '.' '.*\.(cpp|h)$'
|
||||
res = check_encoding(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||
sys.exit(0 if res == 0 else -1)
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
PROD_REPOSITORY="https://upload.pypi.org/legacy/"
|
||||
TEST_REPOSITORY="https://test.pypi.org/legacy/"
|
||||
|
||||
twine upload \
|
||||
--username "$PYPI_USERNAME" \
|
||||
--password "$PYPI_PASSWORD" \
|
||||
--repository-url "$PROD_REPOSITORY" \
|
||||
"$DIR/../python/dist/"*
|
||||
|
||||
Vendored
-225
@@ -1,225 +0,0 @@
|
||||
licenses(["notice"])
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
features = [
|
||||
"-layering_check",
|
||||
"-parse_headers",
|
||||
],
|
||||
)
|
||||
|
||||
exports_files([
|
||||
"LICENSE",
|
||||
])
|
||||
|
||||
load(":build_defs.bzl", "flatbuffer_cc_library")
|
||||
|
||||
# Public flatc library to compile flatbuffer files at runtime.
|
||||
cc_library(
|
||||
name = "flatbuffers",
|
||||
srcs = [
|
||||
"src/code_generators.cpp",
|
||||
"src/idl_gen_fbs.cpp",
|
||||
"src/idl_gen_general.cpp",
|
||||
"src/idl_gen_text.cpp",
|
||||
"src/idl_parser.cpp",
|
||||
"src/reflection.cpp",
|
||||
"src/util.cpp",
|
||||
],
|
||||
hdrs = [":public_headers"],
|
||||
includes = ["include/"],
|
||||
linkstatic = 1,
|
||||
)
|
||||
|
||||
# Public C++ headers for the Flatbuffers library.
|
||||
filegroup(
|
||||
name = "public_headers",
|
||||
srcs = [
|
||||
"include/flatbuffers/base.h",
|
||||
"include/flatbuffers/code_generators.h",
|
||||
"include/flatbuffers/flatbuffers.h",
|
||||
"include/flatbuffers/flexbuffers.h",
|
||||
"include/flatbuffers/hash.h",
|
||||
"include/flatbuffers/idl.h",
|
||||
"include/flatbuffers/minireflect.h",
|
||||
"include/flatbuffers/reflection.h",
|
||||
"include/flatbuffers/reflection_generated.h",
|
||||
"include/flatbuffers/stl_emulation.h",
|
||||
"include/flatbuffers/util.h",
|
||||
],
|
||||
)
|
||||
|
||||
# Public flatc compiler library.
|
||||
cc_library(
|
||||
name = "flatc_library",
|
||||
srcs = [
|
||||
"src/code_generators.cpp",
|
||||
"src/flatc.cpp",
|
||||
"src/idl_gen_fbs.cpp",
|
||||
"src/idl_parser.cpp",
|
||||
"src/reflection.cpp",
|
||||
"src/util.cpp",
|
||||
],
|
||||
hdrs = [
|
||||
"include/flatbuffers/flatc.h",
|
||||
":public_headers",
|
||||
],
|
||||
includes = [
|
||||
"grpc/",
|
||||
"include/",
|
||||
],
|
||||
)
|
||||
|
||||
# Public flatc compiler.
|
||||
cc_binary(
|
||||
name = "flatc",
|
||||
srcs = [
|
||||
"grpc/src/compiler/config.h",
|
||||
"grpc/src/compiler/cpp_generator.cc",
|
||||
"grpc/src/compiler/cpp_generator.h",
|
||||
"grpc/src/compiler/go_generator.cc",
|
||||
"grpc/src/compiler/go_generator.h",
|
||||
"grpc/src/compiler/java_generator.cc",
|
||||
"grpc/src/compiler/java_generator.h",
|
||||
"grpc/src/compiler/schema_interface.h",
|
||||
"src/flatc_main.cpp",
|
||||
"src/idl_gen_cpp.cpp",
|
||||
"src/idl_gen_dart.cpp",
|
||||
"src/idl_gen_general.cpp",
|
||||
"src/idl_gen_kotlin.cpp",
|
||||
"src/idl_gen_go.cpp",
|
||||
"src/idl_gen_grpc.cpp",
|
||||
"src/idl_gen_js_ts.cpp",
|
||||
"src/idl_gen_json_schema.cpp",
|
||||
"src/idl_gen_lobster.cpp",
|
||||
"src/idl_gen_lua.cpp",
|
||||
"src/idl_gen_php.cpp",
|
||||
"src/idl_gen_python.cpp",
|
||||
"src/idl_gen_rust.cpp",
|
||||
"src/idl_gen_text.cpp",
|
||||
"src/util.cpp",
|
||||
],
|
||||
includes = [
|
||||
"grpc/",
|
||||
"include/",
|
||||
],
|
||||
deps = [
|
||||
":flatc_library",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "runtime_cc",
|
||||
hdrs = [
|
||||
"include/flatbuffers/base.h",
|
||||
"include/flatbuffers/flatbuffers.h",
|
||||
"include/flatbuffers/flexbuffers.h",
|
||||
"include/flatbuffers/stl_emulation.h",
|
||||
"include/flatbuffers/util.h",
|
||||
],
|
||||
includes = ["include/"],
|
||||
linkstatic = 1,
|
||||
)
|
||||
|
||||
# Test binary.
|
||||
cc_test(
|
||||
name = "flatbuffers_test",
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
"include/flatbuffers/minireflect.h",
|
||||
"include/flatbuffers/registry.h",
|
||||
"src/code_generators.cpp",
|
||||
"src/idl_gen_fbs.cpp",
|
||||
"src/idl_gen_general.cpp",
|
||||
"src/idl_gen_text.cpp",
|
||||
"src/idl_parser.cpp",
|
||||
"src/reflection.cpp",
|
||||
"src/util.cpp",
|
||||
"tests/namespace_test/namespace_test1_generated.h",
|
||||
"tests/namespace_test/namespace_test2_generated.h",
|
||||
"tests/native_type_test_impl.h",
|
||||
"tests/native_type_test_impl.cpp",
|
||||
"tests/test.cpp",
|
||||
"tests/test_assert.cpp",
|
||||
"tests/test_assert.h",
|
||||
"tests/test_builder.cpp",
|
||||
"tests/test_builder.h",
|
||||
"tests/union_vector/union_vector_generated.h",
|
||||
":public_headers",
|
||||
],
|
||||
copts = [
|
||||
"-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
|
||||
"-DBAZEL_TEST_DATA_PATH",
|
||||
],
|
||||
data = [
|
||||
":tests/include_test/include_test1.fbs",
|
||||
":tests/include_test/sub/include_test2.fbs",
|
||||
":tests/monster_test.bfbs",
|
||||
":tests/monster_test.fbs",
|
||||
":tests/monsterdata_test.golden",
|
||||
":tests/monsterdata_test.json",
|
||||
":tests/prototest/imported.proto",
|
||||
":tests/prototest/test.golden",
|
||||
":tests/prototest/test.proto",
|
||||
":tests/prototest/test_union.golden",
|
||||
":tests/unicode_test.json",
|
||||
":tests/union_vector/union_vector.fbs",
|
||||
":tests/union_vector/union_vector.json",
|
||||
":tests/monster_extra.fbs",
|
||||
":tests/monsterdata_extra.json",
|
||||
":tests/arrays_test.bfbs",
|
||||
":tests/arrays_test.fbs",
|
||||
":tests/arrays_test.golden",
|
||||
":tests/native_type_test.fbs",
|
||||
],
|
||||
includes = [
|
||||
"include/",
|
||||
"tests/",
|
||||
],
|
||||
deps = [
|
||||
":monster_extra_cc_fbs",
|
||||
":monster_test_cc_fbs",
|
||||
":arrays_test_cc_fbs",
|
||||
":native_type_test_cc_fbs",
|
||||
],
|
||||
)
|
||||
|
||||
# Test bzl rules
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "monster_test_cc_fbs",
|
||||
srcs = ["tests/monster_test.fbs"],
|
||||
include_paths = ["tests/include_test"],
|
||||
includes = [
|
||||
"tests/include_test/include_test1.fbs",
|
||||
"tests/include_test/sub/include_test2.fbs",
|
||||
],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "monster_extra_cc_fbs",
|
||||
srcs = ["tests/monster_extra.fbs"],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "arrays_test_cc_fbs",
|
||||
srcs = ["tests/arrays_test.fbs"],
|
||||
flatc_args = [
|
||||
"--gen-object-api",
|
||||
"--gen-compare",
|
||||
"--no-includes",
|
||||
"--gen-mutable",
|
||||
"--reflect-names",
|
||||
"--cpp-ptr-type flatbuffers::unique_ptr",
|
||||
"--scoped-enums" ],
|
||||
)
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "native_type_test_cc_fbs",
|
||||
srcs = ["tests/native_type_test.fbs"],
|
||||
flatc_args = [
|
||||
"--gen-object-api",
|
||||
"--gen-mutable",
|
||||
"--cpp-ptr-type flatbuffers::unique_ptr" ],
|
||||
)
|
||||
|
||||
Vendored
+139
@@ -0,0 +1,139 @@
|
||||
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
|
||||
load("@npm//:defs.bzl", "npm_link_all_packages")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
npm_link_all_packages(name = "node_modules")
|
||||
|
||||
npm_link_package(
|
||||
name = "node_modules/flatbuffers",
|
||||
src = "//ts:flatbuffers",
|
||||
)
|
||||
|
||||
exports_files([
|
||||
"LICENSE",
|
||||
"tsconfig.json",
|
||||
])
|
||||
|
||||
config_setting(
|
||||
name = "platform_freebsd",
|
||||
constraint_values = [
|
||||
"@platforms//os:freebsd",
|
||||
],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "platform_openbsd",
|
||||
constraint_values = [
|
||||
"@platforms//os:openbsd",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "distribution",
|
||||
srcs = [
|
||||
"BUILD.bazel",
|
||||
"WORKSPACE",
|
||||
"build_defs.bzl",
|
||||
"typescript.bzl",
|
||||
"//grpc/src/compiler:distribution",
|
||||
"//reflection:distribution",
|
||||
"//src:distribution",
|
||||
"//ts:distribution",
|
||||
] + glob([
|
||||
"include/flatbuffers/*.h",
|
||||
]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
# Public flatc library to compile flatbuffer files at runtime.
|
||||
cc_library(
|
||||
name = "flatbuffers",
|
||||
hdrs = ["//:public_headers"],
|
||||
linkstatic = 1,
|
||||
strip_include_prefix = "/include",
|
||||
deps = ["//src:flatbuffers"],
|
||||
)
|
||||
|
||||
# Public C++ headers for the Flatbuffers library.
|
||||
filegroup(
|
||||
name = "public_headers",
|
||||
srcs = [
|
||||
"include/flatbuffers/allocator.h",
|
||||
"include/flatbuffers/array.h",
|
||||
"include/flatbuffers/base.h",
|
||||
"include/flatbuffers/buffer.h",
|
||||
"include/flatbuffers/buffer_ref.h",
|
||||
"include/flatbuffers/code_generator.h",
|
||||
"include/flatbuffers/code_generators.h",
|
||||
"include/flatbuffers/default_allocator.h",
|
||||
"include/flatbuffers/detached_buffer.h",
|
||||
"include/flatbuffers/file_manager.h",
|
||||
"include/flatbuffers/flatbuffer_builder.h",
|
||||
"include/flatbuffers/flatbuffers.h",
|
||||
"include/flatbuffers/flex_flat_util.h",
|
||||
"include/flatbuffers/flexbuffers.h",
|
||||
"include/flatbuffers/grpc.h",
|
||||
"include/flatbuffers/hash.h",
|
||||
"include/flatbuffers/idl.h",
|
||||
"include/flatbuffers/minireflect.h",
|
||||
"include/flatbuffers/reflection.h",
|
||||
"include/flatbuffers/reflection_generated.h",
|
||||
"include/flatbuffers/registry.h",
|
||||
"include/flatbuffers/stl_emulation.h",
|
||||
"include/flatbuffers/string.h",
|
||||
"include/flatbuffers/struct.h",
|
||||
"include/flatbuffers/table.h",
|
||||
"include/flatbuffers/util.h",
|
||||
"include/flatbuffers/vector.h",
|
||||
"include/flatbuffers/vector_downward.h",
|
||||
"include/flatbuffers/verifier.h",
|
||||
],
|
||||
)
|
||||
|
||||
# Public flatc compiler library.
|
||||
cc_library(
|
||||
name = "flatc_library",
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
"//src:flatc_library",
|
||||
],
|
||||
)
|
||||
|
||||
# Public flatc compiler.
|
||||
cc_binary(
|
||||
name = "flatc",
|
||||
data = ["//reflection:reflection_fbs_schema"],
|
||||
deps = [
|
||||
"//src:flatc",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "flatc_headers",
|
||||
srcs = [
|
||||
"include/flatbuffers/flatc.h",
|
||||
],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
# Library used by flatbuffer_cc_library rules.
|
||||
cc_library(
|
||||
name = "runtime_cc",
|
||||
hdrs = [
|
||||
"include/flatbuffers/base.h",
|
||||
"include/flatbuffers/flatbuffers.h",
|
||||
"include/flatbuffers/flexbuffers.h",
|
||||
"include/flatbuffers/stl_emulation.h",
|
||||
"include/flatbuffers/util.h",
|
||||
"include/flatbuffers/vector.h",
|
||||
"include/flatbuffers/verifier.h",
|
||||
],
|
||||
linkstatic = 1,
|
||||
strip_include_prefix = "/include",
|
||||
)
|
||||
Vendored
+168
@@ -0,0 +1,168 @@
|
||||
# Flatbuffers Change Log
|
||||
|
||||
All major or breaking changes will be documented in this file, as well as any
|
||||
new features that should be highlighted. Minor fixes or improvements are not
|
||||
necessarily listed.
|
||||
|
||||
## [24.3.25] (March 25 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.25)
|
||||
|
||||
* Fixed license metadata parsing (#8253)
|
||||
* [C++] Allow string_view in `LookUpByKey` in addition to null-terminated c-style strings (#8203)
|
||||
|
||||
## [24.3.7] (March 7 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.7)
|
||||
|
||||
* Just to fix some of the CI build issues from the 24.3.6 release.
|
||||
|
||||
## [24.3.6] (March 6 2024)(https://github.com/google/flatbuffers/releases/tag/v24.3.6)
|
||||
|
||||
* Fix typescript object API to allow 0 values for null-default scalars (#7864)
|
||||
|
||||
## [23.5.26 (May 26 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.26)
|
||||
|
||||
* Mostly bug fixing for 64-bit support
|
||||
* Adds support for specifying underling type of unions in C++ and TS/JS (#7954)
|
||||
|
||||
## [23.5.9 (May 9 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.9)
|
||||
|
||||
* 64-bit support for C++ (#7935)
|
||||
|
||||
## [23.5.8 (May 8 2023)](https://github.com/google/flatbuffers/releases/tag/v23.5.8)
|
||||
|
||||
* add key_field to compiled tests
|
||||
* Add golden language directory
|
||||
* Rework cmake flatc codegeneration (#7938)
|
||||
* remove defining generated files in test srcs
|
||||
* Add binary schema reflection (#7932)
|
||||
* Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
|
||||
* `flat_buffers.dart`: mark const variable finals for internal Dart linters
|
||||
* fixed some windows warnings (#7929)
|
||||
* inject no long for FBS generation to remove logs in flattests (#7926)
|
||||
* Revert "Migrate from rules_nodejs to rules_js/rules_ts (#7923)" (#7927)
|
||||
* Migrate from rules_nodejs to rules_js/rules_ts (#7923)
|
||||
* Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter. (#7881)
|
||||
* additional check for absl::string_view availability (#7897)
|
||||
* Optionally generate Python type annotations (#7858)
|
||||
* Replace deprecated command with environment file (#7921)
|
||||
* drop glibc from runtime dependencies (#7906)
|
||||
* Make JSON supporting advanced union features (#7869)
|
||||
* Allow to use functions from `BuildFlatBuffers.cmake` from a flatbuffers installation installed with CMake. (#7912)
|
||||
* TS/JS: Use TypeError instead of Error when appropriate (#7910)
|
||||
* Go: make generated code more compliant to "go fmt" (#7907)
|
||||
* Support file_identifier in Go (#7904)
|
||||
* Optionally generate type prefixes and suffixes for python code (#7857)
|
||||
* Go: add test for FinishWithFileIdentifier (#7905)
|
||||
* Fix go_sample.sh (#7903)
|
||||
* [TS/JS] Upgrade dependencies (#7889)
|
||||
* Add a FileWriter interface (#7821)
|
||||
* TS/JS: Use minvalue from enum if not found (#7888)
|
||||
* [CS] Verifier (#7850)
|
||||
* README.md: PyPI case typo (#7880)
|
||||
* Update go documentation link to point to root module (#7879)
|
||||
* use Bool for flatbuffers bool instead of Byte (#7876)
|
||||
* fix using null string in vector (#7872)
|
||||
* Add `flatbuffers-64` branch to CI for pushes
|
||||
* made changes to the rust docs so they would compile. new_with_capacity is deprecated should use with_capacity, get_root_as_monster should be root_as_monster (#7871)
|
||||
* Adding comment for code clarification (#7856)
|
||||
* ToCamelCase() when kLowerCamel now converts first char to lower. (#7838)
|
||||
* Fix help output for --java-checkerframework (#7854)
|
||||
* Update filename to README.md and improve formatting (#7855)
|
||||
* Update stale.yml
|
||||
* Updated remaining usages of LICENSE.txt
|
||||
|
||||
## [23.3.3 (Mar 3 2023)](https://github.com/google/flatbuffers/releases/tag/v23.3.3)
|
||||
|
||||
* Refactoring of `flatc` generators to use an interface (#7797).
|
||||
|
||||
* Removed legacy cmake support and set min to 3.8 (#7801).
|
||||
|
||||
## [23.1.21 (Jan 21 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||
|
||||
* Reworked entry points for Typescript/Javascript and compatibility for single
|
||||
file build (#7510)
|
||||
|
||||
## [23.1.20 (Jan 20 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||
|
||||
* Removed go.mod files after some versioning issues were being report (#7780).
|
||||
|
||||
## [23.1.4 (Jan 4 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.4)
|
||||
|
||||
* Major release! Just kidding, we are continuing the
|
||||
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning) of
|
||||
using a date to signify releases. This results in the first release of the new
|
||||
year to bump the tradition major version field.
|
||||
|
||||
* Go minimum version is now 1.19 (#7720) with the addition of Go modules.
|
||||
|
||||
* Added CI support for Big Endian regression testing (#7707).
|
||||
|
||||
* Fixed `getFullyQualifiedName` in typescript to return name delimited by '.'
|
||||
instead of '_' (#7730).
|
||||
|
||||
* Fixed the versioning scheme to not include leading zeros which are not
|
||||
consistently handled by every package manager. Only the last release
|
||||
(12.12.06) should have suffered from this.
|
||||
|
||||
## [22.12.06 (Dec 06 2022)](https://github.com/google/flatbuffers/releases/tag/v22.12.06)
|
||||
|
||||
* Bug fixing release, no major changes.
|
||||
|
||||
## [22.10.25 (Oct 25 2022)](https://github.com/google/flatbuffers/releases/tag/v22.10.25)
|
||||
|
||||
* Added Nim language support with generator and runtime libraries (#7534).
|
||||
|
||||
## [22.9.29 (Sept 29 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.29)
|
||||
|
||||
* Rust soundness fixes to avoid the crate from bing labelled unsafe (#7518).
|
||||
|
||||
## [22.9.24 (Sept 24 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.24)
|
||||
|
||||
* 20 Major releases in a row? Nope, we switched to a new
|
||||
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning)
|
||||
that is based on date.
|
||||
|
||||
* Python supports fixed size arrays now (#7529).
|
||||
|
||||
* Behavior change in how C++ object API uses `UnPackTo`. The original intent of
|
||||
this was to reduce allocations by reusing an existing object to pack data
|
||||
into. At some point, this logic started to merge the states of the two objects
|
||||
instead of clearing the state of the packee. This change goes back to the
|
||||
original intention, the packed object is cleared when getting data packed into
|
||||
it (#7527).
|
||||
|
||||
* Fixed a bug in C++ alignment that was using `sizeof()` instead of the intended
|
||||
`AlignOf()` for structs (#7520).
|
||||
|
||||
* C# has an
|
||||
[official Nuget package](https://www.nuget.org/packages/Google.FlatBuffers)
|
||||
now (#7496).
|
||||
|
||||
## 2.0.8 (Aug 29 2022)
|
||||
|
||||
* Fix for `--keep-prefix` the was generating the wrong include statements for
|
||||
C++ (#7469). The bug was introduced in 2.0.7.
|
||||
|
||||
* Added the `Verifier::Options` option struct to allow specifying runtime
|
||||
configuration settings for the verifier (#7489). This allows to skip verifying
|
||||
nested flatbuffers, a on-by-default change that was introduced in 2.0.7. This
|
||||
deprecates the existing `Verifier` constructor, which may be removed in a
|
||||
future version.
|
||||
|
||||
* Refactor of `tests/test.cpp` that lead to ~10% speedup in compilation of the
|
||||
entire project (#7487).
|
||||
|
||||
## 2.0.7 (Aug 22 2022)
|
||||
|
||||
* This is the first version with an explicit change log, so all the previous
|
||||
features will not be listed.
|
||||
|
||||
* Verifier now checks that buffers are at least the minimum size required to be
|
||||
a flatbuffers (12 bytes). This includes nested flatbuffers, which previously
|
||||
could be declared valid at size 0.
|
||||
|
||||
* Annotated binaries. Given a flatbuffer binary and a schema (or binary schema)
|
||||
one can generate an annotated flatbuffer (.afb) to describe each byte in the
|
||||
binary with schema metadata and value.
|
||||
|
||||
* First binary schema generator (Lua) to generate Lua code via a .bfbs file.
|
||||
This is mostly an implementation detail of flatc internals, but will be slowly
|
||||
applied to the other language generators.
|
||||
@@ -59,6 +59,9 @@ function(build_flatbuffers flatbuffers_schemas
|
||||
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATC_TARGET "")
|
||||
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||
elseif(TARGET flatbuffers::flatc)
|
||||
set(FLATC_TARGET flatbuffers::flatc)
|
||||
set(FLATC flatbuffers::flatc)
|
||||
else()
|
||||
set(FLATC_TARGET flatc)
|
||||
set(FLATC flatc)
|
||||
@@ -150,3 +153,297 @@ function(build_flatbuffers flatbuffers_schemas
|
||||
${copy_text_schemas_dir})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Creates a target that can be linked against that generates flatbuffer headers.
|
||||
#
|
||||
# This function takes a target name and a list of schemas. You can also specify
|
||||
# other flagc flags using the FLAGS option to change the behavior of the flatc
|
||||
# tool.
|
||||
#
|
||||
# When the target_link_libraries is done within a different directory than
|
||||
# flatbuffers_generate_headers is called, then the target should also be dependent
|
||||
# the custom generation target called GENERATE_<TARGET>.
|
||||
#
|
||||
# Arguments:
|
||||
# TARGET: The name of the target to generate.
|
||||
# SCHEMAS: The list of schema files to generate code for.
|
||||
# BINARY_SCHEMAS_DIR: Optional. The directory in which to generate binary
|
||||
# schemas. Binary schemas will only be generated if a path is provided.
|
||||
# INCLUDE: Optional. Search for includes in the specified paths. (Use this
|
||||
# instead of "-I <path>" and the FLAGS option so that CMake is aware of
|
||||
# the directories that need to be searched).
|
||||
# INCLUDE_PREFIX: Optional. The directory in which to place the generated
|
||||
# files. Use this instead of the --include-prefix option.
|
||||
# FLAGS: Optional. A list of any additional flags that you would like to pass
|
||||
# to flatc.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# flatbuffers_generate_headers(
|
||||
# TARGET my_generated_headers_target
|
||||
# INCLUDE_PREFIX ${MY_INCLUDE_PREFIX}"
|
||||
# SCHEMAS ${MY_SCHEMA_FILES}
|
||||
# BINARY_SCHEMAS_DIR "${MY_BINARY_SCHEMA_DIRECTORY}"
|
||||
# FLAGS --gen-object-api)
|
||||
#
|
||||
# target_link_libraries(MyExecutableTarget
|
||||
# PRIVATE my_generated_headers_target
|
||||
# )
|
||||
#
|
||||
# Optional (only needed within different directory):
|
||||
# add_dependencies(app GENERATE_my_generated_headers_target)
|
||||
function(flatbuffers_generate_headers)
|
||||
# Parse function arguments.
|
||||
set(options)
|
||||
set(one_value_args
|
||||
"TARGET"
|
||||
"INCLUDE_PREFIX"
|
||||
"BINARY_SCHEMAS_DIR")
|
||||
set(multi_value_args
|
||||
"SCHEMAS"
|
||||
"INCLUDE"
|
||||
"FLAGS")
|
||||
cmake_parse_arguments(
|
||||
PARSE_ARGV 0
|
||||
FLATBUFFERS_GENERATE_HEADERS
|
||||
"${options}"
|
||||
"${one_value_args}"
|
||||
"${multi_value_args}")
|
||||
|
||||
# Test if including from FindFlatBuffers
|
||||
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATC_TARGET "")
|
||||
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||
elseif(TARGET flatbuffers::flatc)
|
||||
set(FLATC_TARGET flatbuffers::flatc)
|
||||
set(FLATC flatbuffers::flatc)
|
||||
else()
|
||||
set(FLATC_TARGET flatc)
|
||||
set(FLATC flatc)
|
||||
endif()
|
||||
|
||||
set(working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# Generate the include files parameters.
|
||||
set(include_params "")
|
||||
foreach (include_dir ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE})
|
||||
set(include_params -I ${include_dir} ${include_params})
|
||||
endforeach()
|
||||
|
||||
# Create a directory to place the generated code.
|
||||
set(generated_target_dir "${CMAKE_CURRENT_BINARY_DIR}/${FLATBUFFERS_GENERATE_HEADERS_TARGET}")
|
||||
set(generated_include_dir "${generated_target_dir}")
|
||||
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX} STREQUAL "")
|
||||
set(generated_include_dir "${generated_include_dir}/${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX}")
|
||||
list(APPEND FLATBUFFERS_GENERATE_HEADERS_FLAGS
|
||||
"--include-prefix" ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX})
|
||||
endif()
|
||||
|
||||
set(generated_custom_commands)
|
||||
|
||||
# Create rules to generate the code for each schema.
|
||||
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||
get_filename_component(filename ${schema} NAME_WE)
|
||||
set(generated_include "${generated_include_dir}/${filename}_generated.h")
|
||||
|
||||
# Generate files for grpc if needed
|
||||
set(generated_source_file)
|
||||
if("${FLATBUFFERS_GENERATE_HEADERS_FLAGS}" MATCHES "--grpc")
|
||||
# Check if schema file contain a rpc_service definition
|
||||
file(STRINGS ${schema} has_grpc REGEX "rpc_service")
|
||||
if(has_grpc)
|
||||
list(APPEND generated_include "${generated_include_dir}/${filename}.grpc.fb.h")
|
||||
set(generated_source_file "${generated_include_dir}/${filename}.grpc.fb.cc")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${generated_include} ${generated_source_file}
|
||||
COMMAND ${FLATC} ${FLATC_ARGS}
|
||||
-o ${generated_include_dir}
|
||||
${include_params}
|
||||
-c ${schema}
|
||||
${FLATBUFFERS_GENERATE_HEADERS_FLAGS}
|
||||
DEPENDS ${FLATC_TARGET} ${schema}
|
||||
WORKING_DIRECTORY "${working_dir}"
|
||||
COMMENT "Building ${schema} flatbuffers...")
|
||||
list(APPEND all_generated_header_files ${generated_include})
|
||||
list(APPEND all_generated_source_files ${generated_source_file})
|
||||
list(APPEND generated_custom_commands "${generated_include}" "${generated_source_file}")
|
||||
|
||||
# Geneate the binary flatbuffers schemas if instructed to.
|
||||
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
||||
set(binary_schema
|
||||
"${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR}/${filename}.bfbs")
|
||||
add_custom_command(
|
||||
OUTPUT ${binary_schema}
|
||||
COMMAND ${FLATC} -b --schema
|
||||
-o ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR}
|
||||
${include_params}
|
||||
${schema}
|
||||
DEPENDS ${FLATC_TARGET} ${schema}
|
||||
WORKING_DIRECTORY "${working_dir}")
|
||||
list(APPEND generated_custom_commands "${binary_schema}")
|
||||
list(APPEND all_generated_binary_files ${binary_schema})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Create an additional target as add_custom_command scope is only within same directory (CMakeFile.txt)
|
||||
set(generate_target GENERATE_${FLATBUFFERS_GENERATE_HEADERS_TARGET})
|
||||
add_custom_target(${generate_target} ALL
|
||||
DEPENDS ${generated_custom_commands}
|
||||
COMMENT "Generating flatbuffer target ${FLATBUFFERS_GENERATE_HEADERS_TARGET}")
|
||||
|
||||
# Set up interface library
|
||||
add_library(${FLATBUFFERS_GENERATE_HEADERS_TARGET} INTERFACE)
|
||||
target_sources(
|
||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||
INTERFACE
|
||||
${all_generated_header_files}
|
||||
${all_generated_binary_files}
|
||||
${all_generated_source_files}
|
||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||
add_dependencies(
|
||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||
${FLATC}
|
||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||
target_include_directories(
|
||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||
INTERFACE ${generated_target_dir})
|
||||
|
||||
# Organize file layout for IDEs.
|
||||
source_group(
|
||||
TREE "${generated_target_dir}"
|
||||
PREFIX "Flatbuffers/Generated/Headers Files"
|
||||
FILES ${all_generated_header_files})
|
||||
source_group(
|
||||
TREE "${generated_target_dir}"
|
||||
PREFIX "Flatbuffers/Generated/Source Files"
|
||||
FILES ${all_generated_source_files})
|
||||
source_group(
|
||||
TREE ${working_dir}
|
||||
PREFIX "Flatbuffers/Schemas"
|
||||
FILES ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
||||
source_group(
|
||||
TREE "${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR}"
|
||||
PREFIX "Flatbuffers/Generated/Binary Schemas"
|
||||
FILES ${all_generated_binary_files})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Creates a target that can be linked against that generates flatbuffer binaries
|
||||
# from json files.
|
||||
#
|
||||
# This function takes a target name and a list of schemas and Json files. You
|
||||
# can also specify other flagc flags and options to change the behavior of the
|
||||
# flatc compiler.
|
||||
#
|
||||
# Adding this target to your executable ensurses that the flatbuffer binaries
|
||||
# are compiled before your executable is run.
|
||||
#
|
||||
# Arguments:
|
||||
# TARGET: The name of the target to generate.
|
||||
# JSON_FILES: The list of json files to compile to flatbuffers binaries.
|
||||
# SCHEMA: The flatbuffers schema of the Json files to be compiled.
|
||||
# INCLUDE: Optional. Search for includes in the specified paths. (Use this
|
||||
# instead of "-I <path>" and the FLAGS option so that CMake is aware of
|
||||
# the directories that need to be searched).
|
||||
# OUTPUT_DIR: The directly where the generated flatbuffers binaries should be
|
||||
# placed.
|
||||
# FLAGS: Optional. A list of any additional flags that you would like to pass
|
||||
# to flatc.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# flatbuffers_generate_binary_files(
|
||||
# TARGET my_binary_data
|
||||
# SCHEMA "${MY_SCHEMA_DIR}/my_example_schema.fbs"
|
||||
# JSON_FILES ${MY_JSON_FILES}
|
||||
# OUTPUT_DIR "${MY_BINARY_DATA_DIRECTORY}"
|
||||
# FLAGS --strict-json)
|
||||
#
|
||||
# target_link_libraries(MyExecutableTarget
|
||||
# PRIVATE my_binary_data
|
||||
# )
|
||||
function(flatbuffers_generate_binary_files)
|
||||
# Parse function arguments.
|
||||
set(options)
|
||||
set(one_value_args
|
||||
"TARGET"
|
||||
"SCHEMA"
|
||||
"OUTPUT_DIR")
|
||||
set(multi_value_args
|
||||
"JSON_FILES"
|
||||
"INCLUDE"
|
||||
"FLAGS")
|
||||
cmake_parse_arguments(
|
||||
PARSE_ARGV 0
|
||||
FLATBUFFERS_GENERATE_BINARY_FILES
|
||||
"${options}"
|
||||
"${one_value_args}"
|
||||
"${multi_value_args}")
|
||||
|
||||
# Test if including from FindFlatBuffers
|
||||
if(FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATC_TARGET "")
|
||||
set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE})
|
||||
elseif(TARGET flatbuffers::flatc)
|
||||
set(FLATC_TARGET flatbuffers::flatc)
|
||||
set(FLATC flatbuffers::flatc)
|
||||
else()
|
||||
set(FLATC_TARGET flatc)
|
||||
set(FLATC flatc)
|
||||
endif()
|
||||
|
||||
set(working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# Generate the include files parameters.
|
||||
set(include_params "")
|
||||
foreach (include_dir ${FLATBUFFERS_GENERATE_BINARY_FILES_INCLUDE})
|
||||
set(include_params -I ${include_dir} ${include_params})
|
||||
endforeach()
|
||||
|
||||
# Create rules to generate the flatbuffers binary for each json file.
|
||||
foreach(json_file ${FLATBUFFERS_GENERATE_BINARY_FILES_JSON_FILES})
|
||||
get_filename_component(filename ${json_file} NAME_WE)
|
||||
set(generated_binary_file "${FLATBUFFERS_GENERATE_BINARY_FILES_OUTPUT_DIR}/${filename}.bin")
|
||||
add_custom_command(
|
||||
OUTPUT ${generated_binary_file}
|
||||
COMMAND ${FLATC} ${FLATC_ARGS}
|
||||
-o ${FLATBUFFERS_GENERATE_BINARY_FILES_OUTPUT_DIR}
|
||||
${include_params}
|
||||
-b ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA} ${json_file}
|
||||
${FLATBUFFERS_GENERATE_BINARY_FILES_FLAGS}
|
||||
DEPENDS ${FLATC_TARGET} ${json_file}
|
||||
WORKING_DIRECTORY "${working_dir}"
|
||||
COMMENT "Building ${json_file} binary flatbuffers...")
|
||||
list(APPEND all_generated_binary_files ${generated_binary_file})
|
||||
endforeach()
|
||||
|
||||
# Set up interface library
|
||||
add_library(${FLATBUFFERS_GENERATE_BINARY_FILES_TARGET} INTERFACE)
|
||||
target_sources(
|
||||
${FLATBUFFERS_GENERATE_BINARY_FILES_TARGET}
|
||||
INTERFACE
|
||||
${all_generated_binary_files}
|
||||
${FLATBUFFERS_GENERATE_BINARY_FILES_JSON_FILES}
|
||||
${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA})
|
||||
add_dependencies(
|
||||
${FLATBUFFERS_GENERATE_BINARY_FILES_TARGET}
|
||||
${FLATC})
|
||||
|
||||
# Organize file layout for IDEs.
|
||||
source_group(
|
||||
TREE ${working_dir}
|
||||
PREFIX "Flatbuffers/JSON Files"
|
||||
FILES ${FLATBUFFERS_GENERATE_BINARY_FILES_JSON_FILES})
|
||||
source_group(
|
||||
TREE ${working_dir}
|
||||
PREFIX "Flatbuffers/Schemas"
|
||||
FILES ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA})
|
||||
source_group(
|
||||
TREE ${FLATBUFFERS_GENERATE_BINARY_FILES_OUTPUT_DIR}
|
||||
PREFIX "Flatbuffers/Generated/Binary Files"
|
||||
FILES ${all_generated_binary_files})
|
||||
endfunction()
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc)
|
||||
find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(flatbuffers
|
||||
find_package_handle_standard_args(FlatBuffers
|
||||
DEFAULT_MSG FLATBUFFERS_FLATC_EXECUTABLE FLATBUFFERS_INCLUDE_DIR)
|
||||
|
||||
if(FLATBUFFERS_FOUND)
|
||||
@@ -58,4 +58,4 @@ else()
|
||||
set(FLATBUFFERS_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
include("${FLATBUFFERS_CMAKE_DIR}/BuildFlatBuffers.cmake")
|
||||
include("${FLATBUFFERS_CMAKE_DIR}/BuildFlatBuffers.cmake")
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersSharedTargets.cmake" OPTIONAL)
|
||||
|
||||
+2
-16
@@ -17,23 +17,9 @@ if (UNIX)
|
||||
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
# Derive architecture
|
||||
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
FIND_PROGRAM(DPKG_CMD dpkg)
|
||||
IF(NOT DPKG_CMD)
|
||||
MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
|
||||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
|
||||
ENDIF(NOT DPKG_CMD)
|
||||
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
|
||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
|
||||
# Package name
|
||||
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||
SET(CPACK_PACKAGE_FILE_NAME
|
||||
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
|
||||
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
|
||||
|
||||
endif(UNIX)
|
||||
|
||||
+12
-2
@@ -15,14 +15,14 @@ if (UNIX)
|
||||
|
||||
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||
|
||||
# Assume this is not a cross complation build.
|
||||
# Assume this is not a cross compilation build.
|
||||
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "Google, Inc.")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/CMake/DESCRIPTION.txt)
|
||||
|
||||
# This may reduce rpm compatiblity with very old systems.
|
||||
@@ -31,4 +31,14 @@ if (UNIX)
|
||||
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||
set(CPACK_PACKAGE_FILE_NAME
|
||||
"${CPACK_RPM_PACKAGE_NAME}_${CPACK_RPM_PACKAGE_VERSION}_${CPACK_RPM_PACKAGE_ARCHITECTURE}")
|
||||
if(NOT DEFINED ${CPACK_PACKAGING_INSTALL_PREFIX})
|
||||
# Default packaging install prefix on RedHat systems is /usr.
|
||||
# This is the assumed value when this variable is not defined.
|
||||
# There is currently a conflict with
|
||||
# /usr/${CMAKE_INSTALL_LIBDIR}/cmake which is installed by default
|
||||
# by other packages on RedHat (most notably cmake-filesystem). Ensure
|
||||
# that on these systems, flatbuffers does not package this path.
|
||||
# This patch is required for cmake pre-3.17.
|
||||
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/${CMAKE_INSTALL_LIBDIR}/cmake")
|
||||
endif()
|
||||
endif(UNIX)
|
||||
|
||||
+39
-11
@@ -1,11 +1,39 @@
|
||||
find_program(GIT git)
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
|
||||
set(VERSION_MAJOR 24)
|
||||
set(VERSION_MINOR 3)
|
||||
set(VERSION_PATCH 25)
|
||||
set(VERSION_COMMIT 0)
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
find_program(GIT git)
|
||||
if(GIT)
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE GIT_DESCRIBE_RESULT
|
||||
)
|
||||
|
||||
if(GIT_DESCRIBE_RESULT EQUAL 0)
|
||||
# Test if the most recent Git tag matches the pattern "v<major>.<minor>.<patch>*"
|
||||
if(GIT_DESCRIBE_DIRTY MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+.*")
|
||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
|
||||
# If the tag points to the commit, then only the tag is shown in "git describe"
|
||||
if(VERSION_COMMIT STREQUAL GIT_DESCRIBE_DIRTY)
|
||||
set(VERSION_COMMIT 0)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "\"${GIT_DESCRIBE_DIRTY}\" does not match pattern v<major>.<minor>.<patch>-<commit>")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}\nMake sure you cloned with tags or run 'git fetch --tags'.")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git is not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "Proceeding with version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT}")
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersSharedTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/BuildFlatBuffers.cmake" OPTIONAL)
|
||||
@@ -0,0 +1,9 @@
|
||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
|
||||
Name: FlatBuffers
|
||||
Description: Memory Efficient Serialization Library
|
||||
Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@
|
||||
|
||||
Libs: -L${libdir} -lflatbuffers
|
||||
Cflags: -I${includedir}
|
||||
+454
-218
@@ -1,9 +1,15 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
# This is the legacy minimum version flatbuffers supported for a while.
|
||||
cmake_minimum_required(VERSION 3.8...3.25.2)
|
||||
|
||||
# Attempt to read the current version of flatbuffers by looking at the latest tag.
|
||||
include(CMake/Version.cmake)
|
||||
|
||||
project(FlatBuffers
|
||||
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
LANGUAGES CXX)
|
||||
|
||||
# generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
||||
project(FlatBuffers)
|
||||
|
||||
# NOTE: Code coverage only works on Linux & OSX.
|
||||
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
|
||||
@@ -13,7 +19,11 @@ option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library"
|
||||
ON)
|
||||
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
|
||||
ON)
|
||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
||||
option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag"
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" OFF)
|
||||
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
||||
option(FLATBUFFERS_BUILD_SHAREDLIB
|
||||
"Enable the build of the flatbuffers shared library"
|
||||
@@ -29,6 +39,47 @@ option(FLATBUFFERS_PACKAGE_REDHAT
|
||||
option(FLATBUFFERS_PACKAGE_DEBIAN
|
||||
"Build an deb using the 'package' target."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_CPP17
|
||||
"Enable the build of c++17 test target. \"
|
||||
Requirements: Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_LEGACY
|
||||
"Run C++ code generator with '--cpp-std c++0x' switch."
|
||||
OFF)
|
||||
option(FLATBUFFERS_ENABLE_PCH
|
||||
"Enable precompile headers support for 'flatbuffers' and 'flatc'. \"
|
||||
Only work if CMake supports 'target_precompile_headers'. \"
|
||||
This can speed up compilation time."
|
||||
OFF)
|
||||
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
|
||||
"Skip generating monster_extra.fbs that contains non-supported numerical\"
|
||||
types." OFF)
|
||||
option(FLATBUFFERS_STRICT_MODE
|
||||
"Build flatbuffers with all warnings as errors (-Werror or /WX)."
|
||||
OFF)
|
||||
|
||||
if(NOT DEFINED FLATBUFFERS_CPP_STD)
|
||||
set(FLATBUFFERS_CPP_STD 11)
|
||||
endif()
|
||||
|
||||
set(MSVC_LIKE OFF)
|
||||
if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
set(MSVC_LIKE ON)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(IS_CLANG ON)
|
||||
else()
|
||||
set(IS_CLANG OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED FLATBUFFERS_COMPILATION_TIMINGS)
|
||||
message("Recording Compilation Timings to ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
file(REMOVE ${FLATBUFFERS_COMPILATION_TIMINGS})
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
endif()
|
||||
|
||||
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||
message(WARNING
|
||||
@@ -44,8 +95,10 @@ endif()
|
||||
|
||||
# Auto-detect locale-narrow 'strtod_l' and 'strtoull_l' functions.
|
||||
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
||||
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
|
||||
if(MSVC)
|
||||
if(MSVC_LIKE)
|
||||
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||
else()
|
||||
@@ -58,20 +111,41 @@ if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
endif()
|
||||
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||
|
||||
if(NOT WIN32)
|
||||
check_symbol_exists(realpath "stdlib.h" HAVE_REALPATH)
|
||||
if(NOT HAVE_REALPATH)
|
||||
add_definitions(-DFLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(FlatBuffers_Library_SRCS
|
||||
include/flatbuffers/code_generators.h
|
||||
include/flatbuffers/allocator.h
|
||||
include/flatbuffers/array.h
|
||||
include/flatbuffers/base.h
|
||||
include/flatbuffers/buffer.h
|
||||
include/flatbuffers/buffer_ref.h
|
||||
include/flatbuffers/default_allocator.h
|
||||
include/flatbuffers/detached_buffer.h
|
||||
include/flatbuffers/code_generator.h
|
||||
include/flatbuffers/file_manager.h
|
||||
include/flatbuffers/flatbuffer_builder.h
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/flexbuffers.h
|
||||
include/flatbuffers/flex_flat_util.h
|
||||
include/flatbuffers/hash.h
|
||||
include/flatbuffers/idl.h
|
||||
include/flatbuffers/util.h
|
||||
include/flatbuffers/minireflect.h
|
||||
include/flatbuffers/reflection.h
|
||||
include/flatbuffers/reflection_generated.h
|
||||
include/flatbuffers/stl_emulation.h
|
||||
include/flatbuffers/flexbuffers.h
|
||||
include/flatbuffers/registry.h
|
||||
include/flatbuffers/minireflect.h
|
||||
src/code_generators.cpp
|
||||
include/flatbuffers/stl_emulation.h
|
||||
include/flatbuffers/string.h
|
||||
include/flatbuffers/struct.h
|
||||
include/flatbuffers/table.h
|
||||
include/flatbuffers/util.h
|
||||
include/flatbuffers/vector.h
|
||||
include/flatbuffers/vector_downward.h
|
||||
include/flatbuffers/verifier.h
|
||||
src/idl_parser.cpp
|
||||
src/idl_gen_text.cpp
|
||||
src/reflection.cpp
|
||||
@@ -80,22 +154,43 @@ set(FlatBuffers_Library_SRCS
|
||||
|
||||
set(FlatBuffers_Compiler_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_binary.cpp
|
||||
src/idl_gen_text.cpp
|
||||
src/idl_gen_cpp.cpp
|
||||
src/idl_gen_csharp.cpp
|
||||
src/idl_gen_dart.cpp
|
||||
src/idl_gen_general.cpp
|
||||
src/idl_gen_kotlin.cpp
|
||||
src/idl_gen_kotlin_kmp.cpp
|
||||
src/idl_gen_go.cpp
|
||||
src/idl_gen_js_ts.cpp
|
||||
src/idl_gen_java.cpp
|
||||
src/idl_gen_ts.cpp
|
||||
src/idl_gen_php.cpp
|
||||
src/idl_gen_python.cpp
|
||||
src/idl_gen_lobster.cpp
|
||||
src/idl_gen_lua.cpp
|
||||
src/idl_gen_rust.cpp
|
||||
src/idl_gen_fbs.cpp
|
||||
src/idl_gen_grpc.cpp
|
||||
src/idl_gen_json_schema.cpp
|
||||
src/idl_gen_swift.cpp
|
||||
src/file_name_saving_file_manager.cpp
|
||||
src/file_binary_writer.cpp
|
||||
src/file_writer.cpp
|
||||
src/idl_namer.h
|
||||
src/namer.h
|
||||
src/flatc.cpp
|
||||
src/flatc_main.cpp
|
||||
src/bfbs_gen.h
|
||||
src/bfbs_gen_lua.h
|
||||
src/bfbs_gen_nim.h
|
||||
src/bfbs_namer.h
|
||||
include/flatbuffers/code_generators.h
|
||||
src/binary_annotator.h
|
||||
src/binary_annotator.cpp
|
||||
src/annotated_binary_text_gen.h
|
||||
src/annotated_binary_text_gen.cpp
|
||||
src/bfbs_gen_lua.cpp
|
||||
src/bfbs_gen_nim.cpp
|
||||
src/code_generators.cpp
|
||||
grpc/src/compiler/schema_interface.h
|
||||
grpc/src/compiler/cpp_generator.h
|
||||
grpc/src/compiler/cpp_generator.cc
|
||||
@@ -103,6 +198,12 @@ set(FlatBuffers_Compiler_SRCS
|
||||
grpc/src/compiler/go_generator.cc
|
||||
grpc/src/compiler/java_generator.h
|
||||
grpc/src/compiler/java_generator.cc
|
||||
grpc/src/compiler/python_generator.h
|
||||
grpc/src/compiler/python_generator.cc
|
||||
grpc/src/compiler/swift_generator.h
|
||||
grpc/src/compiler/swift_generator.cc
|
||||
grpc/src/compiler/ts_generator.h
|
||||
grpc/src/compiler/ts_generator.cc
|
||||
)
|
||||
|
||||
set(FlatHash_SRCS
|
||||
@@ -113,41 +214,51 @@ set(FlatHash_SRCS
|
||||
set(FlatBuffers_Tests_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_fbs.cpp
|
||||
tests/evolution_test.cpp
|
||||
tests/flexbuffers_test.cpp
|
||||
tests/fuzz_test.cpp
|
||||
tests/json_test.cpp
|
||||
tests/key_field_test.cpp
|
||||
tests/monster_test.cpp
|
||||
tests/optional_scalars_test.cpp
|
||||
tests/parser_test.cpp
|
||||
tests/proto_test.cpp
|
||||
tests/reflection_test.cpp
|
||||
tests/test.cpp
|
||||
tests/test_assert.h
|
||||
tests/test_assert.cpp
|
||||
tests/test_builder.h
|
||||
tests/test_builder.cpp
|
||||
tests/util_test.cpp
|
||||
tests/native_type_test_impl.h
|
||||
tests/native_type_test_impl.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
# file generate by running compiler on tests/arrays_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/arrays_test_generated.h
|
||||
# file generate by running compiler on tests/native_type_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/native_type_test_generated.h
|
||||
tests/alignment_test.h
|
||||
tests/alignment_test.cpp
|
||||
tests/64bit/offset64_test.h
|
||||
tests/64bit/offset64_test.cpp
|
||||
include/flatbuffers/code_generators.h
|
||||
src/code_generators.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Tests_CPP17_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
tests/test_assert.h
|
||||
tests/test_assert.cpp
|
||||
tests/cpp17/test_cpp17.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Binary_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
samples/sample_binary.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Text_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
samples/sample_text.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_BFBS_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_general.cpp
|
||||
samples/sample_bfbs.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_GRPCTest_SRCS
|
||||
@@ -163,210 +274,316 @@ set(FlatBuffers_GRPCTest_SRCS
|
||||
tests/test_builder.cpp
|
||||
grpc/tests/grpctest.cpp
|
||||
grpc/tests/message_builder_test.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
||||
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
||||
|
||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
# do not apply any global settings if the toolchain
|
||||
# is being configured externally
|
||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||
elseif(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
else(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
|
||||
list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning
|
||||
endif()
|
||||
if(FLATBUFFERS_LIBCXX_WITH_CLANG)
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR
|
||||
"${CMAKE_SYSTEM_NAME}" MATCHES "Linux"))
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
elseif(MSVC)
|
||||
# Visual Studio pedantic build settings
|
||||
# warning C4512: assignment operator could not be generated
|
||||
# warning C4316: object allocated on the heap may not be aligned
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316")
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_CODE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
# TODO(dbaileychess): Figure out how this would now work. I posted a question on
|
||||
# https://stackoverflow.com/questions/71772330/override-target-compile-options-via-cmake-command-line.
|
||||
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
|
||||
if(DEFINED FLATBUFFERS_CXX_FLAGS)
|
||||
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
|
||||
endif()
|
||||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
function(add_fsanitize_to_target _target _sanitizer)
|
||||
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
||||
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
||||
)
|
||||
set(_sanitizer_flags "=address,undefined")
|
||||
if(_sanitizer MATCHES "=.*")
|
||||
# override default by user-defined sanitizer list
|
||||
set(_sanitizer_flags ${_sanitizer})
|
||||
if(WIN32)
|
||||
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||
message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to ${_target}")
|
||||
else()
|
||||
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||
if(IS_CLANG OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9))
|
||||
set(_sanitizer_flags "=address,undefined")
|
||||
if(_sanitizer MATCHES "=.*")
|
||||
# override default by user-defined sanitizer list
|
||||
set(_sanitizer_flags ${_sanitizer})
|
||||
endif()
|
||||
target_compile_options(${_target} PRIVATE
|
||||
-g -fsigned-char -fno-omit-frame-pointer
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
target_link_libraries(${_target} PRIVATE
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
set_target_properties(${_target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||
endif()
|
||||
target_compile_options(${_target} PRIVATE
|
||||
-g -fsigned-char -fno-omit-frame-pointer
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
target_link_libraries(${_target} PRIVATE
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(BIICODE)
|
||||
include(biicode/cmake/biicode.cmake)
|
||||
return()
|
||||
endif()
|
||||
function(add_pch_to_target _target _pch_header)
|
||||
# the command is available since cmake 3.16
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(${_target} PRIVATE ${_pch_header})
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(src/util.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
include_directories(include)
|
||||
include_directories(grpc)
|
||||
|
||||
# Creates an interface library that stores the configuration settings that each
|
||||
# target links too. This is a compromise between setting configuration globally
|
||||
# with add_compile_options() and the more targetted target_compile_options().
|
||||
# This way each target in this file can share settings and override them if
|
||||
# needed.
|
||||
add_library(ProjectConfig INTERFACE)
|
||||
target_compile_features(ProjectConfig
|
||||
INTERFACE
|
||||
cxx_std_${FLATBUFFERS_CPP_STD}
|
||||
)
|
||||
|
||||
# Force the standard to be met.
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# We shouldn't rely on any compiler-extensions to make things work.
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if(MSVC_LIKE)
|
||||
target_compile_options(ProjectConfig
|
||||
INTERFACE
|
||||
/W4
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
/WX # Treat all compiler warnings as errors
|
||||
>
|
||||
/wd4512 # C4512: assignment operator could not be generated
|
||||
/wd4316 # C4316: object allocated on the heap may not be aligned
|
||||
/wd4456 # C4456: hides previous local declaration
|
||||
$<$<CXX_COMPILER_ID:Clang>:
|
||||
/D_CRT_SECURE_NO_WARNINGS
|
||||
>
|
||||
)
|
||||
else()
|
||||
target_compile_options(ProjectConfig
|
||||
INTERFACE
|
||||
-Wall
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
-Werror # Treat all compiler warnings as errors
|
||||
|
||||
-fno-rtti # Disable runtime type information
|
||||
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
# False positive string overflow
|
||||
# https://github.com/google/flatbuffers/issues/7366
|
||||
-Wno-error=stringop-overflow
|
||||
>
|
||||
>
|
||||
-pedantic
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
-Wold-style-cast
|
||||
-fsigned-char
|
||||
-Wnon-virtual-dtor
|
||||
|
||||
# This isn't working for some reason: $<$<CXX_COMPILER_ID:CLANG>:
|
||||
$<$<BOOL:${IS_CLANG}>:
|
||||
-Wnewline-eof
|
||||
-Wno-unknown-warning-option
|
||||
-Wmissing-declarations
|
||||
-Wzero-as-null-pointer-constant
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,3.8>:
|
||||
-Wimplicit-fallthrough
|
||||
-Wextra-semi
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
-Werror=unused-private-field
|
||||
>
|
||||
>
|
||||
>
|
||||
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.4>:
|
||||
-Wunused-result
|
||||
-Wunused-parameter
|
||||
-Werror=unused-parameter
|
||||
-Wmissing-declarations
|
||||
>
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.7>:
|
||||
-Wzero-as-null-pointer-constant
|
||||
>
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,7.0>:
|
||||
-faligned-new
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
-Werror=implicit-fallthrough=2
|
||||
>
|
||||
>
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,8.0>:
|
||||
-Wextra-semi
|
||||
>
|
||||
>
|
||||
|
||||
$<$<BOOL:${FLATBUFFERS_CODE_COVERAGE}>:
|
||||
-g
|
||||
-fprofile-arcs
|
||||
-ftest-coverage
|
||||
>
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_CODE_COVERAGE)
|
||||
target_link_options(ProjectConfig
|
||||
INTERFACE
|
||||
-fprofile-arcs
|
||||
-ftest-coverage
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||
# CMake > 2.8.11: Attach header directory for when build via add_subdirectory().
|
||||
target_include_directories(flatbuffers INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
||||
target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
|
||||
# Attach header directory for when build via add_subdirectory().
|
||||
target_include_directories(flatbuffers
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
)
|
||||
target_link_libraries(flatbuffers PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATC)
|
||||
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
||||
target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
|
||||
endif()
|
||||
|
||||
target_link_libraries(flatc PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_compile_options(flatc
|
||||
PRIVATE
|
||||
$<$<AND:$<BOOL:${MSVC_LIKE}>,$<CONFIG:Release>>:
|
||||
/MT
|
||||
>
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# Make flatc.exe not depend on runtime dlls for easy distribution.
|
||||
target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
|
||||
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
|
||||
target_link_libraries(flatc PRIVATE -static)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||
add_executable(flathash ${FlatHash_SRCS})
|
||||
target_link_libraries(flathash PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||
|
||||
# Shared object version: "major.minor.micro"
|
||||
# - micro updated every release when there is no API/ABI changes
|
||||
# - minor updated when there are additions in API/ABI
|
||||
# - major (ABI number) updated when there are changes in ABI (or removals)
|
||||
set(FlatBuffers_Library_SONAME_MAJOR "1")
|
||||
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.11.0")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
||||
target_link_libraries(flatbuffers_shared PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
# FlatBuffers use calendar-based versioning and do not provide any ABI
|
||||
# stability guarantees. Therefore, always use the full version as SOVERSION
|
||||
# in order to avoid breaking reverse dependencies on upgrades.
|
||||
set(FlatBuffers_Library_SONAME_FULL "${PROJECT_VERSION}")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES
|
||||
OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_FULL}"
|
||||
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT)
|
||||
function(compile_schema SRC_FBS OPT OUT_GEN_FILE)
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_HEADER}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --gen-mutable
|
||||
--gen-object-api -o "${SRC_FBS_DIR}"
|
||||
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
||||
--reflect-names ${OPT}
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc)
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
${OPT}
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc ${SRC_FBS}
|
||||
COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`"
|
||||
)
|
||||
set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
||||
compile_flatbuffers_schema_to_cpp_opt(${SRC_FBS} "--no-includes;--gen-compare")
|
||||
function(compile_schema_for_test SRC_FBS OPT)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE)
|
||||
target_sources(flattests PRIVATE ${GEN_FILE})
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_BINARY_SCHEMA}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -b --schema -o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc)
|
||||
function(compile_schema_for_samples SRC_FBS OPT)
|
||||
compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE)
|
||||
target_sources(flatsample PRIVATE ${GEN_FILE})
|
||||
endfunction()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs --scoped-enums)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||
set_property(TARGET flattests
|
||||
PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
if(WIN32)
|
||||
target_compile_definitions(flattests PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||
message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to flattests")
|
||||
else()
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_include_directories(flattests PUBLIC
|
||||
# Ideally everything is fully qualified from the root directories
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
# TODO(derekbailey): update includes to fully qualify src/ and tests/
|
||||
src
|
||||
tests
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
|
||||
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
||||
# Have tests load data from the source directory, not the build directory.
|
||||
add_definitions(-DFLATBUFFERS_TEST_PATH_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||
|
||||
# The flattest target needs some generated files
|
||||
SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names)
|
||||
SET(FLATC_OPT_COMP ${FLATC_OPT};--gen-compare)
|
||||
SET(FLATC_OPT_SCOPED_ENUMS ${FLATC_OPT_COMP};--scoped-enums)
|
||||
|
||||
compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/arrays_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT}")
|
||||
compile_schema_for_test(tests/key_field/key_field_sample.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/64bit/test_64bit.fbs "${FLATC_OPT_COMP};--bfbs-gen-embed")
|
||||
compile_schema_for_test(tests/64bit/evolution/v1.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/64bit/evolution/v2.fbs "${FLATC_OPT_COMP}")
|
||||
compile_schema_for_test(tests/union_underlying_type_test.fbs "${FLATC_OPT_SCOPED_ENUMS}")
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
||||
|
||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||
|
||||
# Add a library so there is a single target that the generated samples can
|
||||
# link too.
|
||||
if(MSVC OR ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0")
|
||||
add_library(flatsample INTERFACE)
|
||||
else()
|
||||
add_library(flatsample STATIC)
|
||||
endif()
|
||||
|
||||
# Since flatsample has no sources, we have to explicitly set the linker lang.
|
||||
set_target_properties(flatsample PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
compile_schema_for_samples(samples/monster.fbs "${FLATC_OPT_COMP}")
|
||||
|
||||
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig> flatsample)
|
||||
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_include_directories(flattests_cpp17 PUBLIC src tests)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
endif(FLATBUFFERS_BUILD_CPP17)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
|
||||
endif()
|
||||
if(NOT GRPC_INSTALL_PATH)
|
||||
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
||||
endif()
|
||||
@@ -375,13 +592,22 @@ if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
endif()
|
||||
INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include)
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src)
|
||||
LINK_DIRECTORIES(${GRPC_INSTALL_PATH}/lib)
|
||||
find_package(Threads REQUIRED)
|
||||
list(APPEND CMAKE_PREFIX_PATH ${GRPC_INSTALL_PATH})
|
||||
find_package(absl CONFIG REQUIRED)
|
||||
find_package(protobuf CONFIG REQUIRED)
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||
target_link_libraries(grpctest grpc++_unsecure grpc_unsecure gpr pthread dl)
|
||||
target_link_libraries(grpctest
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:ProjectConfig>
|
||||
gRPC::grpc++_unsecure
|
||||
gRPC::gpr
|
||||
pthread
|
||||
dl
|
||||
)
|
||||
endif()
|
||||
|
||||
include(CMake/Version.cmake)
|
||||
|
||||
if(FLATBUFFERS_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
@@ -389,28 +615,24 @@ if(FLATBUFFERS_INSTALL)
|
||||
|
||||
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
||||
|
||||
configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
|
||||
configure_file(CMake/flatbuffers-config-version.cmake.in flatbuffers-config-version.cmake @ONLY)
|
||||
install(
|
||||
FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
|
||||
FILES
|
||||
"CMake/flatbuffers-config.cmake"
|
||||
"CMake/BuildFlatBuffers.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-config-version.cmake"
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
endif()
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatBuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
install(EXPORT FlatbuffersTargets
|
||||
FILE FlatbuffersTargets.cmake
|
||||
install(EXPORT FlatBuffersTargets
|
||||
FILE FlatBuffersTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
@@ -431,38 +653,38 @@ if(FLATBUFFERS_INSTALL)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
endif()
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT FlatbuffersSharedTargets
|
||||
FILE FlatbuffersSharedTargets.cmake
|
||||
install(
|
||||
EXPORT FlatBuffersSharedTargets
|
||||
FILE FlatBuffersSharedTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB OR FLATBUFFERS_BUILD_FLATLIB)
|
||||
configure_file(CMake/flatbuffers.pc.in flatbuffers.pc @ONLY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers.pc"
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION
|
||||
"${CMAKE_CURRENT_BINARY_DIR}")
|
||||
add_test(NAME flattests COMMAND flattests)
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
add_test(NAME flattests_cpp17 COMMAND flattests_cpp17)
|
||||
endif()
|
||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
add_test(NAME grpctest COMMAND grpctest)
|
||||
endif()
|
||||
@@ -474,9 +696,23 @@ if(UNIX)
|
||||
# Use of CPack only supported on Linux systems.
|
||||
if(FLATBUFFERS_PACKAGE_DEBIAN)
|
||||
include(CMake/PackageDebian.cmake)
|
||||
include(CPack)
|
||||
endif()
|
||||
if (FLATBUFFERS_PACKAGE_REDHAT)
|
||||
include(CMake/PackageRedhat.cmake)
|
||||
include(CPack)
|
||||
endif()
|
||||
include(CPack)
|
||||
endif()
|
||||
|
||||
# Include for running Google Benchmarks.
|
||||
if(FLATBUFFERS_BUILD_BENCHMARKS)
|
||||
add_subdirectory(benchmarks)
|
||||
endif()
|
||||
|
||||
# Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare
|
||||
add_library(FlatBuffers INTERFACE)
|
||||
add_library(FlatBuffers::FlatBuffers ALIAS FlatBuffers)
|
||||
target_include_directories(
|
||||
FlatBuffers
|
||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FlatBuffers'
|
||||
s.version = '24.3.25'
|
||||
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
||||
|
||||
s.description = "FlatBuffers is a cross platform serialization library architected for
|
||||
maximum memory efficiency. It allows you to directly access serialized
|
||||
data without parsing/unpacking it first, while still having great
|
||||
forwards/backwards compatibility."
|
||||
|
||||
s.homepage = 'https://github.com/google/flatbuffers'
|
||||
s.license = { :type => 'Apache2.0', :file => 'LICENSE' }
|
||||
s.author = { 'mustii' => 'mustii@mmk.one' }
|
||||
s.source = { :git => 'https://github.com/google/flatbuffers.git', :tag => s.version.to_s, :submodules => true }
|
||||
|
||||
s.ios.deployment_target = '11.0'
|
||||
s.osx.deployment_target = '10.14'
|
||||
|
||||
s.swift_version = '5.0'
|
||||
s.source_files = 'swift/Sources/Flatbuffers/*.swift'
|
||||
end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
# Format Guidelines
|
||||
|
||||
If you are interesting in contributing to the flatbuffers project, please take a second to read this document. Each language has it's own set of rules, that are defined in their respective formatter/linter documents.
|
||||
|
||||
# Notes
|
||||
|
||||
- Run the linter on the language you are working on before making a Pull Request.
|
||||
- DONT format/lint the generated code.
|
||||
|
||||
# Languages
|
||||
|
||||
## C++
|
||||
|
||||
C++ uses `clang-format` as it's formatter. Run the following script `sh scripts/clang-format-git.sh`, and it should style the C++ code according to [google style guide](https://google.github.io/styleguide/cppguide.html).
|
||||
|
||||
## Swift
|
||||
|
||||
Swift uses swiftformat as it's formatter. Take a look at [how to install here](https://github.com/nicklockwood/SwiftFormat/blob/master/README.md#how-do-i-install-it). Run the following command `swiftformat --config swift.swiftformat .` in the root directory of the project
|
||||
|
||||
## Typescript
|
||||
|
||||
Typescript uses eslint as it's linter. Take a look at [how to install here](https://eslint.org/docs/user-guide/getting-started). Run the following command `eslint ts/** --ext .ts` in the root directory of the project
|
||||
@@ -1,34 +1,3 @@
|
||||
The code in lib/flat_buffers.dart is based on code that was releases under the
|
||||
following license:
|
||||
|
||||
Copyright 2012, the Dart project authors. All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
To the extent permissible, the changes to that code and the other assets in
|
||||
this package are licensed under the Apache2 license:
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
@@ -218,7 +187,7 @@ this package are licensed under the Apache2 license:
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2014 Google Inc.
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
Vendored
-202
@@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2014 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// swift-tools-version:5.6
|
||||
/*
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "FlatBuffers",
|
||||
platforms: [
|
||||
.iOS(.v11),
|
||||
.macOS(.v10_14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "FlatBuffers",
|
||||
targets: ["FlatBuffers"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: [],
|
||||
path: "swift/Sources"),
|
||||
])
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// swift-tools-version:5.5
|
||||
/*
|
||||
* Copyright 2020 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "FlatBuffers",
|
||||
platforms: [
|
||||
.iOS(.v11),
|
||||
.macOS(.v10_14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "FlatBuffers",
|
||||
targets: ["FlatBuffers"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: [],
|
||||
path: "swift/Sources"),
|
||||
])
|
||||
|
||||
Vendored
+118
@@ -0,0 +1,118 @@
|
||||
 FlatBuffers
|
||||
===========
|
||||
|
||||

|
||||
[](https://buildkite.com/bazel/flatbuffers)
|
||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:flatbuffers)
|
||||
[](https://api.securityscorecards.dev/projects/github.com/google/flatbuffers)
|
||||
[](https://gitter.im/google/flatbuffers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https:///discord.gg/6qgKs3R)
|
||||
[](https://twitter.com/wvo)
|
||||
[](https://twitter.com/dbaileychess)
|
||||
|
||||
|
||||
**FlatBuffers** is a cross platform serialization library architected for
|
||||
maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Build the compiler for flatbuffers (`flatc`)
|
||||
|
||||
Use `cmake` to create the build files for your platform and then perform the compliation (Linux example).
|
||||
|
||||
```
|
||||
cmake -G "Unix Makefiles"
|
||||
make -j
|
||||
```
|
||||
|
||||
2. Define your flatbuffer schema (`.fbs`)
|
||||
|
||||
Write the [schema](https://flatbuffers.dev/flatbuffers_guide_writing_schema.html) to define the data you want to serialize. See [monster.fbs](https://github.com/google/flatbuffers/blob/master/samples/monster.fbs) for an example.
|
||||
|
||||
3. Generate code for your language(s)
|
||||
|
||||
Use the `flatc` compiler to take your schema and generate language-specific code:
|
||||
|
||||
```
|
||||
./flatc --cpp --rust monster.fbs
|
||||
```
|
||||
|
||||
Which generates `monster_generated.h` and `monster_generated.rs` files.
|
||||
|
||||
4. Serialize data
|
||||
|
||||
Use the generated code, as well as the `FlatBufferBuilder` to construct your serialized buffer. ([`C++` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.cpp#L24-L56))
|
||||
|
||||
5. Transmit/store/save Buffer
|
||||
|
||||
Use your serialized buffer however you want. Send it to someone, save it for later, etc...
|
||||
|
||||
6. Read the data
|
||||
|
||||
Use the generated accessors to read the data from the serialized buffer.
|
||||
|
||||
It doesn't need to be the same language/schema version, FlatBuffers ensures the data is readable across languages and schema versions. See the [`Rust` example](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.rs#L92-L106) reading the data written by `C++`.
|
||||
|
||||
## Documentation
|
||||
|
||||
**Go to our [landing page][] to browse our documentation.**
|
||||
|
||||
## Supported operating systems
|
||||
- Windows
|
||||
- macOS
|
||||
- Linux
|
||||
- Android
|
||||
- And any others with a recent C++ compiler (C++ 11 and newer)
|
||||
|
||||
## Supported programming languages
|
||||
|
||||
Code generation and runtime libraries for many popular languages.
|
||||
|
||||
1. C
|
||||
1. C++ - [snapcraft.io](https://snapcraft.io/flatbuffers)
|
||||
1. C# - [nuget.org](https://www.nuget.org/packages/Google.FlatBuffers)
|
||||
1. Dart - [pub.dev](https://pub.dev/packages/flat_buffers)
|
||||
1. Go - [go.dev](https://pkg.go.dev/github.com/google/flatbuffers)
|
||||
1. Java - [Maven](https://search.maven.org/artifact/com.google.flatbuffers/flatbuffers-java)
|
||||
1. JavaScript - [NPM](https://www.npmjs.com/package/flatbuffers)
|
||||
1. Kotlin
|
||||
1. Lobster
|
||||
1. Lua
|
||||
1. PHP
|
||||
1. Python - [PyPI](https://pypi.org/project/flatbuffers/)
|
||||
1. Rust - [crates.io](https://crates.io/crates/flatbuffers)
|
||||
1. Swift - [swiftpackageindex](https://swiftpackageindex.com/google/flatbuffers)
|
||||
1. TypeScript - [NPM](https://www.npmjs.com/package/flatbuffers)
|
||||
1. Nim
|
||||
|
||||
## Versioning
|
||||
|
||||
FlatBuffers does not follow traditional SemVer versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
|
||||
|
||||
## Contribution
|
||||
|
||||
* [FlatBuffers Issues Tracker][] to submit an issue.
|
||||
* [stackoverflow.com][] with [`flatbuffers` tag][] for any questions regarding FlatBuffers.
|
||||
|
||||
*To contribute to this project,* see [CONTRIBUTING][].
|
||||
|
||||
## Community
|
||||
|
||||
* [Discord Server](https:///discord.gg/6qgKs3R)
|
||||
|
||||
## Security
|
||||
|
||||
Please see our [Security Policy](SECURITY.md) for reporting vulnerabilities.
|
||||
|
||||
## Licensing
|
||||
*Flatbuffers* is licensed under the Apache License, Version 2.0. See [LICENSE][] for the full license text.
|
||||
|
||||
<br>
|
||||
|
||||
[CONTRIBUTING]: http://github.com/google/flatbuffers/blob/master/CONTRIBUTING.md
|
||||
[`flatbuffers` tag]: https://stackoverflow.com/questions/tagged/flatbuffers
|
||||
[FlatBuffers Google Group]: https://groups.google.com/forum/#!forum/flatbuffers
|
||||
[FlatBuffers Issues Tracker]: http://github.com/google/flatbuffers/issues
|
||||
[stackoverflow.com]: http://stackoverflow.com/search?q=flatbuffers
|
||||
[landing page]: https://google.github.io/flatbuffers
|
||||
[LICENSE]: https://github.com/google/flatbuffers/blob/master/LICENSE
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
To report a security issue, please use http://g.co/vulnz. We use
|
||||
http://g.co/vulnz for our intake, and do coordination and disclosure here on
|
||||
GitHub (including using GitHub Security Advisory). The Google Security Team will
|
||||
respond within 5 working days of your report on g.co/vulnz.
|
||||
|
||||
Select the `I want to report a technical security or an abuse risk related bug
|
||||
in a Google product (SQLi, XSS, etc.)` option and complete the form.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user