This commit is contained in:
j842 2025-05-26 14:06:23 +12:00
parent 16e93ef078
commit caf8c36a0e
49 changed files with 1642 additions and 11 deletions

View File

@ -21,7 +21,13 @@ RUN apk add --no-cache \
openssl-dev \ openssl-dev \
zlib-static \ zlib-static \
zlib-dev \ zlib-dev \
bash linux-headers \
bash \
ccache \
mold
# Configure mold as the default linker
ENV LD=mold
######################################## ########################################
# nlohmann/json (compiled static .a) # # nlohmann/json (compiled static .a) #
@ -38,8 +44,7 @@ RUN git clone --depth 1 --branch v${JSON_VERSION} https://github.com/nlohmann/js
############################# #############################
# cpphttplib (headeronly) # # cpphttplib (headeronly) #
############################# #############################
ARG HTTPLIB_VERSION=v0.15.4 RUN wget -q https://raw.githubusercontent.com/yhirose/cpp-httplib/master/httplib.h \
RUN wget -q https://raw.githubusercontent.com/yhirose/cpp-httplib/${HTTPLIB_VERSION}/httplib.h \
-O /usr/local/include/httplib.h -O /usr/local/include/httplib.h
################################## ##################################
@ -83,7 +88,16 @@ RUN apk add --no-cache \
ninja \ ninja \
git \ git \
openssl-dev \ openssl-dev \
zlib-static zlib-static \
bash \
wget \
curl \
linux-headers \
ccache \
mold
# Configure mold as the default linker
ENV LD=mold
# Copy prebuilt static libs + headers # Copy prebuilt static libs + headers
COPY --from=builder /usr/local /usr/local COPY --from=builder /usr/local /usr/local
@ -94,4 +108,4 @@ ENV CFLAGS="-static -O2" \
WORKDIR /workspace WORKDIR /workspace
ENTRYPOINT ["/bin/sh"] ENTRYPOINT ["/bin/bash"]

0
build.sh Normal file → Executable file
View File

View File

@ -15,6 +15,6 @@ if [ ! -f /usr/local/lib/libassert.a ]; then
fi fi
if [ ! -f /usr/local/include/httplib.h ]; then if [ ! -f /usr/local/include/httplib.h ]; then
wget https://raw.githubusercontent.com/yhirose/cpp-httplib/refs/heads/master/httplib.h sudo wget -q https://raw.githubusercontent.com/yhirose/cpp-httplib/master/httplib.h \
sudo mv httplib.h /usr/local/include/httplib.h -O /usr/local/include/httplib.h
fi fi

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

82
test/.ccache/0/a/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
3
0
6
0
0
0
0
0
0
6
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Binary file not shown.

82
test/.ccache/0/c/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

82
test/.ccache/0/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
1
16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
16
0
0
0
0

82
test/.ccache/1/1/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

82
test/.ccache/1/2/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

82
test/.ccache/1/e/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
2
0
0
0
0
0
0
2
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

82
test/.ccache/2/5/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

82
test/.ccache/2/d/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
2
0
0
0
0
0
0
2
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Binary file not shown.

82
test/.ccache/2/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
1
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
0
0

82
test/.ccache/3/4/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

82
test/.ccache/3/7/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
2
0
0
0
0
0
0
2
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

82
test/.ccache/3/e/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Binary file not shown.

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

Binary file not shown.

82
test/.ccache/4/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
2
472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
236
0
0
0
0
0
0
0
0
0
0
236
0
0
0
0
0

Binary file not shown.

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

Binary file not shown.

82
test/.ccache/6/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
2
8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
4
0
0
0
0
0
0
0
0
0
0
4
0
0
0
0

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

Binary file not shown.

82
test/.ccache/9/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
1
16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
16
0
0
0
0
0
0

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

82
test/.ccache/a/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
2
20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
4
0
0
0
0
0
0
16
0
0
0
0
0
0
0

Binary file not shown.

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

82
test/.ccache/b/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
1
236
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
236
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Binary file not shown.

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

82
test/.ccache/c/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
1
16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Binary file not shown.

View File

@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by ccache.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/

82
test/.ccache/f/stats Normal file
View File

@ -0,0 +1,82 @@
0
0
0
0
0
0
0
0
0
0
0
1
236
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
236
0
0
0
0
0
0
0
0
0
0
0
0

View File

Binary file not shown.

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(cppstaticbuild) project(cppstaticbuild)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Static build settings # Static build settings
@ -11,4 +11,4 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
include_directories(/usr/local/include) include_directories(/usr/local/include)
add_executable(main main.cpp) add_executable(main main.cpp)
target_link_libraries(main pthread) target_link_libraries(main pthread assert cpptrace dwarf z zstd)

16
test/build.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
rm -f build/main
docker run --rm -v $(pwd):/app -w /app \
-e CCACHE_DIR=/app/.ccache \
-e CC="ccache gcc" \
-e CXX="ccache g++" \
-e LD=mold \
-e CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) \
-e NINJA_STATUS="[%f/%t] " \
cpp-httplib-builder:latest \
-c "mkdir -p build && cd build && cmake -G Ninja .. && ninja -j$(nproc)"
if [ -f build/main ]; then
build/main
fi

View File

@ -5,7 +5,9 @@
#include <libassert/assert.hpp> #include <libassert/assert.hpp>
int main() { int main() {
httplib::Client cli("https://ipinfo.io"); std::cout << "Retrieving IP address..." << std::endl;
httplib::Client cli("http://ipinfo.io");
auto res = cli.Get("/ip"); auto res = cli.Get("/ip");
ASSERT(res->status == 200, "Failed to get IP"); ASSERT(res->status == 200, "Failed to get IP");
@ -16,5 +18,7 @@ int main() {
std::cout << j.dump(4) << std::endl; std::cout << j.dump(4) << std::endl;
std::cout << "Done" << std::endl;
return 0; return 0;
} }

3
test/shell.sh Executable file
View File

@ -0,0 +1,3 @@
#docker run --entrypoint "/bin/sh" -it --rm cpp-httplib-builder:latest -c "/bin/sh"
docker run -it --rm cpp-httplib-builder:latest -c "/bin/bash"