dropshell-build/build.sh
Your Name f26383b66d
Some checks failed
dropshell-build / build (push) Failing after 1m5s
'Generic Commit'
2025-06-03 01:10:16 +12:00

41 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
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="Debug"
rm -rf "${SCRIPT_DIR}/output"
mkdir -p "${SCRIPT_DIR}/output"
docker build \
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
--build-arg PROJECT="${PROJECT}" \
--output "${SCRIPT_DIR}/output" \
"${SCRIPT_DIR}/${PROJECT}"