File tree Expand file tree Collapse file tree 7 files changed +55
-15
lines changed
Expand file tree Collapse file tree 7 files changed +55
-15
lines changed Original file line number Diff line number Diff line change 1+ [env ]
2+ CFLAGS = " /MDd"
3+ CXXFLAGS = " /MDd"
Original file line number Diff line number Diff line change @@ -49,13 +49,21 @@ jobs:
4949 steps :
5050 - uses : actions/checkout@v4
5151
52- - name : Build
52+ - name : Release Build
5353 uses : houseabsolute/actions-rust-cross@v1
5454 with :
5555 command : ${{ matrix.platform.command }}
5656 target : ${{ matrix.platform.target }}
5757 args : " --locked --all --release"
5858
59+ - name : Debug Build
60+ uses : houseabsolute/actions-rust-cross@v1
61+ if : startsWith(matrix.platform.os-name, 'Windows')
62+ with :
63+ command : ${{ matrix.platform.command }}
64+ target : ${{ matrix.platform.target }}
65+ args : " --config .cargo/windbg-config.toml --locked --all"
66+
5967 - name : Store command line tool
6068 uses : actions/upload-artifact@v4
6169 with :
Original file line number Diff line number Diff line change @@ -185,6 +185,15 @@ This creates a distribution archive containing:
185185- C++ header files
186186- CMake configuration files
187187
188+ On Windows, if a debug build is necessary, the library can be built with:
189+ ``` bash
190+ # Build Rust library
191+ cargo build --all
192+
193+ # Generate distribution package
194+ ./package.sh
195+ ```
196+
188197### Running Tests
189198
190199``` bash
Original file line number Diff line number Diff line change 1+ use std:: env;
2+
13fn main ( ) {
24 cxx_build:: bridge ( "src/lib.rs" )
35 . cpp ( true )
46 . std ( "c++14" )
57 . compile ( "rs_dfu" ) ;
8+
9+ if env:: var ( "TARGET" ) . is_ok_and ( |s| s. contains ( "windows-msvc" ) ) {
10+ // MSVC compiler suite
11+ if env:: var ( "CFLAGS" ) . is_ok_and ( |s| s. contains ( "/MDd" ) ) {
12+ // debug runtime flag is set
13+
14+ // Don't link the default CRT
15+ println ! ( "cargo::rustc-link-arg=/nodefaultlib:msvcrt" ) ;
16+ // Link the debug CRT instead
17+ println ! ( "cargo::rustc-link-arg=/defaultlib:msvcrtd" ) ;
18+ }
19+ }
620}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ if(WIN32)
77 set (_rs_dfu_lib_prefix "" )
88 set (_rs_dfu_shared_ext "dll" )
99 set (_rs_dfu_static_ext "lib" )
10+ set (_rs_dfu_debug_suffix "d" )
1011 set (_rs_dfu_system_libs ws2_32 userenv winusb ntdll cfgmgr32)
1112elseif (APPLE )
1213 set (_rs_dfu_lib_prefix "lib" )
@@ -26,7 +27,13 @@ set(RS_DFU_DIR "${CMAKE_CURRENT_LIST_DIR}/..")
2627set (RS_DFU_INCLUDE_DIR "${RS_DFU_DIR} /include" )
2728set (RS_DFU_LIB_DIR "${RS_DFU_DIR} /lib" )
2829
29- set (_rs_dfu_static_lib "${RS_DFU_LIB_DIR} /${_rs_dfu_lib_prefix} rs_dfu.${_rs_dfu_static_ext} " )
30+ if (CMAKE_BUILD_TYPE STREQUAL "Release" )
31+ set (_rs_dfu_libname "${_rs_dfu_lib_prefix} rs_dfu" )
32+ else ()
33+ set (_rs_dfu_libname "${_rs_dfu_lib_prefix} rs_dfu${_rs_dfu_debug_suffix} " )
34+ endif ()
35+
36+ set (_rs_dfu_static_lib "${RS_DFU_LIB_DIR} /${_rs_dfu_libname} .${_rs_dfu_static_ext} " )
3037
3138# Create imported target
3239if (EXISTS "${_rs_dfu_static_lib} " AND NOT TARGET rs_dfu::static )
Original file line number Diff line number Diff line change @@ -47,8 +47,8 @@ target_include_directories(cpp-example PRIVATE
4747 ${CARGO_CXX_TARGET_DIR} /src
4848)
4949
50- target_link_libraries (cpp-example fmt::fmt)
51- target_link_libraries (cpp-example ${RS_DFU_LIB} )
50+ target_link_libraries (cpp-example PRIVATE fmt::fmt)
51+ target_link_libraries (cpp-example PRIVATE ${RS_DFU_LIB} )
5252
5353if (APPLE )
5454 target_link_libraries (cpp-example PRIVATE
Original file line number Diff line number Diff line change 2424LIB_NAME=" rs_dfu"
2525TARGET_DIR=${2:- " target" }
2626
27- if [ -d " ${TARGET_DIR} /release" ]; then
28- PROFILE_DIR=${3:- " release" }
29- elif [ -d " ${TARGET_DIR} /debug" ]; then
30- PROFILE_DIR=${3:- " debug" }
31- TARGET=" ${TARGET} -debug"
32- fi
33-
3427# Create distribution structure
3528rm -rf dist
3629mkdir -p dist/cmake dist/include dist/lib
3730
3831# Copy libraries
39- STATIC_LIB=" ${TARGET_DIR} /${PROFILE_DIR} /${LIB_PREFIX}${LIB_NAME} .${STATIC_EXT} "
40- if [ -f " $STATIC_LIB " ]; then
41- cp " $STATIC_LIB " " dist/lib/"
42- echo " Copied: $STATIC_LIB "
32+ RELEASE_LIB=" ${TARGET_DIR} /release/${LIB_PREFIX}${LIB_NAME} .${STATIC_EXT} "
33+ if [ -f " $RELEASE_LIB " ]; then
34+ cp " $RELEASE_LIB " " dist/lib/"
35+ echo " Copied: $RELEASE_LIB "
36+ fi
37+
38+ DEBUG_LIB=" ${TARGET_DIR} /debug/${LIB_PREFIX}${LIB_NAME} .${STATIC_EXT} "
39+ if [ -f " $DEBUG_LIB " ]; then
40+ cp " $DEBUG_LIB " " dist/lib/${LIB_PREFIX}${LIB_NAME} d.${STATIC_EXT} "
41+ echo " Copied: $DEBUG_LIB -> ${LIB_PREFIX}${LIB_NAME} d.${STATIC_EXT} "
4342fi
4443
4544# Copy headers
You can’t perform that action at this time.
0 commit comments