Unite buildis

This commit is contained in:
Alexander Borsuk 2021-12-18 00:18:31 +01:00
parent 10e7d3cad6
commit fe92ea3f90
13 changed files with 95 additions and 76 deletions

View file

@ -2,25 +2,25 @@
#include <boost/iterator/iterator_facade.hpp>
namespace detail
namespace stl_iterator_detail
{
struct Dummy
{
template <class T> Dummy & operator=(T const &) { return *this; }
};
}
} // namespace stl_iterator_detail
class CounterIterator :
public boost::iterator_facade<CounterIterator, detail::Dummy, boost::forward_traversal_tag>
public boost::iterator_facade<CounterIterator, stl_iterator_detail::Dummy, boost::forward_traversal_tag>
{
size_t m_count;
public:
CounterIterator() : m_count(0) {}
size_t GetCount() const { return m_count; }
detail::Dummy & dereference() const
stl_iterator_detail::Dummy & dereference() const
{
static detail::Dummy dummy;
static stl_iterator_detail::Dummy dummy;
return dummy;
}
void increment() { ++m_count; }

View file

@ -71,6 +71,8 @@ endfunction()
function(omim_add_library library)
add_library(${library} ${ARGN})
set_target_properties(${library} PROPERTIES UNITY_BUILD ON)
set_target_properties(${library} PROPERTIES UNITY_BUILD_BATCH_SIZE 50)
add_dependencies(${library} BuildVersion)
# Enable warnings for all our libraries.
target_compile_options(${library} PRIVATE ${OMIM_WARNING_FLAGS})

View file

@ -10,9 +10,9 @@ namespace df
namespace
{
double const kValidSplineTurn = 15 * math::pi / 180;
double const kCosTurn = cos(kValidSplineTurn);
double const kSinTurn = sin(kValidSplineTurn);
double const kValidPathSplineTurn = 15 * math::pi / 180;
double const kCosTurn = cos(kValidPathSplineTurn);
double const kSinTurn = sin(kValidPathSplineTurn);
double const kRoundStep = 23;
int const kMaxStepsCount = 7;
@ -91,7 +91,7 @@ void AddPointAndRound(m2::Spline & spline, m2::PointD const & pt)
double const dotProduct = m2::DotProduct(dir1, dir2);
if (dotProduct < kCosTurn)
{
int leftStepsCount = static_cast<int>(acos(dotProduct) / kValidSplineTurn);
int leftStepsCount = static_cast<int>(acos(dotProduct) / kValidPathSplineTurn);
std::vector<m2::PointD> roundedCorner;
while (leftStepsCount > 0 && leftStepsCount <= kMaxStepsCount &&
RoundCorner(spline.GetPath()[spline.GetSize() - 2],

View file

@ -23,7 +23,7 @@ static_assert(numeric_limits<double>::has_infinity, "");
double const kInf = numeric_limits<double>::infinity();
// Checks whether (p1 - p) x (p2 - p) >= 0.
bool IsCCW(PointD const & p1, PointD const & p2, PointD const & p, double eps)
bool IsCCWNeg(PointD const & p1, PointD const & p2, PointD const & p, double eps)
{
return robust::OrientedS(p1, p2, p) > -eps;
}
@ -137,7 +137,7 @@ bool CalipersBox::HasPoint(PointD const & p, double eps) const
{
auto const & a = m_points[i];
auto const & b = m_points[(i + 1) % n];
if (!IsCCW(b, p, a, eps))
if (!IsCCWNeg(b, p, a, eps))
return false;
}
return true;

View file

@ -13,7 +13,7 @@ using namespace std;
namespace
{
enum State
enum ParseState
{
EParseTypes,
EParseLanguages
@ -194,7 +194,7 @@ void CategoriesHolder::LoadFromStream(istream & s)
m_name2type.Clear();
m_groupTranslations.clear();
State state = EParseTypes;
ParseState state = EParseTypes;
string line;
Category cat;
vector<uint32_t> types;

View file

@ -123,18 +123,11 @@ void ClassifObject::ConcatChildNames(string & s) const
// Classificator implementation
/////////////////////////////////////////////////////////////////////////////////////////
namespace
{
Classificator & classif(MapStyle mapStyle)
{
static Classificator c[MapStyleCount];
return c[mapStyle];
}
} // namespace
Classificator & classif()
{
return classif(GetStyleReader().GetCurrentStyle());
static Classificator c[MapStyleCount];
MapStyle const mapStyle = GetStyleReader().GetCurrentStyle();
return c[mapStyle];
}
namespace ftype

View file

@ -160,3 +160,24 @@ target_link_libraries(${PROJECT_NAME}
omim_add_test_subdirectory(platform_tests_support)
omim_add_test_subdirectory(platform_tests)
set_property(
SOURCE
preferred_languages.cpp
apple_location_service.mm
gui_thread_apple.mm
http_client_apple.mm
http_thread_apple.h
http_thread_apple.mm
http_uploader_apple.mm
http_uploader_background_dummy.cpp
locale.mm
platform_mac.mm
platform_unix_impl.cpp
platform_unix_impl.hpp
secure_storage_qt.cpp
socket_apple.mm
http_session_manager.mm
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON
)

View file

@ -10,7 +10,7 @@
using namespace routing;
using namespace std;
namespace
namespace bicycle_model
{
// See model specifics in different countries here:
// https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions
@ -379,19 +379,19 @@ VehicleModel::SurfaceInitList const kBicycleSurface = {
{{"psurface", "unpaved_good"}, {1.0, 1.0}},
{{"psurface", "unpaved_bad"}, {0.3, 0.3}}
};
} // namespace
} // namespace bicycle_model
namespace routing
{
BicycleModel::BicycleModel()
: VehicleModel(classif(), kBicycleOptionsDefault, kBicycleSurface,
{kDefaultSpeeds, kDefaultFactors})
: VehicleModel(classif(), bicycle_model::kBicycleOptionsDefault, bicycle_model::kBicycleSurface,
{bicycle_model::kDefaultSpeeds, bicycle_model::kDefaultFactors})
{
Init();
}
BicycleModel::BicycleModel(VehicleModel::LimitsInitList const & speedLimits)
: VehicleModel(classif(), speedLimits, kBicycleSurface, {kDefaultSpeeds, kDefaultFactors})
: VehicleModel(classif(), speedLimits, bicycle_model::kBicycleSurface, {bicycle_model::kDefaultSpeeds, bicycle_model::kDefaultFactors})
{
Init();
}
@ -406,8 +406,8 @@ void BicycleModel::Init()
m_onedirBicycleType = classif().GetTypeByPath({"hwtag", "onedir_bicycle"});
vector<AdditionalRoadTags> const additionalTags = {
{hwtagYesBicycle, m_maxModelSpeed},
{{"route", "ferry"}, kDefaultSpeeds.at(HighwayType::RouteFerry)},
{{"man_made", "pier"}, kDefaultSpeeds.at(HighwayType::ManMadePier)}};
{{"route", "ferry"}, bicycle_model::kDefaultSpeeds.at(HighwayType::RouteFerry)},
{{"man_made", "pier"}, bicycle_model::kDefaultSpeeds.at(HighwayType::ManMadePier)}};
SetAdditionalRoadTypes(classif(), additionalTags);
}
@ -451,14 +451,14 @@ bool BicycleModel::IsOneWay(FeatureType & f) const
return VehicleModel::IsOneWay(f);
}
SpeedKMpH const & BicycleModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; }
SpeedKMpH const & BicycleModel::GetOffroadSpeed() const { return bicycle_model::kSpeedOffroadKMpH; }
// If one of feature types will be disabled for bicycles, features of this type will be simplified
// in generator. Look FeatureBuilder1::IsRoad() for more details.
// static
BicycleModel const & BicycleModel::AllLimitsInstance()
{
static BicycleModel const instance(kBicycleOptionsAll);
static BicycleModel const instance(bicycle_model::kBicycleOptionsAll);
return instance;
}
@ -466,6 +466,7 @@ BicycleModelFactory::BicycleModelFactory(
CountryParentNameGetterFn const & countryParentNameGetterFn)
: VehicleModelFactory(countryParentNameGetterFn)
{
using namespace bicycle_model;
// Names must be the same with country names from countries.txt
m_models[""] = make_shared<BicycleModel>(kBicycleOptionsDefault);
m_models["Australia"] = make_shared<BicycleModel>(kBicycleOptionsAustralia);

View file

@ -12,7 +12,7 @@
using namespace std;
using namespace routing;
namespace
namespace car_model
{
// See model specifics in different countries here:
// https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions
@ -154,31 +154,31 @@ std::unordered_map<char const *, VehicleModel::LimitsInitList> const kCarOptions
{"Slovakia", kCarOptionsNoPassThroughLivingStreet},
{"Ukraine", kCarOptionsNoPassThroughLivingStreetAndService}
};
} // namespace
} // namespace car_model
namespace routing
{
CarModel::CarModel()
: VehicleModel(classif(), kCarOptionsDefault, kCarSurface,
: VehicleModel(classif(), car_model::kCarOptionsDefault, car_model::kCarSurface,
{kHighwayBasedSpeeds, kHighwayBasedFactors})
{
Init();
}
CarModel::CarModel(VehicleModel::LimitsInitList const & roadLimits, HighwayBasedInfo const & info)
: VehicleModel(classif(), roadLimits, kCarSurface, info)
: VehicleModel(classif(), roadLimits, car_model::kCarSurface, info)
{
Init();
}
SpeedKMpH const & CarModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; }
SpeedKMpH const & CarModel::GetOffroadSpeed() const { return car_model::kSpeedOffroadKMpH; }
void CarModel::Init()
{
m_noCarType = classif().GetTypeByPath({"hwtag", "nocar"});
m_yesCarType = classif().GetTypeByPath({"hwtag", "yescar"});
SetAdditionalRoadTypes(classif(), kAdditionalTags);
SetAdditionalRoadTypes(classif(), car_model::kAdditionalTags);
}
VehicleModelInterface::RoadAvailability CarModel::GetRoadAvailability(feature::TypesHolder const & types) const
@ -200,25 +200,25 @@ CarModel const & CarModel::AllLimitsInstance()
}
// static
routing::VehicleModel::LimitsInitList const & CarModel::GetOptions() { return kCarOptionsDefault; }
routing::VehicleModel::LimitsInitList const & CarModel::GetOptions() { return car_model::kCarOptionsDefault; }
// static
vector<routing::VehicleModel::AdditionalRoadTags> const & CarModel::GetAdditionalTags()
{
return kAdditionalTags;
return car_model::kAdditionalTags;
}
// static
VehicleModel::SurfaceInitList const & CarModel::GetSurfaces() { return kCarSurface; }
VehicleModel::SurfaceInitList const & CarModel::GetSurfaces() { return car_model::kCarSurface; }
CarModelFactory::CarModelFactory(CountryParentNameGetterFn const & countryParentNameGetterFn)
: VehicleModelFactory(countryParentNameGetterFn)
{
m_models[""] = make_shared<CarModel>(
kCarOptionsDefault,
car_model::kCarOptionsDefault,
HighwayBasedInfo(kHighwayBasedSpeeds, kHighwayBasedFactors));
for (auto const & kv : kCarOptionsByCountries)
for (auto const & kv : car_model::kCarOptionsByCountries)
{
auto const * country = kv.first;
auto const & limit = kv.second;

View file

@ -10,7 +10,7 @@
using namespace routing;
using namespace std;
namespace
namespace pedestrian_model
{
// See model specifics in different countries here:
// https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions
@ -264,19 +264,19 @@ VehicleModel::SurfaceInitList const kPedestrianSurface = {
{{"psurface", "unpaved_good"}, {1.0, 1.0}},
{{"psurface", "unpaved_bad"}, {0.8, 0.8}}
};
} // namespace
} // namespace pedestrian_model
namespace routing
{
PedestrianModel::PedestrianModel()
: VehicleModel(classif(), kPedestrianOptionsDefault, kPedestrianSurface,
{kDefaultSpeeds, kDefaultFactors})
: VehicleModel(classif(), pedestrian_model::kPedestrianOptionsDefault, pedestrian_model::kPedestrianSurface,
{pedestrian_model::kDefaultSpeeds, pedestrian_model::kDefaultFactors})
{
Init();
}
PedestrianModel::PedestrianModel(VehicleModel::LimitsInitList const & speedLimits)
: VehicleModel(classif(), speedLimits, kPedestrianSurface, {kDefaultSpeeds, kDefaultFactors})
: VehicleModel(classif(), speedLimits, pedestrian_model::kPedestrianSurface, {pedestrian_model::kDefaultSpeeds, pedestrian_model::kDefaultFactors})
{
Init();
}
@ -286,7 +286,7 @@ SpeedKMpH PedestrianModel::GetSpeed(FeatureType & f, SpeedParams const & speedPa
return VehicleModel::GetSpeedWihtoutMaxspeed(f, speedParams);
}
SpeedKMpH const & PedestrianModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; }
SpeedKMpH const & PedestrianModel::GetOffroadSpeed() const { return pedestrian_model::kSpeedOffroadKMpH; }
void PedestrianModel::Init()
{
@ -297,8 +297,8 @@ void PedestrianModel::Init()
vector<AdditionalRoadTags> const additionalTags = {
{hwtagYesFoot, m_maxModelSpeed},
{{"route", "ferry"}, kDefaultSpeeds.at(HighwayType::RouteFerry)},
{{"man_made", "pier"}, kDefaultSpeeds.at(HighwayType::ManMadePier)}};
{{"route", "ferry"}, pedestrian_model::kDefaultSpeeds.at(HighwayType::RouteFerry)},
{{"man_made", "pier"}, pedestrian_model::kDefaultSpeeds.at(HighwayType::ManMadePier)}};
SetAdditionalRoadTypes(classif(), additionalTags);
}
@ -319,7 +319,7 @@ VehicleModelInterface::RoadAvailability PedestrianModel::GetRoadAvailability(fea
// static
PedestrianModel const & PedestrianModel::AllLimitsInstance()
{
static PedestrianModel const instance(kPedestrianOptionsAll);
static PedestrianModel const instance(pedestrian_model::kPedestrianOptionsAll);
return instance;
}
@ -327,6 +327,7 @@ PedestrianModelFactory::PedestrianModelFactory(
CountryParentNameGetterFn const & countryParentNameGetterFn)
: VehicleModelFactory(countryParentNameGetterFn)
{
using namespace pedestrian_model;
// Names must be the same with country names from countries.txt
m_models[""] = make_shared<PedestrianModel>(kPedestrianOptionsDefault);
m_models["Australia"] = make_shared<PedestrianModel>(kPedestrianOptionsAustralia);

View file

@ -15,7 +15,7 @@
using namespace std;
using namespace std::chrono;
namespace
namespace pinger
{
auto constexpr kTimeoutInSeconds = 4.0;
int64_t constexpr kInvalidPing = -1;
@ -56,14 +56,14 @@ Pinger::Endpoints Pinger::ExcludeUnavailableAndSortEndpoints(Endpoints const & u
CHECK_GREATER(size, 0, ());
using EntryT = std::pair<int64_t, size_t>;
std::vector<EntryT> timeUrls(size, {kInvalidPing, 0});
std::vector<EntryT> timeUrls(size, {pinger::kInvalidPing, 0});
{
ThreadPool pool(size, ThreadPool::Exit::ExecPending);
for (size_t i = 0; i < size; ++i)
{
pool.Push([&urls, &timeUrls, i]
{
timeUrls[i] = { DoPing(urls[i]), i };
timeUrls[i] = { pinger::DoPing(urls[i]), i };
});
}
}

View file

@ -14,11 +14,12 @@ OPT_STANDALONE=
OPT_COMPILE_DATABASE=
OPT_LAUNCH_BINARY=
OPT_NJOBS=
while getopts ":cdrstagjlpn:" opt; do
while getopts ":cdrxstagjlpn:" opt; do
case $opt in
a) OPT_STANDALONE=1 ;;
c) OPT_CLEAN=1 ;;
d) OPT_DEBUG=1 ;;
x) CMAKE_CONFIG="${CMAKE_CONFIG:-} -DUSE_PCH=YES" ;;
g) OPT_GCC=1 ;;
j) OPT_COMPILE_DATABASE=1
CMAKE_CONFIG="${CMAKE_CONFIG:-} -DCMAKE_EXPORT_COMPILE_COMMANDS=YES"
@ -35,22 +36,22 @@ while getopts ":cdrstagjlpn:" opt; do
t) OPT_DESIGNER=1 ;;
*)
echo "This tool builds Organic Maps"
echo "Usage: $0 [-d] [-r] [-c] [-s] [-t] [-a] [-g] [-j] [-l] [-p PATH] [-n NUM] [target1 target2 ...]"
echo "Usage: $0 [-d] [-r] [-c] [-x] [-s] [-t] [-a] [-g] [-j] [-l] [-p PATH] [-n NUM] [target1 target2 ...]"
echo
echo "By default all targets for both debug and release versions are built"
echo "and binaries are put into ../omim-build-<buildtype> dir."
echo "By default both debug and release versions are built in ../omim-build-<buildtype> dir."
echo
echo -e "-d\tBuild debug version"
echo -e "-r\tBuild release version"
echo -e "-c\tClean before building"
echo -e "-s\tSkip desktop app building"
echo -e "-t\tBuild designer tool (only for MacOS X platform)"
echo -e "-a\tBuild standalone desktop app (only for MacOS X platform)"
echo -e "-g\tForce use GCC (only for MacOS X platform)"
echo -e "-p\tDirectory for built binaries"
echo -e "-n\tNumber of parallel processes"
echo -e "-j\tGenerate compile_commands.json"
echo -e "-l\tLaunches built binary(ies), useful for tests"
echo -e "-d Build debug version"
echo -e "-r Build release version"
echo -e "-x Use precompiled headers"
echo -e "-c Clean before building"
echo -e "-s Skip desktop app building"
echo -e "-t Build designer tool (only for MacOS X platform)"
echo -e "-a Build standalone desktop app (only for MacOS X platform)"
echo -e "-g Force use GCC (only for MacOS X platform)"
echo -e "-p Directory for built binaries"
echo -e "-n Number of parallel processes"
echo -e "-j Generate compile_commands.json"
echo -e "-l Launches built binary(ies), useful for tests"
exit 1
;;
esac

View file

@ -37,7 +37,7 @@ enum class DateTimeRelation
Equal
};
DateTimeRelation GetDatesRelation(transit::Date const & date1, transit::Date const & date2)
DateTimeRelation GetDatesRelation(::transit::Date const & date1, ::transit::Date const & date2)
{
if (date1.m_year < date2.m_year)
return DateTimeRelation::Earlier;
@ -57,7 +57,7 @@ DateTimeRelation GetDatesRelation(transit::Date const & date1, transit::Date con
return DateTimeRelation::Equal;
}
DateTimeRelation GetTimesRelation(transit::Time const & time1, transit::Time const & time2)
DateTimeRelation GetTimesRelation(::transit::Time const & time1, ::transit::Time const & time2)
{
if (time1.m_hour < time2.m_hour)
return DateTimeRelation::Earlier;
@ -77,14 +77,14 @@ DateTimeRelation GetTimesRelation(transit::Time const & time1, transit::Time con
return DateTimeRelation::Equal;
}
transit::Date GetDate(std::tm const & tm)
::transit::Date GetDate(std::tm const & tm)
{
return transit::Date(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
return ::transit::Date(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
}
transit::Time GetTime(std::tm const & tm)
::transit::Time GetTime(std::tm const & tm)
{
return transit::Time(tm.tm_hour, tm.tm_min, tm.tm_sec);
return ::transit::Time(tm.tm_hour, tm.tm_min, tm.tm_sec);
}
} // namespace