diff --git a/Dockerfile.dropshell-build b/Dockerfile.dropshell-build index c576ad0..3d85a0c 100644 --- a/Dockerfile.dropshell-build +++ b/Dockerfile.dropshell-build @@ -16,13 +16,16 @@ RUN apk add --no-cache \ linux-headers \ mold \ zlib-static \ - ccache + ccache \ + libunwind-dev \ + libdwarf-dev # Set working directory WORKDIR /build -# Copy source files -COPY . . +COPY CMakeLists.txt cmake_prebuild.sh ./ +#COPY cmake ./cmake +COPY src/version.hpp.in ./src/version.hpp.in # Configure and build with ccache RUN mkdir -p build_static && \ @@ -37,6 +40,13 @@ RUN mkdir -p build_static && \ -DPROJECT_NAME="${PROJECT}" \ ${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE} + +# Explicitly build dependencies first (cached separately) +RUN cmake --build build_static --target run_prebuild_script + +# Copy source files +COPY src ./build_static/src + RUN cmake --build build_static # Final stage that only contains the binary diff --git a/build.sh b/build.sh index e72c0a1..9a08616 100755 --- a/build.sh +++ b/build.sh @@ -5,9 +5,28 @@ set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" PROJECT="ipdemo" # Define your project name here +function update_sources() { + CMAKE_FILE="${SCRIPT_DIR}/${PROJECT}/CMakeLists.txt" + + # Generate the list of source files with relative paths + SOURCE_FILES=$(cd "${SCRIPT_DIR}/${PROJECT}" && find "src" -name '*.cpp' | sort | sed 's/^/ /') + + # Use awk to replace the SOURCES block in CMakeLists.txt + awk -v sources="$SOURCE_FILES" ' + BEGIN {in_sources=0} + /^set\(SOURCES/ {print; print sources; in_sources=1; next} + in_sources && /^\)/ {in_sources=0; print; next} + !in_sources {print} + ' "$CMAKE_FILE" > "${CMAKE_FILE}.tmp" && mv "${CMAKE_FILE}.tmp" "$CMAKE_FILE" + + echo "Updated SOURCES in ${CMAKE_FILE}" +} + +update_sources + mkdir -p "${SCRIPT_DIR}/output" -export CMAKE_BUILD_TYPE="Release" +export CMAKE_BUILD_TYPE="Debug" rm -rf "${SCRIPT_DIR}/output" mkdir -p "${SCRIPT_DIR}/output" diff --git a/ipdemo/CMakeLists.txt b/ipdemo/CMakeLists.txt index 93b3891..00210c2 100644 --- a/ipdemo/CMakeLists.txt +++ b/ipdemo/CMakeLists.txt @@ -45,11 +45,6 @@ configure_file( # Set CMAKE_MODULE_PATH to include our custom find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -# Auto-detect source files -file(GLOB_RECURSE SOURCES "src/*.cpp") -file(GLOB_RECURSE HEADERS "src/*.hpp") -file(GLOB_RECURSE HEADERS "src/*.h") - # Add custom target to run cmake_prebuild.sh at the start of the build process add_custom_target(run_prebuild_script ALL COMMAND ${CMAKE_COMMAND} -E echo "Running cmake_prebuild.sh..." @@ -57,6 +52,13 @@ add_custom_target(run_prebuild_script ALL WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +set(SOURCES + src/main.cpp +) + +# Mark sources as GENERATED to defer existence check until build time +set_source_files_properties(${SOURCES} PROPERTIES GENERATED TRUE) + # Add executable add_executable(${PROJECT_EXE_NAME} ${SOURCES}) add_dependencies(${PROJECT_EXE_NAME} run_prebuild_script) diff --git a/ipdemo/src/main.cpp b/ipdemo/src/main.cpp index ca79d63..c4d2a40 100644 --- a/ipdemo/src/main.cpp +++ b/ipdemo/src/main.cpp @@ -6,6 +6,10 @@ #include "httplib.hpp" #include "version.hpp" +void crashy() { + ASSERT(false,"SUCCESS!"); +} + int main() { std::cout << "ipdemo version: " << ipdemo::VERSION << std::endl; std::cout << std::endl; @@ -23,6 +27,8 @@ int main() { std::cout << j.dump(4) << std::endl; std::cout << "Done" << std::endl; - + + crashy(); + return 0; }