Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable PDB generation on Windows build #2294

Merged
merged 2 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@ endif()

# Update CFLAGS
if (MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
add_compile_options(/MT)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

# Use custom CFLAGS for MSVC
#
# /W3 ...... Show up to 'production quality' msgs.
# /Zi ...... Generate pdb files.
# /MT ...... Static link C runtimes.
#
set(CMAKE_C_FLAGS "/DWIN32 /D_WINDOWS /DNDEBUG /W3 /O2 /Zi")
set(CMAKE_EXE_LINKER_FLAGS "/Debug /INCREMENTAL:NO")
set(CMAKE_BUILD_TYPE None)

# Use add_compile_options() to set /MT since Visual Studio
# Generator does not notice /MT in CMAKE_C_FLAGS.
add_compile_options(/MT)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif()
Expand Down
11 changes: 6 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ platform:
- Win32
- x64

environment:
vspath: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community'

configuration:
- Release

install:
- if %PLATFORM%==x86 (set MSYS2_MSYSTEM=MINGW32) else set MSYS2_MSYSTEM=MINGW64
- if %PLATFORM%==x86 (set MSYS2_PREFIX=C:\msys64\mingw32) else set MSYS2_PREFIX=C:\msys64\mingw64
- cmd: set PATH=%MSYS2_PREFIX%\bin;C:\msys64\usr\bin;%PATH%
- cmd: C:\msys64\usr\bin\pacman -Su --noconfirm bison flex

before_build:
- cmd: if "%platform%"=="Win32" set msvc=Visual Studio 15 2017
- cmd: if "%platform%"=="x64" set msvc=Visual Studio 15 2017 Win64
- if %PLATFORM%==Win32 call "%vspath%\VC\Auxiliary\Build\vcvars32.bat"
- if %PLATFORM%==x64 call "%vspatH%\VC\Auxiliary\Build\vcvars64.bat"

build_script:
- powershell ".\ci\do-ut.ps1;exit $LASTEXITCODE"
- cd build
- cpack -C "%configuration%"
- cpack

artifacts:
- path: build/td-agent-bit-*.exe
Expand Down
9 changes: 4 additions & 5 deletions ci/do-ut.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cd build

# CACHE GENERATION
cmake -G "$ENV:msvc" -DCMAKE_BUILD_TYPE="$ENV:configuration" `
-DCIO_BACKEND_FILESYSTEM=Off `
-DFLB_TESTS_INTERNAL=On `
cmake -G "NMake Makefiles" `
-D FLB_TESTS_INTERNAL=On `
-D FLB_WITHOUT_flb-rt-out_elasticsearch=On `
-D FLB_WITHOUT_flb-rt-out_td=On `
-D FLB_WITHOUT_flb-rt-out_forward=On `
Expand All @@ -17,7 +16,7 @@ cmake -G "$ENV:msvc" -DCMAKE_BUILD_TYPE="$ENV:configuration" `
../

# COMPILE
cmake --build . --config "$ENV:configuration"
cmake --build .

# RUNNING TESTS
ctest -C "$ENV:configuration" --build-run-dir $PWD --output-on-failure
ctest --build-run-dir $PWD --output-on-failure
15 changes: 15 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ if(FLB_SHARED_LIB)
target_link_libraries(fluent-bit-shared ${FLB_DEPS} -lpthread)
endif()

if (MSVC)
set_target_properties(fluent-bit-shared
PROPERTIES PDB_NAME fluent-bit.dll)
target_link_options(fluent-bit-shared
PUBLIC /pdb:$<TARGET_PDB_FILE:fluent-bit-shared>)
endif()

# Library install routines
install(TARGETS fluent-bit-shared
LIBRARY DESTINATION ${FLB_INSTALL_LIBDIR}
Expand Down Expand Up @@ -351,6 +358,14 @@ if(FLB_BINARY)
ENABLE_EXPORTS ON)
install(TARGETS fluent-bit-bin RUNTIME DESTINATION ${FLB_INSTALL_BINDIR})

# Include PDB file (if available)
if (MSVC)
target_link_options(fluent-bit-bin
PUBLIC /pdb:$<TARGET_PDB_FILE:fluent-bit-bin>)
install(FILES $<TARGET_PDB_FILE:fluent-bit-bin>
DESTINATION "${FLB_INSTALL_BINDIR}")
endif()

# Detect init system, install upstart, systemd or init.d script
if(IS_DIRECTORY /lib/systemd/system)
set(FLB_SYSTEMD_SCRIPT "${PROJECT_SOURCE_DIR}/init/${FLB_OUT_NAME}.service")
Expand Down