1
0
Files
wavefront-parser/build.sh

54 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
# Determine absolute project root (scripts parent directory)
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Helper to configure & build
# $1 = build directory name under PROJECT_ROOT/build
# $2 = CMake build type (arbitrary string; flags are driven by -DCMAKE_CXX_FLAGS)
# $3 = CXX flags
cmake_build() {
local name=$1
local type=$2
local flags=$3
local build_dir="${PROJECT_ROOT}/build/${name}"
echo "=== Configuring ${name} (${flags}) ==="
rm -rf "${build_dir}"
mkdir -p "${build_dir}"
pushd "${build_dir}" >/dev/null
cmake \
-DCMAKE_BUILD_TYPE="${type}" \
-DCMAKE_CXX_FLAGS="${flags}" \
"${PROJECT_ROOT}"
make -j$(nproc)
popd >/dev/null
}
# 1) Debug: -g
cmake_build "Debug" "Debug" "-g"
# 2) Release: -O3
cmake_build "Release" "Release" "-O3"
# 3) RelWithDebugInfo: -g -O3
cmake_build "RelWithDebugInfo" "RelWithDebInfo" "-g -O3"
# 4) Generate verbose assembly (.S) for all translation units in RelWithDebugInfo
echo "=== Generating .S assembly in build/RelWithDebugInfo ==="
ASM_OUT_DIR="${PROJECT_ROOT}/build/RelWithDebugInfo/asm"
mkdir -p "${ASM_OUT_DIR}"
# adjust the sourcefile patterns as needed (e.g. .cc, .cxx)
find "${PROJECT_ROOT}" -type f \( -name '*.cpp' -o -name '*.cc' \) | while read -r src; do
fname="$(basename "${src}")"
base="${fname%.*}"
g++ -g -O3 -masm=intel -fno-verbose-asm -std=c++20 -S "${src}" \
-o "${ASM_OUT_DIR}/${base}.S"
done
echo "All builds complete."