Fix bug in mt_mpmc.c, in Linux mutexes are not recursive. Add arena_trim_string() to the arena API Removing arena->path, now paths are pushed to arena->metadata Replacing fe->owner[128] with char *owner; the owner is not pushed as a string to arena->metadata and trimed with arena_trim_string() Improving cache locality in arena->metadata, the memory layout is not fe; fe->path; fe->owner. Cache aligning all arenas except HasherContext->arena to sizeof(void *). Pushing elements one by one instead of snprintf() in finalize_file() and hash_worker(). Getting the full path of current directory instead of "." Fixing bug in path formating, this allow us to remove normalize_path() from the hot loop.
173 lines
4.6 KiB
Batchfile
173 lines
4.6 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
set PROJECT_NAME=dfin
|
|
|
|
:: ============================================================================
|
|
:: build.bat
|
|
:: ============================================================================
|
|
|
|
:: Get script directory (project root)
|
|
set SCRIPT_DIR=%~dp0
|
|
set SCRIPT_DIR=%SCRIPT_DIR:~0,-1%
|
|
|
|
:: ---------------------------------------------------------------------------
|
|
:: Default values
|
|
:: ---------------------------------------------------------------------------
|
|
|
|
set BUILD_TYPE=Release
|
|
set CLEAN_BUILD=0
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Parse arguments
|
|
:: --------------------------------------------------------------------------
|
|
:parse_args
|
|
if "%~1"=="" goto :main
|
|
|
|
if /i "%~1"=="Release" (
|
|
set BUILD_TYPE=Release
|
|
shift
|
|
goto :parse_args
|
|
)
|
|
if /i "%~1"=="Debug" (
|
|
set BUILD_TYPE=Debug
|
|
shift
|
|
goto :parse_args
|
|
)
|
|
if /i "%~1"=="clean" (
|
|
set CLEAN_BUILD=1
|
|
shift
|
|
goto :parse_args
|
|
)
|
|
|
|
echo Unknown argument: %~1
|
|
echo Usage: build [Release^|Debug] [clean]
|
|
exit /b 1
|
|
|
|
:main
|
|
set BUILD_DIR=%SCRIPT_DIR%\build\windows\%BUILD_TYPE%
|
|
|
|
echo === Building %PROJECT_NAME% (%BUILD_TYPE%) ===
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Clean if requested
|
|
:: --------------------------------------------------------------------------
|
|
if %CLEAN_BUILD%==1 (
|
|
echo Cleaning...
|
|
if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%" 2>nul
|
|
)
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Create build directory
|
|
:: --------------------------------------------------------------------------
|
|
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
|
|
pushd "%BUILD_DIR%"
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Compiler selection
|
|
:: --------------------------------------------------------------------------
|
|
set CC=
|
|
|
|
where clang-cl >nul 2>&1
|
|
if !ERRORLEVEL! equ 0 (
|
|
echo Compiler: clang-cl ^(preferred^)
|
|
set "CC=-DCMAKE_C_COMPILER=clang-cl"
|
|
goto :find_generator
|
|
)
|
|
|
|
where gcc >nul 2>&1
|
|
if !ERRORLEVEL! equ 0 (
|
|
echo Compiler: gcc ^(fallback^)
|
|
set "CC=-DCMAKE_C_COMPILER=gcc"
|
|
goto :find_generator
|
|
)
|
|
|
|
where clang >nul 2>&1
|
|
if !ERRORLEVEL! equ 0 (
|
|
echo Compiler: clang ^(last resort^)
|
|
set "CC=-DCMAKE_C_COMPILER=clang"
|
|
goto :find_generator
|
|
)
|
|
|
|
echo ERROR: No suitable compiler found!
|
|
popd
|
|
exit /b 1
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Generator selection (prefer ninja)
|
|
:: --------------------------------------------------------------------------
|
|
:find_generator
|
|
set GEN=
|
|
where ninja >nul 2>&1
|
|
if !ERRORLEVEL! equ 0 (
|
|
echo Generator: Ninja
|
|
set "GEN=-G Ninja"
|
|
) else (
|
|
echo Generator: Default
|
|
)
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Configure
|
|
:: --------------------------------------------------------------------------
|
|
echo.
|
|
echo Configuring CMake...
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: compile_commands.json logic
|
|
:: --------------------------------------------------------------------------
|
|
set EXPORT_COMPILE_COMMANDS=OFF
|
|
|
|
if /i "%BUILD_TYPE%"=="Release" (
|
|
if exist "%SCRIPT_DIR%\compile_commands.json" (
|
|
echo compile_commands.json already exists - skipping generation
|
|
) else (
|
|
echo compile_commands.json will be generated
|
|
set EXPORT_COMPILE_COMMANDS=ON
|
|
)
|
|
)
|
|
|
|
set CMD=cmake "%SCRIPT_DIR%" %GEN% %CC% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_EXPORT_COMPILE_COMMANDS=%EXPORT_COMPILE_COMMANDS%
|
|
|
|
echo !CMD!
|
|
!CMD!
|
|
if !ERRORLEVEL! neq 0 (
|
|
echo ERROR: Configuration failed
|
|
popd
|
|
exit /b 1
|
|
)
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Build
|
|
:: --------------------------------------------------------------------------
|
|
echo.
|
|
echo Building...
|
|
cmake --build . --config %BUILD_TYPE%
|
|
if !ERRORLEVEL! neq 0 (
|
|
echo ERROR: Build failed
|
|
popd
|
|
exit /b 1
|
|
)
|
|
|
|
:: --------------------------------------------------------------------------
|
|
:: Copy compile_commands.json (only if generated)
|
|
:: --------------------------------------------------------------------------
|
|
if /i "%EXPORT_COMPILE_COMMANDS%"=="ON" (
|
|
if exist "compile_commands.json" (
|
|
echo.
|
|
echo clangd: compile_commands.json generated
|
|
|
|
copy /Y "compile_commands.json" "%SCRIPT_DIR%\compile_commands.json" >nul 2>&1
|
|
if !ERRORLEVEL! equ 0 (
|
|
echo clangd: Copied to project root
|
|
) else (
|
|
echo clangd: Copy failed
|
|
)
|
|
)
|
|
)
|
|
|
|
popd
|
|
|
|
echo.
|
|
echo === Build Complete ===
|
|
echo Executable: %BUILD_DIR%\%PROJECT_NAME%.exe
|