parent
1fce6fc0b4
commit
222ed229ef
@ -36,8 +36,9 @@ This base image is designed to create statically-linked C++ executables using:
|
||||
5. **cURL** (8.7.1) - HTTP client with OpenSSL support
|
||||
6. **MariaDB Connector/C** (3.4.5) - MySQL/MariaDB client
|
||||
7. **SQLite3** (3.45.0) - Embedded database
|
||||
8. **MySQL client** (8.0.36) - MySQL client library
|
||||
9. **Drogon** (latest from git) - C++ web framework
|
||||
8. **fmt** (10.2.1) - Modern formatting library
|
||||
9. **spdlog** (1.13.0) - Fast C++ logging library
|
||||
10. **Drogon** (latest from git) - C++ web framework
|
||||
|
||||
### Build Characteristics
|
||||
- All libraries installed in `/usr/local/` with specific prefixes
|
||||
|
@ -152,6 +152,30 @@ RUN wget https://www.sqlite.org/2024/sqlite-autoconf-3450000.tar.gz && \
|
||||
|
||||
# Skip MySQL build - use MariaDB Connector/C for MySQL support instead
|
||||
|
||||
# Build fmt library statically
|
||||
ARG FMT_VERSION=10.2.1
|
||||
WORKDIR /tmp
|
||||
RUN curl -LO https://github.com/fmtlib/fmt/archive/refs/tags/${FMT_VERSION}.tar.gz && \
|
||||
tar xzf ${FMT_VERSION}.tar.gz && \
|
||||
cd fmt-${FMT_VERSION} && \
|
||||
mkdir build && cd build && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=/usr/local && \
|
||||
make -j$(nproc) && \
|
||||
make install && \
|
||||
cd / && rm -rf /tmp/fmt-${FMT_VERSION} /tmp/${FMT_VERSION}.tar.gz
|
||||
|
||||
# Build spdlog library statically
|
||||
ARG SPDLOG_VERSION=1.13.0
|
||||
WORKDIR /tmp
|
||||
RUN curl -LO https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz && \
|
||||
tar xzf v${SPDLOG_VERSION}.tar.gz && \
|
||||
cd spdlog-${SPDLOG_VERSION} && \
|
||||
mkdir build && cd build && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DSPDLOG_FMT_EXTERNAL=ON && \
|
||||
make -j$(nproc) && \
|
||||
make install && \
|
||||
cd / && rm -rf /tmp/spdlog-${SPDLOG_VERSION} /tmp/v${SPDLOG_VERSION}.tar.gz
|
||||
|
||||
#ARG DROGON_VERSION=1.9.5
|
||||
WORKDIR /tmp
|
||||
RUN git clone --recurse-submodules https://github.com/drogonframework/drogon.git /tmp/drogon && \
|
||||
|
2
build.sh
2
build.sh
@ -17,5 +17,5 @@ docker build \
|
||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||
--build-arg PROJECT="${PROJECT}" \
|
||||
--output "${SCRIPT_DIR}/output" \
|
||||
"${SCRIPT_DIR}/${PROJECT}"
|
||||
"${SCRIPT_DIR}/tests/${PROJECT}"
|
||||
|
||||
|
30
test.sh
30
test.sh
@ -4,9 +4,33 @@ set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
echo "Testing"
|
||||
echo "Building and testing test_libs..."
|
||||
|
||||
[ -f "${SCRIPT_DIR}/output/ipdemo" ] || { echo "ipdemo binary not found"; exit 1; }
|
||||
# Build test_libs
|
||||
docker run --rm \
|
||||
-v "${SCRIPT_DIR}/tests:/tests" \
|
||||
-v "${SCRIPT_DIR}/output:/output" \
|
||||
-w /tests/test_libs \
|
||||
gitea.jde.nz/public/dropshell-build-base:latest \
|
||||
sh -c "mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make && cp test_libs /output/"
|
||||
|
||||
"${SCRIPT_DIR}/output/ipdemo" || echo "Success!"
|
||||
# Run test_libs
|
||||
if [ -f "${SCRIPT_DIR}/output/test_libs" ]; then
|
||||
echo "Running test_libs..."
|
||||
"${SCRIPT_DIR}/output/test_libs"
|
||||
echo "test_libs completed successfully!"
|
||||
else
|
||||
echo "test_libs binary not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Testing ipdemo..."
|
||||
|
||||
# Check if ipdemo exists
|
||||
if [ -f "${SCRIPT_DIR}/output/ipdemo" ]; then
|
||||
echo "Running ipdemo..."
|
||||
"${SCRIPT_DIR}/output/ipdemo" || echo "ipdemo test completed!"
|
||||
else
|
||||
echo "ipdemo binary not found - run ./build.sh first"
|
||||
fi
|
25
tests/test_libs/CMakeLists.txt
Normal file
25
tests/test_libs/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(test_libs)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Force static linking
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
|
||||
# Find packages
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(spdlog REQUIRED)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
add_executable(test_libs test_libs.cpp)
|
||||
|
||||
target_link_libraries(test_libs
|
||||
fmt::fmt
|
||||
spdlog::spdlog
|
||||
SQLite3::SQLite3
|
||||
Threads::Threads
|
||||
rt
|
||||
)
|
41
tests/test_libs/test_libs.cpp
Normal file
41
tests/test_libs/test_libs.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <fmt/format.h>
|
||||
#include <sqlite3.h>
|
||||
#include <ctime>
|
||||
|
||||
int main() {
|
||||
// Test fmt
|
||||
std::string formatted = fmt::format("Testing fmt: {} + {} = {}", 1, 2, 3);
|
||||
std::cout << formatted << std::endl;
|
||||
|
||||
// Test spdlog
|
||||
spdlog::info("Testing spdlog: Hello from spdlog!");
|
||||
spdlog::warn("This is a warning message");
|
||||
|
||||
// Test sqlite3
|
||||
sqlite3* db;
|
||||
int rc = sqlite3_open(":memory:", &db);
|
||||
if (rc == SQLITE_OK) {
|
||||
spdlog::info("SQLite3 opened successfully, version: {}", sqlite3_libversion());
|
||||
sqlite3_close(db);
|
||||
} else {
|
||||
spdlog::error("Failed to open SQLite3");
|
||||
}
|
||||
|
||||
// Test pthread
|
||||
std::thread t([]() {
|
||||
spdlog::info("Hello from thread!");
|
||||
});
|
||||
t.join();
|
||||
|
||||
// Test rt (real-time) - using clock_gettime
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_REALTIME, &ts) == 0) {
|
||||
spdlog::info("Real-time clock: {}.{} seconds", ts.tv_sec, ts.tv_nsec);
|
||||
}
|
||||
|
||||
spdlog::info("All libraries linked successfully!");
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user