Skip to content

Commit f0a38c2

Browse files
committed
Fix android build
Signed-off-by: Vitalii Koshura <[email protected]>
1 parent c1b1275 commit f0a38c2

25 files changed

+1680
-0
lines changed

Diff for: 3rdParty/vcpkg_ports/ports/openssl/asm-comments.patch

+704
Large diffs are not rendered by default.
+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
diff --git a/crypto/ec/ecp_sm2p256.c b/crypto/ec/ecp_sm2p256.c
2+
index 6ec4245..d47689a 100644
3+
--- a/crypto/ec/ecp_sm2p256.c
4+
+++ b/crypto/ec/ecp_sm2p256.c
5+
@@ -40,28 +40,28 @@ typedef struct {
6+
7+
#if !defined(OPENSSL_NO_SM2_PRECOMP)
8+
/* Coordinates of G, for which we have precomputed tables */
9+
-static const BN_ULONG def_xG[P256_LIMBS] ALIGN32 = {
10+
+ALIGN32 static const BN_ULONG def_xG[P256_LIMBS] = {
11+
0x715a4589334c74c7, 0x8fe30bbff2660be1,
12+
0x5f9904466a39c994, 0x32c4ae2c1f198119
13+
};
14+
15+
-static const BN_ULONG def_yG[P256_LIMBS] ALIGN32 = {
16+
+ALIGN32 static const BN_ULONG def_yG[P256_LIMBS] = {
17+
0x02df32e52139f0a0, 0xd0a9877cc62a4740,
18+
0x59bdcee36b692153, 0xbc3736a2f4f6779c,
19+
};
20+
#endif
21+
22+
/* p and order for SM2 according to GB/T 32918.5-2017 */
23+
-static const BN_ULONG def_p[P256_LIMBS] ALIGN32 = {
24+
+ALIGN32 static const BN_ULONG def_p[P256_LIMBS] = {
25+
0xffffffffffffffff, 0xffffffff00000000,
26+
0xffffffffffffffff, 0xfffffffeffffffff
27+
};
28+
-static const BN_ULONG def_ord[P256_LIMBS] ALIGN32 = {
29+
+ALIGN32 static const BN_ULONG def_ord[P256_LIMBS] = {
30+
0x53bbf40939d54123, 0x7203df6b21c6052b,
31+
0xffffffffffffffff, 0xfffffffeffffffff
32+
};
33+
34+
-static const BN_ULONG ONE[P256_LIMBS] ALIGN32 = {1, 0, 0, 0};
35+
+ALIGN32 static const BN_ULONG ONE[P256_LIMBS] = {1, 0, 0, 0};
36+
37+
/* Functions implemented in assembly */
38+
/*
39+
@@ -139,10 +139,10 @@ static ossl_inline int is_greater(const BN_ULONG *a, const BN_ULONG *b)
40+
/* Binary algorithm for inversion in Fp */
41+
#define BN_MOD_INV(out, in, mod_div, mod_sub, mod) \
42+
do { \
43+
- BN_ULONG u[4] ALIGN32; \
44+
- BN_ULONG v[4] ALIGN32; \
45+
- BN_ULONG x1[4] ALIGN32 = {1, 0, 0, 0}; \
46+
- BN_ULONG x2[4] ALIGN32 = {0}; \
47+
+ ALIGN32 BN_ULONG u[4] ; \
48+
+ ALIGN32 BN_ULONG v[4] ; \
49+
+ ALIGN32 BN_ULONG x1[4] = {1, 0, 0, 0}; \
50+
+ ALIGN32 BN_ULONG x2[4] = {0}; \
51+
\
52+
if (is_zeros(in)) \
53+
return; \
54+
@@ -188,9 +188,9 @@ static ossl_inline void ecp_sm2p256_mod_ord_inverse(BN_ULONG* out,
55+
static void ecp_sm2p256_point_double(P256_POINT *R, const P256_POINT *P)
56+
{
57+
unsigned int i;
58+
- BN_ULONG tmp0[P256_LIMBS] ALIGN32;
59+
- BN_ULONG tmp1[P256_LIMBS] ALIGN32;
60+
- BN_ULONG tmp2[P256_LIMBS] ALIGN32;
61+
+ ALIGN32 BN_ULONG tmp0[P256_LIMBS] ;
62+
+ ALIGN32 BN_ULONG tmp1[P256_LIMBS] ;
63+
+ ALIGN32 BN_ULONG tmp2[P256_LIMBS] ;
64+
65+
/* zero-check P->Z */
66+
if (is_zeros(P->Z)) {
67+
@@ -225,10 +225,10 @@ static void ecp_sm2p256_point_add_affine(P256_POINT *R, const P256_POINT *P,
68+
const P256_POINT_AFFINE *Q)
69+
{
70+
unsigned int i;
71+
- BN_ULONG tmp0[P256_LIMBS] ALIGN32 = {0};
72+
- BN_ULONG tmp1[P256_LIMBS] ALIGN32 = {0};
73+
- BN_ULONG tmp2[P256_LIMBS] ALIGN32 = {0};
74+
- BN_ULONG tmp3[P256_LIMBS] ALIGN32 = {0};
75+
+ ALIGN32 BN_ULONG tmp0[P256_LIMBS] = {0};
76+
+ ALIGN32 BN_ULONG tmp1[P256_LIMBS] = {0};
77+
+ ALIGN32 BN_ULONG tmp2[P256_LIMBS] = {0};
78+
+ ALIGN32 BN_ULONG tmp3[P256_LIMBS] = {0};
79+
80+
/* zero-check P->Z */
81+
if (is_zeros(P->Z)) {
82+
@@ -288,9 +288,9 @@ static void ecp_sm2p256_point_add(P256_POINT *R, const P256_POINT *P,
83+
const P256_POINT *Q)
84+
{
85+
unsigned int i;
86+
- BN_ULONG tmp0[P256_LIMBS] ALIGN32 = {0};
87+
- BN_ULONG tmp1[P256_LIMBS] ALIGN32 = {0};
88+
- BN_ULONG tmp2[P256_LIMBS] ALIGN32 = {0};
89+
+ ALIGN32 BN_ULONG tmp0[P256_LIMBS] = {0};
90+
+ ALIGN32 BN_ULONG tmp1[P256_LIMBS] = {0};
91+
+ ALIGN32 BN_ULONG tmp2[P256_LIMBS] = {0};
92+
93+
/* zero-check P | Q ->Z */
94+
if (is_zeros(P->Z)) {
95+
@@ -382,7 +382,7 @@ static void ecp_sm2p256_point_P_mul_by_scalar(P256_POINT *R, const BN_ULONG *k,
96+
{
97+
int i, init = 0;
98+
unsigned int index, mask = 0x0f;
99+
- P256_POINT precomputed[16] ALIGN64;
100+
+ ALIGN64 P256_POINT precomputed[16] ;
101+
102+
memset(R, 0, sizeof(P256_POINT));
103+
104+
@@ -427,8 +427,8 @@ static void ecp_sm2p256_point_P_mul_by_scalar(P256_POINT *R, const BN_ULONG *k,
105+
static void ecp_sm2p256_point_get_affine(P256_POINT_AFFINE *R,
106+
const P256_POINT *P)
107+
{
108+
- BN_ULONG z_inv3[P256_LIMBS] ALIGN32 = {0};
109+
- BN_ULONG z_inv2[P256_LIMBS] ALIGN32 = {0};
110+
+ ALIGN32 BN_ULONG z_inv3[P256_LIMBS] = {0};
111+
+ ALIGN32 BN_ULONG z_inv2[P256_LIMBS] = {0};
112+
113+
if (is_one(P->Z)) {
114+
memcpy(R->X, P->X, 32);
115+
@@ -461,13 +461,13 @@ static int ecp_sm2p256_get_affine(const EC_GROUP *group,
116+
const EC_POINT *point,
117+
BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
118+
{
119+
- BN_ULONG z_inv2[P256_LIMBS] ALIGN32 = {0};
120+
- BN_ULONG z_inv3[P256_LIMBS] ALIGN32 = {0};
121+
- BN_ULONG x_aff[P256_LIMBS] ALIGN32 = {0};
122+
- BN_ULONG y_aff[P256_LIMBS] ALIGN32 = {0};
123+
- BN_ULONG point_x[P256_LIMBS] ALIGN32 = {0};
124+
- BN_ULONG point_y[P256_LIMBS] ALIGN32 = {0};
125+
- BN_ULONG point_z[P256_LIMBS] ALIGN32 = {0};
126+
+ ALIGN32 BN_ULONG z_inv2[P256_LIMBS] = {0};
127+
+ ALIGN32 BN_ULONG z_inv3[P256_LIMBS] = {0};
128+
+ ALIGN32 BN_ULONG x_aff[P256_LIMBS] = {0};
129+
+ ALIGN32 BN_ULONG y_aff[P256_LIMBS] = {0};
130+
+ ALIGN32 BN_ULONG point_x[P256_LIMBS] = {0};
131+
+ ALIGN32 BN_ULONG point_y[P256_LIMBS] = {0};
132+
+ ALIGN32 BN_ULONG point_z[P256_LIMBS] = {0};
133+
134+
if (EC_POINT_is_at_infinity(group, point)) {
135+
ECerr(ERR_LIB_EC, EC_R_POINT_AT_INFINITY);
136+
@@ -510,7 +510,7 @@ static int ecp_sm2p256_windowed_mul(const EC_GROUP *group,
137+
unsigned int i;
138+
int ret = 0;
139+
const BIGNUM **scalars = NULL;
140+
- BN_ULONG k[P256_LIMBS] ALIGN32 = {0};
141+
+ ALIGN32 BN_ULONG k[P256_LIMBS] = {0};
142+
P256_POINT kP;
143+
ALIGN32 union {
144+
P256_POINT p;
145+
@@ -572,7 +572,7 @@ static int ecp_sm2p256_points_mul(const EC_GROUP *group,
146+
{
147+
int ret = 0, p_is_infinity = 0;
148+
const EC_POINT *generator = NULL;
149+
- BN_ULONG k[P256_LIMBS] ALIGN32 = {0};
150+
+ ALIGN32 BN_ULONG k[P256_LIMBS] = {0};
151+
ALIGN32 union {
152+
P256_POINT p;
153+
P256_POINT_AFFINE a;
154+
@@ -646,9 +646,9 @@ err:
155+
static int ecp_sm2p256_field_mul(const EC_GROUP *group, BIGNUM *r,
156+
const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
157+
{
158+
- BN_ULONG a_fe[P256_LIMBS] ALIGN32 = {0};
159+
- BN_ULONG b_fe[P256_LIMBS] ALIGN32 = {0};
160+
- BN_ULONG r_fe[P256_LIMBS] ALIGN32 = {0};
161+
+ ALIGN32 BN_ULONG a_fe[P256_LIMBS] = {0};
162+
+ ALIGN32 BN_ULONG b_fe[P256_LIMBS] = {0};
163+
+ ALIGN32 BN_ULONG r_fe[P256_LIMBS] = {0};
164+
165+
if (a == NULL || b == NULL || r == NULL)
166+
return 0;
167+
@@ -670,8 +670,8 @@ static int ecp_sm2p256_field_mul(const EC_GROUP *group, BIGNUM *r,
168+
static int ecp_sm2p256_field_sqr(const EC_GROUP *group, BIGNUM *r,
169+
const BIGNUM *a, BN_CTX *ctx)
170+
{
171+
- BN_ULONG a_fe[P256_LIMBS] ALIGN32 = {0};
172+
- BN_ULONG r_fe[P256_LIMBS] ALIGN32 = {0};
173+
+ ALIGN32 BN_ULONG a_fe[P256_LIMBS] = {0};
174+
+ ALIGN32 BN_ULONG r_fe[P256_LIMBS] = {0};
175+
176+
if (a == NULL || r == NULL)
177+
return 0;
178+
@@ -693,8 +693,8 @@ static int ecp_sm2p256_inv_mod_ord(const EC_GROUP *group, BIGNUM *r,
179+
const BIGNUM *x, BN_CTX *ctx)
180+
{
181+
int ret = 0;
182+
- BN_ULONG t[P256_LIMBS] ALIGN32 = {0};
183+
- BN_ULONG out[P256_LIMBS] ALIGN32 = {0};
184+
+ ALIGN32 BN_ULONG t[P256_LIMBS] = {0};
185+
+ ALIGN32 BN_ULONG out[P256_LIMBS] = {0};
186+
187+
if (bn_wexpand(r, P256_LIMBS) == NULL) {
188+
ECerr(ERR_LIB_EC, ERR_R_BN_LIB);
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function(install_pc_file name pc_data)
2+
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
3+
configure_file("${CMAKE_CURRENT_LIST_DIR}/openssl.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${name}.pc" @ONLY)
4+
endif()
5+
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
6+
configure_file("${CMAKE_CURRENT_LIST_DIR}/openssl.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${name}.pc" @ONLY)
7+
endif()
8+
endfunction()
9+
10+
install_pc_file(openssl [[
11+
Name: OpenSSL
12+
Description: Secure Sockets Layer and cryptography libraries and tools
13+
Requires: libssl libcrypto
14+
]])
15+
16+
install_pc_file(libssl [[
17+
Name: OpenSSL-libssl
18+
Description: Secure Sockets Layer and cryptography libraries
19+
Libs: -L"${libdir}" -llibssl
20+
Requires: libcrypto
21+
Cflags: -I"${includedir}"
22+
]])
23+
24+
install_pc_file(libcrypto [[
25+
Name: OpenSSL-libcrypto
26+
Description: OpenSSL cryptography library
27+
Libs: -L"${libdir}" -llibcrypto
28+
Libs.private: -lcrypt32 -lws2_32 -ladvapi32 -luser32
29+
Cflags: -I"${includedir}"
30+
]])
31+
32+
vcpkg_fixup_pkgconfig()

Diff for: 3rdParty/vcpkg_ports/ports/openssl/openssl.pc.in

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
prefix=${pcfiledir}/../..
2+
exec_prefix=${prefix}
3+
libdir=${exec_prefix}/lib
4+
includedir=${prefix}/include
5+
Version: @VERSION@
6+
@pc_data@

Diff for: 3rdParty/vcpkg_ports/ports/openssl/portfile.cmake

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
if(EXISTS "${CURRENT_INSTALLED_DIR}/share/libressl/copyright"
2+
OR EXISTS "${CURRENT_INSTALLED_DIR}/share/boringssl/copyright")
3+
message(FATAL_ERROR "Can't build openssl if libressl/boringssl is installed. Please remove libressl/boringssl, and try install openssl again if you need it.")
4+
endif()
5+
6+
if(VCPKG_TARGET_IS_EMSCRIPTEN)
7+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
8+
endif()
9+
10+
if (NOT "${VERSION}" MATCHES [[^([0-9]+)\.([0-9]+)\.([0-9]+)$]])
11+
message(FATAL_ERROR "Version regex did not match.")
12+
endif()
13+
set(OPENSSL_VERSION_MAJOR "${CMAKE_MATCH_1}")
14+
set(OPENSSL_VERSION_MINOR "${CMAKE_MATCH_2}")
15+
set(OPENSSL_VERSION_FIX "${CMAKE_MATCH_3}")
16+
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)
17+
18+
vcpkg_from_github(
19+
OUT_SOURCE_PATH SOURCE_PATH
20+
REPO openssl/openssl
21+
REF "openssl-${VERSION}"
22+
SHA512 aaf4f13b7b8020be37837f8084ab7aa3db64e6eb1ecabf04473ed5bd09bcabb8790f0dc1f7604febbbf974702b1fbe41795a7b575e7f88b07cbe094493926a6b
23+
PATCHES
24+
asm-comments.patch
25+
declspec-align.patch
26+
qt-msvc.patch
27+
script-prefix.patch
28+
windows/install-layout.patch
29+
windows/install-pdbs.patch
30+
unix/android-cc.patch
31+
unix/move-openssldir.patch
32+
unix/no-empty-dirs.patch
33+
unix/no-static-libs-for-shared.patch
34+
unix/disable-quicserver.patch
35+
)
36+
37+
vcpkg_list(SET CONFIGURE_OPTIONS
38+
enable-static-engine
39+
enable-capieng
40+
no-tests
41+
no-docs
42+
)
43+
44+
set(INSTALL_FIPS "")
45+
if("fips" IN_LIST FEATURES)
46+
vcpkg_list(APPEND INSTALL_FIPS install_fips)
47+
vcpkg_list(APPEND CONFIGURE_OPTIONS enable-fips)
48+
endif()
49+
50+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
51+
vcpkg_list(APPEND CONFIGURE_OPTIONS shared)
52+
else()
53+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-shared no-module)
54+
endif()
55+
56+
if(NOT "tools" IN_LIST FEATURES)
57+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-apps)
58+
endif()
59+
60+
if("weak-ssl-ciphers" IN_LIST FEATURES)
61+
vcpkg_list(APPEND CONFIGURE_OPTIONS enable-weak-ssl-ciphers)
62+
endif()
63+
64+
if("ssl3" IN_LIST FEATURES)
65+
vcpkg_list(APPEND CONFIGURE_OPTIONS enable-ssl3)
66+
vcpkg_list(APPEND CONFIGURE_OPTIONS enable-ssl3-method)
67+
endif()
68+
69+
if(DEFINED OPENSSL_USE_NOPINSHARED)
70+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-pinshared)
71+
endif()
72+
73+
if(OPENSSL_NO_AUTOLOAD_CONFIG)
74+
vcpkg_list(APPEND CONFIGURE_OPTIONS no-autoload-config)
75+
endif()
76+
77+
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
78+
include("${CMAKE_CURRENT_LIST_DIR}/windows/portfile.cmake")
79+
include("${CMAKE_CURRENT_LIST_DIR}/install-pc-files.cmake")
80+
else()
81+
include("${CMAKE_CURRENT_LIST_DIR}/unix/portfile.cmake")
82+
endif()
83+
84+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
85+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")

Diff for: 3rdParty/vcpkg_ports/ports/openssl/qt-msvc.patch

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/include/openssl/e_ostime.h b/include/openssl/e_ostime.h
2+
index 8a7cc9880fa79..0e17487504992 100644
3+
--- a/include/openssl/e_ostime.h
4+
+++ b/include/openssl/e_ostime.h
5+
@@ -22,7 +22,15 @@
6+
*/
7+
8+
# if defined(OPENSSL_SYS_WINDOWS)
9+
-# include <winsock2.h>
10+
+# if !defined(_WINSOCKAPI_)
11+
+ /*
12+
+ * winsock2.h defines _WINSOCK2API_ and both winsock2.h and winsock.h define
13+
+ * _WINSOCKAPI_. Both of these provide struct timeval. Don't include
14+
+ * winsock2.h if either header has been included to avoid breakage with
15+
+ * applications that prefer to use <winsock.h> over <winsock2.h>.
16+
+ */
17+
+# include <winsock2.h>
18+
+# endif
19+
# else
20+
# include <sys/time.h>
21+
# endif
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/tools/c_rehash.in b/tools/c_rehash.in
2+
index 343cdc1..e48038e 100644
3+
--- a/tools/c_rehash.in
4+
+++ b/tools/c_rehash.in
5+
@@ -12,7 +12,7 @@
6+
# and add symbolic links to their hash values.
7+
8+
my $dir = {- quotify1($config{openssldir}) -};
9+
-my $prefix = {- quotify1($config{prefix}) -};
10+
+use FindBin;
11+
12+
my $errorcount = 0;
13+
my $openssl = $ENV{OPENSSL} || "openssl";
14+
@@ -61,7 +61,7 @@ if (defined(&Cwd::getcwd)) {
15+
16+
# DOS/Win32 or Unix delimiter? Prefix our installdir, then search.
17+
my $path_delim = ($pwd =~ /^[a-z]\:/i) ? ';' : ':';
18+
-$ENV{PATH} = "$prefix/bin" . ($ENV{PATH} ? $path_delim . $ENV{PATH} : "");
19+
+$ENV{PATH} = "$FindBin::Bin" . ($ENV{PATH} ? $path_delim . $ENV{PATH} : "");
20+
21+
if (! -x $openssl) {
22+
my $found = 0;
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf
2+
index 41ad922..d15e34c 100644
3+
--- a/Configurations/15-android.conf
4+
+++ b/Configurations/15-android.conf
5+
@@ -102,6 +102,7 @@
6+
my $cflags;
7+
my $cppflags;
8+
9+
+if (0) {
10+
# see if there is NDK clang on $PATH, "universal" or "standalone"
11+
if (which("clang") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) {
12+
my $host=$1;
13+
@@ -158,6 +159,7 @@
14+
$sysroot =~ s|^$ndk/||;
15+
$sysroot = " --sysroot=\$($ndk_var)/$sysroot";
16+
}
17+
+}
18+
$android_ndk = {
19+
cflags => $cflags . $sysroot,
20+
cppflags => $cppflags,

0 commit comments

Comments
 (0)