Skip to content

Commit 5c40573

Browse files
authored
Support for iOS compiling (#2307)
1 parent 95a518e commit 5c40573

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,21 +343,21 @@ set(private_headers
343343
lib/src/ConfigAdapter.h
344344
lib/src/MultipartStreamParser.h)
345345

346-
if (NOT WIN32)
346+
if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
347347
set(DROGON_SOURCES
348348
${DROGON_SOURCES}
349349
lib/src/SharedLibManager.cc)
350350
set(private_headers
351351
${private_headers}
352352
lib/src/SharedLibManager.h)
353-
else (NOT WIN32)
353+
elseif(WIN32)
354354
set(DROGON_SOURCES
355355
${DROGON_SOURCES}
356356
third_party/mman-win32/mman.c)
357357
set(private_headers
358358
${private_headers}
359359
third_party/mman-win32/mman.h)
360-
endif (NOT WIN32)
360+
endif()
361361

362362
if (BUILD_POSTGRESQL)
363363
# find postgres

lib/inc/drogon/HttpAppFramework.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
#include <vector>
4444
#include <chrono>
4545

46+
#if defined(__APPLE__) && defined(__MACH__)
47+
#if defined(__ENVIRONMENT_IPHONE_OS__) || \
48+
defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
49+
// iOS
50+
#define TARGET_OS_IOS 1
51+
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
52+
// macOS
53+
#endif
54+
#endif
55+
4656
namespace drogon
4757
{
4858
// the drogon banner
@@ -997,7 +1007,7 @@ class DROGON_EXPORT HttpAppFramework : public trantor::NonCopyable
9971007
virtual HttpAppFramework &setFileTypes(
9981008
const std::vector<std::string> &types) = 0;
9991009

1000-
#ifndef _WIN32
1010+
#if !defined(_WIN32) && !TARGET_OS_IOS
10011011
/// Enable supporting for dynamic views loading.
10021012
/**
10031013
*

lib/src/ConfigLoader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void loadApp(const Json::Value &app)
383383
{
384384
drogon::app().setMaxConnectionNumPerIP(maxConnsPerIP);
385385
}
386-
#ifndef _WIN32
386+
#if !defined(_WIN32) && !TARGET_OS_IOS
387387
// dynamic views
388388
auto enableDynamicViews = app.get("load_dynamic_views", false).asBool();
389389
if (enableDynamicViews)

lib/src/HttpAppFrameworkImpl.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static void TERMFunction(int sig)
184184
HttpAppFrameworkImpl::~HttpAppFrameworkImpl() noexcept
185185
{
186186
// Destroy the following objects before the loop destruction
187-
#ifndef _WIN32
187+
#if !defined(_WIN32) && !TARGET_OS_IOS
188188
sharedLibManagerPtr_.reset();
189189
#endif
190190
sessionManagerPtr_.reset();
@@ -236,7 +236,7 @@ const std::string &HttpAppFrameworkImpl::getImplicitPage() const
236236
{
237237
return StaticFileRouter::instance().getImplicitPage();
238238
}
239-
#ifndef _WIN32
239+
#if !defined(_WIN32) && !TARGET_OS_IOS
240240
HttpAppFramework &HttpAppFrameworkImpl::enableDynamicViewsLoading(
241241
const std::vector<std::string> &libPaths,
242242
const std::string &outputPath)
@@ -599,7 +599,7 @@ void HttpAppFrameworkImpl::run()
599599
LOG_INFO << "Start child process";
600600
}
601601

602-
#ifndef _WIN32
602+
#if !defined(_WIN32) && !TARGET_OS_IOS
603603
if (!libFilePaths_.empty())
604604
{
605605
sharedLibManagerPtr_ =

lib/src/HttpAppFrameworkImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class HttpAppFrameworkImpl final : public HttpAppFramework
267267
HttpAppFramework &setUploadPath(const std::string &uploadPath) override;
268268
HttpAppFramework &setFileTypes(
269269
const std::vector<std::string> &types) override;
270-
#ifndef _WIN32
270+
#if !defined(_WIN32) && !TARGET_OS_IOS
271271
HttpAppFramework &enableDynamicViewsLoading(
272272
const std::vector<std::string> &libPaths,
273273
const std::string &outputPath) override;
@@ -709,7 +709,7 @@ class HttpAppFrameworkImpl final : public HttpAppFramework
709709
size_t threadNum_{1};
710710
std::unique_ptr<trantor::EventLoopThreadPool> ioLoopThreadPool_;
711711

712-
#ifndef _WIN32
712+
#if !defined(_WIN32) && !TARGET_OS_IOS
713713
std::vector<std::string> libFilePaths_;
714714
std::string libFileOutputPath_;
715715
std::unique_ptr<SharedLibManager> sharedLibManagerPtr_;

0 commit comments

Comments
 (0)