4coder/build_new/config/build-config.sh

225 lines
6.6 KiB
Bash

#!/bin/bash
# build-config.sh - Essential build configuration extracted from 4ed_build.cpp
# This file contains all the platform-specific compiler flags, linker flags, and build settings
# =============================================================================
# Directory Configuration
# =============================================================================
# Get the directory containing this script
CONFIG_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$CONFIG_SCRIPT_DIR/../.." && pwd)"
# Build directories (absolute paths)
BUILD_DIR="$PROJECT_ROOT/build"
BUILD_TEMP_DIR="$PROJECT_ROOT/build_new/temp"
PACK_DIR="$PROJECT_ROOT/distributions"
SITE_DIR="$PROJECT_ROOT/site"
# Source directories (absolute paths)
CODE_DIR="$PROJECT_ROOT/code"
GENERATED_DIR="$PROJECT_ROOT/code/generated"
CUSTOM_DIR="$PROJECT_ROOT/code/custom"
CUSTOM_GENERATED_DIR="$PROJECT_ROOT/code/custom/generated"
FOREIGN_DIR="$PROJECT_ROOT/non-source/foreign"
SCRIPTS_DIR="$PROJECT_ROOT/build_new/scripts"
HELPERS_DIR="$PROJECT_ROOT/build_new/helpers"
# Include directories
INCLUDES=(
"$CUSTOM_DIR"
"$FOREIGN_DIR/freetype2"
)
# =============================================================================
# Platform Detection
# =============================================================================
# Platform codes
PLATFORM_WINDOWS=0
PLATFORM_LINUX=1
PLATFORM_MAC=2
# Architecture codes
ARCH_X64=0
ARCH_X86=1
# =============================================================================
# Build Flags
# =============================================================================
# Build flag bits (matching 4ed_build.cpp)
FLAG_OPTS=$((0x1)) # Compiler warnings/options
FLAG_LIBS=$((0x2)) # Link libraries
FLAG_ICON=$((0x4)) # Windows icon resource
FLAG_SHARED_CODE=$((0x8)) # Build as shared library
FLAG_DEBUG_INFO=$((0x10)) # Debug symbols
FLAG_OPTIMIZATION=$((0x20)) # Optimization level
FLAG_SUPER=$((0x40)) # Super tier features
FLAG_INTERNAL=$((0x80)) # Internal build flags
FLAG_SHIP=$((0x100)) # Shipping build
# =============================================================================
# Compiler Options - Windows (CL equivalent using clang)
# =============================================================================
# Windows compiler options (translated from CL to clang)
CLANG_OPTS_WINDOWS=(
"-Wall" # Enable most warnings
"-Wno-unused-parameter" # Disable unused parameter warnings
"-Wno-unused-variable" # Disable unused variable warnings
"-Wno-missing-field-initializers" # Disable missing field initializer warnings
"-Wno-deprecated-declarations" # Disable deprecated declarations warnings
"-Wno-missing-braces" # Disable missing braces warnings
"-Wno-tautological-compare" # Disable tautological compare warnings
"-Wno-write-strings" # Disable write strings warnings
"-Werror" # Treat warnings as errors
"-fno-rtti" # Disable RTTI (equivalent to /GR-)
"-fno-exceptions" # Disable exceptions (equivalent to /EHa-)
"-std=c++11" # C++11 standard
"-target x86_64-pc-windows-msvc" # Target Windows with MSVC ABI
)
# Windows libraries
LIBS_WINDOWS=(
"-luser32"
"-lwinmm"
"-lgdi32"
"-lopengl32"
"-lcomdlg32"
"-luserenv"
)
# Windows FreeType libraries
FREETYPE_LIB_WINDOWS_X64="$FOREIGN_DIR/x64/freetype.lib"
FREETYPE_LIB_WINDOWS_X86="$FOREIGN_DIR/x86/freetype.lib"
# Windows icon resource
WINDOWS_ICON="$PROJECT_ROOT/non-source/res/icon.res"
# =============================================================================
# Compiler Options - Linux (GCC equivalent using clang)
# =============================================================================
CLANG_OPTS_LINUX=(
"-Wno-write-strings"
"-D_GNU_SOURCE"
"-fPIC"
"-fno-threadsafe-statics"
"-pthread"
"-Wno-unused-result"
"-std=c++11"
"-target x86_64-linux-gnu" # Target Linux
)
# Linux libraries
LIBS_LINUX=(
"-lX11"
"-lpthread"
"-lm"
"-lrt"
"-lGL"
"-ldl"
"-lXfixes"
"-lfreetype"
"-lfontconfig"
)
# Linux platform includes
PLATFORM_INCLUDES_LINUX=(
"platform_all"
"platform_unix"
)
# =============================================================================
# Compiler Options - macOS (Clang native)
# =============================================================================
CLANG_OPTS_MACOS=(
"-Wno-write-strings"
"-Wno-deprecated-declarations"
"-Wno-comment"
"-Wno-switch"
"-Wno-null-dereference"
"-Wno-tautological-compare"
"-Wno-unused-result"
"-Wno-missing-declarations"
"-Wno-nullability-completeness"
"-std=c++11"
# Target will be set based on architecture
)
# macOS frameworks (equivalent to libraries)
FRAMEWORKS_MACOS=(
"-lc++"
"-lobjc"
-framework Cocoa
-framework QuartzCore
-framework CoreServices
-framework OpenGL
-framework IOKit
-framework Metal
-framework MetalKit
)
# macOS FreeType libraries
FREETYPE_LIB_MACOS_X64="$FOREIGN_DIR/x64/libfreetype-mac.a"
FREETYPE_LIB_MACOS_X86="$FOREIGN_DIR/x86/libfreetype-mac.a"
# macOS platform includes
PLATFORM_INCLUDES_MACOS=(
"platform_all"
"platform_unix"
)
# =============================================================================
# Architecture-specific flags
# =============================================================================
# 64-bit architecture
ARCH_FLAGS_X64=(
"-m64"
"-DFTECH_64_BIT"
)
# 32-bit architecture
ARCH_FLAGS_X86=(
"-m32"
"-DFTECH_32_BIT"
)
# =============================================================================
# Build Mode Flags
# =============================================================================
# Debug flags
DEBUG_FLAGS=(
"-g" # Debug symbols
"-O0" # No optimization
"-DDO_CRAZY_EXPENSIVE_ASSERTS" # Enable expensive assertions
)
# Release flags
RELEASE_FLAGS=(
"-O2" # Optimization level 2 (clang equivalent to -O3 for performance)
)
# =============================================================================
# Build Outputs
# =============================================================================
# Main executable names
EXECUTABLE_WINDOWS="4ed.exe"
EXECUTABLE_LINUX="4ed"
EXECUTABLE_MACOS="4ed"
# Shared library names
SHARED_LIB_WINDOWS="4ed_app.dll"
SHARED_LIB_LINUX="4ed_app.so"
SHARED_LIB_MACOS="4ed_app.so"
# Custom layer library names
CUSTOM_LIB_WINDOWS="custom_4coder.dll"
CUSTOM_LIB_LINUX="custom_4coder.so"
CUSTOM_LIB_MACOS="custom_4coder.so"