Skip to content

Commit 6225905

Browse files
committed
Merge remote-tracking branch 'origin/master' into garethsb-http-ssl_context_callback
2 parents 43773b9 + a917bd4 commit 6225905

File tree

10 files changed

+162
-41
lines changed

10 files changed

+162
-41
lines changed

Build_android/configure.sh

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ set -e
2222

2323
DO_BOOST=1
2424
DO_OPENSSL=1
25+
DO_CMAKE=1
2526
DO_CPPRESTSDK=1
2627

27-
BOOSTVER=1.65.1
28-
OPENSSLVER=1.0.2k
28+
BOOSTVER=1.69.0
29+
OPENSSLVER=1.1.0j
30+
CMAKEVER=3.14.0
2931

3032
API=15
31-
STL=c++_static
33+
STL=c++_shared
3234

3335
function usage {
3436
echo "Usage: $0 [--skip-boost] [--skip-openssl] [--skip-cpprestsdk] [-h] [--ndk <android-ndk>]"
@@ -51,6 +53,9 @@ do
5153
"--skip-openssl")
5254
DO_OPENSSL=0
5355
;;
56+
"--skip-cmake")
57+
DO_CMAKE=0
58+
;;
5459
"--skip-cpprestsdk")
5560
DO_CPPRESTSDK=0
5661
;;
@@ -59,6 +64,11 @@ do
5964
DO_BOOST=1
6065
BOOSTVER=$1
6166
;;
67+
"--cmake")
68+
shift
69+
DO_CMAKE=1
70+
CMAKEVER=$1
71+
;;
6272
"--openssl")
6373
shift
6474
DO_OPENSSL=1
@@ -130,8 +140,8 @@ if [ "${DO_OPENSSL}" == "1" ]; then (
130140
if [ ! -d "openssl" ]; then mkdir openssl; fi
131141
cd openssl
132142
cp -af "${DIR}/openssl/." .
133-
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_GCC_VERSION=4.9 ANDROID_ABI=armeabi-v7a OPENSSL_PREFIX=armeabi-v7a OPENSSL_VERSION=$OPENSSLVER
134-
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_GCC_VERSION=4.9 ANDROID_ABI=x86 OPENSSL_PREFIX=x86 OPENSSL_VERSION=$OPENSSLVER
143+
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_ABI=armeabi-v7a OPENSSL_PREFIX=armeabi-v7a OPENSSL_VERSION=$OPENSSLVER -j $NCPU
144+
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_ABI=x86 OPENSSL_PREFIX=x86 OPENSSL_VERSION=$OPENSSLVER -j $NCPU
135145
) fi
136146

137147
# -----
@@ -143,7 +153,7 @@ if [ "${DO_OPENSSL}" == "1" ]; then (
143153
if [ "${DO_BOOST}" == "1" ]; then (
144154
if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/moritz-wundke/Boost-for-Android; fi
145155
cd Boost-for-Android
146-
git checkout 84973078a3d7668067d422d4654696ef59ab9d6d
156+
git checkout 1356b87fed389b4abf1ff671adec0b899877174b
147157
PATH="$PATH:$NDK_DIR" \
148158
CXXFLAGS="-std=gnu++11" \
149159
./build-android.sh \
@@ -153,23 +163,38 @@ if [ "${DO_BOOST}" == "1" ]; then (
153163
"${NDK_DIR}" || exit 1
154164
) fi
155165

166+
# ------
167+
# CMake
168+
# ------
169+
# We update CMake because the version included with Ubuntu is too old to handle Boost 1.69.
170+
171+
if [ "${DO_CMAKE}" == "1" ]; then (
172+
if [ ! -d "cmake-${CMAKEVER}" ]; then wget https://github.com/Kitware/CMake/releases/download/v${CMAKEVER}/cmake-${CMAKEVER}-Linux-x86_64.sh; fi
173+
chmod +x cmake-${CMAKEVER}-Linux-x86_64.sh
174+
rm -rf cmake-${CMAKEVER}
175+
mkdir cmake-${CMAKEVER}
176+
cd cmake-${CMAKEVER}
177+
../cmake-${CMAKEVER}-Linux-x86_64.sh --skip-license
178+
) fi
179+
156180
# ----------
157181
# casablanca
158182
# ----------
159183

160184
if [ "${DO_CPPRESTSDK}" == "1" ]; then
161185
# Use the builtin CMake toolchain configuration that comes with the NDK
162186
function build_cpprestsdk { (
163-
mkdir -p $1
164-
cd $1
165-
cmake "${DIR}/.." \
187+
rm -rf $1
188+
./cmake-${CMAKEVER}/bin/cmake \
166189
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
167190
-DANDROID_NDK="${ANDROID_NDK}" \
168191
-DANDROID_TOOLCHAIN=clang \
169192
-DANDROID_ABI=$2 \
170193
-DBOOST_VERSION="${BOOSTVER}" \
171-
-DCMAKE_BUILD_TYPE=$3
172-
make -j $NCPU
194+
-DCMAKE_BUILD_TYPE=$3 \
195+
-S "${DIR}/.." \
196+
-B $1
197+
make -j $NCPU -C $1
173198
) }
174199

175200
# Build the cpprestsdk for each target configuration
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
This patch applies several changes that enable OpenSSL 1.1.0g to be built
2+
for Android using either Clang or GCC toolchains.
3+
4+
diff -Naur org/Configurations/10-main.conf mod/Configurations/10-main.conf
5+
--- org/Configurations/10-main.conf 2017-11-02 07:29:01.000000000 -0700
6+
+++ mod/Configurations/10-main.conf 2018-01-18 10:59:41.675138500 -0800
7+
@@ -910,15 +910,27 @@
8+
# systems are perfectly capable of executing binaries targeting
9+
# Froyo. Keep in mind that in the nutshell Android builds are
10+
# about JNI, i.e. shared libraries, not applications.
11+
- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
12+
+ cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")),
13+
bin_cflags => "-pie",
14+
},
15+
+ "android-clang" => {
16+
+ inherit_from => [ "linux-generic32" ],
17+
+ cc => "clang",
18+
+ cflags => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")),
19+
+},
20+
"android-x86" => {
21+
inherit_from => [ "android", asm("x86_asm") ],
22+
cflags => add(picker(release => "-fomit-frame-pointer")),
23+
bn_ops => "BN_LLONG",
24+
perlasm_scheme => "android",
25+
},
26+
+ "android-x86-clang" => {
27+
+ inherit_from => [ "android-clang", asm("x86_asm") ],
28+
+ cflags => add(picker(default => "-target i686-none-linux-android",
29+
+ release => "-fomit-frame-pointer")),
30+
+ bn_ops => "BN_LLONG",
31+
+ perlasm_scheme => "android",
32+
+ },
33+
################################################################
34+
# Contemporary Android applications can provide multiple JNI
35+
# providers in .apk, targeting multiple architectures. Among
36+
@@ -943,20 +955,38 @@
37+
"android-armeabi" => {
38+
inherit_from => [ "android", asm("armv4_asm") ],
39+
},
40+
+ "android-armeabi-clang" => {
41+
+ inherit_from => [ "android-clang", asm("armv4_asm") ],
42+
+ cflags => add("-target armv7-none-linux-androideabi"),
43+
+ },
44+
"android-mips" => {
45+
inherit_from => [ "android", asm("mips32_asm") ],
46+
perlasm_scheme => "o32",
47+
},
48+
-
49+
+ "android-mips-clang" => {
50+
+ inherit_from => [ "android-clang", asm("mips32_asm") ],
51+
+ cflags => add("-target mipsel-none-linux-android"),
52+
+ perlasm_scheme => "o32",
53+
+ },
54+
"android64" => {
55+
inherit_from => [ "linux-generic64" ],
56+
- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
57+
+ cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")),
58+
bin_cflags => "-pie",
59+
},
60+
+ "android64-clang" => {
61+
+ inherit_from => [ "linux-generic64" ],
62+
+ cc => "clang",
63+
+ cflags => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")),
64+
+ },
65+
"android64-aarch64" => {
66+
inherit_from => [ "android64", asm("aarch64_asm") ],
67+
perlasm_scheme => "linux64",
68+
},
69+
+ "android64-aarch64-clang" => {
70+
+ inherit_from => [ "android64-clang", asm("aarch64_asm") ],
71+
+ cflags => add("-target aarch64-none-linux-android"),
72+
+ perlasm_scheme => "linux64",
73+
+ },
74+
75+
#### *BSD
76+
"BSD-generic32" => {

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cmake_minimum_required(VERSION 3.1)
22
project(cpprestsdk-root NONE)
3-
3+
enable_testing()
44
add_subdirectory(Release)

Release/cmake/cpprest_find_boost.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ function(cpprest_find_boost)
3535
endif()
3636
elseif(ANDROID)
3737
set(Boost_COMPILER "-clang")
38-
if(ARM)
38+
if(ANDROID_ABI STREQUAL "armeabi-v7a")
3939
set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/armeabi-v7a" CACHE INTERNAL "")
4040
set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/armeabi-v7a/lib" CACHE INTERNAL "")
41+
set(Boost_ARCHITECTURE "-a32" CACHE INTERNAL "")
4142
else()
4243
set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/x86" CACHE INTERNAL "")
4344
set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/x86/lib" CACHE INTERNAL "")
45+
set(Boost_ARCHITECTURE "-x32" CACHE INTERNAL "")
4446
endif()
4547
cpprestsdk_find_boost_android_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS random system thread filesystem chrono atomic)
4648
elseif(UNIX)

Release/include/cpprest/filestream.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,19 @@ class basic_file_buffer : public details::streambuf_state_manager<_CharType>
649649
if (mode == std::ios_base::in)
650650
{
651651
m_readOps.wait();
652+
size_t current_pos = static_cast<size_t>(-1);
652653
switch (way)
653654
{
654655
case std::ios_base::beg: return (pos_type)_seekrdpos_fsb(m_info, size_t(offset), sizeof(_CharType));
655656
case std::ios_base::cur:
656657
return (pos_type)_seekrdpos_fsb(m_info, size_t(m_info->m_rdpos + offset), sizeof(_CharType));
657-
case std::ios_base::end: return (pos_type)_seekrdtoend_fsb(m_info, int64_t(offset), sizeof(_CharType));
658+
case std::ios_base::end:
659+
current_pos = _seekrdtoend_fsb(m_info, int64_t(offset), sizeof(_CharType));
660+
if (current_pos == static_cast<size_t>(-1))
661+
{
662+
return -1;
663+
}
664+
return (pos_type)current_pos;
658665
default:
659666
// Fail on invalid input (_S_ios_seekdir_end)
660667
assert(false);

Release/src/http/common/http_msg.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,25 @@ void http_msg_base::_complete(utility::size64_t body_size, const std::exception_
427427
{
428428
const auto& completionEvent = _get_data_available();
429429
auto closeTask = pplx::task_from_result();
430-
431-
if (exceptionPtr == std::exception_ptr())
430+
if (m_default_outstream)
432431
{
433-
if (m_default_outstream)
432+
// if the outstream is one we created by default on the customer's behalf, try to close it
433+
auto& out = outstream();
434+
if (out.is_valid())
434435
{
435-
closeTask = outstream().close();
436+
if (exceptionPtr == std::exception_ptr())
437+
{
438+
closeTask = out.close();
439+
}
440+
else
441+
{
442+
closeTask = out.close(exceptionPtr);
443+
}
436444
}
445+
}
437446

447+
if (exceptionPtr == std::exception_ptr())
448+
{
438449
inline_continuation(closeTask, [completionEvent, body_size](pplx::task<void> t) {
439450
try
440451
{
@@ -459,11 +470,6 @@ void http_msg_base::_complete(utility::size64_t body_size, const std::exception_
459470
}
460471
else
461472
{
462-
if (outstream().is_valid())
463-
{
464-
closeTask = outstream().close(exceptionPtr);
465-
}
466-
467473
inline_continuation(closeTask, [completionEvent, exceptionPtr](pplx::task<void> t) {
468474
// If closing stream throws an exception ignore since we already have an error.
469475
try

Release/src/streams/fileio_win32.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,11 +905,26 @@ size_t __cdecl _seekrdtoend_fsb(_In_ streams::details::_file_info* info, int64_t
905905
fInfo->m_bufoff = fInfo->m_buffill = fInfo->m_bufsize = 0;
906906
}
907907

908+
#ifdef _WIN64
909+
LARGE_INTEGER filesize;
910+
filesize.QuadPart = 0;
911+
912+
BOOL result = GetFileSizeEx(fInfo->m_handle, &filesize);
913+
if (FALSE == result)
914+
{
915+
return static_cast<size_t>(-1);
916+
}
917+
else
918+
{
919+
fInfo->m_rdpos = static_cast<size_t>(filesize.QuadPart) / char_size;
920+
}
921+
#else
908922
auto newpos = SetFilePointer(fInfo->m_handle, (LONG)(offset * char_size), nullptr, FILE_END);
909923

910924
if (newpos == INVALID_SET_FILE_POINTER) return static_cast<size_t>(-1);
911925

912926
fInfo->m_rdpos = static_cast<size_t>(newpos) / char_size;
927+
#endif
913928

914929
return fInfo->m_rdpos;
915930
}

Release/tests/functional/http/client/connections_and_errors.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,7 @@ SUITE(connections_and_errors)
226226
http_response rsp = client.request(msg).get();
227227

228228
// The response body should timeout and we should receive an exception
229-
#ifndef _WIN32
230-
// CodePlex 295
231-
VERIFY_THROWS(rsp.content_ready().wait(), http_exception);
232-
#else
233229
VERIFY_THROWS_HTTP_ERROR_CODE(rsp.content_ready().wait(), std::errc::timed_out);
234-
#endif
235230
}
236231

237232
buf.close(std::ios_base::out).wait();
@@ -261,12 +256,7 @@ SUITE(connections_and_errors)
261256

262257
// The response body should timeout and we should receive an exception
263258
auto readTask = rsp.body().read_to_end(streams::producer_consumer_buffer<uint8_t>());
264-
#ifndef _WIN32
265-
// CodePlex 295
266-
VERIFY_THROWS(readTask.get(), http_exception);
267-
#else
268259
VERIFY_THROWS_HTTP_ERROR_CODE(readTask.wait(), std::errc::timed_out);
269-
#endif
270260
}
271261

272262
buf.close(std::ios_base::out).wait();

azure-pipelines.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
steps:
88
- script: .\vcpkg\bootstrap-vcpkg.bat
99
displayName: Bootstrap vcpkg
10-
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli
10+
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli --vcpkg-root .\vcpkg
1111
displayName: vcpkg install dependencies
1212
- script: mkdir build.common
1313
displayName: Make Build Directory
@@ -38,7 +38,7 @@ jobs:
3838
steps:
3939
- script: .\vcpkg\bootstrap-vcpkg.bat
4040
displayName: Bootstrap vcpkg
41-
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli --triplet x64-windows
41+
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli --triplet x64-windows --vcpkg-root .\vcpkg
4242
displayName: vcpkg install dependencies
4343
- script: mkdir build.common
4444
displayName: Make Build Directory
@@ -71,7 +71,7 @@ jobs:
7171
steps:
7272
- script: .\vcpkg\bootstrap-vcpkg.bat
7373
displayName: Bootstrap vcpkg
74-
- script: .\vcpkg\vcpkg.exe install zlib --triplet x64-uwp
74+
- script: .\vcpkg\vcpkg.exe install zlib --triplet x64-uwp --vcpkg-root .\vcpkg
7575
displayName: vcpkg install dependencies
7676
- script: mkdir build.common
7777
displayName: Make Build Directory
@@ -90,7 +90,7 @@ jobs:
9090
steps:
9191
- script: .\vcpkg\bootstrap-vcpkg.bat
9292
displayName: Bootstrap vcpkg
93-
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli
93+
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli --vcpkg-root .\vcpkg
9494
displayName: vcpkg install dependencies
9595
- script: mkdir build.common
9696
displayName: Make Build Directory
@@ -121,7 +121,7 @@ jobs:
121121
steps:
122122
- script: .\vcpkg\bootstrap-vcpkg.bat
123123
displayName: Bootstrap vcpkg
124-
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli --triplet x64-windows
124+
- script: .\vcpkg\vcpkg.exe install zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli --triplet x64-windows --vcpkg-root .\vcpkg
125125
displayName: vcpkg install dependencies
126126
- script: mkdir build.common
127127
displayName: Make Build Directory
@@ -194,7 +194,7 @@ jobs:
194194
sudo apt-get -y update
195195
sudo apt-get install g++-7 ninja-build -y
196196
./vcpkg/bootstrap-vcpkg.sh
197-
./vcpkg/vcpkg install zlib openssl boost-system boost-date-time boost-regex websocketpp boost-thread boost-filesystem boost-random boost-chrono boost-interprocess brotli
197+
./vcpkg/vcpkg install zlib openssl boost-system boost-date-time boost-regex websocketpp boost-thread boost-filesystem boost-random boost-chrono boost-interprocess brotli --vcpkg-root ./vcpkg
198198
displayName: Vcpkg install dependencies
199199
- script: |
200200
mkdir build.debug
@@ -284,7 +284,7 @@ jobs:
284284
- script: |
285285
brew install gcc ninja
286286
./vcpkg/bootstrap-vcpkg.sh
287-
./vcpkg/vcpkg install zlib openssl boost-system boost-date-time boost-regex websocketpp boost-thread boost-filesystem boost-random boost-chrono boost-interprocess brotli
287+
./vcpkg/vcpkg install zlib openssl boost-system boost-date-time boost-regex websocketpp boost-thread boost-filesystem boost-random boost-chrono boost-interprocess brotli --vcpkg-root ./vcpkg
288288
displayName: Vcpkg install dependencies
289289
- script: |
290290
mkdir build.debug

vcpkg

Submodule vcpkg updated 918 files

0 commit comments

Comments
 (0)