diff --git a/BUILDING_ANDROID.md b/BUILDING_ANDROID.md new file mode 100644 index 000000000..5a17aa468 --- /dev/null +++ b/BUILDING_ANDROID.md @@ -0,0 +1,80 @@ +Building for Android +--- + +## Dependencies + +* CMake 3.10 or later +* A build tool Ninja +* A C++11-compliant compiler +* GCC 7.3 or later +* Clang 3.3 or later + +## Supported Crypto solutions +* OpenSSL 1.1.1 or later +* libsodium is not supported yet. + +## NOTE + +The Cmake file fetches and builds the required libraries for Android: Protobuf and OpenSSL. (not libsodium yet) + +## Build by a Linux machine +It is tested at a local Linux machine Debian 12. + +Download Android NDK from Google's site, extract it + +https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip~/android-ndk-r15c + +Install ncurses +``` +sudo apt-get install libncurses5 +``` + +Clone GameNetworkingSockets and create build folder +``` +git clone https://github.com/ValveSoftware/GameNetworkingSockets.git +cd GameNetworkingSockets +mkdir buildAndroid +cd buildAndroid +``` + +Configure GameNetworkingSockets +``` +sudo cmake -DCMAKE_TOOLCHAIN_FILE=../../android-ndk-r15c/build/cmake/android.toolchain.cmake -DANDROID_NDK_RPATH=../../android-ndk-r15c -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-21 -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DANDROID_STL=c++_static -DOpenSSLTag=OpenSSL_1_1_1e -DProtobufTag=v3.21.6 -G Ninja .. +``` +Note: Configure will fetch and build Protobuf and OpenSSL libraries for Android. + +* -DCMAKE_TOOLCHAIN_FILE: Path to the toolchain cmake file for android NDK +* -DANDROID_NDK_RPATH: Relative path to the android NDK +* -DANDROID_ABI: Can be arm64-v8a or armeabi-v7a, both supports. +* -DANDROID_PLATFORM: Android platform +* -DCMAKE_BUILD_TYPE: can be Release or Debug +* -DOpenSSLTag: OpenSSL git tag +* -DProtobufTag: Protobuf git tag + +Finally, build GameNetworkingSockets +``` +sudo ninja +``` + +## After build +**Folder structure** + +android-ndk-r15c/
+GameNetworkingSockets/
+    buildAndroid/
+        bin/
+            **libGameNetworkingSockets.so**
+        src/
+            **libGameNetworkingSockets_s.a**
+    _deps/
+        protobuf-build/
+            **libprotoc.a**
+            **libprotobuf.a**
+            **libprotobuf-lite.a**
+        openssl-src/
+            **libssl.a**
+            **libcrypto.a**
+ +## Build by a Windows machine + +I believe with the right shell, MSYS2 or WSL, it should be building properly with the Linux commands above. diff --git a/BUILDING_IOS.md b/BUILDING_IOS.md new file mode 100644 index 000000000..d81242507 --- /dev/null +++ b/BUILDING_IOS.md @@ -0,0 +1,76 @@ +Building for iOS +--- + +## Dependencies + +* CMake 3.10 or later +* A build tool Ninja +* A C++11-compliant compiler +* GCC 7.3 or later +* Clang 3.3 or later +* A Macintosh + +## Supported Crypto solutions +* OpenSSL 1.1.1 or later +* libsodium is not supported yet. + +## NOTE + +The Cmake file fetches and builds the required libraries for iOS: Protobuf and OpenSSL. (not libsodium yet) +It requires a MacOS platform. + +## Build with a Mac + +Install Brew if not installed. +``` +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +Install ninja by brew +``` +brew install ninja llvm +``` +Install xcode +``` +xcode-select --install +``` +Clone GameNetworkingSockets and create build folder +``` +git clone https://github.com/ValveSoftware/GameNetworkingSockets.git +cd GameNetworkingSockets +mkdir buildiOS +cd buildiOS +``` + +Configure GameNetworkingSockets +``` +sudo cmake -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DOpenSSLTag=OpenSSL_1_1_1e -DProtobufTag=v3.21.6 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -G Ninja .. +``` +Note: Configure will fetch and build Protobuf and OpenSSL libraries for iOS. + +* -DCMAKE_BUILD_TYPE: can be Release or Debug +* -DOpenSSLTag: OpenSSL git tag +* -DProtobufTag: Protobuf git tag + +Finally, build GameNetworkingSockets +``` +sudo ninja +``` + +## After build +**Folder structure** + +GameNetworkingSockets/
+    buildiOS/
+        bin/
+            **libGameNetworkingSockets.dylib**
+        src/
+            **libGameNetworkingSockets_s.a**
+    _deps/
+        protobuf-build/
+            **libprotoc.a**
+            **libprotobuf.a**
+            **libprotobuf-lite.a**
+        openssl-src/
+            **libssl.a**
+            **libcrypto.a**
diff --git a/CMakeLists.txt b/CMakeLists.txt index 90899a494..5e4e6d22b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,166 @@ if (WIN32) endif() endif() +if (ANDROID OR APPLE) + # + # Fetch Protobuf, configure it and build it for the desired platform. Supported platforms: iOS, Android and MacOS + # Build it twice, one at config time for current platform and one at compile time for desired platform + # So we can protoc source files before compile time with the current platform (Otherwise protoc may be built for different arch. than your building machine cpu) + # + message( "Fetching protobuf... ") + include(FetchContent) + FetchContent_GetProperties(Protobuf) + if(NOT Protobuf_POPULATED) + + FetchContent_Declare(Protobuf + GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git + GIT_TAG ${ProtobufTag} + OVERRIDE_FIND_PACKAGE + ) + FetchContent_MakeAvailable(Protobuf) + endif () + + message( "Configuring protobuf... ") + + # Some pre-configs for Protobuf config and buid operations + if (UNIX) + set (fileName "build.sh") + set (fileHeader "#!/bin/sh\n") + endif() + + if (CMAKE_SYSTEM_NAME MATCHES Darwin) + set (depsBuildFolderName buildMacOS) + elseif (CMAKE_SYSTEM_NAME MATCHES iOS) + set (depsBuildFolderName buildiOS) + elseif (ANDROID) + set (depsBuildFolderName buildAndroid) + endif() + + # Configure Protobuf for desired platform + file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/_deps/protobuf-src/${depsBuildFolderName}) + file (WRITE ${PROJECT_BINARY_DIR}/_deps/protobuf-src/${depsBuildFolderName}/${fileName} ${fileHeader}) + + if (ANDROID) + + file (APPEND ${PROJECT_BINARY_DIR}/_deps/protobuf-src/${depsBuildFolderName}/${fileName} "cmake -DCMAKE_TOOLCHAIN_FILE=../../${ANDROID_NDK_RPATH}/build/cmake/android.toolchain.cmake -DANDROID_ABI=${ANDROID_ABI} -DANDROID_PLATFORM=android-21 -DCMAKE_CXX_FLAGS=-std=c++14 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DANDROID_STL=c++_static -G Ninja ..") + + elseif (CMAKE_SYSTEM_NAME MATCHES Darwin) #MACOS + file (APPEND ${PROJECT_BINARY_DIR}/_deps/protobuf-src/${depsBuildFolderName}/${fileName} "cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -G Ninja ..") + elseif(CMAKE_SYSTEM_NAME MATCHES iOS) #iOS + set( OPENSSL_TARGET_ARCHITECTURES_iphoneos arm64 ) + file (APPEND ${PROJECT_BINARY_DIR}/_deps/protobuf-src/${depsBuildFolderName}/${fileName} "cmake -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -G Ninja .. +sudo cmake --build . --parallel 10") + endif() + + # Configure Protobuf for current platform + file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildCurrentPlatform) + file (WRITE ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildCurrentPlatform/${fileName} ${fileHeader}) + + if (ANDROID) + file (APPEND ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildCurrentPlatform/${fileName} "cmake -G Ninja .. + sudo cmake --build . --parallel 10") + elseif (CMAKE_SYSTEM_NAME MATCHES Darwin) #MACOS + file (APPEND ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildCurrentPlatform/${fileName} "cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS=\"-fpic -O2\" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -G Ninja .. + sudo cmake --build . --parallel 10") + elseif(CMAKE_SYSTEM_NAME MATCHES iOS) #iOS + file (APPEND ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildCurrentPlatform/${fileName} "cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS=\"-fpic -O2\" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -G Ninja .. + sudo cmake --build . --parallel 10") + endif() + + if (UNIX) + # Build Protobuf for desired platform + execute_process (COMMAND bash "-c" "bash ${fileName}" + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/_deps/protobuf-src/${depsBuildFolderName} + RESULT_VARIABLE errorval ) + + # Build Protobuf for cırrent platform + execute_process (COMMAND bash "-c" "bash ${fileName}" + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildCurrentPlatform + RESULT_VARIABLE errorval ) + endif () + + # + # Fetch OpenSSL, configure it and build it, supported platforms: iOS, Android and MacOS + # + message( "Fetching & Building OpenSSL... ") + FetchContent_GetProperties(OpenSSL) + if(NOT OpenSSL_POPULATED) + + FetchContent_Declare(OpenSSL + GIT_REPOSITORY https://github.com/openssl/openssl.git + GIT_TAG ${OpenSSLTag} + OVERRIDE_FIND_PACKAGE + ) + FetchContent_MakeAvailable(OpenSSL) + endif () + + # + # Set some paths for fetched libraries + # + + set(OPENSSL_CRYPTO_LIBRARY ${PROJECT_BINARY_DIR}/_deps/openssl-src/libcrypto.so) + set(OPENSSL_INCLUDE_DIR ${PROJECT_BINARY_DIR}/_deps/openssl-src/include) + include_directories(${OPENSSL_INCLUDE_DIR}) + + # Configure OpenSSL for desired platform + file (WRITE ${PROJECT_BINARY_DIR}/_deps/openssl-src/${fileName} ${fileHeader}) + + if (ANDROID) + if (ANDROID_ABI STREQUAL "arm64-v8a") + set (64BitArg "android-arm64") + else() + set (64BitArg "android-arm") + endif() + + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set (BuildType "--debug") + else() + set (BuildType "--release") + endif() + file (APPEND ${PROJECT_BINARY_DIR}/_deps/openssl-src/${fileName} "export ANDROID_NDK_HOME=../../${ANDROID_NDK_RPATH} +PATH=$ANDROID_NDK_HOME/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin:$PATH +PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH +./Configure no-tests ${64BitArg} -D__ANDROID_API__=21 ${BuildType} +make") + + elseif (CMAKE_SYSTEM_NAME MATCHES Darwin) + file (APPEND ${PROJECT_BINARY_DIR}/_deps/openssl-src/${fileName} "export SDKROOT=\"$(xcrun --sdk macosx --show-sdk-path)\" +./Configure darwin64-x86_64-cc no-shared enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp ${BuildType} +make") + elseif (CMAKE_SYSTEM_NAME MATCHES iOS) + set( OPENSSL_TARGET_ARCHITECTURES_iphoneos arm64 ) + # Specify the minimum iOS version + file (APPEND ${PROJECT_BINARY_DIR}/_deps/openssl-src/${fileName} "export CC=clang; +export CROSS_TOP=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer +export CROSS_SDK=iPhoneOS.sdk +PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$PATH +./Configure no-tests ios64-cross no-shared no-dso no-hw no-engine ${BuildType} +make") + endif() + + # Build OpenSSL for desired platform + if (UNIX) + execute_process (COMMAND bash "-c" "bash ${fileName}" + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/_deps/openssl-src + RESULT_VARIABLE errorval ) + endif() + + if (WIN32) + execute_process (COMMAND cmd "-c" "${fileName}" + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/_deps/openssl-src + RESULT_VARIABLE errorval ) + endif() + + # + # Optional: Set -s flag to strip(removes symbols) the output library (for ex: libGameNetworkingSockets.so) + # + if (ANDROID) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") + endif () + +endif (ANDROID OR APPLE) + if (USE_CRYPTO STREQUAL "OpenSSL") # Match the OpenSSL runtime to our setting. # Note that once found the library paths are cached and will not change if the option is changed. @@ -114,7 +274,13 @@ if (USE_CRYPTO STREQUAL "OpenSSL") if(WIN32 AND OPENSSL_USE_STATIC_LIBS) list(APPEND CMAKE_REQUIRED_LIBRARIES ws2_32 crypt32) endif() - check_symbol_exists(EVP_MD_CTX_free openssl/evp.h OPENSSL_NEW_ENOUGH) + #Bypassing "EVP_MD_CTX_free" check for Android and iOS + #because it fails even OpenSSL version is higher than 1.1.1 + if (NOT ANDROID AND NOT APPLE) + check_symbol_exists(EVP_MD_CTX_free openssl/evp.h OPENSSL_NEW_ENOUGH) + else() + set(OPENSSL_NEW_ENOUGH TRUE) + endif () if (NOT OPENSSL_NEW_ENOUGH) message(FATAL_ERROR "Cannot find EVP_MD_CTX_free in OpenSSL headers/libs for the target architecture. Check that you're using OpenSSL 1.1.0 or later.") endif() @@ -161,6 +327,8 @@ function(set_target_common_gns_properties TGT) target_compile_definitions(${TGT} PUBLIC LINUX) elseif(CMAKE_SYSTEM_NAME MATCHES Darwin) target_compile_definitions(${TGT} PUBLIC OSX) + elseif(CMAKE_SYSTEM_NAME MATCHES iOS) + target_compile_definitions(${TGT} PUBLIC OSX) elseif(CMAKE_SYSTEM_NAME MATCHES FreeBSD) target_compile_definitions(${TGT} PUBLIC FREEBSD) elseif(CMAKE_SYSTEM_NAME MATCHES Windows) @@ -189,6 +357,8 @@ function(set_target_common_gns_properties TGT) ) target_compile_options(${TGT} PRIVATE -fno-stack-protector) endif() + elseif(CMAKE_SYSTEM_NAME MATCHES Android) + target_compile_definitions(${TGT} PUBLIC ANDROID) else() message(FATAL_ERROR "Could not identify your target operating system") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 393eb7efb..bc621df78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -160,22 +160,117 @@ if(NOT SANITIZE_UNDEFINED) ) endif() -protobuf_generate_cpp(GNS_COMMON_PROTO_SRCS GNS_COMMON_PROTO_HDRS ${GNS_COMMON_PROTOS}) -protobuf_generate_cpp(GNS_CLIENTLIB_PROTO_SRCS GNS_CLIENTLIB_PROTO_HDRS ${GNS_CLIENTLIB_PROTOS}) +# +# Implemented a custom protobuf_generate_cpp logic for Android and iOS +# Why? When using "FetchContent_Declare" with OVERRIDE_FIND_PACKAGE, protobuf-config.cmake won't be used, thus the protobuf-generate macro "protobuf_generate_cpp" would be unavailable. +# There is already a fix at below link +# fix link: https://github.com/protocolbuffers/protobuf/pull/10426 +# But merged fix date may be a later date than the protobuf git version we want to build with, so i find it better to stay safe with a custom protobuf_generate_cpp method. It is pretty straightforward. +# + +if (ANDROID OR APPLE) + + # set some file names depending on the platform + if (UNIX) + set (fileName "protocFiles.sh") + set (fileHeader "#!/bin/sh\n") + endif() + + # Cache protoc commands to a bash file by iterating proto files + file (WRITE ${PROJECT_BINARY_DIR}/${fileName} ${fileHeader}) + file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/protos/common) + file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/protos/clientlib) + + foreach (X IN LISTS GNS_COMMON_PROTOS) + file (APPEND ${PROJECT_BINARY_DIR}/${fileName} "_deps/protobuf-src/buildCurrentPlatform/protoc -I=../src/common --cpp_out=protos/common ../src/${X}\n") + endforeach() + foreach (X IN LISTS GNS_CLIENTLIB_PROTOS) + file (APPEND ${PROJECT_BINARY_DIR}/${fileName} "_deps/protobuf-src/buildCurrentPlatform/protoc -I=../src/common --cpp_out=protos/clientlib ../src/${X}\n") + endforeach() + foreach (X IN LISTS GNS_COMMON_PROTOS) + file (APPEND ${PROJECT_BINARY_DIR}/${fileName} "_deps/protobuf-src/buildCurrentPlatform/protoc -I=../src/common --cpp_out=../src/common ../src/${X}\n") + endforeach() + foreach (X IN LISTS GNS_CLIENTLIB_PROTOS) + file (APPEND ${PROJECT_BINARY_DIR}/${fileName} "_deps/protobuf-src/buildCurrentPlatform/protoc -I=../src/common --cpp_out=../src/common ../src/${X}\n") + endforeach() + + # Run the bash file + if (UNIX) + execute_process (COMMAND bash -c "bash ${fileName}" + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + RESULT_VARIABLE errorval ) + endif() + + # Populate the output lists + file(GLOB GNS_COMMON_PROTO_SRCS + "${PROJECT_BINARY_DIR}/protos/common/*.cc" + ) + file(GLOB GNS_COMMON_PROTO_HDRS + "${PROJECT_BINARY_DIR}/protos/common/*.h" + ) + file(GLOB GNS_CLIENTLIB_PROTO_SRCS + "${PROJECT_BINARY_DIR}/protos/clientlib/*.cc" + ) + file(GLOB GNS_CLIENTLIB_PROTO_HDRS + "${PROJECT_BINARY_DIR}/protos/clientlib/*.h" + ) +else() + protobuf_generate_cpp(GNS_COMMON_PROTO_SRCS GNS_COMMON_PROTO_HDRS ${GNS_COMMON_PROTOS}) + protobuf_generate_cpp(GNS_CLIENTLIB_PROTO_SRCS GNS_CLIENTLIB_PROTO_HDRS ${GNS_CLIENTLIB_PROTOS}) +endif() function(gns_set_target_protobuf_properties TGT ) + +# Set some configs for Android and Apple +if (ANDROID OR APPLE) + list(APPEND CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR}/_deps/protobuf-src/src) + include_directories(${PROJECT_BINARY_DIR}/_deps/protobuf-src/src) + + list(APPEND CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR}/_deps/openssl-src/include) + include_directories(${PROJECT_BINARY_DIR}/_deps/openssl-src/include) +endif () + +# Android requires that log library +if (ANDROID) target_link_libraries(${TGT} PUBLIC protobuf::libprotobuf Threads::Threads + log ) +elseif (CMAKE_SYSTEM_NAME MATCHES iOS) + + target_link_libraries(${TGT} PUBLIC + ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildiOS/libprotobuf.a + Threads::Threads + ) +elseif (CMAKE_SYSTEM_NAME MATCHES Darwin) + target_link_libraries(${TGT} PUBLIC + ${PROJECT_BINARY_DIR}/_deps/protobuf-src/buildCurrentPlatform/libprotobuf.a + Threads::Threads + ) +else() + target_link_libraries(${TGT} PUBLIC + protobuf::libprotobuf + Threads::Threads + ) +endif() endfunction() # Set the target properties (sources, link libs, defines) based on crypto settings function(gns_set_target_crypto_properties TGT) if(USE_CRYPTO STREQUAL "OpenSSL" OR USE_CRYPTO25519 STREQUAL "OpenSSL") + + # linking staticly for Android and iOS + if (ANDROID OR APPLE) + target_link_libraries(${TGT} PUBLIC + ${PROJECT_BINARY_DIR}/_deps/openssl-src/libcrypto.a + ) + else() target_link_libraries(${TGT} PUBLIC OpenSSL::Crypto ) + endif(ANDROID OR APPLE) + if(WIN32 AND OPENSSL_USE_STATIC_LIBS) target_link_libraries(${TGT} PUBLIC ws2_32 @@ -184,6 +279,7 @@ function(gns_set_target_crypto_properties TGT) endif() endif() + # Currently libsodium linking is not supported for Android and Apple. if(USE_CRYPTO STREQUAL "libsodium" OR USE_CRYPTO25519 STREQUAL "libsodium") target_link_libraries(${TGT} PUBLIC sodium @@ -304,6 +400,10 @@ macro(set_clientlib_target_properties GNS_TARGET) if(USE_CRYPTO STREQUAL "BCrypt") target_link_libraries(${GNS_TARGET} PUBLIC bcrypt) endif() + elseif(CMAKE_SYSTEM_NAME MATCHES Android) + + elseif(CMAKE_SYSTEM_NAME MATCHES iOS) + else() message(FATAL_ERROR "Could not identify your target operating system") endif() diff --git a/src/public/minbase/minbase_endian.h b/src/public/minbase/minbase_endian.h index f9ad35fb5..51a92f9b8 100644 --- a/src/public/minbase/minbase_endian.h +++ b/src/public/minbase/minbase_endian.h @@ -38,7 +38,10 @@ inline T WordSwapC( T w ) template inline T DWordSwapC( T dw ) { + // Compiling for Android always gives assertion here. + #ifndef IsAndroid PLAT_COMPILE_TIME_ASSERT( sizeof( T ) == sizeof(uint32) ); + #endif uint32 temp; #if defined( _MSC_VER ) || defined( __ICC ) temp = _byteswap_ulong( *(uint32*)&dw ); diff --git a/src/tier0/dbg.cpp b/src/tier0/dbg.cpp index dd31cc389..2e767ac4c 100644 --- a/src/tier0/dbg.cpp +++ b/src/tier0/dbg.cpp @@ -88,6 +88,8 @@ bool Plat_IsInDebugSession() // NDA material #elif IsNintendoSwitch() return false; +#elif IsAndroid() + return false; #else #error "HALP" #endif