Skip to content

Commit c912b80

Browse files
authored
Merge branch 'main' into user/jasonsa/lhc-and-bug-pr
2 parents 8212d40 + 0341897 commit c912b80

9 files changed

Lines changed: 257 additions & 148 deletions

File tree

Build/libHttpClient.Linux/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PATH_TO_ROOT}/Out/x64/Release/libHt
2323
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PATH_TO_ROOT}/Out/x64/Debug/libHttpClient.Linux)
2424
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PATH_TO_ROOT}/Out/x64/Release/libHttpClient.Linux)
2525

26-
# BINARY_DIR is a temp folder used by cmake itself.
27-
# Binary folder can be remove freely.
28-
# See more details: https://cmake.org/cmake/help/v3.4/command/add_subdirectory.html
29-
set(BINARY_DIR ${PATH_TO_ROOT}/Int/CMake/libHttpClient.Linux)
30-
3126
set(LIBCRYPTO_BINARY_PATH
3227
${PATH_TO_ROOT}/Out/x64/${CMAKE_BUILD_TYPE}/libcrypto.Linux/libcrypto.a
3328
)
@@ -168,6 +163,13 @@ target_include_directories(
168163
"${ZLIB_INCLUDE_DIRS}"
169164
)
170165

166+
# Turn on compiler warnings for all source files.
167+
# For zlib, which is external, mask some of the unimportant warnings. This keeps our build output clean without
168+
# adding friction to taking zlib updates. If new warnings show up in updates, they should be assessed for impact and
169+
# disabled if not considered problematic.
170+
target_compile_options("${PROJECT_NAME}" PRIVATE -Werror)
171+
set_source_files_properties(${ZLIB_SOURCE_FILES} PROPERTIES COMPILE_OPTIONS "-Wno-implicit-function-declaration")
172+
171173
include("../libHttpClient.CMake/GetLibHCFlags.cmake")
172174
get_libhc_flags(FLAGS FLAGS_DEBUG FLAGS_RELEASE)
173175

Build/libHttpClient.Linux/curl_Linux.bash

100644100755
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
46
CONFIGURATION="Release"
57

@@ -21,24 +23,35 @@ while [[ $# -gt 0 ]]; do
2123
esac
2224
done
2325

24-
pushd "$SCRIPT_DIR"/../../External/curl
25-
autoreconf -fi "$SCRIPT_DIR"/../../External/curl
26-
2726
if [ -f "$SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcurl.Linux/libcurl.a" ]; then
2827
echo "Previously-built library present at $SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcurl.Linux/libcurl.a - skipping build"
2928
exit 0
3029
else
3130
echo "No previously-built library present at $SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcurl.Linux/libcurl.a - performing build"
3231
fi
3332

33+
pushd "$SCRIPT_DIR"/../../External/curl
34+
autoreconf -fi "$SCRIPT_DIR"/../../External/curl
35+
36+
OPENSSL_INSTALL_DIR="$SCRIPT_DIR/../../Int/x64/$CONFIGURATION/openssl.Linux/"
37+
38+
CONFIGURE_ARGS=(
39+
--disable-shared
40+
--with-zlib
41+
--disable-dependency-tracking
42+
--with-openssl=$OPENSSL_INSTALL_DIR
43+
--enable-symbol-hiding
44+
--without-brotli
45+
)
3446
if [ "$CONFIGURATION" = "Debug" ]; then
35-
# make libcrypto and libssl
36-
./configure --disable-shared --with-zlib --disable-dependency-tracking -with-openssl=/usr/local/ssl --enable-symbol-hiding --enable-debug --without-brotli
47+
CONFIGURE_ARGS+=(--enable-debug)
3748
else
38-
# make libcrypto and libssl
39-
./configure --disable-shared --with-zlib --disable-dependency-tracking -with-openssl=/usr/local/ssl --enable-symbol-hiding --disable-debug --without-brotli
49+
CONFIGURE_ARGS+=(--disable-debug)
4050
fi
4151

52+
# make libcrypto and libssl
53+
./configure "${CONFIGURE_ARGS[@]}"
54+
4255
MAKE_PARALLELISM="-j$(nproc)" # run Make in parallel to speed up the build process
4356
make $MAKE_PARALLELISM
4457

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
POSITIONAL_ARGS=()
8+
DO_INSTALL=true
9+
while [[ $# -gt 0 ]]; do
10+
case $1 in
11+
--check)
12+
DO_INSTALL=false
13+
shift # past value
14+
;;
15+
-*|--*)
16+
echo "Unknown option $1"
17+
exit 1
18+
;;
19+
*)
20+
POSITIONAL_ARGS+=("$1") # save positional arg
21+
shift # past argument
22+
;;
23+
esac
24+
done
25+
26+
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
27+
28+
build_dependencies=(clang make autoconf automake libtool)
29+
library_dependencies=(zlib1g zlib1g-dev)
30+
31+
if [ "$DO_INSTALL" = false ]; then
32+
33+
dependencies_missing=false
34+
for dep in "${build_dependencies[@]}" "${library_dependencies[@]}"; do
35+
if ! dpkg -s "$dep" &> /dev/null; then
36+
echo "Missing dependency: $dep"
37+
dependencies_missing=true
38+
else
39+
echo "Dependency installed: $dep"
40+
fi
41+
done
42+
43+
if [ "$dependencies_missing" = true ]; then
44+
exit 1
45+
fi
46+
47+
echo "All dependencies are installed"
48+
exit 0
49+
fi
50+
51+
echo "Installing dependencies..."
52+
echo "Build dependencies: ${build_dependencies[*]}"
53+
echo "Library dependencies: ${library_dependencies[*]}"
54+
55+
sudo apt-get update
56+
sudo apt-get -y install "${build_dependencies[@]}" "${library_dependencies[@]}"

Build/libHttpClient.Linux/libHttpClient_Linux.bash

100644100755
Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
3+
set -e
4+
25
log () {
36
echo "***** $1 *****"
47
}
@@ -15,6 +18,8 @@ BUILD_STATIC=false
1518
BUILD_UNREAL_ENGINE_4=false
1619
C_COMPILER="clang"
1720
CXX_COMPILER="clang++"
21+
INSTALL_DEPENDENCIES=false
22+
REQUIRE_VERIFIED_DEPENDENCIES=true
1823

1924
while [[ $# -gt 0 ]]; do
2025
case $1 in
@@ -35,8 +40,16 @@ while [[ $# -gt 0 ]]; do
3540
BUILD_UNREAL_ENGINE_4=true
3641
shift
3742
;;
43+
--install-dependencies)
44+
INSTALL_DEPENDENCIES=true
45+
shift
46+
;;
3847
-sg|--skipaptget)
39-
DO_APTGET=false
48+
# NOOP. allow user to specify old --skipaptget args before that became the default
49+
shift
50+
;;
51+
-sd|--skip-dependency-check)
52+
REQUIRE_VERIFIED_DEPENDENCIES=false
4053
shift
4154
;;
4255
-st|--static)
@@ -56,22 +69,37 @@ done
5669

5770
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
5871

59-
if [ "$DO_APTGET" != "false" ]; then
60-
sudo hwclock --hctosys
61-
sudo apt-get update
62-
sudo apt-get install clang
63-
sudo apt-get install make
64-
sudo apt-get install autoconf
65-
sudo apt-get install automake
66-
sudo apt-get install libtool
67-
sudo apt-get install zlib1g zlib1g-dev
72+
set +e # temporarily disable exit-on-error to provide more graceful handling of dependency installation failures
73+
if [ "$INSTALL_DEPENDENCIES" = "true" ]; then
74+
bash "$SCRIPT_DIR"/install_dependencies.bash
75+
if [ $? -ne 0 ]; then
76+
echo ""
77+
echo "Failed to install dependencies."
78+
exit 1
79+
fi
80+
else
81+
bash "$SCRIPT_DIR"/install_dependencies.bash --check
82+
if [ $? -ne 0 ]; then
83+
if [ "$REQUIRE_VERIFIED_DEPENDENCIES" = true ]; then
84+
echo ""
85+
echo "Some dependencies are missing."
86+
echo "Please run with --install-dependencies to install them or run $SCRIPT_DIR/install_dependencies.bash directly"
87+
exit 1
88+
else
89+
echo ""
90+
echo "Some dependencies are missing."
91+
echo "--skip-dependency-check specified, ignoring and continuing."
92+
echo ""
93+
fi
94+
fi
6895
fi
96+
set -e # re-enable exit-on-error after dependency installation check
6997

7098
log "CONFIGURATION = ${CONFIGURATION}"
7199
log "BUILD SSL = ${BUILD_SSL}"
72100
log "BUILD CURL = ${BUILD_CURL}"
73101
log "CMakeLists.txt = ${SCRIPT_DIR}"
74-
log "CMake output = ${SCRIPT_DIR}/../../Int/CMake/libHttpClient.Linux"
102+
log "CMake output = ${SCRIPT_DIR}/../../Int/x64/$CONFIGURATION/libHttpClient.Linux"
75103

76104
if [ "$BUILD_UNREAL_ENGINE_4" = true ]; then
77105
log "Unreal Compatibility Enabled"
@@ -97,10 +125,10 @@ fi
97125
MAKE_PARALLELISM="-j$(nproc)" # run Make in parallel to speed up the build process
98126
if [ "$BUILD_STATIC" = false ]; then
99127
# make libHttpClient shared
100-
sudo cmake -S "$SCRIPT_DIR" -B "$SCRIPT_DIR"/../../Int/CMake/libHttpClient.Linux -D CMAKE_BUILD_TYPE=$CONFIGURATION -D CMAKE_C_COMPILER=$C_COMPILER -D CMAKE_CXX_COMPILER=$CXX_COMPILER -D BUILD_SHARED_LIBS=ON
101-
sudo make $MAKE_PARALLELISM -C "$SCRIPT_DIR"/../../Int/CMake/libHttpClient.Linux
128+
cmake -S "$SCRIPT_DIR" -B "$SCRIPT_DIR"/../../Int/x64/$CONFIGURATION/libHttpClient.Linux -D CMAKE_BUILD_TYPE=$CONFIGURATION -D CMAKE_C_COMPILER=$C_COMPILER -D CMAKE_CXX_COMPILER=$CXX_COMPILER -D BUILD_SHARED_LIBS=ON
129+
make $MAKE_PARALLELISM -C "$SCRIPT_DIR"/../../Int/x64/$CONFIGURATION/libHttpClient.Linux
102130
else
103131
# make libHttpClient static
104-
sudo cmake -S "$SCRIPT_DIR" -B "$SCRIPT_DIR"/../../Int/CMake/libHttpClient.Linux -D CMAKE_BUILD_TYPE=$CONFIGURATION -D CMAKE_C_COMPILER=$C_COMPILER -D CMAKE_CXX_COMPILER=$CXX_COMPILER -D BUILD_SHARED_LIBS=OFF
105-
sudo make $MAKE_PARALLELISM -C "$SCRIPT_DIR"/../../Int/CMake/libHttpClient.Linux
132+
cmake -S "$SCRIPT_DIR" -B "$SCRIPT_DIR"/../../Int/x64/$CONFIGURATION/libHttpClient.Linux -D CMAKE_BUILD_TYPE=$CONFIGURATION -D CMAKE_C_COMPILER=$C_COMPILER -D CMAKE_CXX_COMPILER=$CXX_COMPILER -D BUILD_SHARED_LIBS=OFF
133+
make $MAKE_PARALLELISM -C "$SCRIPT_DIR"/../../Int/x64/$CONFIGURATION/libHttpClient.Linux
106134
fi

Build/libHttpClient.Linux/openssl_Linux.bash

100644100755
Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
46
OPENSSL_SRC="$SCRIPT_DIR/../../External/openssl"
57
CONFIGURATION="Release"
@@ -22,48 +24,59 @@ while [[ $# -gt 0 ]]; do
2224
esac
2325
done
2426

25-
sudo hwclock --hctosys
26-
sudo rm -rf /usr/local/ssl
27-
sudo mkdir /usr/local/ssl
28-
sudo mkdir /usr/local/ssl/lib
29-
sudo mkdir /usr/local/ssl/include
30-
sudo mkdir /usr/local/ssl/include/openssl
27+
if [ -f "$SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcrypto.Linux/libcrypto.a" ]; then
28+
echo "Previously-built library present at $SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcrypto.Linux/libcrypto.a - skipping build"
29+
exit 0
30+
else
31+
echo "No previously-built library present at $SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcrypto.Linux/libcrypto.a - performing build"
32+
fi
33+
34+
OPENSSL_INSTALL_DIR="$SCRIPT_DIR/../../Int/x64/$CONFIGURATION/openssl.Linux/"
3135

32-
if [ ! -d /usr/local/ssl ] ; then
33-
echo "Directory /usr/local/ssl does not exist"
36+
rm -rf "$OPENSSL_INSTALL_DIR"
37+
mkdir -p "$OPENSSL_INSTALL_DIR"
38+
mkdir -p "$OPENSSL_INSTALL_DIR/lib"
39+
mkdir -p "$OPENSSL_INSTALL_DIR/include"
40+
mkdir -p "$OPENSSL_INSTALL_DIR/include/openssl"
41+
42+
if [ ! -d "$OPENSSL_INSTALL_DIR" ] ; then
43+
echo "Directory $OPENSSL_INSTALL_DIR does not exist"
3444
exit 1
3545
fi
36-
if [ ! -d /usr/local/ssl/lib ] ; then
37-
echo "Directory /usr/local/ssl/lib does not exist"
46+
if [ ! -d "$OPENSSL_INSTALL_DIR/lib" ] ; then
47+
echo "Directory $OPENSSL_INSTALL_DIR/lib does not exist"
3848
exit 1
3949
fi
40-
if [ ! -d /usr/local/ssl/include/openssl ] ; then
41-
echo "Directory /usr/local/ssl/include/openssl does not exist"
50+
if [ ! -d "$OPENSSL_INSTALL_DIR/include/openssl" ] ; then
51+
echo "Directory $OPENSSL_INSTALL_DIR/include/openssl does not exist"
4252
exit 1
4353
fi
4454

45-
if [ -f "$SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcrypto.Linux/libcrypto.a" ]; then
46-
echo "Previously-built library present at $SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcrypto.Linux/libcrypto.a - skipping build"
47-
exit 0
48-
else
49-
echo "No previously-built library present at $SCRIPT_DIR/../../Out/x64/$CONFIGURATION/libcrypto.Linux/libcrypto.a - performing build"
50-
fi
51-
5255
pushd $OPENSSL_SRC
53-
make clean
56+
if [ -f Makefile ]; then
57+
echo "Cleaning previous OpenSSL build"
58+
make clean
59+
fi
5460
sed -i -e 's/\r$//' Configure
5561

62+
CONFIGURE_ARGS=(
63+
--prefix=$OPENSSL_INSTALL_DIR
64+
--openssldir=$OPENSSL_INSTALL_DIR
65+
linux-x86_64-clang
66+
no-shared
67+
no-hw
68+
no-tests
69+
)
5670
if [ "$CONFIGURATION" = "Debug" ]; then
57-
# make libcrypto and libssl
58-
./Configure --prefix=/usr/local/ssl --openssldir=/usr/local/ssl linux-x86_64-clang no-shared no-hw no-tests -d
59-
else
60-
# make libcrypto and libssl
61-
./Configure --prefix=/usr/local/ssl --openssldir=/usr/local/ssl linux-x86_64-clang no-shared no-hw no-tests
71+
CONFIGURE_ARGS+=(-d)
6272
fi
6373

74+
# make libcrypto and libssl
75+
./Configure "${CONFIGURE_ARGS[@]}"
76+
6477
MAKE_PARALLELISM="-j$(nproc)" # run Make in parallel to speed up the build process
6578
make $MAKE_PARALLELISM CFLAGS="-fvisibility=hidden" CXXFLAGS="-fvisibility=hidden"
66-
sudo make install
79+
make install
6780
# copies binaries to final directory
6881
mkdir -p "$SCRIPT_DIR"/../../Out/x64/"$CONFIGURATION"/libcrypto.Linux
6982
cp -R "$PWD"/libcrypto.a "$SCRIPT_DIR"/../../Out/x64/"$CONFIGURATION"/libcrypto.Linux

0 commit comments

Comments
 (0)